完善资料让更多小伙伴认识你,还能领取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个回答
|
|
怀疑硬件定时器有问题,就先测试定时器,没问题了,再写应用不是更好么
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
1124 浏览 0 评论
893 浏览 0 评论
7967 浏览 0 评论
如何使用python调起UDE STK5.2进行下载自动化下载呢?
3082 浏览 0 评论
开启全新AI时代 智能嵌入式系统快速发展——“第六届国产嵌入式操作系统技术与产业发展论坛”圆满结束
3121 浏览 0 评论
74215 浏览 21 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-13 05:45 , Processed in 0.502471 second(s), Total 71, Slave 55 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号