123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726 |
- #include "app_chargerpin_conn_detect.h"
- #include "system.h"
- #include "bsp_time.h"
- #include "bsp_adc.h"
- #include "ble_comm.h"
- #include "hal_led.h"
- #include "hal_mt.h"
- #include "app_flash.h"
- #include "app_pair_chargerpin.h"
- #include "app_one_wire.h"
- #include "fml_adc.h"
- #define SHELF_CHECK_ADC_VALUE 1800
- //=================debug=============
- #include "ringframe.h"
- extern char logbuftemp[50];
- extern int logbuftemp_len ;
- extern ringframe_t battlog;
- #define log(...) {logbuftemp_len = sprintf(logbuftemp,__VA_ARGS__); while(ringframe_in(&battlog,logbuftemp,logbuftemp_len)!=0){ringframe_throw(&battlog);}}
- //void cb_BLE_Client_PRADC(void* handle)
- //{
- //// BLE_Client_Rx_t* target = handle;
- // DEBUG_LOG("cb_BLE_Client_ERR:%d,%d\n", 1, 1);
- // BLE_Client_Rx_Regist(BLE_ERR, cb_BLE_Client_ERR);
- //}
- //=================debug=============
- extern void app_pair_client_process_case1(void);
- extern void app_pair_client_process(void);
- struct client_ram_type{
- char init;
- char statu;
- short adc_value;
- pair_line_t pair_line;
- unsigned int delay_pair_count;
- Event into_event;
- Event over_event;
- }client_ram;
- struct{
- char init;
- char statu;
- unsigned int pulluppcs_timer;
- short adc_value;
- pair_line_t pair_line;
- unsigned int delay_pair_count;
- Event into_event;
- Event over_event;
- }host_ram;
- extern void app_pair_host_process(void);
- extern void app_pair_host_process_case1(void);
- extern void app_pair_host_process_case2(void);
- void fml_adc_callback(uint32_t sample_point, Fml_Adc_All_Channel_Adc_Value_t all_adc_value)
- {
- #if 1
- switch(sample_point)
- {
- case FML_ADC_SAMPLE_POINT_0:
- case FML_ADC_SAMPLE_POINT_2:
- //PAIR_CHARGERPIN_PRINT("FML_ADC_SAMPLE_POINT_2 NULL %d\n",all_adc_value.channel_4_adc_value);
- if(host_ram.init)
- {
- if(host_ram.statu == 1)
- {
- host_ram.adc_value=all_adc_value.channel_4_adc_value;
- app_pair_host_process_case1();
- }
- }
-
- if(client_ram.init)
- {
- if(client_ram.statu == 1)
- {
- client_ram.adc_value=all_adc_value.channel_4_adc_value;
- app_pair_client_process_case1();
- }
- }
- break;
- case FML_ADC_SAMPLE_POINT_1:
- //PAIR_CHARGERPIN_PRINT("FML_ADC_SAMPLE_POINT_1 NULL %d\n",all_adc_value.channel_4_adc_value);
- if(host_ram.init)
- {
- if(host_ram.statu == 2)
- {
- host_ram.adc_value=all_adc_value.channel_4_adc_value;
- app_pair_host_process_case2();
- }
- }
- break;
- }
-
- #else
- static char asjdhaskjhdki=0;
- PAIR_CHARGERPIN_PRINT("ADC_Read fml_adc_callback %d\n", all_adc_value.channel_4_adc_value);
- if(asjdhaskjhdki%2==0)fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_PULLUP);
- else fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
- asjdhaskjhdki++;
- #endif
- }
- //====================================================================================
- #define ADC_CHECKMS 1000
- #define PAIROVERTIME 3000
- #define DELAY_PAIR_COUNT 100
- void app_pair_host_init(Event into,Event over)
- {
- host_ram.init=1;
- host_ram.adc_value=0;
- host_ram.delay_pair_count=0;
- host_ram.pulluppcs_timer=0;
- host_ram.statu=0;
- host_ram.pair_line=DISCONNECT_CHARGE;
- host_ram.into_event=into;
- host_ram.over_event=over;
- fml_adc_sample_update_notify_register(fml_adc_callback);
- Process_Start(ADC_CHECKMS, "app_pair_host_process", app_pair_host_process);
- }
- void app_pair_host_uninit(void)
- {
- host_ram.init=0;
- Process_Stop(app_pair_host_process);
- }
- #define DISCON_HOST_MAX_ADC 1200
- //#define DISCON_HOST_MIN_ADC 600
- #define DISCON_HOST_MIN_ADC 1000
- #define CON_HOST_MAX_ADC DISCON_HOST_MIN_ADC
- #define CON_HOST_MIN_ADC 300
- static void null_pcs(void)
- {
- }
- #define UPPULL_MS 3
- //-------------------------------------------
- unsigned char shefcheck_buff[5];
- char shefcheck_event_fag=0;
- check_callbackt check_callbackt_ram;
- Event check_callback_find_hi_ram;
- void shefcheck_event(unsigned char *buff, int length)
- {
- shefcheck_event_fag=1;
- }
- char one_byte_receive_error_code=0;
- void one_byte_receive_Event_err_hander(unsigned char error_code)
- {
- one_byte_receive_error_code=1;
- }
- void check_callback_regist(check_callbackt evt)
- {
- check_callbackt_ram=evt;
- }
- void check_callback_find_hi_regist(Event evt)
- {
- check_callback_find_hi_ram=evt;
- }
- //-------------------------------------------
- void app_pair_host_process_case1(void)
- {
- if(mFlash.isHost!=HOST_SHOSE)
- {
- app_pair_host_uninit();
- app_pair_chargerpin_Init();
- PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d %d\n",TIME_GetTicks(),mFlash.isHost );
- }
- //==============================s
- if(host_ram.adc_value>DISCON_HOST_MAX_ADC)
- {
- PAIR_CHARGERPIN_PRINT("CHARGE\n");
- if(host_ram.pair_line!=CHARGE)
- {
- PAIR_CHARGERPIN_INFO("INTO CHARGE %d\n", mFlash.isHost);
- host_ram.pair_line=CHARGE;
- }
- host_ram.statu=1;
- }
-
- PAIR_CHARGERPIN_PRINT("ADC f( %d ):isHost %d Ticks %d\n", host_ram.adc_value, mFlash.isHost,TIME_GetTicks());
- if(host_ram.adc_value>SHELF_CHECK_ADC_VALUE)
- {
- PAIR_CHARGERPIN_PRINT("------------check_callback_find_hi_ram-----check_callbackt_ram---------%d %d\n", mFlash.isHost, TIME_GetTicks());
- if(check_callbackt_ram)
- {
- host_ram.statu=11;
- host_ram.delay_pair_count=TIME_GetTicks();
- Process_UpdatePeroid(app_pair_host_process,100);
- Process_SetHoldOn(app_pair_host_process,1);
- one_byte_receive_init(shefcheck_buff,2,shefcheck_event);
- shefcheck_event_fag=0;
-
- one_byte_receive_Event_err_register(one_byte_receive_Event_err_hander);
- one_byte_receive_error_code=0;
-
- fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
- if(check_callback_find_hi_ram)check_callback_find_hi_ram();
- PAIR_CHARGERPIN_INFO("INTO SHELF_CHECK_ADC_VALUE %d\n", mFlash.isHost);
- PAIR_CHARGERPIN_PRINT("------------check_callback_find_hi_ram--------------%d %d\n", mFlash.isHost, TIME_GetTicks());
- return;
- }
- else
- {
- PAIR_CHARGERPIN_PRINT("check_callbackt_ram NULL\n");
- }
- }
- //==============================e
- fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_PULLUP);
- PAIR_CHARGERPIN_PRINT("nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_PULLUP); %d \n",TIME_GetTicks() );
- host_ram.pulluppcs_timer = TIME_GetTicks();
- Process_Start(0, "null_pcs", null_pcs);
- Process_SetHoldOn(null_pcs, 1);
- host_ram.statu = 2;
- }
- void app_pair_host_process_case2(void)
- {
-
- fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
- Process_Stop(null_pcs);
- log("ad:%d,%d\n",host_ram.adc_value, host_ram.pair_line);
- PAIR_CHARGERPIN_PRINT("ADC ( %d ): pair_line %d\n", host_ram.adc_value, host_ram.pair_line);
-
- if(host_ram.adc_value>DISCON_HOST_MIN_ADC)
- {
- PAIR_CHARGERPIN_PRINT("DISCONNECT_CHARGE\n");
- if(host_ram.pair_line!=DISCONNECT_CHARGE)
- {
- PAIR_CHARGERPIN_INFO("INTO DISCONNECT_CHARGE %d\n", mFlash.isHost);
- host_ram.pair_line=DISCONNECT_CHARGE;
- }
- host_ram.statu=1;
- }
- else if(host_ram.adc_value>CON_HOST_MIN_ADC)
- {
- PAIR_CHARGERPIN_PRINT("CONNECT_NO_CHARGE\n");
- if(host_ram.pair_line!=CONNECT_NO_CHARGE)
- {
- host_ram.pair_line=CONNECT_NO_CHARGE;
- fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_PULLUP);
- host_ram.delay_pair_count=TIME_GetTicks();
-
- Process_UpdatePeroid(app_pair_host_process,1);
- Process_SetHoldOn(app_pair_host_process,1);
-
- fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
-
- host_ram.statu=3;
- PAIR_CHARGERPIN_INFO("INTO CONNECT_NO_CHARGE %d\n", mFlash.isHost);
- }
- else
- {
- host_ram.statu=1;
- }
- }
- else
- {
- PAIR_CHARGERPIN_PRINT("ADCVALUE ======================================================ERROR %d\n", host_ram.adc_value);
- host_ram.statu=1;
- }
- }
- char host_into_fig_status=0;
- void host_into_fig(void *t)
- {
- static short count=0;
- static unsigned int bit_width = 0;
- static unsigned int now_bit = 0;
-
- switch(host_into_fig_status)
- {
- case 0:
- count=0;
- nrf_gpio_cfg(
- PIN_CHARGING,
- NRF_GPIO_PIN_DIR_OUTPUT,
- NRF_GPIO_PIN_INPUT_CONNECT,
- NRF_GPIO_PIN_NOPULL,
- NRF_GPIO_PIN_D0H1,
- NRF_GPIO_PIN_NOSENSE);
- nrf_gpio_cfg_watcher(PIN_CHARGING);
- host_into_fig_status = 1;
- nrf_gpio_pin_clear(PIN_CHARGING);
- break;
- case 1:
- count++;
- if(count>50)
- {
- host_into_fig_status = 2;
- nrf_gpio_pin_set(PIN_CHARGING);
- count=0;
- }
- break;
- case 2:
- count++;
- if(count>50)
- {
- host_into_fig_status = 20;
- nrf_gpio_pin_clear(PIN_CHARGING);
- TIME_UnRegist(host_into_fig);
- }
- break;
-
- case 10:
- count=0;
- nrf_gpio_cfg(
- PIN_CHARGING,
- NRF_GPIO_PIN_DIR_OUTPUT,
- NRF_GPIO_PIN_INPUT_CONNECT,
- NRF_GPIO_PIN_NOPULL,
- NRF_GPIO_PIN_D0H1,
- NRF_GPIO_PIN_NOSENSE);
- nrf_gpio_cfg_watcher(PIN_CHARGING);
- host_into_fig_status = 11;
- bit_width=0;
- nrf_gpio_pin_clear(PIN_CHARGING);
- now_bit = nrf_gpio_pin_read(PIN_CHARGING);
- break;
-
- case 11:
- if (now_bit == nrf_gpio_pin_read(PIN_CHARGING))
- {
- bit_width++;
- }
- else
- {
- if(now_bit==0)//上升
- {
- now_bit=1;
- }
- else//下降
- {
- now_bit=0;
- if((bit_width>48)&&(bit_width<60))
- {
- host_into_fig_status = 20;
- TIME_UnRegist(host_into_fig);
- }
- }
- bit_width=0;
- }
- count++;
- if(count>220)
- {
- host_into_fig_status = 30;
- TIME_UnRegist(host_into_fig);
- }
- break;
- }
- }
- void send_host_into_fig(void)
- {
- TIME_Regist(host_into_fig);
- host_into_fig_status=0;
- }
- char host_into_fig_senddone(void)
- {
- if(host_into_fig_status==20)return 1;
- else return 0;
- }
- char host_into_fig_receivedone(void)
- {
- if(host_into_fig_status==20)return 1;
- if(host_into_fig_status==30)return 2;
- else return 0;
- }
- void receive_host_into_fig(void)
- {
- TIME_Regist(host_into_fig);
- host_into_fig_status=10;
- }
- static void app_pair_host_process(void)
- {
- for(int i=1;i>0;i--)
- {
- switch(host_ram.statu)
- {
- case 0:
-
- fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
-
- host_ram.statu=1;
- break;
- case 1:
- break;
- case 2:
-
- break;
- case 3://
- if ((TIME_GetTicks() - host_ram.delay_pair_count > ADC_CHECKMS+ADC_CHECKMS))
- {
- PAIR_CHARGERPIN_PRINT(" UP pull over time %d \n", TIME_GetTicks());
- log("pull over time\n");
- nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_NOPULL);
- Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_host_process,0);
- host_ram.statu=1;
- }
- else if(nrf_gpio_pin_read(PIN_CHARGING))//?áμ?é?à-D?o?ò?oó£??μ?÷clientò??-á??óé?
- {
- PAIR_CHARGERPIN_PRINT(" nrf_gpio_pin_read(PIN_CHARGING SUCCESS \n", TIME_GetTicks());
- host_ram.statu=4;
- host_ram.delay_pair_count=TIME_GetTicks();
- nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_NOPULL);
- }
- break;
- case 4:
- if(nrf_gpio_pin_read(PIN_CHARGING)==0)
- {
- host_ram.statu=5;
- host_ram.delay_pair_count=TIME_GetTicks();
- fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
- send_host_into_fig();
- }
- else if(TIME_GetTicks() - host_ram.delay_pair_count > 500)
- {
- PAIR_CHARGERPIN_PRINT(" wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
- host_ram.statu=0;
- Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_host_process,0);
- i=3;
- }
- break;
-
- case 5:
- if(host_into_fig_senddone())
- {
- host_ram.statu=6;
- host_ram.into_event();
- PAIR_CHARGERPIN_PRINT(" into_event %d \n", TIME_GetTicks());
- host_ram.delay_pair_count=TIME_GetTicks();
- }
- break;
-
- case 6:
- if (TIME_GetTicks() - host_ram.delay_pair_count > PAIROVERTIME)
- {
- PAIR_CHARGERPIN_PRINT(" over_event %d\n", TIME_GetTicks());
- host_ram.statu=0;
- host_ram.over_event();
- Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_host_process,0);
- i=3;
- }
- break;
- //==============================s
- case 11:
- if((TIME_GetTicks() - host_ram.delay_pair_count > 5000)||(shefcheck_event_fag)||(one_byte_receive_error_code==1))
- {
- if(shefcheck_event_fag)
- {
- if(check_callbackt_ram)
- {
- check_callbackt_ram(shefcheck_buff[0]);
- PAIR_CHARGERPIN_INFO("check_callbackt_ram(shefcheck_buff[0]); %d\n", shefcheck_buff[0]);
- }
- }
- else
- {
- PAIR_CHARGERPIN_PRINT(" =====================wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
- }
- if(one_byte_receive_error_code==1)
- {
- one_byte_receive_error_code=0;
- PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d one_byte_receive_error_code\n", mFlash.isHost);
- }
- host_ram.statu=0;
- Process_UpdatePeroid(app_pair_host_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_host_process,0);
- one_byte_receive_uninit();
- PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d %d\n", mFlash.isHost,one_byte_receive_error_code);
- i=3;
- }
- break;
- //==============================s
- }
- }
- }
- //============================================================================================================
- #define CONN_MAX_ADC 1000
- #define CONN_MIN_ADC 750
- void app_pair_client_init(Event into,Event over)
- {
- client_ram.init=1;
- client_ram.adc_value=0;
- client_ram.delay_pair_count=0;
- client_ram.statu=0;
- client_ram.pair_line=DISCONNECT_CHARGE;
- client_ram.into_event=into;
- client_ram.over_event=over;
- fml_adc_sample_update_notify_register(fml_adc_callback);
- Process_Start(ADC_CHECKMS, "app_pair_client_process", app_pair_client_process);
- }
- void app_pair_client_uninit(void)
- {
- client_ram.init=0;
- Process_Stop(app_pair_client_process);
- }
- void app_pair_client_process_case1(void)
- {
- if(mFlash.isHost==HOST_SHOSE)
- {
- app_pair_client_uninit();
- app_pair_chargerpin_Init();
- PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d %d\n",TIME_GetTicks(),mFlash.isHost );
- }
- log("ad:%d,%d\n",client_ram.adc_value, client_ram.pair_line);
- PAIR_CHARGERPIN_PRINT("ADC ( %d ):isHost %d Ticks %d\n", client_ram.adc_value, mFlash.isHost,TIME_GetTicks());
-
- if(client_ram.adc_value>CONN_MAX_ADC)
- {
- PAIR_CHARGERPIN_PRINT("CHARGE\n");
- if(client_ram.pair_line!=CHARGE)
- {
- PAIR_CHARGERPIN_INFO("INTO CHARGE %d\n", mFlash.isHost);
- client_ram.pair_line=CHARGE;
- }
- }
- else if((client_ram.adc_value>CONN_MIN_ADC)&&(client_ram.adc_value<CONN_MIN_ADC+100))
- {
- PAIR_CHARGERPIN_PRINT("CONNECT_NO_CHARGE\n");
- if(client_ram.pair_line!=CONNECT_NO_CHARGE)
- {
- PAIR_CHARGERPIN_INFO("INTO CONNECT_NO_CHARGE %d %d\n", mFlash.isHost,client_ram.adc_value);
- client_ram.pair_line=CONNECT_NO_CHARGE;
-
- fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
-
-
- nrf_gpio_cfg(
- PIN_CHARGING,
- NRF_GPIO_PIN_DIR_OUTPUT,
- NRF_GPIO_PIN_INPUT_CONNECT,
- NRF_GPIO_PIN_NOPULL,
- NRF_GPIO_PIN_D0H1,
- NRF_GPIO_PIN_NOSENSE);
- nrf_gpio_cfg_watcher(PIN_CHARGING);
- nrf_gpio_pin_set(PIN_CHARGING);//à-??100ms
-
- client_ram.delay_pair_count=TIME_GetTicks();
- Process_UpdatePeroid(app_pair_client_process,1);
- Process_SetHoldOn(app_pair_client_process,1);
- client_ram.statu=2;
-
- }
- }
- else
- {
- if(client_ram.pair_line!=DISCONNECT_CHARGE)
- {
- PAIR_CHARGERPIN_INFO("INTO DISCONNECT_CHARGE %d\n", mFlash.isHost);
- client_ram.pair_line=DISCONNECT_CHARGE;
- }
- }
-
- //==============================s
- if(client_ram.adc_value>SHELF_CHECK_ADC_VALUE)
- {
- if(check_callbackt_ram)
- {
- client_ram.statu=11;
- client_ram.delay_pair_count=TIME_GetTicks();
- Process_UpdatePeroid(app_pair_client_process,100);
- Process_SetHoldOn(app_pair_client_process,1);
- one_byte_receive_init(shefcheck_buff,2,shefcheck_event);
- shefcheck_event_fag=0;
-
- one_byte_receive_Event_err_register(one_byte_receive_Event_err_hander);
- one_byte_receive_error_code=0;
-
- fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
- PAIR_CHARGERPIN_INFO("INTO SHELF_CHECK_ADC_VALUE %d\n", 1);
- if(check_callback_find_hi_ram)
- {
- check_callback_find_hi_ram();
- }
- return;
- }
- else
- {
- PAIR_CHARGERPIN_PRINT("check_callbackt_ram NULL\n");
- }
- }
- //==============================e
- }
- static void app_pair_client_process(void)
- {
- for(int i=1;i>0;i--)
- {
- switch(client_ram.statu)
- {
- case 0:
-
- fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
-
- client_ram.statu=1;
- break;
- case 1:
-
- break;
- case 2:
- if(TIME_GetTicks() - client_ram.delay_pair_count > 100)//μè100ms
- {
- nrf_gpio_pin_clear(PIN_CHARGING);
- client_ram.statu=3;
- client_ram.delay_pair_count=TIME_GetTicks();
- }
- break;
-
- case 3:
- if(nrf_gpio_pin_read(PIN_CHARGING)==0)
- {
- receive_host_into_fig();
- client_ram.statu=4;
- }
- else if(TIME_GetTicks() - client_ram.delay_pair_count > 100)
- {
- PAIR_CHARGERPIN_PRINT(" wait low over time1 %d\n", nrf_gpio_pin_read(PIN_CHARGING));
- client_ram.statu=0;
- Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_client_process,0);
- i=3;
- }
- break;
-
- case 4:
- if(host_into_fig_receivedone()==1)
- {
- client_ram.into_event();
- client_ram.delay_pair_count=TIME_GetTicks();
- PAIR_CHARGERPIN_PRINT(" into_event-C %d\n", TIME_GetTicks());
- client_ram.statu=5;
- }
- else if(host_into_fig_receivedone()==2)
- {
- PAIR_CHARGERPIN_PRINT(" wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
- client_ram.statu=0;
- Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_client_process,0);
- i=3;
- }
- break;
-
- case 5:
- if (TIME_GetTicks() - client_ram.delay_pair_count > PAIROVERTIME)
- {
- client_ram.statu=0;
- client_ram.over_event();
- Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_client_process,0);
- PAIR_CHARGERPIN_PRINT(" over_event %d\n", TIME_GetTicks());
- i=3;
- }
- break;
- //==============================s
- case 11:
- if((TIME_GetTicks() - client_ram.delay_pair_count > 5000)||(shefcheck_event_fag)||(one_byte_receive_error_code==1))
- {
- if(shefcheck_event_fag)
- {
- if(check_callbackt_ram)
- {
- check_callbackt_ram(shefcheck_buff[0]);
- PAIR_CHARGERPIN_INFO("check_callbackt_ram(shefcheck_buff[0]); %d\n", shefcheck_buff[0]);
- }
- }
- else
- {
- PAIR_CHARGERPIN_PRINT(" =====================wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
- }
-
- if(one_byte_receive_error_code==1)
- {
- one_byte_receive_error_code=0;
- PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d one_byte_receive_error_code\n", mFlash.isHost);
- }
- client_ram.statu=0;
- Process_UpdatePeroid(app_pair_client_process,ADC_CHECKMS);
- Process_SetHoldOn(app_pair_client_process,0);
- one_byte_receive_uninit();
- PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d %d\n", mFlash.isHost,one_byte_receive_error_code );
- i=3;
- }
- break;
- //==============================s
- }
- }
- }
- pair_line_t app_chargepin_pairline(void)
- {
- if (host_ram.init)
- {
- return host_ram.pair_line;
- }
- if (client_ram.init)
- {
- return client_ram.pair_line;
- }
- return NUL;
- }
|