12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #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"
- #include "app_flash.h"
- /************************ º¯ÊýÉùÃ÷ ***********************************/
- void MT_process(void);
- /************************ ±äÁ¿ ***********************************/
- /************************ º¯Êý¶¨Òå ***********************************/
- static uint32_t mt_time = 0;
- void MT_Run(uint32_t tim)
- {
- SEGGER_RTT_printf(0,"MT MT_Run:%d \n",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 >=HeartTime_Interval)mt_time -=HeartTime_Interval;
- 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;
-
- uint16_t t = ((uint16_t)(target->pDat[0])<<8) | ((uint16_t)(target->pDat[1])<<0);
-
- if(mFlash.isHost)
- {
- if(target->pDat[2]==1)
- {
- MT_Run(t);
- }
- else if(target->pDat[2]==0)
- {
- MT_Run(t);
- BLE_Host_Tx_Send(0,BLE_SHOCK,target->pDat,target->datLen);
- }
- else
- {
- BLE_Host_Tx_Send(0,BLE_SHOCK,target->pDat,target->datLen);
- }
- }
- else
- {
- if((target->pDat[2]==2)||(target->pDat[2]==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_SHOCK,cb_BLE_Client_R_SHOCK);
- }
|