创建定时器如何使用了?

发布于 2023-12-12 10:28:05

tls_os_timer_create创建成功了,tls_os_timer_start一开启定时器就报错

ret = tls_os_timer_create(ctx->mqtt_demo_heartbeat_timer,

                    mqtt_demo_heart_timer,
                    NULL, (10 * HZ), TRUE, NULL);
                
                wm_printf("ret:%d\n",ret);
                if(ret == TLS_OS_SUCCESS)
                {
                    tls_os_timer_start(ctx->mqtt_demo_heartbeat_timer);
                }

查看更多

关注者
0
被浏览
786
2 个回答
solid_2022
solid_2022 2023-12-12
This guy hasn't written anything yet

参考wm_timer_demo.c写是可以的,但不是os的

792711732
792711732 2024-01-02
This guy hasn't written anything yet

u8 timer_id;
struct tls_timer_cfg timer_cfg;

timer_cfg.unit = TLS_TIMER_UNIT_MS;
timer_cfg.timeout = 1000;
timer_cfg.is_repeat = 1;
timer_cfg.callback = (tls_timer_irq_callback)demo_timer_irq;
timer_cfg.arg = NULL;
timer_id = tls_timer_create(&timer_cfg);
tls_timer_start(timer_id);
用这个定时器

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览