Do not restart timer on bounce
@@ -630,6 +630,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
We disable interrupts and clear this early interrupt flag before re-enabling them so that the *real*
interrupt can fire.
*/
+ if(!((&htim2)->Instance->CR1 & TIM_CR1_CEN)){
HAL_NVIC_DisableIRQ(TIM2_IRQn);
__HAL_TIM_SetCounter(&htim2, 0);
__HAL_TIM_SetCompare(&htim2, TIM_CHANNEL_1, long_press_exit_time * 10); // press-to-reset-time
@@ -637,6 +638,7 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
HAL_TIM_Base_Start_IT(&htim2);
__HAL_TIM_CLEAR_FLAG(&htim2, TIM_SR_UIF);
HAL_NVIC_EnableIRQ(TIM2_IRQn);
+ }
} else {
if(__HAL_TIM_GetCounter(&htim2) > 200){ // 20ms debounce time
