|
|
@@ -56,20 +56,14 @@ void MX_GPIO_Init(void) |
|
|
|
|
|
|
|
/*Configure GPIO pin : PB5 */ |
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_5; |
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL; |
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
|
|
|
|
|
|
|
/*Configure GPIO pin : PB7 */ |
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_7; |
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
|
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP; |
|
|
|
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
|
|
|
|
|
|
|
/*Configure GPIO pin : PG12 */ |
|
|
|
GPIO_InitStruct.Pin = GPIO_PIN_12; |
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; |
|
|
|
GPIO_InitStruct.Pull = GPIO_NOPULL; |
|
|
|
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; |
|
|
|
GPIO_InitStruct.Pull = GPIO_PULLUP; |
|
|
|
HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); |
|
|
|
|
|
|
|
/*Configure GPIO pins : PH6 PH8 PH9 PH7 */ |
|
|
@@ -83,6 +77,9 @@ void MX_GPIO_Init(void) |
|
|
|
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 3, 0); |
|
|
|
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); |
|
|
|
|
|
|
|
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0); |
|
|
|
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/* USER CODE BEGIN 2 */ |
|
|
@@ -100,7 +97,7 @@ static volatile uint8_t s_trigger_flag = 0; ///< 触发标志,防止重 |
|
|
|
*/ |
|
|
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) |
|
|
|
{ |
|
|
|
if (GPIO_Pin == GPIO_PIN_7) |
|
|
|
if (GPIO_Pin == GPIO_PIN_12||GPIO_Pin == GPIO_PIN_5) |
|
|
|
{ |
|
|
|
uint32_t current_time = HAL_GetTick(); |
|
|
|
/* 防抖处理:检查时间间隔和触发标志 */ |
|
|
|