freertos: Reduce ESP specific code

This commit is contained in:
Zim Kalinowski
2021-08-30 14:45:31 +08:00
parent ed8df94915
commit 5f2a66a8a5
6 changed files with 314 additions and 223 deletions

View File

@@ -38,6 +38,18 @@
#include "timers.h"
#include "event_groups.h"
#ifdef ESP_PLATFORM
#define taskCRITICAL_MUX &pxEventBits->eventGroupMux
#undef taskENTER_CRITICAL
#undef taskEXIT_CRITICAL
#undef taskENTER_CRITICAL_ISR
#undef taskEXIT_CRITICAL_ISR
#define taskENTER_CRITICAL( ) portENTER_CRITICAL( taskCRITICAL_MUX )
#define taskEXIT_CRITICAL( ) portEXIT_CRITICAL( taskCRITICAL_MUX )
#define taskENTER_CRITICAL_ISR( ) portENTER_CRITICAL_ISR( taskCRITICAL_MUX )
#define taskEXIT_CRITICAL_ISR( ) portEXIT_CRITICAL_ISR( taskCRITICAL_MUX )
#endif
/* Lint e961, e750 and e9021 are suppressed as a MISRA exception justified
* because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
* for the header files above, but not in this file, in order to generate the
@@ -212,7 +224,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
}
#endif
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
uxOriginalBitValue = pxEventBits->uxEventBits;
@@ -255,7 +267,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
}
}
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
if( xTicksToWait != ( TickType_t ) 0 )
{
@@ -270,7 +282,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
{
/* The task timed out, just return the current event bit value. */
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
uxReturn = pxEventBits->uxEventBits;
@@ -287,7 +299,7 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
mtCOVERAGE_TEST_MARKER();
}
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
xTimeoutOccurred = pdTRUE;
}
@@ -332,7 +344,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
}
#endif
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
const EventBits_t uxCurrentEventBits = pxEventBits->uxEventBits;
@@ -400,7 +412,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor );
}
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
if( xTicksToWait != ( TickType_t ) 0 )
{
@@ -414,7 +426,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
if( ( uxReturn & eventUNBLOCKED_DUE_TO_BIT_SET ) == ( EventBits_t ) 0 )
{
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
/* The task timed out, just return the current event bit value. */
uxReturn = pxEventBits->uxEventBits;
@@ -439,7 +451,7 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
xTimeoutOccurred = pdTRUE;
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
}
else
{
@@ -470,7 +482,7 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
configASSERT( xEventGroup );
configASSERT( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 );
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
traceEVENT_GROUP_CLEAR_BITS( xEventGroup, uxBitsToClear );
@@ -481,7 +493,7 @@ EventBits_t xEventGroupClearBits( EventGroupHandle_t xEventGroup,
/* Clear the bits. */
pxEventBits->uxEventBits &= ~uxBitsToClear;
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
return uxReturn;
}
@@ -536,7 +548,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
pxList = &( pxEventBits->xTasksWaitingForBits );
pxListEnd = listGET_END_MARKER( pxList ); /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. */
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
@@ -608,7 +620,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
* bit was set in the control word. */
pxEventBits->uxEventBits &= ~uxBitsToClear;
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
return pxEventBits->uxEventBits;
}
@@ -621,7 +633,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
traceEVENT_GROUP_DELETE( xEventGroup );
taskENTER_CRITICAL( &pxEventBits->eventGroupMux );
taskENTER_CRITICAL();
{
while( listCURRENT_LIST_LENGTH( pxTasksWaitingForBits ) > ( UBaseType_t ) 0 )
{
@@ -631,7 +643,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup )
xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET );
}
}
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
taskEXIT_CRITICAL();
#if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) )
{