|
@@ -69,6 +69,15 @@ void fml_adc_callback(uint32_t sample_point, Fml_Adc_All_Channel_Adc_Value_t all
|
|
|
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);
|
|
@@ -83,15 +92,6 @@ void fml_adc_callback(uint32_t sample_point, Fml_Adc_All_Channel_Adc_Value_t all
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- 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();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
#else
|
|
|
static char asjdhaskjhdki=0;
|
|
|
PAIR_CHARGERPIN_PRINT("ADC_Read fml_adc_callback %d\n", all_adc_value.channel_4_adc_value);
|
|
@@ -141,19 +141,27 @@ static void null_pcs(void)
|
|
|
//-------------------------------------------
|
|
|
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;
|
|
|
+ check_callbackt_ram=evt;
|
|
|
}
|
|
|
void check_callback_find_hi_regist(Event evt)
|
|
|
{
|
|
|
-check_callback_find_hi_ram=evt;
|
|
|
+ check_callback_find_hi_ram=evt;
|
|
|
}
|
|
|
//-------------------------------------------
|
|
|
|
|
@@ -189,6 +197,10 @@ void app_pair_host_process_case1(void)
|
|
|
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);
|
|
@@ -255,6 +267,120 @@ void app_pair_host_process_case2(void)
|
|
|
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)
|
|
|
{
|
|
@@ -274,7 +400,7 @@ static void app_pair_host_process(void)
|
|
|
case 2:
|
|
|
|
|
|
break;
|
|
|
- case 3://é?à-è?′ó?ú·¢??????D?o?
|
|
|
+ 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());
|
|
@@ -295,17 +421,10 @@ static void app_pair_host_process(void)
|
|
|
case 4:
|
|
|
if(nrf_gpio_pin_read(PIN_CHARGING)==0)
|
|
|
{
|
|
|
- PAIR_CHARGERPIN_PRINT(" into_event %d \n", TIME_GetTicks());
|
|
|
host_ram.statu=5;
|
|
|
host_ram.delay_pair_count=TIME_GetTicks();
|
|
|
-
|
|
|
-
|
|
|
fml_adc_remove_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL);
|
|
|
-
|
|
|
-
|
|
|
- log("into_event-H\n");
|
|
|
- host_ram.into_event();
|
|
|
-
|
|
|
+ send_host_into_fig();
|
|
|
}
|
|
|
else if(TIME_GetTicks() - host_ram.delay_pair_count > 500)
|
|
|
{
|
|
@@ -316,7 +435,18 @@ static void app_pair_host_process(void)
|
|
|
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());
|
|
@@ -329,21 +459,30 @@ static void app_pair_host_process(void)
|
|
|
break;
|
|
|
//==============================s
|
|
|
case 11:
|
|
|
- if((TIME_GetTicks() - host_ram.delay_pair_count > 5000)||(shefcheck_event_fag))
|
|
|
+ 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]);
|
|
|
+ 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\n", mFlash.isHost);
|
|
|
+ PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d %d\n", mFlash.isHost,one_byte_receive_error_code);
|
|
|
i=3;
|
|
|
}
|
|
|
break;
|
|
@@ -355,7 +494,7 @@ static void app_pair_host_process(void)
|
|
|
|
|
|
|
|
|
#define CONN_MAX_ADC 1000
|
|
|
-#define CONN_MIN_ADC 600
|
|
|
+#define CONN_MIN_ADC 750
|
|
|
void app_pair_client_init(Event into,Event over)
|
|
|
{
|
|
|
client_ram.init=1;
|
|
@@ -395,12 +534,12 @@ void app_pair_client_process_case1(void)
|
|
|
client_ram.pair_line=CHARGE;
|
|
|
}
|
|
|
}
|
|
|
- else if(client_ram.adc_value>CONN_MIN_ADC)
|
|
|
+ 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\n", mFlash.isHost);
|
|
|
+ PAIR_CHARGERPIN_INFO("INTO CONNECT_NO_CHARGE %d %d\n", mFlash.isHost,client_ram.adc_value);
|
|
|
client_ram.pair_line=CONNECT_NO_CHARGE;
|
|
|
|
|
|
|
|
@@ -444,6 +583,10 @@ void app_pair_client_process_case1(void)
|
|
|
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)
|
|
@@ -482,26 +625,42 @@ static void app_pair_client_process(void)
|
|
|
client_ram.delay_pair_count=TIME_GetTicks();
|
|
|
}
|
|
|
break;
|
|
|
+
|
|
|
case 3:
|
|
|
if(nrf_gpio_pin_read(PIN_CHARGING)==0)
|
|
|
{
|
|
|
- log("into_event-C\n");
|
|
|
- client_ram.into_event();
|
|
|
- client_ram.delay_pair_count=TIME_GetTicks();
|
|
|
- PAIR_CHARGERPIN_PRINT(" into_event-C %d\n", TIME_GetTicks());
|
|
|
- PAIR_CHARGERPIN_PRINT(" wait pair %d\n", nrf_gpio_pin_read(PIN_CHARGING));
|
|
|
+ receive_host_into_fig();
|
|
|
client_ram.statu=4;
|
|
|
}
|
|
|
else if(TIME_GetTicks() - client_ram.delay_pair_count > 100)
|
|
|
{
|
|
|
- PAIR_CHARGERPIN_PRINT(" wait low over time %d\n", nrf_gpio_pin_read(PIN_CHARGING));
|
|
|
+ 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;
|
|
@@ -514,21 +673,31 @@ static void app_pair_client_process(void)
|
|
|
break;
|
|
|
//==============================s
|
|
|
case 11:
|
|
|
- if((TIME_GetTicks() - client_ram.delay_pair_count > 5000)||(shefcheck_event_fag))
|
|
|
+ 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]);
|
|
|
+ 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\n", 1);
|
|
|
+ PAIR_CHARGERPIN_INFO("EXTI SHELF_CHECK_ADC_VALUE %d %d\n", mFlash.isHost,one_byte_receive_error_code );
|
|
|
i=3;
|
|
|
}
|
|
|
break;
|