STM32移植嵌入式开源按键框架

[复制链接]
发表于 2026-2-14 04:16:13 | 显示全部楼层 |阅读模式
目次
STM32移植嵌入式开源按键框架
MultiButton简介
multi_button.c文件
multi_button.h文件
按键变乱
案例利用方法
学习分析


STM32移植嵌入式开源按键框架

   本日移植了一款嵌入式按键框架工程MultiButton,MultiButton是一个小巧简朴易用的变乱驱动型按键驱动模块。
  Github地点:GitHub - 0x1abin/MultiButton: Button driver for embedded system
  

  现于2024.04.15举行移植,详细就两个文件:multi_button的c文件和h文件。
  
MultiButton简介

   MultiButton 是一个小巧简朴易用的变乱驱动型按键驱动模块可无穷量扩展按键,按键变乱的回调异步处置惩罚方式可以简化你的步调布局,去除冗余的按键处置惩罚硬编码,让你的按键业务逻辑更清楚。
  
multi_button.c文件

   把license内容放到代码首段。
  1. /*
  2. * MIT License
  3. * Copyright (c) 2018 Zibin Zheng
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a copy
  6. * of this software and associated documentation files (the "Software"), to deal
  7. * in the Software without restriction, including without limitation the rights
  8. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. * copies of the Software, and to permit persons to whom the Software is
  10. * furnished to do so, subject to the following conditions:
  11. *
  12. * The above copyright notice and this permission notice shall be included in all
  13. * copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  21. * SOFTWARE.
  22. */
  23. /* github:https://github.com/0x1abin/MultiButton */
  24. #include "driver_button.h"
  25. #define EVENT_CB(ev)   if(handle->cb[ev])handle->cb[ev]((void*)handle)
  26. #define PRESS_REPEAT_MAX_NUM  15 /*!< The maximum value of the repeat counter */
  27. //button handle list head.
  28. static struct Button* head_handle = NULL;
  29. static void button_handler(struct Button* handle);
  30. /**
  31.   * @brief  Initializes the button struct handle.
  32.   * @param  handle: the button handle struct.
  33.   * @param  pin_level: read the HAL GPIO of the connected button level.
  34.   * @param  active_level: pressed GPIO level.
  35.   * @param  button_id: the button id.
  36.   * @retval None
  37.   */
  38. void button_init(struct Button* handle, uint8_t(*pin_level)(uint8_t), uint8_t active_level, uint8_t
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!qidao123.com:ToB企服之家,中国第一个企服评测及软件市场,开放入驻,技术点评得现金

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表