|
@@ -7,6 +7,7 @@
|
|
#include "hal_mt.h"
|
|
#include "hal_mt.h"
|
|
#include "app_flash.h"
|
|
#include "app_flash.h"
|
|
#include "app_pair_chargerpin.h"
|
|
#include "app_pair_chargerpin.h"
|
|
|
|
+#include "app_one_wire.h"
|
|
|
|
|
|
//=================debug=============
|
|
//=================debug=============
|
|
#include "ringframe.h"
|
|
#include "ringframe.h"
|
|
@@ -57,7 +58,7 @@ void app_pair_host_uninit(void)
|
|
}
|
|
}
|
|
|
|
|
|
#define DISCON_HOST_MAX_ADC 1200
|
|
#define DISCON_HOST_MAX_ADC 1200
|
|
-#define DISCON_HOST_MIN_ADC 700
|
|
|
|
|
|
+#define DISCON_HOST_MIN_ADC 600
|
|
|
|
|
|
#define CON_HOST_MAX_ADC DISCON_HOST_MIN_ADC
|
|
#define CON_HOST_MAX_ADC DISCON_HOST_MIN_ADC
|
|
#define CON_HOST_MIN_ADC 300
|
|
#define CON_HOST_MIN_ADC 300
|
|
@@ -65,7 +66,7 @@ void app_pair_host_uninit(void)
|
|
static void null_pcs(void)
|
|
static void null_pcs(void)
|
|
{
|
|
{
|
|
}
|
|
}
|
|
-#define UPPULL_MS 5
|
|
|
|
|
|
+#define UPPULL_MS 3
|
|
static void ReadAdc_timcallback(void *t)
|
|
static void ReadAdc_timcallback(void *t)
|
|
{
|
|
{
|
|
if(TIME_GetTicks()-host_ram.pulluppcs_timer<UPPULL_MS)return;
|
|
if(TIME_GetTicks()-host_ram.pulluppcs_timer<UPPULL_MS)return;
|
|
@@ -100,7 +101,19 @@ static void ReadAdc_timcallback(void *t)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+//-------------------------------------------
|
|
|
|
+unsigned char shefcheck_buff[5];
|
|
|
|
+char shefcheck_event_fag=0;
|
|
|
|
+check_callbackt check_callbackt_ram;
|
|
|
|
+void shefcheck_event(unsigned char *buff, int length)
|
|
|
|
+{
|
|
|
|
+ shefcheck_event_fag=1;
|
|
|
|
+}
|
|
|
|
+void check_callback_regist(check_callbackt evt)
|
|
|
|
+{
|
|
|
|
+check_callbackt_ram=evt;
|
|
|
|
+}
|
|
|
|
+//-------------------------------------------
|
|
static void app_pair_host_process(void)
|
|
static void app_pair_host_process(void)
|
|
{
|
|
{
|
|
for(int i=1;i>0;i--)
|
|
for(int i=1;i>0;i--)
|
|
@@ -120,11 +133,32 @@ static void app_pair_host_process(void)
|
|
app_pair_chargerpin_Init();
|
|
app_pair_chargerpin_Init();
|
|
PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d %d\n",TIME_GetTicks(),mFlash.isHost );
|
|
PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d %d\n",TIME_GetTicks(),mFlash.isHost );
|
|
}
|
|
}
|
|
-// if (ADC_OP_SUCCESS != ADC_Read(PIN_CHARGING_CHANNEL, &host_ram.adc_value))
|
|
|
|
-// {
|
|
|
|
-// PAIR_CHARGERPIN_PRINT("ADC_Read ERROR %d\n", host_ram.adc_value);
|
|
|
|
-// }
|
|
|
|
-// PAIR_CHARGERPIN_PRINT("ADC f( %d ):isHost %d Ticks %d\n", host_ram.adc_value, mFlash.isHost,TIME_GetTicks());
|
|
|
|
|
|
+//==============================s
|
|
|
|
+ if (ADC_OP_SUCCESS != ADC_Read(PIN_CHARGING_CHANNEL, &host_ram.adc_value))
|
|
|
|
+ {
|
|
|
|
+ PAIR_CHARGERPIN_PRINT("ADC_Read ERROR %d\n", host_ram.adc_value);
|
|
|
|
+ }
|
|
|
|
+ PAIR_CHARGERPIN_PRINT("ADC f( %d ):isHost %d Ticks %d\n", host_ram.adc_value, mFlash.isHost,TIME_GetTicks());
|
|
|
|
+ if(host_ram.adc_value>2800)
|
|
|
|
+ {
|
|
|
|
+ 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;
|
|
|
|
+ i=2;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ PAIR_CHARGERPIN_PRINT("check_callbackt_ram NULL\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+//==============================e
|
|
|
|
+
|
|
nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_PULLUP);
|
|
nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_PULLUP);
|
|
PAIR_CHARGERPIN_PRINT("nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_PULLUP); %d \n",TIME_GetTicks() );
|
|
PAIR_CHARGERPIN_PRINT("nrf_gpio_cfg_input(PIN_CHARGING, NRF_GPIO_PIN_PULLUP); %d \n",TIME_GetTicks() );
|
|
host_ram.pulluppcs_timer = TIME_GetTicks();
|
|
host_ram.pulluppcs_timer = TIME_GetTicks();
|
|
@@ -238,6 +272,27 @@ static void app_pair_host_process(void)
|
|
i=3;
|
|
i=3;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+//==============================s
|
|
|
|
+ case 11:
|
|
|
|
+ if((TIME_GetTicks() - host_ram.delay_pair_count > 5000)||(shefcheck_event_fag))
|
|
|
|
+ {
|
|
|
|
+ if(shefcheck_event_fag)
|
|
|
|
+ {
|
|
|
|
+ if(check_callbackt_ram)check_callbackt_ram(shefcheck_buff[0]);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ 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);
|
|
|
|
+ one_byte_receive_uninit();
|
|
|
|
+
|
|
|
|
+ i=3;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+//==============================s
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -294,6 +349,28 @@ static void app_pair_client_process(void)
|
|
}
|
|
}
|
|
log("ad:%d,%d\n",client_ram.adc_value, client_ram.pair_line);
|
|
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());
|
|
PAIR_CHARGERPIN_PRINT("ADC ( %d ):isHost %d Ticks %d\n", client_ram.adc_value, mFlash.isHost,TIME_GetTicks());
|
|
|
|
+
|
|
|
|
+//==============================s
|
|
|
|
+ if(client_ram.adc_value>2800)
|
|
|
|
+ {
|
|
|
|
+ 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;
|
|
|
|
+ i=2;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ PAIR_CHARGERPIN_PRINT("check_callbackt_ram NULL\n");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+//==============================e
|
|
|
|
+
|
|
if(client_ram.adc_value>CONN_MAX_ADC)
|
|
if(client_ram.adc_value>CONN_MAX_ADC)
|
|
{
|
|
{
|
|
PAIR_CHARGERPIN_PRINT("CHARGE\n");
|
|
PAIR_CHARGERPIN_PRINT("CHARGE\n");
|
|
@@ -379,6 +456,27 @@ static void app_pair_client_process(void)
|
|
i=3;
|
|
i=3;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+//==============================s
|
|
|
|
+ case 11:
|
|
|
|
+ if((TIME_GetTicks() - client_ram.delay_pair_count > 5000)||(shefcheck_event_fag))
|
|
|
|
+ {
|
|
|
|
+ if(shefcheck_event_fag)
|
|
|
|
+ {
|
|
|
|
+ if(check_callbackt_ram)check_callbackt_ram(shefcheck_buff[0]);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ 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);
|
|
|
|
+ one_byte_receive_uninit();
|
|
|
|
+
|
|
|
|
+ i=3;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+//==============================s
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|