完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
RT_TIMER_CTRL_GET_STATE
应该是新版本增加的命令字 看代码正确的返回值是0或1,不清楚为何你的返回0x20a7,自己单步调试看看,哪里有问题吧 /** * @Brief This function will get or set some options of the timer * * @param timer the timer to be get or set * @param cmd the control command * @param arg the argument * * @Return the statu of control */ rt_err_t rt_timer_control(rt_timer_t timer, int cmd, void *arg) { rt_base_t level; /* parameter check */ RT_ASSERT(timer != RT_NULL); RT_ASSERT(rt_object_get_type(&timer->parent) == RT_Object_Class_Timer); level = rt_hw_interrupt_disable(); switch (cmd) { case RT_TIMER_CTRL_GET_TIME: *(rt_tick_t *)arg = timer->init_tick; break; case RT_TIMER_CTRL_SET_TIME: RT_ASSERT((*(rt_tick_t *)arg) < RT_TICK_MAX / 2); timer->init_tick = *(rt_tick_t *)arg; break; case RT_TIMER_CTRL_SET_ONESHOT: timer->parent.flag &= ~RT_TIMER_FLAG_PERIODIC; break; case RT_TIMER_CTRL_SET_PERIODIC: timer->parent.flag |= RT_TIMER_FLAG_PERIODIC; break; case RT_TIMER_CTRL_GET_STATE: if(timer->parent.flag & RT_TIMER_FLAG_ACTIVATED) { /*timer is start and run*/ *(rt_uint32_t *)arg = RT_TIMER_FLAG_ACTIVATED; } else { /*timer is stop*/ *(rt_uint32_t *)arg = RT_TIMER_FLAG_DEACTIVATED; } break; case RT_TIMER_CTRL_GET_REMAIN_TIME: *(rt_tick_t *)arg = timer->timeout_tick; break; default: break; } rt_hw_interrupt_enable(level); return RT_EOK; } |
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
798 浏览 0 评论
4836 浏览 0 评论
如何使用python调起UDE STK5.2进行下载自动化下载呢?
2622 浏览 0 评论
开启全新AI时代 智能嵌入式系统快速发展——“第六届国产嵌入式操作系统技术与产业发展论坛”圆满结束
2958 浏览 0 评论
获奖公布!2024 RT-Thread全球巡回线下培训火热来袭!报名提问有奖!
31763 浏览 11 评论
73109 浏览 21 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 00:29 , Processed in 0.510158 second(s), Total 43, Slave 37 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号