diff --git a/portable/ThirdParty/GCC/RP2040/include/portmacro.h b/portable/ThirdParty/GCC/RP2040/include/portmacro.h index 430e518884..2d6c6ccfe3 100644 --- a/portable/ThirdParty/GCC/RP2040/include/portmacro.h +++ b/portable/ThirdParty/GCC/RP2040/include/portmacro.h @@ -278,7 +278,7 @@ extern void vPortEnableInterrupts(); /*-----------------------------------------------------------*/ -#define portUSING_GRANULAR_LOCKS ( 1 ) +#define portUSING_GRANULAR_LOCKS ( 0 ) /*-----------------------------------------------------------*/ diff --git a/portable/ThirdParty/GCC/RP2040/port.c b/portable/ThirdParty/GCC/RP2040/port.c index 0709cd3dd9..b0011a6f65 100644 --- a/portable/ThirdParty/GCC/RP2040/port.c +++ b/portable/ThirdParty/GCC/RP2040/port.c @@ -1261,115 +1261,117 @@ void vPortSpinlockRelease( portSPINLOCK_TYPE *pxSpinlock ) } } -void vPortLockDataGroup( portSPINLOCK_TYPE *pxTaskSpinlock, portSPINLOCK_TYPE *pxISRSpinlock ) -{ - uint32_t uxTaskSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxTaskSpinlock->uxSpinlockNumber ); - uint32_t uxISRSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxISRSpinlock->uxSpinlockNumber ); +#if portUSING_GRANULAR_LOCKS == 1 + void vPortLockDataGroup( portSPINLOCK_TYPE *pxTaskSpinlock, portSPINLOCK_TYPE *pxISRSpinlock ) + { + uint32_t uxTaskSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxTaskSpinlock->uxSpinlockNumber ); + uint32_t uxISRSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxISRSpinlock->uxSpinlockNumber ); - portDISABLE_INTERRUPTS(); + portDISABLE_INTERRUPTS(); - BaseType_t xCoreID = portGET_CORE_ID(); + BaseType_t xCoreID = portGET_CORE_ID(); - if( uxTaskSpinlockIndex < 2 ) - { - vPortRecursiveLock(uxTaskSpinlockIndex, spin_lock_instance(pxTaskSpinlock->uxSpinlockNumber), pdTRUE); - vPortRecursiveLock(uxISRSpinlockIndex, spin_lock_instance(pxISRSpinlock->uxSpinlockNumber), pdTRUE); - uxCriticalNestings[ xCoreID ]++; - uxCriticalNestings[ xCoreID ]++; - } - else - { - /* Task spinlock is optional and is always taken first */ - if( pxTaskSpinlock != NULL ) + if( uxTaskSpinlockIndex < 2 ) { - vPortSpinlockTake( pxTaskSpinlock ); + vPortRecursiveLock(uxTaskSpinlockIndex, spin_lock_instance(pxTaskSpinlock->uxSpinlockNumber), pdTRUE); + vPortRecursiveLock(uxISRSpinlockIndex, spin_lock_instance(pxISRSpinlock->uxSpinlockNumber), pdTRUE); + uxCriticalNestings[ xCoreID ]++; uxCriticalNestings[ xCoreID ]++; } + else + { + /* Task spinlock is optional and is always taken first */ + if( pxTaskSpinlock != NULL ) + { + vPortSpinlockTake( pxTaskSpinlock ); + uxCriticalNestings[ xCoreID ]++; + } - /* ISR spinlock must always be provided */ - vPortSpinlockTake( pxISRSpinlock ); - uxCriticalNestings[ xCoreID ]++; + /* ISR spinlock must always be provided */ + vPortSpinlockTake( pxISRSpinlock ); + uxCriticalNestings[ xCoreID ]++; + } } -} -void vPortUnlockDataGroup( portSPINLOCK_TYPE *pxTaskSpinlock, portSPINLOCK_TYPE *pxISRSpinlock ) -{ - BaseType_t xCoreID = portGET_CORE_ID(); - BaseType_t xYieldCurrentTask; - - uint32_t uxTaskSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxTaskSpinlock->uxSpinlockNumber ); - uint32_t uxISRSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxISRSpinlock->uxSpinlockNumber ); + void vPortUnlockDataGroup( portSPINLOCK_TYPE *pxTaskSpinlock, portSPINLOCK_TYPE *pxISRSpinlock ) + { + BaseType_t xCoreID = portGET_CORE_ID(); + BaseType_t xYieldCurrentTask; - configASSERT( uxCriticalNestings[ xCoreID ] > 0U ); + uint32_t uxTaskSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxTaskSpinlock->uxSpinlockNumber ); + uint32_t uxISRSpinlockIndex = portSPINLOCK_NUMBER_TO_INDEX( pxISRSpinlock->uxSpinlockNumber ); - /* Get the xYieldPending stats inside the critical section. */ - xYieldCurrentTask = xTaskUnlockCanYield(); + configASSERT( uxCriticalNestings[ xCoreID ] > 0U ); - if( uxTaskSpinlockIndex < 2 ) - { - vPortRecursiveLock(uxTaskSpinlockIndex, spin_lock_instance(pxTaskSpinlock->uxSpinlockNumber), pdFALSE); - vPortRecursiveLock(uxISRSpinlockIndex, spin_lock_instance(pxISRSpinlock->uxSpinlockNumber), pdFALSE); - uxCriticalNestings[ xCoreID ]--; - uxCriticalNestings[ xCoreID ]--; - } - else - { - /* ISR spinlock must always be provided */ - vPortSpinlockRelease( pxISRSpinlock ); - uxCriticalNestings[ xCoreID ]--; + /* Get the xYieldPending stats inside the critical section. */ + xYieldCurrentTask = xTaskUnlockCanYield(); - /* Task spinlock is optional and is always taken first */ - if( pxTaskSpinlock != NULL ) + if( uxTaskSpinlockIndex < 2 ) { - vPortSpinlockRelease( pxTaskSpinlock); + vPortRecursiveLock(uxTaskSpinlockIndex, spin_lock_instance(pxTaskSpinlock->uxSpinlockNumber), pdFALSE); + vPortRecursiveLock(uxISRSpinlockIndex, spin_lock_instance(pxISRSpinlock->uxSpinlockNumber), pdFALSE); + uxCriticalNestings[ xCoreID ]--; uxCriticalNestings[ xCoreID ]--; } - } - - assert(uxCriticalNestings[ xCoreID ] >= 0); + else + { + /* ISR spinlock must always be provided */ + vPortSpinlockRelease( pxISRSpinlock ); + uxCriticalNestings[ xCoreID ]--; - if( uxCriticalNestings[ xCoreID ] == 0 ) - { - portENABLE_INTERRUPTS(); + /* Task spinlock is optional and is always taken first */ + if( pxTaskSpinlock != NULL ) + { + vPortSpinlockRelease( pxTaskSpinlock); + uxCriticalNestings[ xCoreID ]--; + } + } - /* When a task yields in a critical section it just sets xYieldPending to - * true. So now that we have exited the critical section check if xYieldPending - * is true, and if so yield. */ + assert(uxCriticalNestings[ xCoreID ] >= 0); - if( xYieldCurrentTask != pdFALSE ) - { - portYIELD(); - } - else + if( uxCriticalNestings[ xCoreID ] == 0 ) { - mtCOVERAGE_TEST_MARKER(); + portENABLE_INTERRUPTS(); + + /* When a task yields in a critical section it just sets xYieldPending to + * true. So now that we have exited the critical section check if xYieldPending + * is true, and if so yield. */ + + if( xYieldCurrentTask != pdFALSE ) + { + portYIELD(); + } + else + { + mtCOVERAGE_TEST_MARKER(); + } } } -} -UBaseType_t uxPortLockDataGroupFromISR( portSPINLOCK_TYPE *pxISRSpinlock ) -{ - UBaseType_t uxSavedInterruptStatus = 0; + UBaseType_t uxPortLockDataGroupFromISR( portSPINLOCK_TYPE *pxISRSpinlock ) + { + UBaseType_t uxSavedInterruptStatus = 0; - uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); + uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); - vPortSpinlockTake( pxISRSpinlock ); - uxCriticalNestings[ portGET_CORE_ID() ]++; + vPortSpinlockTake( pxISRSpinlock ); + uxCriticalNestings[ portGET_CORE_ID() ]++; - return uxSavedInterruptStatus; -} + return uxSavedInterruptStatus; + } -void vPortUnlockDataGroupFromISR( UBaseType_t uxSavedInterruptStatus, portSPINLOCK_TYPE *pxISRSpinlock ) -{ - BaseType_t xCoreID = portGET_CORE_ID(); + void vPortUnlockDataGroupFromISR( UBaseType_t uxSavedInterruptStatus, portSPINLOCK_TYPE *pxISRSpinlock ) + { + BaseType_t xCoreID = portGET_CORE_ID(); - vPortSpinlockRelease( pxISRSpinlock ); - uxCriticalNestings[ xCoreID ]--; + vPortSpinlockRelease( pxISRSpinlock ); + uxCriticalNestings[ xCoreID ]--; - assert(uxCriticalNestings[ xCoreID ] >= 0); + assert(uxCriticalNestings[ xCoreID ] >= 0); - if( uxCriticalNestings[ xCoreID ] == 0 ) - { - portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + if( uxCriticalNestings[ xCoreID ] == 0 ) + { + portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ); + } } -} \ No newline at end of file +#endif