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.

asked Apr 18, 2018 at 19:06
\$\endgroup\$

2 Answers 2

2
\$\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.

answered Apr 18, 2018 at 22:04
\$\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/

answered Apr 19, 2018 at 23:15
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.