CmakeLists.txt 添加os路径
target_include_directories(app PRIVATE ${ZEPHYR_BASE}/include/portability)
timer.c
#include <cmsis_os.h>
/* specify delay between greetings (in ms); compute equivalent in ticks */
#define TIMER_TICKS 100
osTimerId timer_id;
void ostimer_callback(void const *arg);
osTimerDef(myTimer, ostimer_callback);
启动定时器
timer_id = osTimerCreate(osTimer(myTimer), osTimerPeriodic, NULL);
osTimerStart(timer_id, TIMER_TICKS);
定时器回调函数
void ostimer_callback(void const *arg)
{
static u_int16_t tick = 0;
tick++;
}