软件SPI可以驱动屏幕

This commit is contained in:
2026-07-14 14:44:07 +08:00
parent 3577003fb6
commit 0a5c478a42
53 changed files with 9354 additions and 87 deletions

View File

@@ -0,0 +1,63 @@
/*
* 模块名称:按键驱动适配层
* 模块功能提供MultiButton库与STM32 HAL库的适配接口
* 适用平台STM32F103C8T6
* 作者:王建锋
* 创建日期2026-07-13
* 修改记录:
* 2026-07-13 王建锋 创建初始版本
*/
#ifndef __BUTTON_DRIVER_H
#define __BUTTON_DRIVER_H
#ifdef __cplusplus
extern "C" {
#endif
#include "multi_button.h"
#include "main.h"
/* 按键ID定义 */
typedef enum {
BUTTON_ID_KEY1 = 0, /* KEY1: PB4 */
BUTTON_ID_KEY2, /* KEY2: PB5 */
BUTTON_ID_KEY3, /* KEY3: PB3 */
BUTTON_ID_KEY4, /* KEY4: PC14 */
BUTTON_ID_KEY5, /* KEY5: PC15 */
BUTTON_ID_MAX /* 按键总数 */
} ButtonId_t;
/* 按键有效电平定义 */
#define BUTTON_ACTIVE_LEVEL_LOW 0 /* 低电平有效 */
#define BUTTON_ACTIVE_LEVEL_HIGH 1 /* 高电平有效 */
/*
* 函数功能:按键驱动初始化
* 入口参数:无
* 返回值:无
* 函数说明:初始化所有按键对象,注册回调函数,启动按键轮询
*/
void button_driver_init(void);
/*
* 函数功能:获取指定按键的电平状态
* 入口参数button_id - 按键标识符
* 返回值GPIO电平值 (0或1)
* 函数说明根据按键ID读取对应GPIO引脚的电平
*/
uint8_t button_driver_read_level(uint8_t button_id);
/*
* 函数功能:获取指定按键的事件
* 入口参数button_id - 按键标识符
* 返回值:按键事件
* 函数说明:返回指定按键的当前事件
*/
ButtonEvent button_driver_get_event(uint8_t button_id);
#ifdef __cplusplus
}
#endif
#endif /* __BUTTON_DRIVER_H */