文章作者: 盧宜良
主要funtion:
k_timer_expiry_t function pointer
k_timer_init 初始化
k_timer_start 開始
k_timer_stop_t 停止,呼叫後執行 STOP k_timer_expiry_t
測試CODE:
static struct k_timer timer;
static int count = 0;
static void timer_expire(struct k_timer *timer)
{
count++;
printk("timer_expire [%d]:%u\n", count, timer->status);
if (count == 10) // run 10 time
k_timer_stop(timer); // call timer_stop
}
static void timer_stop(struct k_timer *timer)
{
printk("timer_stop\n");
}
void main(void)
{
console_init();
printk("Hello World! %s\n", CONFIG_ARCH);
k_timer_init(&timer, timer_expire, timer_stop);
k_timer_start(&timer, 10000, 1000); // wait 10 sec , period 1 sec
while (1) {
k_sleep(1000); // nothing
}
}
GoMCU![[原創] NXP i.MX8QXP dev kit notes tutorial 開發紀錄教學-GoMCU](https://imxdev.gitlab.io/images/imx8qxp-top.jpg)