完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
写了一个控制门的代码,开门时间20s,算出来每开1%用t时间,然后定时器以这个t时间执行回调函数。
下面是关门的代码 else if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_target_portion == 0 ) { if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_target_portion < g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_cur_portion +10 ) { rt_kprintf(" guiling bili kongzhilllllllllllln"); rt_kprintf("cur_portion=%4d target=%4dn",g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_cur_portion,g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_target_portion); /*如果当前状态不是关门,需要修改定时器溢出时间*/ if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_status != 2) { //rt_kprintf("guann"); rt_kprintf("guan pertime = %dn",g_workpara_1.mg_sidewindoor_config.sidewindw_close_ms); rt_enter_critical(); rt_timer_stop( mount_wall_windoor_timer ); rt_timer_control(mount_wall_windoor_timer, RT_TIMER_CTRL_SET_TIME ,&g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_close_ms ); rt_timer_start( mount_wall_windoor_timer ); rt_exit_critical(); // rt_kprintf("sidewindow_timer againn"); /*修改当前状态为关门*/ g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_status = 2; } } else if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_target_portion >= g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_cur_portion +10 ) { g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_status = 0; } } 程序是走关门这个分支的,门状态为2,需要关门,在定时器回调函数里,当前比例-1,但是定时器的回调函数,却不动了,什么都不执行,也不-1 /* wind door control timer callback function*/ void mount_wall_windoor_timeout(void * para) { // rt_kprintf(" mount wall windoor timeout!n"); if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_status == 1 ) { //rt_kprintf("real kain"); g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_cur_portion += 1; MG_ctrl_mountwall_winddoor(1); } else if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_status == 2 ) { rt_kprintf("real guann"); g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_cur_portion -= 1; MG_ctrl_mountwall_winddoor(2); } else if( g_workpara_1.mg_sidewindoor_config.mount_wall_windoor_status == 0 ) { MG_ctrl_mountwall_winddoor(0); } } 希望大家给一些思路,谢谢 |
|
相关推荐
1个回答
|
|
怀疑硬件定时器有问题,就先测试定时器,没问题了,再写应用不是更好么
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
开启全新AI时代 智能嵌入式系统快速发展——“第六届国产嵌入式操作系统技术与产业发展论坛”圆满结束
394 浏览 0 评论
2024 RT-Thread全球巡回线下培训火热来袭!报名提问有奖!
1875 浏览 8 评论
1532 浏览 0 评论
IaaS+on+DPU(IoD)+下一代高性能算力底座技术白皮书
2729 浏览 0 评论
飞凌嵌入式-ELFBOARD 常用的USB接口及其不同版本介绍第1期
1153 浏览 0 评论
66782 浏览 21 评论
嵌入式热门DIY项目:智能机器人开源资料合集(原理图、代码、论文)
68235 浏览 22 评论
浏览过的版块 |
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-9-1 10:21 , Processed in 0.913441 second(s), Total 69, Slave 52 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191