芯片解密单片机矩阵键盘扫描驱动程序
- 芯片解密#ifndef __Key_matrix_H
- 芯片解密#define __Key_matrix_H
- 芯片解密#include "gpio.h"
- #include "gpio_bool.h"
- /*务必把这4个输出IO设置为上拉输入*/
- #define KEY_HOR1 PAin(7)
- #define KEY_HOR2 PAin(6)
- #define KEY_HOR3 PAin(5)
- #define KEY_HOR4 PAin(4)
- /*务必把这4个输出IO设置为开漏*/
- #define KEY_LON1 PBout(0)
- #define KEY_LON2 PCout(5)
- #define KEY_LON3 PCout(4)
- #define KEY_LON4 PCout(3)
- #define KEY_PRESS_TIME 20//消抖常数
- #define KEY_LONG_PRESS_TIME 3000//单个按键长按阈值3s
- /*通过读取(只读)这三个变量即可获得按键的单按、长按和组合键信息*/
- extern volatile uint16_t Key_Phy_Num;
- extern volatile uint8_t Key_Pulse_Num;
- extern volatile uint16_t Key_LP_Num;
- typedef enum
- {
- KPL_DISABLE=0,
- KPL_ENABLE
- }K_L_P;//按键的长按状态
- typedef struct
- {
- K_L_P KEY_LONG_PRESS;
- uint16_t KeyOpenCount;
- uint8_t KOC_EN;
- uint16_t KeyCloseCount;
- uint8_t KCC_EN;
- }Key_Para;
- exter Key_Par Key_1,Key_2,Key_3,Key_4,Key_5,Key_6,Key_7,Key_8,Key_9,Key_10,Key_11,Key_12,Key_13,Key_14,Key_15,Key_16;
- void Clear_Key_Pulse_Num(void);//当读取完Key_Pulse_Num后调用
- void KeyCount_Run(void);//在1ms滴答里调用
- void Key_Scan(void);//大循环或者滴答里边都行
- #endif

芯片解密