app_chargerpin_conn_detect.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. #include "app_chargerpin_conn_detect.h"
  2. #include "system.h"
  3. #include "bsp_time.h"
  4. #include "bsp_adc.h"
  5. #include "ble_comm.h"
  6. #include "hal_led.h"
  7. #include "hal_mt.h"
  8. #include "app_flash.h"
  9. #include "app_pair_chargerpin.h"
  10. #include "app_one_wire.h"
  11. #include "fml_adc.h"
  12. #define SHELF_CHECK_ADC_VALUE 1800
  13. //=================debug=============
  14. #include "ringframe.h"
  15. extern char logbuftemp[50];
  16. extern int logbuftemp_len ;
  17. extern ringframe_t battlog;
  18. #define log(...) {logbuftemp_len = sprintf(logbuftemp,__VA_ARGS__); while(ringframe_in(&battlog,logbuftemp,logbuftemp_len)!=0){ringframe_throw(&battlog);}}
  19. //void cb_BLE_Client_PRADC(void* handle)
  20. //{
  21. //// BLE_Client_Rx_t* target = handle;
  22. // DEBUG_LOG("cb_BLE_Client_ERR:%d,%d\n", 1, 1);
  23. // BLE_Client_Rx_Regist(BLE_ERR, cb_BLE_Client_ERR);
  24. //}
  25. //=================debug=============
  26. extern void app_pair_client_process_case1(void);
  27. extern void app_pair_client_process(void);
  28. struct client_ram_type{
  29. char init;
  30. char statu;
  31. short adc_value;
  32. pair_line_t pair_line;
  33. unsigned int delay_pair_count;
  34. Event into_event;
  35. Event over_event;
  36. }client_ram={0,0,DISCONNECT_CHARGE,0,NULL,NULL};
  37. struct{
  38. char init;
  39. char statu;
  40. unsigned int pulluppcs_timer;
  41. short adc_value;
  42. pair_line_t pair_line;
  43. unsigned int delay_pair_count;
  44. Event into_event;
  45. Event over_event;
  46. }host_ram={0,0,0,DISCONNECT_CHARGE,0,NULL,NULL};
  47. extern void app_pair_host_process(void);
  48. extern void app_pair_host_process_case1(void);
  49. extern void app_pair_host_process_case2(void);
  50. void fml_adc_callback(uint32_t sample_point, Fml_Adc_All_Channel_Adc_Value_t all_adc_value)
  51. {
  52. #if 1
  53. switch(sample_point)
  54. {
  55. case FML_ADC_SAMPLE_POINT_0:
  56. case FML_ADC_SAMPLE_POINT_2:
  57. //PAIR_CHARGERPIN_PRINT("FML_ADC_SAMPLE_POINT_2 NULL %d\n",all_adc_value.channel_4_adc_value);
  58. if(host_ram.init)
  59. {
  60. if(host_ram.statu == 1)
  61. {
  62. host_ram.adc_value=all_adc_value.channel_4_adc_value;
  63. app_pair_host_process_case1();
  64. }
  65. }
  66. break;
  67. case FML_ADC_SAMPLE_POINT_1:
  68. //PAIR_CHARGERPIN_PRINT("FML_ADC_SAMPLE_POINT_1 NULL %d\n",all_adc_value.channel_4_adc_value);
  69. if(host_ram.init)
  70. {
  71. if(host_ram.statu == 2)
  72. {
  73. host_ram.adc_value=all_adc_value.channel_4_adc_value;
  74. app_pair_host_process_case2();
  75. }
  76. }
  77. break;
  78. }
  79. if(client_ram.init)
  80. {
  81. if(client_ram.statu == 1)
  82. {
  83. client_ram.adc_value=all_adc_value.channel_4_adc_value;
  84. app_pair_client_process_case1();
  85. }
  86. }
  87. #else
  88. static char asjdhaskjhdki=0;
  89. PAIR_CHARGERPIN_PRINT("ADC_Read fml_adc_callback %d\n", all_adc_value.channel_4_adc_value);
  90. if(asjdhaskjhdki%2==0)fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_PULLUP);
  91. else fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
  92. asjdhaskjhdki++;
  93. #endif
  94. }
  95. //====================================================================================
  96. #define ADC_CHECKMS 1000
  97. #define PAIROVERTIME 3000
  98. #define DELAY_PAIR_COUNT 100
  99. void app_pair_host_init(Event into,Event over)
  100. {
  101. host_ram.init=1;
  102. host_ram.adc_value=0;
  103. host_ram.delay_pair_count=0;
  104. host_ram.pulluppcs_timer=0;
  105. host_ram.statu=0;
  106. host_ram.pair_line=DISCONNECT_CHARGE;
  107. host_ram.into_event=into;
  108. host_ram.over_event=over;
  109. fml_adc_sample_update_notify_register(fml_adc_callback);
  110. Process_Start(ADC_CHECKMS, "app_pair_host_process", app_pair_host_process);
  111. }
  112. void app_pair_host_uninit(void)
  113. {
  114. host_ram.init=0;
  115. Process_Stop(app_pair_host_process);
  116. }
  117. #define DISCON_HOST_MAX_ADC 1200
  118. #define DISCON_HOST_MIN_ADC 600
  119. #define CON_HOST_MAX_ADC DISCON_HOST_MIN_ADC
  120. #define CON_HOST_MIN_ADC 300
  121. static void null_pcs(void)
  122. {
  123. }
  124. #define UPPULL_MS 3
  125. //-------------------------------------------
  126. unsigned char shefcheck_buff[5];
  127. char shefcheck_event_fag=0;
  128. check_callbackt check_callbackt_ram;
  129. Event check_callback_find_hi_ram;
  130. void shefcheck_event(unsigned char *buff, int length)
  131. {
  132. shefcheck_event_fag=1;
  133. }
  134. void check_callback_regist(check_callbackt evt)
  135. {
  136. check_callbackt_ram=evt;
  137. }
  138. void check_callback_find_hi_regist(Event evt)
  139. {
  140. check_callback_find_hi_ram=evt;
  141. }
  142. //-------------------------------------------
  143. void app_pair_host_process_case1(void)
  144. {
  145. if(mFlash.isHost!=HOST_SHOSE)
  146. {
  147. app_pair_host_uninit();
  148. app_pair_chargerpin_Init();
  149. PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d %d\n",TIME_GetTicks(),mFlash.isHost );
  150. }
  151. //==============================s
  152. if(host_ram.adc_value>DISCON_HOST_MAX_ADC)
  153. {
  154. PAIR_CHARGERPIN_PRINT("CHARGE\n");
  155. if(host_ram.pair_line!=CHARGE)
  156. {
  157. PAIR_CHARGERPIN_INFO("INTO CHARGE %d\n", mFlash.isHost);
  158. host_ram.pair_line=CHARGE;
  159. }
  160. host_ram.statu=1;
  161. }
  162. PAIR_CHARGERPIN_PRINT("ADC f( %d ):isHost %d Ticks %d\n", host_ram.adc_value, mFlash.isHost,TIME_GetTicks());
  163. if(host_ram.adc_value>SHELF_CHECK_ADC_VALUE)
  164. {
  165. PAIR_CHARGERPIN_PRINT("------------check_callback_find_hi_ram-----check_callbackt_ram---------%d %d\n", mFlash.isHost, TIME_GetTicks());
  166. if(check_callbackt_ram)
  167. {
  168. host_ram.statu=11;
  169. host_ram.delay_pair_count=TIME_GetTicks();
  170. Process_UpdatePeroid(app_pair_host_process,100);
  171. Process_SetHoldOn(app_pair_host_process,1);
  172. one_byte_receive_init(shefcheck_buff,2,shefcheck_event);
  173. shefcheck_event_fag=0;
  174. fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
  175. if(check_callback_find_hi_ram)check_callback_find_hi_ram();
  176. PAIR_CHARGERPIN_INFO("INTO SHELF_CHECK_ADC_VALUE %d\n", mFlash.isHost);
  177. PAIR_CHARGERPIN_PRINT("------------check_callback_find_hi_ram--------------%d %d\n", mFlash.isHost, TIME_GetTicks());
  178. return;
  179. }
  180. else
  181. {
  182. PAIR_CHARGERPIN_PRINT("check_callbackt_ram NULL\n");
  183. }
  184. }
  185. //==============================e
  186. fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_PULLUP);
  187. PAIR_CHARGERPIN_PRINT("nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_PULLUP); %d \n",TIME_GetTicks() );
  188. host_ram.pulluppcs_timer = TIME_GetTicks();
  189. Process_Start(0, "null_pcs", null_pcs);
  190. Process_SetHoldOn(null_pcs, 1);
  191. host_ram.statu = 2;
  192. }
  193. void app_pair_host_process_case2(void)
  194. {
  195. fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
  196. Process_Stop(null_pcs);
  197. log("ad:%d,%d\n",host_ram.adc_value, host_ram.pair_line);
  198. PAIR_CHARGERPIN_PRINT("ADC ( %d ): pair_line %d\n", host_ram.adc_value, host_ram.pair_line);
  199. if(host_ram.adc_value>DISCON_HOST_MIN_ADC)
  200. {
  201. PAIR_CHARGERPIN_PRINT("DISCONNECT_CHARGE\n");
  202. if(host_ram.pair_line!=DISCONNECT_CHARGE)
  203. {
  204. PAIR_CHARGERPIN_INFO("INTO DISCONNECT_CHARGE %d\n", mFlash.isHost);
  205. host_ram.pair_line=DISCONNECT_CHARGE;
  206. }
  207. host_ram.statu=1;
  208. }
  209. else if(host_ram.adc_value>CON_HOST_MIN_ADC)
  210. {
  211. PAIR_CHARGERPIN_PRINT("CONNECT_NO_CHARGE\n");
  212. if(host_ram.pair_line!=CONNECT_NO_CHARGE)
  213. {
  214. host_ram.pair_line=CONNECT_NO_CHARGE;
  215. fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_PULLUP);
  216. host_ram.delay_pair_count=TIME_GetTicks();
  217. Process_UpdatePeroid(app_pair_host_process,1);
  218. Process_SetHoldOn(app_pair_host_process,1);
  219. fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
  220. host_ram.statu=3;
  221. PAIR_CHARGERPIN_INFO("INTO CONNECT_NO_CHARGE %d\n", mFlash.isHost);
  222. }
  223. else
  224. {
  225. host_ram.statu=1;
  226. }
  227. }
  228. else
  229. {
  230. PAIR_CHARGERPIN_PRINT("ADCVALUE ======================================================ERROR %d\n", host_ram.adc_value);
  231. host_ram.statu=1;
  232. }
  233. }
  234. static void app_pair_host_process(void)
  235. {
  236. for(int i=1;i>0;i--)
  237. {
  238. switch(host_ram.statu)
  239. {
  240. case 0:
  241. fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
  242. host_ram.statu=1;
  243. break;
  244. case 1:
  245. break;
  246. case 2:
  247. break;
  248. case 3://é?à-è?′ó?ú·¢??????D?o?
  249. if ((TIME_GetTicks() - host_ram.delay_pair_count > ADC_CHECKMS+ADC_CHECKMS))
  250. {
  251. PAIR_CHARGERPIN_PRINT(" UP pull over time %d \n", TIME_GetTicks());
  252. log("pull over time\n");
  253. nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_NOPULL);
  254. Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
  255. Process_SetHoldOn(app_pair_host_process,0);
  256. host_ram.statu=1;
  257. }
  258. else if(nrf_gpio_pin_read(PIN_CHARGING))//?áμ?é?à-D?o?ò?oó£??μ?÷clientò??-á??óé?
  259. {
  260. PAIR_CHARGERPIN_PRINT(" nrf_gpio_pin_read(PIN_CHARGING SUCCESS \n", TIME_GetTicks());
  261. host_ram.statu=4;
  262. host_ram.delay_pair_count=TIME_GetTicks();
  263. nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_NOPULL);
  264. }
  265. break;
  266. case 4:
  267. if(nrf_gpio_pin_read(PIN_CHARGING)==0)
  268. {
  269. PAIR_CHARGERPIN_PRINT(" into_event %d \n", TIME_GetTicks());
  270. host_ram.statu=5;
  271. host_ram.delay_pair_count=TIME_GetTicks();
  272. fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
  273. log("into_event-H\n");
  274. host_ram.into_event();
  275. }
  276. else if(TIME_GetTicks() - host_ram.delay_pair_count > 500)
  277. {
  278. PAIR_CHARGERPIN_PRINT(" wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
  279. host_ram.statu=0;
  280. Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
  281. Process_SetHoldOn(app_pair_host_process,0);
  282. i=3;
  283. }
  284. break;
  285. case 5:
  286. if (TIME_GetTicks() - host_ram.delay_pair_count > PAIROVERTIME)
  287. {
  288. PAIR_CHARGERPIN_PRINT(" over_event %d\n", TIME_GetTicks());
  289. host_ram.statu=0;
  290. host_ram.over_event();
  291. Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
  292. Process_SetHoldOn(app_pair_host_process,0);
  293. i=3;
  294. }
  295. break;
  296. //==============================s
  297. case 11:
  298. if((TIME_GetTicks() - host_ram.delay_pair_count > 5000)||(shefcheck_event_fag))
  299. {
  300. if(shefcheck_event_fag)
  301. {
  302. if(check_callbackt_ram)check_callbackt_ram(shefcheck_buff[0]);
  303. }
  304. else
  305. {
  306. PAIR_CHARGERPIN_PRINT(" =====================wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
  307. }
  308. host_ram.statu=0;
  309. Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
  310. Process_SetHoldOn(app_pair_host_process,0);
  311. one_byte_receive_uninit();
  312. PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d\n", mFlash.isHost);
  313. i=3;
  314. }
  315. break;
  316. //==============================s
  317. }
  318. }
  319. }
  320. //============================================================================================================
  321. #define CONN_MAX_ADC 1000
  322. #define CONN_MIN_ADC 750
  323. void app_pair_client_init(Event into,Event over)
  324. {
  325. client_ram.init=1;
  326. client_ram.adc_value=0;
  327. client_ram.delay_pair_count=0;
  328. client_ram.statu=0;
  329. client_ram.pair_line=DISCONNECT_CHARGE;
  330. client_ram.into_event=into;
  331. client_ram.over_event=over;
  332. fml_adc_sample_update_notify_register(fml_adc_callback);
  333. Process_Start(ADC_CHECKMS, "app_pair_client_process", app_pair_client_process);
  334. }
  335. void app_pair_client_uninit(void)
  336. {
  337. client_ram.init=0;
  338. Process_Stop(app_pair_client_process);
  339. }
  340. void app_pair_client_process_case1(void)
  341. {
  342. if(mFlash.isHost==HOST_SHOSE)
  343. {
  344. app_pair_client_uninit();
  345. app_pair_chargerpin_Init();
  346. PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d %d\n",TIME_GetTicks(),mFlash.isHost );
  347. }
  348. log("ad:%d,%d\n",client_ram.adc_value, client_ram.pair_line);
  349. PAIR_CHARGERPIN_PRINT("ADC ( %d ):isHost %d Ticks %d\n", client_ram.adc_value, mFlash.isHost,TIME_GetTicks());
  350. if(client_ram.adc_value>CONN_MAX_ADC)
  351. {
  352. PAIR_CHARGERPIN_PRINT("CHARGE\n");
  353. if(client_ram.pair_line!=CHARGE)
  354. {
  355. PAIR_CHARGERPIN_INFO("INTO CHARGE %d\n", mFlash.isHost);
  356. client_ram.pair_line=CHARGE;
  357. }
  358. }
  359. else if((client_ram.adc_value>CONN_MIN_ADC)&&(client_ram.adc_value < CONN_MIN_ADC+100))
  360. {
  361. PAIR_CHARGERPIN_PRINT("CONNECT_NO_CHARGE\n");
  362. if(client_ram.pair_line!=CONNECT_NO_CHARGE)
  363. {
  364. PAIR_CHARGERPIN_INFO("INTO CONNECT_NO_CHARGE %d\n", mFlash.isHost);
  365. client_ram.pair_line=CONNECT_NO_CHARGE;
  366. fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
  367. nrf_gpio_cfg(
  368. PIN_CHARGING,
  369. NRF_GPIO_PIN_DIR_OUTPUT,
  370. NRF_GPIO_PIN_INPUT_CONNECT,
  371. NRF_GPIO_PIN_NOPULL,
  372. NRF_GPIO_PIN_D0H1,
  373. NRF_GPIO_PIN_NOSENSE);
  374. nrf_gpio_cfg_watcher(PIN_CHARGING);
  375. nrf_gpio_pin_set(PIN_CHARGING);//à-??100ms
  376. client_ram.delay_pair_count=TIME_GetTicks();
  377. Process_UpdatePeroid(app_pair_client_process,1);
  378. Process_SetHoldOn(app_pair_client_process,1);
  379. client_ram.statu=2;
  380. }
  381. }
  382. else
  383. {
  384. if(client_ram.pair_line!=DISCONNECT_CHARGE)
  385. {
  386. PAIR_CHARGERPIN_INFO("INTO DISCONNECT_CHARGE %d\n", mFlash.isHost);
  387. client_ram.pair_line=DISCONNECT_CHARGE;
  388. }
  389. }
  390. //==============================s
  391. if(client_ram.adc_value>SHELF_CHECK_ADC_VALUE)
  392. {
  393. if(check_callbackt_ram)
  394. {
  395. client_ram.statu=11;
  396. client_ram.delay_pair_count=TIME_GetTicks();
  397. Process_UpdatePeroid(app_pair_client_process,100);
  398. Process_SetHoldOn(app_pair_client_process,1);
  399. one_byte_receive_init(shefcheck_buff,2,shefcheck_event);
  400. shefcheck_event_fag=0;
  401. fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
  402. PAIR_CHARGERPIN_INFO("INTO SHELF_CHECK_ADC_VALUE %d\n", 1);
  403. if(check_callback_find_hi_ram)
  404. {
  405. check_callback_find_hi_ram();
  406. }
  407. return;
  408. }
  409. else
  410. {
  411. PAIR_CHARGERPIN_PRINT("check_callbackt_ram NULL\n");
  412. }
  413. }
  414. //==============================e
  415. }
  416. static void app_pair_client_process(void)
  417. {
  418. for(int i=1;i>0;i--)
  419. {
  420. switch(client_ram.statu)
  421. {
  422. case 0:
  423. fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
  424. client_ram.statu=1;
  425. break;
  426. case 1:
  427. break;
  428. case 2:
  429. if(TIME_GetTicks() - client_ram.delay_pair_count > 100)//μè100ms
  430. {
  431. nrf_gpio_pin_clear(PIN_CHARGING);
  432. client_ram.statu=3;
  433. client_ram.delay_pair_count=TIME_GetTicks();
  434. }
  435. break;
  436. case 3:
  437. if(nrf_gpio_pin_read(PIN_CHARGING)==0)
  438. {
  439. log("into_event-C\n");
  440. client_ram.into_event();
  441. client_ram.delay_pair_count=TIME_GetTicks();
  442. PAIR_CHARGERPIN_PRINT(" into_event-C %d\n", TIME_GetTicks());
  443. PAIR_CHARGERPIN_PRINT(" wait pair %d\n", nrf_gpio_pin_read(PIN_CHARGING));
  444. client_ram.statu=4;
  445. }
  446. else if(TIME_GetTicks() - client_ram.delay_pair_count > 100)
  447. {
  448. PAIR_CHARGERPIN_PRINT(" wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
  449. client_ram.statu=0;
  450. Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
  451. Process_SetHoldOn(app_pair_client_process,0);
  452. i=3;
  453. }
  454. break;
  455. case 4:
  456. if (TIME_GetTicks() - client_ram.delay_pair_count > PAIROVERTIME)
  457. {
  458. client_ram.statu=0;
  459. client_ram.over_event();
  460. Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
  461. Process_SetHoldOn(app_pair_client_process,0);
  462. PAIR_CHARGERPIN_PRINT(" over_event %d\n", TIME_GetTicks());
  463. i=3;
  464. }
  465. break;
  466. //==============================s
  467. case 11:
  468. if((TIME_GetTicks() - client_ram.delay_pair_count > 5000)||(shefcheck_event_fag))
  469. {
  470. if(shefcheck_event_fag)
  471. {
  472. if(check_callbackt_ram)check_callbackt_ram(shefcheck_buff[0]);
  473. }
  474. else
  475. {
  476. PAIR_CHARGERPIN_PRINT(" =====================wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
  477. }
  478. client_ram.statu=0;
  479. Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
  480. Process_SetHoldOn(app_pair_client_process,0);
  481. one_byte_receive_uninit();
  482. PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d\n", 1);
  483. i=3;
  484. }
  485. break;
  486. //==============================s
  487. }
  488. }
  489. }
  490. pair_line_t app_chargepin_pairline(void)
  491. {
  492. if (host_ram.init)
  493. {
  494. return host_ram.pair_line;
  495. }
  496. if (client_ram.init)
  497. {
  498. return client_ram.pair_line;
  499. }
  500. return 0xff;
  501. }