1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #ifndef __KEY_DRIVERS_H
- #define __KEY_DRIVERS_H
- #include "stm32f1xx_hal.h"
- //按键状态
- typedef enum {
- Key_Status_NoPress = 0U, //无
- Key_Status_ShortPress, //短按
- Key_Status_LongPress //长按
- }Key_Status_t;
- //按键类型定义
- typedef struct //缓冲区各变量,用于相关函数的参数
- {
- uint16_t *ADC_result; //GPIO_PIN_x
- uint8_t Trg; //按键触发标志
- uint8_t Cont; //计数
- uint8_t PressFlasg; //按键按下标识
- uint16_t TimeCnt; //按键计时
- Key_Status_t KeyStatus; //按键状态
- }Key_TypeDef;
- //按键状态编码
- typedef union
- {
- struct
- {
- uint8_t Power :1;//Power
- uint8_t Walk :1;//Walk
- uint8_t Add :1;//+
- uint8_t Dec :1;//-
- uint8_t Set :1;//Set
- uint8_t Light :1;//Light
- uint8_t RS3 :1;
- uint8_t RS4 :1;
- }Key_Bit;
- uint8_t Code;
- }KeyScanCode_Struct_t;
- extern Key_TypeDef Key_On_Off;
- extern Key_TypeDef Key_Walk;
- extern Key_TypeDef Key_Light;
- extern Key_TypeDef Key_Set;
- extern Key_TypeDef Key_Down;
- extern Key_TypeDef Key_Up;
- //按键GPIO初始化
- void KeyInitial(void);
- //按键检测函数
- void Key_Check(Key_TypeDef* Key, uint8_t DelayTime);
- extern void KeyParamInit(Key_TypeDef * Key);
- extern void KeyParamInit_no_cont(Key_TypeDef * Key);
- //按键扫描编码
- KeyScanCode_Struct_t KeyScan(void);
- #endif
|