Skip to content

Commit dfb6d60

Browse files
authored
Add possibility to redefine SD detection pin irq handlers at application level (#74)
Add configuration macro to allow interrupt handlers related to SD detection pin to be deactivated at compile time without changing the source code. Description ----------- The way STM32F4xx and STM32F7xx ports handle interrupts related to SD detection pin is a bit limiting for 2 reasons: - the implementation may use a GPIO outside of EXTI10 to 15 range - the implementation may need GPIOs in EXTI10 to 15 range for other purpose The idea here is to give the possibility to a user to handle this interrupt - if needed - at application level without changing the library source code. This PR introduces `ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER` macro. There is also a modification applied to STM32F4xx and STM32F7xx ports to surround `HAL_GPIO_EXTI_Callback` and `EXTI15_10_IRQHandler` with this newly defined macro. FYI - related to [this discussion on the forum](https://forums.freertos.org/t/freertos-fat-redefinition-of-irq-handler-in-stm32fx-port/22231/1). Test Steps ----------- Integrate the content of this PR in my project to check that functions can be defined at application level without conflicts. Checklist: ---------- - [x] I have tested my changes. No regression in existing tests. - [ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request. Related Issue ----------- https://forums.freertos.org/t/freertos-fat-redefinition-of-irq-handler-in-stm32fx-port/22231/1 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent 5d67968 commit dfb6d60

File tree

3 files changed

+44
-25
lines changed

3 files changed

+44
-25
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
# Currently no unit tests
1212
formatting:
13-
runs-on: ubuntu-20.04
13+
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
1616
- name: Check Formatting of Files

portable/STM32F4xx/ff_sddisk.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
#define sdARRAY_SIZE( x ) ( int ) ( sizeof( x ) / sizeof( x )[ 0 ] )
8383
#endif
8484

85+
#ifndef ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER
86+
/* Set to 0 to remove SD detection interrupt handlers definition. */
87+
#define ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER 1
88+
#endif
89+
90+
8591
/*-----------------------------------------------------------*/
8692

8793
/*
@@ -1153,20 +1159,24 @@ static const char * prvSDCodePrintable( uint32_t ulCode )
11531159
#endif /* SDIO_USES_DMA != 0 */
11541160
/*-----------------------------------------------------------*/
11551161

1156-
void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
1157-
{
1158-
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
1159-
1160-
if( GPIO_Pin == configSD_DETECT_PIN )
1162+
#if ( ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0 )
1163+
void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
11611164
{
1162-
vApplicationCardDetectChangeHookFromISR( &xHigherPriorityTaskWoken );
1163-
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
1165+
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
1166+
1167+
if( GPIO_Pin == configSD_DETECT_PIN )
1168+
{
1169+
vApplicationCardDetectChangeHookFromISR( &xHigherPriorityTaskWoken );
1170+
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
1171+
}
11641172
}
1165-
}
1173+
#endif /* ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0*/
11661174
/*-----------------------------------------------------------*/
11671175

1168-
void EXTI15_10_IRQHandler( void )
1169-
{
1170-
HAL_GPIO_EXTI_IRQHandler( configSD_DETECT_PIN ); /* GPIO PIN H.13 */
1171-
}
1176+
#if ( ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0 )
1177+
void EXTI15_10_IRQHandler( void )
1178+
{
1179+
HAL_GPIO_EXTI_IRQHandler( configSD_DETECT_PIN ); /* GPIO PIN H.13 */
1180+
}
1181+
#endif /* ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0*/
11721182
/*-----------------------------------------------------------*/

portable/STM32F7xx/ff_sddisk.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
#define sdARRAY_SIZE( x ) ( int ) ( sizeof( x ) / sizeof( x )[ 0 ] )
9595
#endif
9696

97+
#ifndef ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER
98+
/* Set to 0 to remove SD detection interrupt handlers definition. */
99+
#define ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER 1
100+
#endif
101+
97102
#ifdef STM32F7xx
98103

99104
#define SRAM1_MAX_SIZE ( 368U * 1024U )
@@ -1263,20 +1268,24 @@ static const char * prvSDCodePrintable( uint32_t ulCode )
12631268
#endif /* SDIO_USES_DMA != 0 */
12641269
/*-----------------------------------------------------------*/
12651270

1266-
void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
1267-
{
1268-
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
1269-
1270-
if( GPIO_Pin == configSD_DETECT_PIN )
1271+
#if ( ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0 )
1272+
void HAL_GPIO_EXTI_Callback( uint16_t GPIO_Pin )
12711273
{
1272-
vApplicationCardDetectChangeHookFromISR( &xHigherPriorityTaskWoken );
1273-
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
1274+
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
1275+
1276+
if( GPIO_Pin == configSD_DETECT_PIN )
1277+
{
1278+
vApplicationCardDetectChangeHookFromISR( &xHigherPriorityTaskWoken );
1279+
portYIELD_FROM_ISR( xHigherPriorityTaskWoken );
1280+
}
12741281
}
1275-
}
1282+
#endif /* ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0*/
12761283
/*-----------------------------------------------------------*/
12771284

1278-
void EXTI15_10_IRQHandler( void )
1279-
{
1280-
HAL_GPIO_EXTI_IRQHandler( configSD_DETECT_PIN ); /* GPIO PIN H.13 */
1281-
}
1285+
#if ( ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0 )
1286+
void EXTI15_10_IRQHandler( void )
1287+
{
1288+
HAL_GPIO_EXTI_IRQHandler( configSD_DETECT_PIN ); /* GPIO PIN H.13 */
1289+
}
1290+
#endif /* ffconfigSDIO_DRIVER_DEFINES_SD_DETECTION_INTERRUPT_HANDLER != 0*/
12821291
/*-----------------------------------------------------------*/

0 commit comments

Comments
 (0)