HAL KEY 的頭文件 按鍵定義為什么要采用寄存器操作,而不是函數(shù)操作
/*?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; ??}
熱門產(chǎn)品 :
CH390:以太網(wǎng)控制器芯片