#include "usr_config.h" #include "bsp_time.h" #include "system.h" #include "nrf_gpio.h" #include "app_charge.h" #include "app_flash.h" #include "ble_comm.h" #include "bsp_adc.h" #include "app_pair_chargerpin.h" #define PIN_LED_RUN 2 #define NO_BUTTON 0 #define DATA_LENGTH 4 #define BITWIDTH 40 #define LOW_BIT_DELAY 20 #define DELAY_SEND 100 #define DELAY_REPLY 100 #define DELAY_CHECK 100 #define DELAY_LEDON (BITWIDTH*(8*DATA_LENGTH+3)*2+DELAY_SEND+DELAY_REPLY+DELAY_CHECK+5*BITWIDTH) #define LEDON_KEEP 100 unsigned static char rxbuf[DATA_LENGTH]; unsigned static char txbuf[DATA_LENGTH]; __IO static char writefig=0; unsigned static char savebuf[DATA_LENGTH]; static char one_ms_status = 0; static void chargerpin_one_ms_pcs(void* t) { unsigned int ms = *(unsigned int*)t; static unsigned int bit_width = 0; static unsigned int now_bit = 0; static unsigned int delay_send_count = 0; static unsigned int delay_reply_count = 0; static unsigned int delay_check_count = 0; static unsigned int delay_ledon_count = 0; static int bitindex = 0; static int bytesindes = 0; static int value = 0; static int txrxcount = 0; static char lowbitdelay=0; switch (one_ms_status) { case 0://init bit_width = 0; now_bit = 0; delay_send_count = 0; delay_reply_count = 0; delay_check_count = 0; delay_ledon_count = 0; bitindex = 0; bytesindes = 0; value = 0; txrxcount = 0; one_ms_status = 0; lowbitdelay=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); one_ms_status = 1; nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("nrf_gpio_cfg_watcher(PIN_CHARGING); clear.%d\r\n", ms); break; case 1: if (now_bit == nrf_gpio_pin_read(PIN_CHARGING)) { bit_width++; //左鞋自动触发配对 #if NO_BUTTON if(mFlash.isHost) { if((bit_width>2000)&&(now_bit==0)) { nrf_gpio_pin_toggle(PIN_CHARGING); } if((bit_width>BITWIDTH*3)&&(now_bit==1)) { nrf_gpio_pin_toggle(PIN_CHARGING); } } #endif } else { //由高电平切换到低电平,下降信号 if (now_bit == 1) { now_bit = 0; if ((bit_width > 1.5 * BITWIDTH - BITWIDTH/10) && (bit_width < 1.5 * BITWIDTH + BITWIDTH/10)) { one_ms_status = 3; txrxcount = 1.5 * BITWIDTH; value = 30; if (mFlash.isHost == 0) { delay_ledon_count = 1.5 * BITWIDTH + DELAY_SEND; PAIR_CHARGERPIN_PRINT("delay_ledon_count = 1.5 * BITWIDTH + DELAY_SEND.%d\r\n", txrxcount); } else { delay_ledon_count = 2.5 * BITWIDTH + DELAY_SEND + BITWIDTH * 8 * DATA_LENGTH + 1.5 * BITWIDTH + DELAY_REPLY; PAIR_CHARGERPIN_PRINT("delay_ledon_count = 2.5 * BITWIDTH + DELAY_SEND + BITWIDTH*8*DATA_LENGTH + 1.5 * BITWIDTH + DELAY_REPLY .%d\r\n", txrxcount); } PAIR_CHARGERPIN_PRINT("-----------------------RX MODE start .%d\r\n", bit_width); break; } else { if (mFlash.isHost) { delay_send_count = 1; //左边鞋发送数据 } PAIR_CHARGERPIN_INFO("EXTI CHARGEING MOID.%d bit_width %d \r\n", ms,bit_width); } } else { now_bit = 1; delay_send_count = 0; delay_reply_count = 0; delay_check_count = 0; nrf_gpio_pin_write(PIN_LED_RUN, 0); delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count = 0 .%d\r\n", txrxcount); PAIR_CHARGERPIN_INFO("INTO CHARGEING MOID.%d\r\n", ms); } bit_width = 0; } if (delay_send_count != 0) { delay_send_count++; } if (delay_send_count > DELAY_SEND) { unsigned char macbuff[32]; delay_send_count = 0; PAIR_CHARGERPIN_PRINT("BEGIN send MAC.%d\r\n", ms); Get_MACaddr(macbuff); macbuff[DATA_LENGTH - 1] = 0; for (int i = 0; i < DATA_LENGTH - 1; i++) { macbuff[DATA_LENGTH - 1] += macbuff[i]; } memcpy(txbuf, macbuff, DATA_LENGTH); PAIR_CHARGERPIN_PRINT("host_mac send.%d\r\n", ms); one_ms_status = 2; txrxcount = 0; for (int i = 0; i < DATA_LENGTH; i++) { PAIR_CHARGERPIN_PRINT("txbuf.%x\r\n", txbuf[i]); } break; } if (delay_reply_count != 0) { delay_reply_count++; } if (delay_reply_count > DELAY_REPLY) { unsigned char macbuff[16]; delay_reply_count = 0; PAIR_CHARGERPIN_PRINT("BEGIN send MAC.%d\r\n", ms); Get_MACaddr(macbuff); memcpy(txbuf, &macbuff[3], DATA_LENGTH); txbuf[DATA_LENGTH - 1] = 0; for (int i = 0; i < DATA_LENGTH - 1; i++) { txbuf[DATA_LENGTH - 1] += txbuf[i]; } PAIR_CHARGERPIN_PRINT("host_mac send.%d\r\n", ms); one_ms_status = 2; txrxcount = 0; for (int i = 0; i < DATA_LENGTH; i++) { PAIR_CHARGERPIN_PRINT("txbuf.%x\r\n", txbuf[i]); } break; } if (delay_check_count != 0) { delay_check_count++; } if (delay_check_count > DELAY_CHECK) { delay_check_count = 0; one_ms_status = 4; txrxcount = 0; PAIR_CHARGERPIN_PRINT("CHECK start.%d\r\n", ms); break; } else if (delay_check_count > 0) { if (now_bit > 0) { delay_check_count = 0; PAIR_CHARGERPIN_PRINT("CANCEL CHECK.%d\r\n", ms); } } break; case 2://tx { lowbitdelay++; static char send_interrupt = 0; if ((now_bit == 0) && (nrf_gpio_pin_read(PIN_CHARGING)) && (lowbitdelay>LOW_BIT_DELAY)) { if (mFlash.isHost) { one_ms_status = 1; nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", ms); delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count1 = 0;\r\n", txrxcount); PAIR_CHARGERPIN_PRINT("EXTI SEND MODE.CAN NOT SET LOW %d\r\n", txrxcount); send_interrupt = 0; break; } else { nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", ms); send_interrupt = 1; } } if ((txrxcount == 0) && (send_interrupt == 0)) { nrf_gpio_pin_set(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("set.%d\r\n", ms); now_bit = 1; } if ((txrxcount == 1.5 * BITWIDTH) && (send_interrupt == 0)) { nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", ms); now_bit = 0; lowbitdelay=0; } if ((txrxcount >= (int)(2.5 * BITWIDTH) && (txrxcount - (int)(2.5 * BITWIDTH)) % BITWIDTH == 0) && (send_interrupt == 0)) { bytesindes = ((txrxcount - (int)(2.5 * BITWIDTH)) / BITWIDTH) / 8; bitindex = 7 - ((txrxcount - (int)(2.5 * BITWIDTH)) / BITWIDTH) % 8; nrf_gpio_pin_write(PIN_CHARGING, (txbuf[bytesindes] >> bitindex) & 0x01); lowbitdelay=0; PAIR_CHARGERPIN_PRINT("write.%d %d\r\n", ((txbuf[bytesindes] >> bitindex) & 0x01), ms); now_bit = (txbuf[bytesindes] >> bitindex) & 0x01; PAIR_CHARGERPIN_PRINT("%d %d %d %d %x\r\n", (txrxcount - (int)(2.5 * BITWIDTH)) / BITWIDTH , bytesindes , bitindex , (txbuf[bytesindes] >> bitindex) & 0x01 , txbuf[bytesindes] ); } if (send_interrupt) { if (nrf_gpio_pin_read(PIN_CHARGING) == 0) { send_interrupt = 0; delay_ledon_count = DELAY_SEND; PAIR_CHARGERPIN_PRINT("delay_ledon_count = DELAY_SEND;.%d\r\n", txrxcount); PAIR_CHARGERPIN_PRINT("RX SEND MODE MAC START.%d\r\n", txrxcount); txrxcount = 0; break; } } if (txrxcount == BITWIDTH * (8 * DATA_LENGTH + 2.5) - 1) { nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", ms); if (mFlash.isHost == 0) { delay_check_count = 1; } } if(delay_check_count!=0)delay_check_count++; if (txrxcount >= BITWIDTH * (8 * DATA_LENGTH + 2.5) - 1 + LOW_BIT_DELAY) { one_ms_status = 1; send_interrupt = 0; now_bit = 0; bit_width = 0; PAIR_CHARGERPIN_PRINT("SEDN DONE .%d pin one_ms_status %d\r\n", ms,nrf_gpio_pin_read(PIN_CHARGING)); break; } txrxcount++; } break; case 3://rx if (now_bit == nrf_gpio_pin_read(PIN_CHARGING)) { bit_width++; } else { if (now_bit == 1) { now_bit = 0; if ((bit_width > 1.5 * BITWIDTH - 3) && (bit_width < 1.8 * BITWIDTH + 3)) { txrxcount = 1.5 * BITWIDTH; value = 30; delay_ledon_count = DELAY_SEND + 1.5 * BITWIDTH; PAIR_CHARGERPIN_PRINT("DELAY_SEND + 1.5 * BITWIDTHt .%d\r\n", txrxcount); PAIR_CHARGERPIN_PRINT("RX MODE restart .%d\r\n", ms); } } else { now_bit = 1; } bit_width = 0; } if (txrxcount >= (int)(3.5 * BITWIDTH) && (txrxcount - (int)(3.5 * BITWIDTH)) % BITWIDTH == 0) { bytesindes = ((txrxcount - (int)(3.5 * BITWIDTH)) / BITWIDTH) / 8; bitindex = 7 - ((txrxcount - (int)(3.5 * BITWIDTH)) / BITWIDTH) % 8; if (value > 0) { rxbuf[bytesindes] |= 0x01 << bitindex; } else { rxbuf[bytesindes] &= ~(0x01 << bitindex); } PAIR_CHARGERPIN_PRINT("%d %d %d %d %x\r\n", txrxcount , bytesindes , bitindex , value , rxbuf[bytesindes] ); value = 0; nrf_gpio_pin_toggle(PIN_LED_RUN); } else { if (now_bit) { value++; } else { value--; } } if (txrxcount >= BITWIDTH * (8 * DATA_LENGTH + 2.5)) { unsigned char dataerrcheck = 0; unsigned char crc = 0; one_ms_status = 1; PAIR_CHARGERPIN_PRINT("RECEVIC DONE .%d\r\n", txrxcount); nrf_gpio_pin_clear(PIN_LED_RUN); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", ms); for (int i = 0; i < DATA_LENGTH - 1; i++) { crc += rxbuf[i]; } for (int i = 0; i < DATA_LENGTH - 1; i++) { if (rxbuf[i] == 0) { dataerrcheck++; } } if (dataerrcheck == DATA_LENGTH - 1) { PAIR_CHARGERPIN_PRINT("CRC ERROR ALL 0x00.%x\r\n", crc); delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count 2= 0;\r\n", txrxcount); break; } dataerrcheck = 0; for (int i = 0; i < DATA_LENGTH - 1; i++) { if (rxbuf[i] == 0xff) { dataerrcheck++; } } if (dataerrcheck == DATA_LENGTH - 1) { PAIR_CHARGERPIN_PRINT("CRC ERROR ALL 0xFF.%x\r\n", crc); delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count 3= 0;\r\n", txrxcount); break; } if (crc == rxbuf[DATA_LENGTH - 1]) { if (mFlash.isHost) { delay_check_count = 1; //延时校验计数器 } else { delay_reply_count = 1; //延时回复计数器 } PAIR_CHARGERPIN_PRINT("---------------CRC SUCCESS .%x----------------\r\n", crc); } else { PAIR_CHARGERPIN_PRINT("CRC ERROR .%x\r\n", crc); delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count 4= 0;\r\n", txrxcount); } for (int i = 0; i < DATA_LENGTH; i++) { PAIR_CHARGERPIN_PRINT("rxbuf[%d].%x\r\n",i, rxbuf[i]); } } txrxcount++; break; case 4: if (nrf_gpio_pin_read(PIN_CHARGING)) { value++; } else { value--; } if (mFlash.isHost) { if (txrxcount == 0) { value = 0; nrf_gpio_pin_set(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("set.%d\r\n", ms); } if (txrxcount == 3 * BITWIDTH) { nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", delay_ledon_count); } if (txrxcount >= 3 * BITWIDTH + LOW_BIT_DELAY) { value = 0; one_ms_status = 1; now_bit = 0; bit_width = 0; } } else { if (txrxcount == 0) { value = 0; } if (txrxcount > 3 * BITWIDTH) { if (value < 2 * BITWIDTH) { PAIR_CHARGERPIN_PRINT("CHECK ERROR .%d\r\n", txrxcount); delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count 5= 0;\r\n", txrxcount); } else { PAIR_CHARGERPIN_PRINT("CHECK DONE .%d\r\n", txrxcount); } value = 0; one_ms_status = 1; nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT("clear.%d\r\n", ms); now_bit = 1; bit_width = 0; } } txrxcount++; break; } if (delay_ledon_count != 0) { delay_ledon_count++; } if (delay_ledon_count == DELAY_LEDON) { nrf_gpio_pin_write(PIN_LED_RUN, 1); PAIR_CHARGERPIN_PRINT("LEDCOPEN.%d\r\n", ms); memcpy(savebuf,rxbuf,DATA_LENGTH-1); } if ((delay_ledon_count > DELAY_LEDON ) && (delay_ledon_count - DELAY_LEDON == LEDON_KEEP)) { delay_ledon_count = 0; PAIR_CHARGERPIN_PRINT("delay_ledon_count 6= 0;\r\n", txrxcount); nrf_gpio_pin_write(PIN_LED_RUN, 0); PAIR_CHARGERPIN_PRINT("LEDCLOSE.%d\r\n", ms); writefig=1; } } //写配对相关的flish static int pair_writeflish(unsigned char* macAddr_L, unsigned char* macAddr_R) { if (memcmp(macAddr_L, mFlash.macHost, 6) != 0) { goto writein; } if (memcmp(macAddr_R, mFlash.mClient.macAddr, 6) != 0) { goto writein; } if (mFlash.mClient.isConfig != 'C') { goto writein; } PAIR_CHARGERPIN_PRINT("mFlash.mClient.isConfig:%X\n", mFlash.mClient.isConfig); PAIR_CHARGERPIN_PRINT("mFlash.mClient.macAddr:%02X %02X %02X %02X %02X %02X\n", mFlash.mClient.macAddr[0], mFlash.mClient.macAddr[1], mFlash.mClient.macAddr[2], mFlash.mClient.macAddr[3], mFlash.mClient.macAddr[4], mFlash.mClient.macAddr[5]); PAIR_CHARGERPIN_PRINT("mFlash.macHost:%02X %02X %02X %02X %02X %02X\n", mFlash.macHost[0], mFlash.macHost[1], mFlash.macHost[2], mFlash.macHost[3], mFlash.macHost[4], mFlash.macHost[5]); return 0; writein: mFlash.mClient.isConfig = 'C'; for (int i = 0; i < 6; i++) { mFlash.mClient.macAddr[i] = macAddr_R[i]; //从机自身mac地址 mFlash.macHost[i] = macAddr_L[i]; //主机发过来的mac地址 } PAIR_CHARGERPIN_PRINT("mFlash.mClient.isConfig:%X\n", mFlash.mClient.isConfig); PAIR_CHARGERPIN_PRINT("mFlash.mClient.macAddr:%02X %02X %02X %02X %02X %02X\n", mFlash.mClient.macAddr[0], mFlash.mClient.macAddr[1], mFlash.mClient.macAddr[2], mFlash.mClient.macAddr[3], mFlash.mClient.macAddr[4], mFlash.mClient.macAddr[5]); PAIR_CHARGERPIN_PRINT("mFlash.macHost:%02X %02X %02X %02X %02X %02X\n", mFlash.macHost[0], mFlash.macHost[1], mFlash.macHost[2], mFlash.macHost[3], mFlash.macHost[4], mFlash.macHost[5]); Flash_SaveInfomation(); return 1; } static void load_adv_name_from_flish(void) { char buf[16]; memset(buf, 0, 16); advertising_stop(); sprintf(buf, "%02X%02X%02X%02X%02X%02X", mFlash.macHost[0], mFlash.macHost[1], mFlash.macHost[2], mFlash.mClient.macAddr[3], mFlash.mClient.macAddr[4], mFlash.mClient.macAddr[5]); SEGGER_RTT_printf(0, "advName(%d):%s\n", strlen(buf), buf); slave_set_adv_name(buf, strlen(buf)); slave_adv_init(); advertising_start(); } static void load_scan_name_from_flish(void) { char buf[16]; memset(buf, 0, 16); sprintf(buf, "%02X%02X%02X%02X%02X%02X", mFlash.macHost[0], mFlash.macHost[1], mFlash.macHost[2], mFlash.mClient.macAddr[3], mFlash.mClient.macAddr[4], mFlash.mClient.macAddr[5]); SEGGER_RTT_printf(0, "scanName1(%d):%s\n", strlen(buf), buf); host_set_scan_name(buf, strlen(buf)); } static void load_scan_name_dafual(void) { char buf[] = "SCANBUFF"; SEGGER_RTT_printf(0, "scanName1(%d):%s\n", strlen(buf), buf); host_set_scan_name(buf, strlen(buf)); } static void app_pair_chargerpin_pcs(void) { int rev=0; if(writefig==1) { unsigned char Lbuff[6]; unsigned char Rbuff[6]; if(mFlash.isHost) { Get_MACaddr(Lbuff); Rbuff[0]=0xFF;Rbuff[1]=0xFF;Rbuff[2]=0xFF; Rbuff[3]=savebuf[0];Rbuff[4]=savebuf[1];Rbuff[5]=savebuf[2]; } else { Get_MACaddr(Rbuff); Lbuff[0]=savebuf[0];Lbuff[1]=savebuf[1];Lbuff[2]=savebuf[2]; Lbuff[3]=0xFF;Lbuff[4]=0xFF;Lbuff[5]=0xFF; } rev=pair_writeflish(Lbuff,Rbuff); if(rev) { if(mFlash.isHost) { load_scan_name_from_flish(); } else { load_adv_name_from_flish(); } } writefig=0; } } static void chargerpin_one_ms_pcs_test(void* t) { static unsigned int count=0; count++; if(count%20==0) { nrf_gpio_pin_toggle(PIN_LED_RUN); SEGGER_RTT_printf(0, "count ( %d ):\n", count); } } #define CHARGE_ADC 1800 #define DISCON_L_MAX_ADC 1450 #define DISCON_L_MIN_ADC 1300 #define CONN_MAX_ADC 1000 #define CONN_MIN_ADC 500 #define DISCON_R_MAX_ADC 100 typedef enum { CHARGE=0, CONNECT_NO_CHARGE, DISCONNECT_CHARGE, }pair_line_t; #define ADC_CHECKMS 1000 #define DELAY_PAIR_COUNT 100 void adc_check(void) { static unsigned char status=0; short ADC_value=0; static pair_line_t pair_line; static unsigned int delay_pair_count=0; static unsigned int overtime=0; static unsigned char ishost; switch(status) { case 0: ishost=mFlash.isHost; if (mFlash.isHost == 1) { ADC_Disable(); ADC_SetPinChannel(PIN_CHARGING,PIN_CHARGING_CHANNEL,NRF_GPIO_PIN_PULLUP); ADC_Initialize(); } else { ADC_Disable(); ADC_SetPinChannel(PIN_CHARGING,PIN_CHARGING_CHANNEL,NRF_GPIO_PIN_NOPULL); ADC_Initialize(); } status=1; break; case 1: if(ishost!=mFlash.isHost) { status=0; PAIR_CHARGERPIN_PRINT("mFlash.isHost change %d\n",mFlash.isHost); } ADC_Read(PIN_CHARGING_CHANNEL,&ADC_value); PAIR_CHARGERPIN_PRINT( "ADC ( %d ):%d\n", ADC_value,mFlash.isHost); if(ADC_value>=CHARGE_ADC) { PAIR_CHARGERPIN_PRINT(" CHARGE_ADC \n"); pair_line=CHARGE; } if(mFlash.isHost) { if((ADC_value<=DISCON_L_MAX_ADC)&&(ADC_value>=DISCON_L_MIN_ADC)) { PAIR_CHARGERPIN_PRINT("L DISCON_L_ADC \n"); pair_line=DISCONNECT_CHARGE; } } else { if(ADC_value<=DISCON_R_MAX_ADC) { PAIR_CHARGERPIN_PRINT("R DISCON_R_MAX_ADC \n"); pair_line=DISCONNECT_CHARGE; } } if((ADC_value>=CONN_MIN_ADC)&&(ADC_value<=CONN_MAX_ADC)) { PAIR_CHARGERPIN_PRINT(" CONN_ADC %d \n",pair_line); if(pair_line!=CONNECT_NO_CHARGE) { PAIR_CHARGERPIN_PRINT(" Process_SetHoldOn(adc_check,1); \n"); overtime=TIME_GetTicks(); Process_UpdatePeroid(adc_check,10); Process_SetHoldOn(adc_check,1); if(mFlash.isHost) { status=2; delay_pair_count=TIME_GetTicks(); } else { status=5; TIME_Regist(chargerpin_one_ms_pcs); one_ms_status = 0; } } pair_line=CONNECT_NO_CHARGE; } break; case 2:// if(TIME_GetTicks()- delay_pair_count > ADC_CHECKMS+100) { TIME_Regist(chargerpin_one_ms_pcs); one_ms_status = 0; status=3; PAIR_CHARGERPIN_PRINT(" TIME_Regist(chargerpin_one_ms_pcs); %d \n",TIME_GetTicks()); } break; case 3: if(TIME_GetTicks()- delay_pair_count > DELAY_PAIR_COUNT) { nrf_gpio_pin_set(PIN_CHARGING); PAIR_CHARGERPIN_PRINT(" SEND PAIR TAG HIG; %d \n",TIME_GetTicks()); status=4; } break; case 4: if(TIME_GetTicks()- delay_pair_count>(DELAY_PAIR_COUNT+100)) { nrf_gpio_pin_clear(PIN_CHARGING); PAIR_CHARGERPIN_PRINT(" SEND PAIR TAG LOW; %d \n",TIME_GetTicks()); status=5; } break; case 5: if(writefig==1) { app_pair_chargerpin_pcs(); TIME_UnRegist(chargerpin_one_ms_pcs); Process_UpdatePeroid(adc_check,ADC_CHECKMS); Process_SetHoldOn(adc_check,0); status=0; PAIR_CHARGERPIN_PRINT(" ---------------------------PAIR SUCESS------------- \n"); } if(TIME_GetTicks()-overtime > DELAY_LEDON+DELAY_PAIR_COUNT+2000) { TIME_UnRegist(chargerpin_one_ms_pcs); Process_UpdatePeroid(adc_check,ADC_CHECKMS); Process_SetHoldOn(adc_check,0); status=0; PAIR_CHARGERPIN_PRINT(" ---------------------------PAIR OVER TIME %d------------- \n",TIME_GetTicks()); } break; } } void app_pair_chargerpin_Init(void) { Process_Start(ADC_CHECKMS,"adc_check",adc_check); }