#include "hal_mt.h" #include "nrf_gpio.h" #include "usr_config.h" #include "bsp_time.h" #include "system.h" #include "hal_ble_client.h" #include "hal_ble_host.h" /************************ 函数声明 ***********************************/ void MT_process(void); /************************ 变量 ***********************************/ /************************ 函数定义 ***********************************/ static uint32_t mt_time = 0; void MT_Run(uint32_t tim) { if(tim>0){ mt_time = tim; nrf_gpio_pin_write(PIN_MT_EN,1); Process_SetHoldOn(MT_process,1); } } void gpio_mt_run(uint32_t tim) { MT_Run(tim); } void MT_process(void) { } void MT_TimerCounter(void* t) { if(mt_time>0){ if(mt_time >=10)mt_time -=10; else mt_time=0;; if(mt_time==0){ nrf_gpio_pin_write(PIN_MT_EN,0); Process_SetHoldOn(MT_process,0); } } } void cb_BLE_Client_R_SHOCK(void* handle) { BLE_Client_Rx_t *target = handle; BLE_Host_Tx_Send(0,BLE_Host_T_SHOCK,target->pDat,target->datLen); uint16_t t = ((uint16_t)(target->pDat[0])<<8) | ((uint16_t)(target->pDat[0])<<0); MT_Run(t); SEGGER_RTT_printf(0,"MT RUN:%d \n",t); } void MT_Init(void) { nrf_gpio_cfg_output(PIN_MT_EN); nrf_gpio_pin_write(PIN_MT_EN,0); MT_Run(100); TIME_Regist(MT_TimerCounter); Process_Start(0,"MT_process",MT_process); BLE_Client_Rx_Regist(BLE_Client_R_SHOCK,cb_BLE_Client_R_SHOCK); }