소스 검색

add selfcheck rec

Chenyingjia 2 년 전
부모
커밋
8b9c926956
1개의 변경된 파일39개의 추가작업 그리고 1개의 파일을 삭제
  1. 39 1
      hal/hal_charge.c

+ 39 - 1
hal/hal_charge.c

@@ -12,7 +12,7 @@
 #include "app_pair_chargerpin.h"
 #include "hal_charge.h"
 #include "fml_adc.h"
-
+#include "app_one_wire.h"
 /************************ º¯ÊýÉùÃ÷ ***********************************/
 
 /************************ ±äÁ¿ ***********************************/
@@ -63,6 +63,43 @@ void cb_BLE_Host_R_CHARGE(void* handle)
 //	DEBUG_LOG("cb_BLE_Host_R_CHARGE:%d,%d,%d\n",target->pDat[0],target->pDat[1],target->datLen);
 }
 
+extern	void selfcheck_trigger_callback(char order);
+unsigned char recbuf[4];
+static char selfcheck_trigger_ok=0;
+static unsigned int ms_cnt=0;
+__IO char tsfd=0;
+void wait_times(void)
+{
+		ms_cnt++;
+		if(tsfd)
+		{
+			tsfd=0;
+			selfcheck_trigger_callback((char)recbuf[0]);	
+		}
+		if(ms_cnt<1000)return;
+//		SEGGER_RTT_printf(0,"wait_times out...\n");
+		Process_Stop(wait_times);
+		one_byte_receive_uninit();
+		ms_cnt=0;selfcheck_trigger_ok=0;
+		fml_adc_set_pin_channel(PIN_CHARGING, PIN_CHARGING_CHANNEL, NRF_GPIO_PIN_NOPULL);
+}
+void Event_self_check(unsigned char *buf,int length)
+{
+	tsfd=1;
+//	SEGGER_RTT_printf(0,"Event_self_check out... %x\n",buf[0]);
+}
+
+void open_one_shel(void)
+{
+	if(selfcheck_trigger_ok)return;
+	selfcheck_trigger_ok=1;
+	one_byte_receive_init(recbuf,2,Event_self_check);
+//	SEGGER_RTT_printf(0,"open_one_shel in...\n");
+	Process_Start(1, "wait_times", wait_times);
+	Process_SetHoldOn(wait_times, 1);
+}
+
+
 static void hal_charge_Process(void)
 {
 	#if ONE_WIRE_ENABLE
@@ -93,6 +130,7 @@ static void hal_charge_Process(void)
 			hal_charge_state = BLE_CHARGE_INSERT;
 			Process_SetHoldOn(hal_charge_Process,1);
 			hal_send_charge();
+			open_one_shel();
 		}
 	}
 }