Fix IRQ management in FreeRTOS to avoid crash and deadlock in BLE stack.

This commit is contained in:
Jean-François Milants 2021-02-14 14:42:30 +01:00
parent 6420885abb
commit 01e194426d
2 changed files with 24 additions and 2 deletions

View File

@ -354,4 +354,24 @@ static void vPortEnableVFP( void )
configASSERT( NVIC_GetPriorityGrouping() <= ulMaxPRIGROUPValue ); configASSERT( NVIC_GetPriorityGrouping() <= ulMaxPRIGROUPValue );
} }
uint32_t ulSetInterruptMaskFromISR( void )
{
__asm volatile (
" mrs r0, PRIMASK \n"
" cpsid i \n"
" bx lr "
::: "memory"
);
}
/*-----------------------------------------------------------*/
void vClearInterruptMaskFromISR( __attribute__( ( unused ) ) uint32_t ulMask )
{
__asm volatile (
" msr PRIMASK, r0 \n"
" bx lr "
::: "memory"
);
}
#endif /* configASSERT_DEFINED */ #endif /* configASSERT_DEFINED */

View File

@ -104,8 +104,10 @@ typedef unsigned long UBaseType_t;
/* Critical section management. */ /* Critical section management. */
extern void vPortEnterCritical( void ); extern void vPortEnterCritical( void );
extern void vPortExitCritical( void ); extern void vPortExitCritical( void );
#define portSET_INTERRUPT_MASK_FROM_ISR() ulPortRaiseBASEPRI() extern uint32_t ulSetInterruptMaskFromISR( void ) __attribute__( ( naked ) );
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortSetBASEPRI(x) extern void vClearInterruptMaskFromISR( uint32_t ulMask ) __attribute__( ( naked ) );
#define portSET_INTERRUPT_MASK_FROM_ISR() ulSetInterruptMaskFromISR()
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vClearInterruptMaskFromISR( x )
#define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" ) #define portDISABLE_INTERRUPTS() __asm volatile ( " cpsid i " ::: "memory" )
#define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" ) #define portENABLE_INTERRUPTS() __asm volatile ( " cpsie i " ::: "memory" )
#define portENTER_CRITICAL() vPortEnterCritical() #define portENTER_CRITICAL() vPortEnterCritical()