0
\$\begingroup\$

I am using STM32L433CCT6 and I am programming it with eclipse and code genereted by STM32CubeMX.

I would like to ask you, if is possible to add iterrupt that will be called, if i press two (or more) buttons.

I mean something like this interrupt

void EXTI2_IRQHandler(void) {
    HAL_NVIC_ClearPendingIRQ(EXTI2_IRQn);
    HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2);
    {
        /* EXTI line interrupt detected*/
        if (__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_2) != SET) {

            //what I would like to do when is detected rising/falling edge

            __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_2);
            HAL_GPIO_EXTI_Callback(GPIO_PIN_2);

        }
    }
}

but it will be called when I detect 2 pressed buttons, instead of rising or falling edge.

Thank you for your reply.

\$\endgroup\$
1
\$\begingroup\$

No, it is not possible - you need additional logic for that.

What's more - some EXTI lines serve multiple GPIOs at once.

A reasonable option would be to save the interrupt time (Hal_GetTick() of memory serves) and in the main loop check if the button times are close together.

\$\endgroup\$
0
\$\begingroup\$

Buttons and EXIT is a very bad companion. For many reasons - there is a lots of information about it across the internet. The correct approach is to check it in the timer interrupt.

Here you have the example:

https://www.diymat.co.uk/arm-three-function-click-double-and-long-click-button-library-timer-interrupt-driven/

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.