嵌入式STM32按键状态机-单击双击长按操作

上传者: 44078824 | 上传时间: 2022-06-02 20:01:03 | 文件大小: 182KB | 文件类型: 7Z
个人博客:CSDN “老子姓李!” 参考教程链接:http://t.csdn.cn/W9rIy 引言: 在日常生活中,有不少按键长按、短按的应用实例。比如:一个台灯,短按切换亮度,长按关机。 问题来了,单片机是如何区分按键的短按和长按的呢? 本程序使用定时器,运用状态机的思想,实现了单按键的单击长按操作。 代码简洁规范,可读性强,移植性强。 实验器材: 自制开发板,STM32F03C8T6平台 实验目的: 学习定时器中断、按键使用。实现单击双击长按操作 硬件资源: 按键(PA0,也称之为WK_UP) 定时器3 串口1,用于打印输出 按键事件: 长按事件:任何大于 1秒 按下并释放事件(不支持连按,需连按,稍微修改状态机即可) 单击事件:按下时间不超过 1秒 且 释放后 500ms 内无再次按下的操作 双击事件:俩次短按时间间隔小于500ms,俩次短按操 本程序只供学习使用,未经作者许可,不得用于其它任何用途 感谢大家的阅读与下载,码字开源分享不易,麻烦给个免费的赞。 如果有帮助的,请不要吝啬三连。点赞评论收藏,让更多人看到有用的内容。 本博客作抛砖引玉,欢迎大家评论交流。

文件下载

资源详情

