void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) { if (htim->Instance == TIM10) { switch (KeyState) { case KEY_CHECK: if (HAL_GPIO_ReadPin(B1GPIO_Port, B1_Pin) == GPIO_PIN_RESET) { KeyState = KEY_COMFIRM; } break; case KEY_COMFIRM: if (HAL_GPIO_ReadPin(B1GPIO_Port, B1_Pin) == GPIO_PIN_RESET) { KeyState = KEY_RELEASE; KeyFlag = 1; }else{ KeyState = KEY_CHECK; } break; case KEY_RELEASE: if (HAL_GPIO_ReadPin(B1GPIO_Port, B1_Pin) == GPIO_PIN_RESET) { KeyState = KEY_CHECK; } break; default: break; } } }
标签:RESET,break,HAL,扫描,状态机,KEY,按键,KeyState,GPIO From: https://www.cnblogs.com/ycp666/p/17071267.html