#include "sdk_common.h" #include "bsp_time.h" #include "nrf_drv_timer.h" #include "SEGGER_RTT.h" #include "system.h" #include "nrf_drv_rtc.h" #include "hal_soft_time.h" #include "system.h" static bsp_soft_time_t mIbsp_soft_time_t={0}; void hal_soft_time_create(bsp_soft_time_t *soft_time_p){ if(NULL == soft_time_p)return; bsp_soft_time_t *head_soft_time =&mIbsp_soft_time_t; while(head_soft_time->next){ head_soft_time = head_soft_time->next; } soft_time_p->next = NULL; head_soft_time->tim = TIME_GetTicks(); head_soft_time->next = soft_time_p; } void hal_soft_time_stop(bsp_soft_time_t *soft_time_p){ if(NULL == soft_time_p)return; soft_time_p->state = 0; } void hal_soft_time_restart(bsp_soft_time_t *soft_time_p){ if(NULL == soft_time_p)return; soft_time_p->state = 1; } void hal_soft_time_Process(void) { bsp_soft_time_t *head_soft_time =&mIbsp_soft_time_t; while(head_soft_time->next){ if(head_soft_time->next->state){ if((TIME_GetTicks()-head_soft_time->tim) >= head_soft_time->next->peroid){ head_soft_time->tim = TIME_GetTicks(); head_soft_time->next->cb(); } } head_soft_time = head_soft_time->next; } } void hal_soft_time_init(void){ Process_Start(0,"hal_soft_time",hal_soft_time_Process); }