[{"title":"( 79 个子文件 182KB ) 嵌入式STM32按键状态机-单击双击长按操作","children":[{"title":"OBJ","children":[{"title":"LED.hex <span style='color:#111;'> 9.76KB </span>","children":null,"spread":false}],"spread":true},{"title":"HARDWARE","children":[{"title":"TIMER","children":[{"title":"timer.c <span style='color:#111;'> 2.45KB </span>","children":null,"spread":false},{"title":"timer.h <span style='color:#111;'> 585B </span>","children":null,"spread":false}],"spread":true},{"title":"KEY","children":[{"title":"key.c <span style='color:#111;'> 6.71KB </span>","children":null,"spread":false},{"title":"key.h <span style='color:#111;'> 1.40KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"keilkilll.bat <span style='color:#111;'> 399B </span>","children":null,"spread":false},{"title":"SYSTEM","children":[{"title":"delay","children":[{"title":"delay.h <span style='color:#111;'> 1.94KB </span>","children":null,"spread":false},{"title":"delay.c <span style='color:#111;'> 7.74KB </span>","children":null,"spread":false}],"spread":true},{"title":"sys","children":[{"title":"sys.h <span style='color:#111;'> 2.74KB </span>","children":null,"spread":false},{"title":"sys.c <span style='color:#111;'> 876B </span>","children":null,"spread":false}],"spread":true},{"title":"usart","children":[{"title":"usart.h <span style='color:#111;'> 1.25KB </span>","children":null,"spread":false},{"title":"usart.c <span style='color:#111;'> 4.97KB </span>","children":null,"spread":false}],"spread":true}],"spread":true},{"title":"STM32F10x_FWLib","children":[{"title":"inc","children":[{"title":"stm32f10x_adc.h <span style='color:#111;'> 21.18KB </span>","children":null,"spread":false},{"title":"stm32f10x_tim.h <span style='color:#111;'> 51.20KB </span>","children":null,"spread":false},{"title":"stm32f10x_usart.h <span style='color:#111;'> 16.16KB </span>","children":null,"spread":false},{"title":"stm32f10x_dac.h <span style='color:#111;'> 14.88KB </span>","children":null,"spread":false},{"title":"stm32f10x_bkp.h <span style='color:#111;'> 7.38KB </span>","children":null,"spread":false},{"title":"stm32f10x_dbgmcu.h <span style='color:#111;'> 3.73KB </span>","children":null,"spread":false},{"title":"stm32f10x_pwr.h <span style='color:#111;'> 4.28KB </span>","children":null,"spread":false},{"title":"stm32f10x_sdio.h <span style='color:#111;'> 21.35KB </span>","children":null,"spread":false},{"title":"stm32f10x_wwdg.h <span style='color:#111;'> 2.90KB </span>","children":null,"spread":false},{"title":"stm32f10x_rtc.h <span style='color:#111;'> 3.77KB </span>","children":null,"spread":false},{"title":"stm32f10x_gpio.h <span style='color:#111;'> 19.70KB </span>","children":null,"spread":false},{"title":"stm32f10x_flash.h <span style='color:#111;'> 24.85KB </span>","children":null,"spread":false},{"title":"stm32f10x_dma.h <span style='color:#111;'> 20.27KB </span>","children":null,"spread":false},{"title":"stm32f10x_rcc.h <span style='color:#111;'> 29.74KB </span>","children":null,"spread":false},{"title":"stm32f10x_iwdg.h <span style='color:#111;'> 3.74KB </span>","children":null,"spread":false},{"title":"stm32f10x_fsmc.h <span style='color:#111;'> 26.38KB </span>","children":null,"spread":false},{"title":"stm32f10x_exti.h <span style='color:#111;'> 6.66KB </span>","children":null,"spread":false},{"title":"misc.h <span style='color:#111;'> 8.77KB </span>","children":null,"spread":false},{"title":"stm32f10x_spi.h <span style='color:#111;'> 17.31KB </span>","children":null,"spread":false},{"title":"stm32f10x_crc.h <span style='color:#111;'> 2.11KB </span>","children":null,"spread":false},{"title":"stm32f10x_i2c.h <span style='color:#111;'> 29.33KB </span>","children":null,"spread":false},{"title":"stm32f10x_can.h <span style='color:#111;'> 26.91KB </span>","children":null,"spread":false},{"title":"stm32f10x_cec.h <span style='color:#111;'> 6.42KB </span>","children":null,"spread":false}],"spread":false},{"title":"src","children":[{"title":"stm32f10x_sdio.c <span style='color:#111;'> 28.25KB </span>","children":null,"spread":false},{"title":"stm32f10x_adc.c <span style='color:#111;'> 46.09KB </span>","children":null,"spread":false},{"title":"stm32f10x_bkp.c <span style='color:#111;'> 8.26KB </span>","children":null,"spread":false},{"title":"stm32f10x_cec.c <span style='color:#111;'> 11.38KB </span>","children":null,"spread":false},{"title":"stm32f10x_usart.c <span style='color:#111;'> 37.41KB </span>","children":null,"spread":false},{"title":"stm32f10x_pwr.c <span style='color:#111;'> 8.55KB </span>","children":null,"spread":false},{"title":"stm32f10x_flash.c <span style='color:#111;'> 61.08KB </span>","children":null,"spread":false},{"title":"stm32f10x_dbgmcu.c <span style='color:#111;'> 5.03KB </span>","children":null,"spread":false},{"title":"stm32f10x_wwdg.c <span style='color:#111;'> 5.60KB </span>","children":null,"spread":false},{"title":"stm32f10x_gpio.c <span style='color:#111;'> 22.68KB </span>","children":null,"spread":false},{"title":"stm32f10x_crc.c <span style='color:#111;'> 3.27KB </span>","children":null,"spread":false},{"title":"stm32f10x_rtc.c <span style='color:#111;'> 8.40KB </span>","children":null,"spread":false},{"title":"stm32f10x_dac.c <span style='color:#111;'> 18.64KB </span>","children":null,"spread":false},{"title":"stm32f10x_spi.c <span style='color:#111;'> 29.52KB </span>","children":null,"spread":false},{"title":"stm32f10x_can.c <span style='color:#111;'> 44.05KB </span>","children":null,"spread":false},{"title":"stm32f10x_iwdg.c <span style='color:#111;'> 4.80KB </span>","children":null,"spread":false},{"title":"stm32f10x_dma.c <span style='color:#111;'> 28.91KB </span>","children":null,"spread":false},{"title":"stm32f10x_tim.c <span style='color:#111;'> 106.60KB </span>","children":null,"spread":false},{"title":"stm32f10x_i2c.c <span style='color:#111;'> 44.71KB </span>","children":null,"spread":false},{"title":"stm32f10x_rcc.c <span style='color:#111;'> 50.07KB </span>","children":null,"spread":false},{"title":"misc.c <span style='color:#111;'> 6.88KB </span>","children":null,"spread":false},{"title":"stm32f10x_exti.c <span style='color:#111;'> 6.80KB </span>","children":null,"spread":false},{"title":"stm32f10x_fsmc.c <span style='color:#111;'> 34.65KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"CORE","children":[{"title":"startup_stm32f10x_md.s <span style='color:#111;'> 12.47KB </span>","children":null,"spread":false},{"title":"core_cm3.c <span style='color:#111;'> 16.87KB </span>","children":null,"spread":false},{"title":"core_cm3.h <span style='color:#111;'> 83.71KB </span>","children":null,"spread":false},{"title":"startup_stm32f10x_hd.s <span style='color:#111;'> 15.14KB </span>","children":null,"spread":false}],"spread":true},{"title":"USER","children":[{"title":"Objects","children":null,"spread":false},{"title":"stm32f10x_it.c <span style='color:#111;'> 2.36KB </span>","children":null,"spread":false},{"title":"main.c <span style='color:#111;'> 337B </span>","children":null,"spread":false},{"title":"LED.uvoptx <span style='color:#111;'> 13.70KB </span>","children":null,"spread":false},{"title":"JLinkSettings.ini <span style='color:#111;'> 671B </span>","children":null,"spread":false},{"title":"DebugConfig","children":[{"title":"LED_STM32F103ZE_1.0.0.dbgconf <span style='color:#111;'> 6.79KB </span>","children":null,"spread":false},{"title":"LED_STM32F103C8_1.0.0.dbgconf <span style='color:#111;'> 6.79KB </span>","children":null,"spread":false},{"title":"LED_STM32F103ZE.dbgconf <span style='color:#111;'> 6.79KB </span>","children":null,"spread":false},{"title":"LED_STM32F103C8.dbgconf <span style='color:#111;'> 6.79KB </span>","children":null,"spread":false}],"spread":true},{"title":"Listings","children":null,"spread":false},{"title":"LED.uvguix.Administrator <span style='color:#111;'> 68.19KB </span>","children":null,"spread":false},{"title":"system_stm32f10x.h <span style='color:#111;'> 2.04KB </span>","children":null,"spread":false},{"title":"stm32f10x_conf.h <span style='color:#111;'> 3.16KB </span>","children":null,"spread":false},{"title":"LED.uvprojx <span style='color:#111;'> 17.71KB </span>","children":null,"spread":false},{"title":"system_stm32f10x.c <span style='color:#111;'> 35.72KB </span>","children":null,"spread":false},{"title":"stm32f10x_it.h <span style='color:#111;'> 1.94KB </span>","children":null,"spread":false},{"title":"stm32f10x.h <span style='color:#111;'> 619.08KB </span>","children":null,"spread":false},{"title":"LED.uvguix.nanshou <span style='color:#111;'> 83.18KB </span>","children":null,"spread":false}],"spread":false},{"title":"README.TXT <span style='color:#111;'> 1.21KB </span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明