From 6c14c84800cf151828b3199d5f73c216301a9f2d Mon Sep 17 00:00:00 2001 From: Mark Burton Date: Tue, 18 Sep 2018 11:40:56 +0100 Subject: [PATCH] Now stm32f4 external interrupt handler checks interrupt status before passing interrupt down. Without this check, I was seeing multiple interrupts when only 1 was expected. I note that all examples on the internet that show how to use the external interrupts do include the call to EXTI_GetITStatus() so I guess that is is required. --- src/platform/stm32f4/platform_int.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/platform/stm32f4/platform_int.c b/src/platform/stm32f4/platform_int.c index b6dbaa4e..81cb8ac0 100644 --- a/src/platform/stm32f4/platform_int.c +++ b/src/platform/stm32f4/platform_int.c @@ -74,17 +74,20 @@ static int exint_gpio_to_src( pio_type piodata ) static void all_exti_irqhandler( int line ) { u16 v, port, pin; - - v = exti_line_to_gpio( line ); - port = PLATFORM_IO_GET_PORT( v ); - pin = PLATFORM_IO_GET_PIN( v ); - if( EXTI->RTSR & (1 << line ) && platform_pio_op( port, 1 << pin, PLATFORM_IO_PIN_GET ) ) - cmn_int_handler( INT_GPIO_POSEDGE, v ); - if( EXTI->FTSR & (1 << line ) && ( platform_pio_op( port, 1 << pin, PLATFORM_IO_PIN_GET ) == 0 ) ) - cmn_int_handler( INT_GPIO_NEGEDGE, v ); + if( EXTI_GetITStatus( exti_line[ line ] ) == SET ) + { + v = exti_line_to_gpio( line ); + port = PLATFORM_IO_GET_PORT( v ); + pin = PLATFORM_IO_GET_PIN( v ); - EXTI_ClearITPendingBit( exti_line[ line ] ); + if( EXTI->RTSR & (1 << line ) && platform_pio_op( port, 1 << pin, PLATFORM_IO_PIN_GET ) ) + cmn_int_handler( INT_GPIO_POSEDGE, v ); + if( EXTI->FTSR & (1 << line ) && ( platform_pio_op( port, 1 << pin, PLATFORM_IO_PIN_GET ) == 0 ) ) + cmn_int_handler( INT_GPIO_NEGEDGE, v ); + + EXTI_ClearITPendingBit( exti_line[ line ] ); + } } void EXTI0_IRQHandler()