#include "task.h" #include "cfg/task_header.h" #include "task_hal.h" #ifdef __cplusplus extern "C" { #endif // function prototype AL_STATIC int8_t TaskTimer(struct pt *pt1); AL_STATIC TASK_DATA TaskDb[]={ {1, TASK_MODE_PERIOD, TASK_ID(TaskTimer), TASK_NAME(TaskTimer), 1L, 1L, TaskTimer,{0}} , #include "cfg/task_container.h" }; static TIMER_DATA TimerData[MAX_TIMER]; static volatile uint32_t TMP1msCount = 0; __attribute__((weak)) void idle(void) { } #define __NOP() __asm("nop") void TaskProc(void) { uint32_t i = 0; while(1) { if(!TMP1msCount) { idle(); } else { for(i=0;icUse) continue; if((--(pt->lLastTime))<=0) { switch(pt->cMode) { case TIMER_MODE_TIMER: // timer only pt->cUse=0; break; case TIMER_MODE_CYCROUTINE: // cyclely routine pt->lLastTime+=pt->lPeriod; pt->routine(pt->Param1); // start user's routine break; case TIMER_MODE_ONCEROUTINE: // timer routine once pt->cUse=0; //prevents the start of timer after stoptimer in the routine from causing an error stop pt->routine(pt->Param1); // start user routine break; default: pt->cUse=0; break; } } } UNUSED_PARAM(pt1); return 0; } //Counter //HOOK systick Interrupt volatile AL_STATIC uint64_t AllTickCount = 0; void Task_SysTick_Handler(void) { AllTickCount++; TMP1msCount++; } #ifdef __cplusplus } #endif