102 lines
3.4 KiB
C
102 lines
3.4 KiB
C
#ifndef __KEYx_H
|
||
#define __KEYx_H
|
||
#include "stm32f10x_gpio.h"
|
||
|
||
/*****************************************
|
||
*自定义常变量
|
||
****************************************/
|
||
/*按键状态*/
|
||
#define KEYON 0 //按键按下
|
||
#define KEYOFF 1 //按键松开
|
||
|
||
/*按键端口、引脚、状态映射*/
|
||
#define KEY0_PORT PD
|
||
#define KEY0_PIN PIN11
|
||
#define KEY1_PORT PA
|
||
#define KEY1_PIN PIN8
|
||
#define KEY2_PORT PC
|
||
#define KEY2_PIN PIN9
|
||
#define KEY3_PORT PC
|
||
#define KEY3_PIN PIN8
|
||
#define KEY4_PORT PC
|
||
#define KEY4_PIN PIN7
|
||
#define KEY5_PORT PC
|
||
#define KEY5_PIN PIN6
|
||
#define KEY6_PORT PD
|
||
#define KEY6_PIN PIN15
|
||
#define KEY7_PORT PD
|
||
#define KEY7_PIN PIN14
|
||
#define KEY8_PORT PD
|
||
#define KEY8_PIN PIN13
|
||
#define KEY9_PORT PD
|
||
#define KEY9_PIN PIN12
|
||
#define MENU_KEY_PORT PA
|
||
#define MENU_KEY_PIN PIN12
|
||
#define BACK_KEY_PORT PA
|
||
#define BACK_KEY_PIN PIN11
|
||
|
||
#define KEY0_IN PDin(11) //KEY0的输入电平
|
||
#define KEY1_IN PAin(8) //KEY1的输入电平
|
||
#define KEY2_IN PCin(9) //.
|
||
#define KEY3_IN PCin(8) //.
|
||
#define KEY4_IN PCin(7) //.
|
||
#define KEY5_IN PCin(6)
|
||
#define KEY6_IN PDin(15)
|
||
#define KEY7_IN PDin(14)
|
||
#define KEY8_IN PDin(13)
|
||
#define KEY9_IN PDin(12)
|
||
#define MUNE_KEY_IN PAin(12)
|
||
#define BACK_KEY_IN PAin(11)
|
||
#define KEYUP_KEY_IN KEY2_IN
|
||
#define KEYDOWN_KEY_IN KEY8_IN
|
||
#define KEYLEFT_KEY_IN KEY4_IN
|
||
#define KEYRIGHT_KEY_IN KEY6_IN
|
||
#define KEYOK_KEY_IN KEY5_IN
|
||
/*按键复用宏定义*/
|
||
#define KEYUP_PORT KEY2_PORT
|
||
#define KEYUP_PIN KEY2_PIN
|
||
#define KEYDOWN_PORT KEY8_PORT
|
||
#define KEYDOWN_PIN KEY8_PIN
|
||
#define KEYLEFT_PORT KEY4_PORT
|
||
#define KEYLEFT_PIN KEY4_PIN
|
||
#define KEYRIGHT_PORT KEY6_PORT
|
||
#define KEYRIGHT_PIN KEY6_PIN
|
||
#define KEYOK_PORT KEY5_PORT
|
||
#define KEYOK_PIN KEY5_PIN
|
||
|
||
/*按键值映射*/
|
||
#define KEY0 1
|
||
#define KEY1 2
|
||
#define KEY2 3
|
||
#define KEY3 4
|
||
#define KEY4 5
|
||
#define KEY5 6
|
||
#define KEY6 7
|
||
#define KEY7 8
|
||
#define KEY8 9
|
||
#define KEY9 10
|
||
#define KEYMENU 11
|
||
#define KEYBACK 12
|
||
#define KEYUP KEY2
|
||
#define KEYDOWN KEY8
|
||
#define KEYLEFT KEY4
|
||
#define KEYRIGHT KEY6
|
||
#define KEYOK KEY5
|
||
|
||
#define SAVESYSTEM ((MUNE_KEY_IN == KEYON)&&(BACK_KEY_IN == KEYON)) //在设备上电/复位前,同时按住MENU和BACK键直到boot启动,设备会进入应急模式跳转APP1
|
||
#define ACTIVEOAT ((KEYLEFT_KEY_IN == KEYON)&&(KEYRIGHT_KEY_IN == KEYON))//在设备上电/复位前,同时按住KEYLEFT和KEYRIGHT键直到boot启动,设备会进入主动升级模式
|
||
//struct key_e
|
||
//{
|
||
// unsigned KEY0:1 ;
|
||
// unsigned KEY1:1 ;
|
||
// unsigned KEY2:1 ;
|
||
//} ;
|
||
|
||
/*****************************************
|
||
*对外接口函数声明
|
||
****************************************/
|
||
extern void KeyInit(void) ;
|
||
|
||
#endif
|
||
|