HAL KEY 的头文件 按键定义为什么要采用寄存器操作,而不是函数操作
/* 1 - KEY */ #define KEY1_BV BV(22) #define KEY2_BV #define KEY3_BV #define KEY4_BV #define KEY1_PU (R32_PB_PU |= KEY1_BV) #define KEY2_PU () #define KEY3_PU () #define KEY4_PU () #define KEY1_DIR (R32_PB_DIR &= ~KEY1_BV) #define KEY2_PU () #define KEY3_PU () #define KEY4_PU () #define KEY1_IN (ACTIVE_LOW(R32_PB_PIN&KEY1_BV)) #define KEY2_IN () #define KEY3_IN () #define KEY4_IN () #define HAL_PUSH_BUTTON1() ( KEY1_IN ) //添加自定义按键 #define HAL_PUSH_BUTTON2() ( 0 ) #define HAL_PUSH_BUTTON3() ( 0 ) #define HAL_PUSH_BUTTON4() ( 0 )
为什么不直接定义
#define HAL_PUSH_BUTTON1() ( GPIOB_ReadPortPin(GPIO_Pin_22 ) //添加自定义按键
if( HAL_PUSH_BUTTON1()==0 ){ keys |= HAL_KEY_SW_1; }
热门产品 :
CH634: 4端口USB3.0 HUB控制器芯片