freertos: cherrypicked code layout changes from freertos upgrade branch

This commit is contained in:
Zim Kalinowski
2021-08-26 13:45:51 +08:00
parent ceeb594f2d
commit a8c7db62be
7 changed files with 882 additions and 860 deletions

View File

@@ -255,7 +255,6 @@ EventBits_t xEventGroupSync( EventGroupHandle_t xEventGroup,
} }
} }
} }
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux ); taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
if( xTicksToWait != ( TickType_t ) 0 ) if( xTicksToWait != ( TickType_t ) 0 )
@@ -401,7 +400,6 @@ EventBits_t xEventGroupWaitBits( EventGroupHandle_t xEventGroup,
traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor ); traceEVENT_GROUP_WAIT_BITS_BLOCK( xEventGroup, uxBitsToWaitFor );
} }
} }
taskEXIT_CRITICAL( &pxEventBits->eventGroupMux ); taskEXIT_CRITICAL( &pxEventBits->eventGroupMux );
if( xTicksToWait != ( TickType_t ) 0 ) if( xTicksToWait != ( TickType_t ) 0 )
@@ -538,7 +536,6 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
pxList = &( pxEventBits->xTasksWaitingForBits ); 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. */ 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( &pxEventBits->eventGroupMux );
{ {
traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet ); traceEVENT_GROUP_SET_BITS( xEventGroup, uxBitsToSet );
@@ -619,8 +616,8 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup,
void vEventGroupDelete( EventGroupHandle_t xEventGroup ) void vEventGroupDelete( EventGroupHandle_t xEventGroup )
{ {
EventGroup_t *pxEventBits = xEventGroup; EventGroup_t * pxEventBits = xEventGroup;
const List_t *pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits ); const List_t * pxTasksWaitingForBits = &( pxEventBits->xTasksWaitingForBits );
traceEVENT_GROUP_DELETE( xEventGroup ); traceEVENT_GROUP_DELETE( xEventGroup );

View File

@@ -84,9 +84,8 @@
* \ingroup EventGroup * \ingroup EventGroup
*/ */
struct EventGroupDef_t; struct EventGroupDef_t;
//typedef struct EventGroupDef_t * EventGroupHandle_t;
typedef void * EventGroupHandle_t; typedef void * EventGroupHandle_t;
// typedef struct EventGroupDef_t * EventGroupHandle_t;
/* /*
* The type that holds event bits always matches TickType_t - therefore the * The type that holds event bits always matches TickType_t - therefore the
* number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1, * number of bits it holds is set by configUSE_16_BIT_TICKS (16 bits if set to 1,

View File

@@ -129,27 +129,24 @@ void vListInsert( List_t * const pxList,
{ {
/* *** NOTE *********************************************************** /* *** NOTE ***********************************************************
* If you find your application is crashing here then likely causes are * If you find your application is crashing here then likely causes are
* listed below. In addition see https://www.freertos.org/FAQHelp.html for * listed below. In addition see https://www.FreeRTOS.org/FAQHelp.html for
* more tips, and ensure configASSERT() is defined! * more tips, and ensure configASSERT() is defined!
* https://www.freertos.org/a00110.html#configASSERT * https://www.FreeRTOS.org/a00110.html#configASSERT
* *
* 1) Stack overflow - * 1) Stack overflow -
* see https://www.freertos.org/Stacks-and-stack-overflow-checking.html * see https://www.FreeRTOS.org/Stacks-and-stack-overflow-checking.html
* 2) Incorrect interrupt priority assignment, especially on Cortex-M * 2) Incorrect interrupt priority assignment, especially on Cortex-M
* parts where numerically high priority values denote low actual * parts where numerically high priority values denote low actual
* interrupt priorities, which can seem counter intuitive. See * interrupt priorities, which can seem counter intuitive. See
* https://www.freertos.org/RTOS-Cortex-M3-M4.html and the definition * https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html and the definition
* of configMAX_SYSCALL_INTERRUPT_PRIORITY on * of configMAX_SYSCALL_INTERRUPT_PRIORITY on
* https://www.freertos.org/a00110.html * https://www.FreeRTOS.org/a00110.html
* 3) Calling an API function from within a critical section or when * 3) Calling an API function from within a critical section or when
* the scheduler is suspended, or calling an API function that does * the scheduler is suspended, or calling an API function that does
* not end in "FromISR" from an interrupt. * not end in "FromISR" from an interrupt.
* 4) Using a queue or semaphore before it has been initialised or * 4) Using a queue or semaphore before it has been initialised or
* before the scheduler has been started (are interrupts firing * before the scheduler has been started (are interrupts firing
* before vTaskStartScheduler() has been called?). * before vTaskStartScheduler() has been called?).
* 5) If the FreeRTOS port supports interrupt nesting then ensure that
* the priority of the tick interrupt is at or below
* configMAX_SYSCALL_INTERRUPT_PRIORITY.
**********************************************************************/ **********************************************************************/
for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */ for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */

View File

@@ -92,7 +92,7 @@ typedef struct SemaphoreData
/* /*
* Definition of the queue used by the scheduler. * Definition of the queue used by the scheduler.
* Items are queued by copy, not reference. See the following link for the * Items are queued by copy, not reference. See the following link for the
* rationale: https://www.freertos.org/Embedded-RTOS-Queues.html * rationale: https://www.FreeRTOS.org/Embedded-RTOS-Queues.html
*/ */
typedef struct QueueDefinition /* The old naming convention is used to prevent breaking kernel aware debuggers. */ typedef struct QueueDefinition /* The old naming convention is used to prevent breaking kernel aware debuggers. */
{ {
@@ -1030,7 +1030,7 @@ BaseType_t xQueueGenericSendFromISR( QueueHandle_t xQueue,
* system call interrupt priority. FreeRTOS maintains a separate interrupt * system call interrupt priority. FreeRTOS maintains a separate interrupt
* safe API to ensure interrupt entry is as fast and as simple as possible. * safe API to ensure interrupt entry is as fast and as simple as possible.
* More information (albeit Cortex-M specific) is provided on the following * More information (albeit Cortex-M specific) is provided on the following
* link: https://www.freertos.org/RTOS-Cortex-M3-M4.html */ * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
/* Similar to xQueueGenericSend, except without blocking if there is no room /* Similar to xQueueGenericSend, except without blocking if there is no room
@@ -1199,7 +1199,7 @@ BaseType_t xQueueGiveFromISR( QueueHandle_t xQueue,
* system call interrupt priority. FreeRTOS maintains a separate interrupt * system call interrupt priority. FreeRTOS maintains a separate interrupt
* safe API to ensure interrupt entry is as fast and as simple as possible. * safe API to ensure interrupt entry is as fast and as simple as possible.
* More information (albeit Cortex-M specific) is provided on the following * More information (albeit Cortex-M specific) is provided on the following
* link: https://www.freertos.org/RTOS-Cortex-M3-M4.html */ * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
@@ -1847,7 +1847,7 @@ BaseType_t xQueueReceiveFromISR( QueueHandle_t xQueue,
* system call interrupt priority. FreeRTOS maintains a separate interrupt * system call interrupt priority. FreeRTOS maintains a separate interrupt
* safe API to ensure interrupt entry is as fast and as simple as possible. * safe API to ensure interrupt entry is as fast and as simple as possible.
* More information (albeit Cortex-M specific) is provided on the following * More information (albeit Cortex-M specific) is provided on the following
* link: https://www.freertos.org/RTOS-Cortex-M3-M4.html */ * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
@@ -1944,7 +1944,7 @@ BaseType_t xQueuePeekFromISR( QueueHandle_t xQueue,
* system call interrupt priority. FreeRTOS maintains a separate interrupt * system call interrupt priority. FreeRTOS maintains a separate interrupt
* safe API to ensure interrupt entry is as fast and as simple as possible. * safe API to ensure interrupt entry is as fast and as simple as possible.
* More information (albeit Cortex-M specific) is provided on the following * More information (albeit Cortex-M specific) is provided on the following
* link: https://www.freertos.org/RTOS-Cortex-M3-M4.html */ * link: https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
portASSERT_IF_INTERRUPT_PRIORITY_INVALID(); portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR(); uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
@@ -2346,7 +2346,7 @@ static void prvUnlockQueue( Queue_t * const pxQueue )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static BaseType_t prvIsQueueEmpty( const Queue_t *pxQueue ) static BaseType_t prvIsQueueEmpty( const Queue_t * pxQueue )
{ {
BaseType_t xReturn; BaseType_t xReturn;
Queue_t * pxQ = (Queue_t *)pxQueue; Queue_t * pxQ = (Queue_t *)pxQueue;

View File

@@ -166,7 +166,7 @@ static size_t prvBytesInBuffer( const StreamBuffer_t * const pxStreamBuffer ) PR
* no data is written into the buffer). * no data is written into the buffer).
*/ */
static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer, static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer,
const uint8_t *pucData, const uint8_t * pucData,
size_t xCount ) PRIVILEGED_FUNCTION; size_t xCount ) PRIVILEGED_FUNCTION;
/* /*
@@ -269,6 +269,7 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
pucAllocatedMemory = NULL; pucAllocatedMemory = NULL;
} }
if( pucAllocatedMemory != NULL ) if( pucAllocatedMemory != NULL )
{ {
prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */ prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */
@@ -711,7 +712,7 @@ static size_t prvWriteMessageToBuffer( StreamBuffer_t * const pxStreamBuffer,
if( xShouldWrite != pdFALSE ) if( xShouldWrite != pdFALSE )
{ {
/* Writes the data itself. */ /* Writes the data itself. */
xReturn = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) pvTxData, xDataLengthBytes ); /*lint !e9079 Storage buffer is implemented as uint8_t for ease of sizing, alighment and access. */ xReturn = prvWriteBytesToBuffer( pxStreamBuffer, ( const uint8_t * ) pvTxData, xDataLengthBytes ); /*lint !e9079 Storage buffer is implemented as uint8_t for ease of sizing, alignment and access. */
} }
else else
{ {
@@ -1118,7 +1119,7 @@ static size_t prvWriteBytesToBuffer( StreamBuffer_t * const pxStreamBuffer,
/* Write as many bytes as can be written in the first write. */ /* Write as many bytes as can be written in the first write. */
configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength ); configASSERT( ( xNextHead + xFirstLength ) <= pxStreamBuffer->xLength );
( void ) memcpy( ( void* ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */ ( void ) memcpy( ( void * ) ( &( pxStreamBuffer->pucBuffer[ xNextHead ] ) ), ( const void * ) pucData, xFirstLength ); /*lint !e9087 memcpy() requires void *. */
/* If the number of bytes written was less than the number that could be /* If the number of bytes written was less than the number that could be
* written in the first write... */ * written in the first write... */

File diff suppressed because it is too large Load Diff

View File

@@ -55,7 +55,7 @@
#if ( configUSE_TIMERS == 1 ) #if ( configUSE_TIMERS == 1 )
/* Misc definitions. */ /* Misc definitions. */
#define tmrNO_DELAY ( TickType_t ) 0U #define tmrNO_DELAY ( TickType_t ) 0U
/* The name assigned to the timer service task. This can be overridden by /* The name assigned to the timer service task. This can be overridden by
* defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */ * defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */
@@ -487,7 +487,7 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
const char * pcTimerGetName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ const char * pcTimerGetName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
{ {
Timer_t *pxTimer = xTimer; Timer_t * pxTimer = xTimer;
configASSERT( xTimer ); configASSERT( xTimer );
return pxTimer->pcTimerName; return pxTimer->pcTimerName;
@@ -500,21 +500,21 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */ Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList ); /*lint !e9087 !e9079 void * is used as this macro is used with tasks and co-routines too. Alignment is known to be fine as the type of the pointer stored and retrieved is the same. */
/* Remove the timer from the list of active timers. A check has already /* Remove the timer from the list of active timers. A check has already
been performed to ensure the list is not empty. */ * been performed to ensure the list is not empty. */
( void ) uxListRemove( &( pxTimer->xTimerListItem ) ); ( void ) uxListRemove( &( pxTimer->xTimerListItem ) );
traceTIMER_EXPIRED( pxTimer ); traceTIMER_EXPIRED( pxTimer );
/* If the timer is an auto reload timer then calculate the next /* If the timer is an auto-reload timer then calculate the next
expiry time and re-insert the timer in the list of active timers. */ * expiry time and re-insert the timer in the list of active timers. */
if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 ) if( ( pxTimer->ucStatus & tmrSTATUS_IS_AUTORELOAD ) != 0 )
{ {
/* The timer is inserted into a list using a time relative to anything /* The timer is inserted into a list using a time relative to anything
other than the current time. It will therefore be inserted into the * other than the current time. It will therefore be inserted into the
correct list relative to the time this task thinks it is now. */ * correct list relative to the time this task thinks it is now. */
if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) != pdFALSE ) if( prvInsertTimerInActiveList( pxTimer, ( xNextExpireTime + pxTimer->xTimerPeriodInTicks ), xTimeNow, xNextExpireTime ) != pdFALSE )
{ {
/* The timer expired before it was added to the active timer /* The timer expired before it was added to the active timer
list. Reload it now. */ * list. Reload it now. */
xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY ); xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY );
configASSERT( xResult ); configASSERT( xResult );
( void ) xResult; ( void ) xResult;
@@ -543,26 +543,26 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
/* Just to avoid compiler warnings. */ /* Just to avoid compiler warnings. */
( void ) pvParameters; ( void ) pvParameters;
#if( configUSE_DAEMON_TASK_STARTUP_HOOK == 1 ) #if ( configUSE_DAEMON_TASK_STARTUP_HOOK == 1 )
{ {
extern void vApplicationDaemonTaskStartupHook( void ); extern void vApplicationDaemonTaskStartupHook( void );
/* Allow the application writer to execute some code in the context of /* Allow the application writer to execute some code in the context of
this task at the point the task starts executing. This is useful if the * this task at the point the task starts executing. This is useful if the
application includes initialisation code that would benefit from * application includes initialisation code that would benefit from
executing after the scheduler has been started. */ * executing after the scheduler has been started. */
vApplicationDaemonTaskStartupHook(); vApplicationDaemonTaskStartupHook();
} }
#endif /* configUSE_DAEMON_TASK_STARTUP_HOOK */ #endif /* configUSE_DAEMON_TASK_STARTUP_HOOK */
for( ;; ) for( ; ; )
{ {
/* Query the timers list to see if it contains any timers, and if so, /* Query the timers list to see if it contains any timers, and if so,
obtain the time at which the next timer will expire. */ * obtain the time at which the next timer will expire. */
xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty ); xNextExpireTime = prvGetNextExpireTime( &xListWasEmpty );
/* If a timer has expired, process it. Otherwise, block this task /* If a timer has expired, process it. Otherwise, block this task
until either a timer does expire, or a command is received. */ * until either a timer does expire, or a command is received. */
prvProcessTimerOrBlockTask( xNextExpireTime, xListWasEmpty ); prvProcessTimerOrBlockTask( xNextExpireTime, xListWasEmpty );
/* Empty the command queue. */ /* Empty the command queue. */
@@ -571,7 +571,8 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty ) static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime,
BaseType_t xListWasEmpty )
{ {
TickType_t xTimeNow; TickType_t xTimeNow;
BaseType_t xTimerListsWereSwitched; BaseType_t xTimerListsWereSwitched;
@@ -579,11 +580,12 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
taskENTER_CRITICAL( &xTimerMux); taskENTER_CRITICAL( &xTimerMux);
{ {
/* Obtain the time now to make an assessment as to whether the timer /* Obtain the time now to make an assessment as to whether the timer
has expired or not. If obtaining the time causes the lists to switch * has expired or not. If obtaining the time causes the lists to switch
then don't process this timer as any timers that remained in the list * then don't process this timer as any timers that remained in the list
when the lists were switched will have been processed within the * when the lists were switched will have been processed within the
prvSampleTimeNow() function. */ * prvSampleTimeNow() function. */
xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched ); xTimeNow = prvSampleTimeNow( &xTimerListsWereSwitched );
if( xTimerListsWereSwitched == pdFALSE ) if( xTimerListsWereSwitched == pdFALSE )
{ {
/* The tick count has not overflowed, has the timer expired? */ /* The tick count has not overflowed, has the timer expired? */
@@ -595,15 +597,15 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
else else
{ {
/* The tick count has not overflowed, and the next expire /* The tick count has not overflowed, and the next expire
time has not been reached yet. This task should therefore * time has not been reached yet. This task should therefore
block to wait for the next expire time or a command to be * block to wait for the next expire time or a command to be
received - whichever comes first. The following line cannot * received - whichever comes first. The following line cannot
be reached unless xNextExpireTime > xTimeNow, except in the * be reached unless xNextExpireTime > xTimeNow, except in the
case when the current timer list is empty. */ * case when the current timer list is empty. */
if( xListWasEmpty != pdFALSE ) if( xListWasEmpty != pdFALSE )
{ {
/* The current timer list is empty - is the overflow list /* The current timer list is empty - is the overflow list
also empty? */ * also empty? */
xListWasEmpty = listLIST_IS_EMPTY( pxOverflowTimerList ); xListWasEmpty = listLIST_IS_EMPTY( pxOverflowTimerList );
} }
@@ -612,9 +614,9 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
taskEXIT_CRITICAL( &xTimerMux); taskEXIT_CRITICAL( &xTimerMux);
/* Yield to wait for either a command to arrive, or the /* Yield to wait for either a command to arrive, or the
block time to expire. If a command arrived between the * block time to expire. If a command arrived between the
critical section being exited and this yield then the yield * critical section being exited and this yield then the yield
will not cause the task to block. */ * will not cause the task to block. */
portYIELD_WITHIN_API(); portYIELD_WITHIN_API();
} }
@@ -632,13 +634,14 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
TickType_t xNextExpireTime; TickType_t xNextExpireTime;
/* Timers are listed in expiry time order, with the head of the list /* Timers are listed in expiry time order, with the head of the list
referencing the task that will expire first. Obtain the time at which * referencing the task that will expire first. Obtain the time at which
the timer with the nearest expiry time will expire. If there are no * the timer with the nearest expiry time will expire. If there are no
active timers then just set the next expire time to 0. That will cause * active timers then just set the next expire time to 0. That will cause
this task to unblock when the tick count overflows, at which point the * this task to unblock when the tick count overflows, at which point the
timer lists will be switched and the next expiry time can be * timer lists will be switched and the next expiry time can be
re-assessed. */ * re-assessed. */
*pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList ); *pxListWasEmpty = listLIST_IS_EMPTY( pxCurrentTimerList );
if( *pxListWasEmpty == pdFALSE ) if( *pxListWasEmpty == pdFALSE )
{ {
xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList ); xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
@@ -676,7 +679,10 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer, const TickType_t xNextExpiryTime, const TickType_t xTimeNow, const TickType_t xCommandTime ) static BaseType_t prvInsertTimerInActiveList( Timer_t * const pxTimer,
const TickType_t xNextExpiryTime,
const TickType_t xTimeNow,
const TickType_t xCommandTime )
{ {
BaseType_t xProcessTimerNow = pdFALSE; BaseType_t xProcessTimerNow = pdFALSE;
@@ -686,11 +692,11 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
if( xNextExpiryTime <= xTimeNow ) if( xNextExpiryTime <= xTimeNow )
{ {
/* Has the expiry time elapsed between the command to start/reset a /* Has the expiry time elapsed between the command to start/reset a
timer was issued, and the time the command was processed? */ * timer was issued, and the time the command was processed? */
if( ( ( TickType_t ) ( xTimeNow - xCommandTime ) ) >= pxTimer->xTimerPeriodInTicks ) /*lint !e961 MISRA exception as the casts are only redundant for some ports. */ if( ( ( TickType_t ) ( xTimeNow - xCommandTime ) ) >= pxTimer->xTimerPeriodInTicks ) /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
{ {
/* The time between a command being issued and the command being /* The time between a command being issued and the command being
processed actually exceeds the timers period. */ * processed actually exceeds the timers period. */
xProcessTimerNow = pdTRUE; xProcessTimerNow = pdTRUE;
} }
else else
@@ -703,8 +709,8 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) ) if( ( xTimeNow < xCommandTime ) && ( xNextExpiryTime >= xCommandTime ) )
{ {
/* If, since the command was issued, the tick count has overflowed /* If, since the command was issued, the tick count has overflowed
but the expiry time has not, then the timer must have already passed * but the expiry time has not, then the timer must have already passed
its expiry time and should be processed immediately. */ * its expiry time and should be processed immediately. */
xProcessTimerNow = pdTRUE; xProcessTimerNow = pdTRUE;
} }
else else
@@ -720,7 +726,7 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
static void prvProcessReceivedCommands( void ) static void prvProcessReceivedCommands( void )
{ {
DaemonTaskMessage_t xMessage; DaemonTaskMessage_t xMessage;
Timer_t *pxTimer; Timer_t * pxTimer;
BaseType_t xTimerListsWereSwitched, xResult; BaseType_t xTimerListsWereSwitched, xResult;
TickType_t xTimeNow; TickType_t xTimeNow;
@@ -729,13 +735,13 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
#if ( INCLUDE_xTimerPendFunctionCall == 1 ) #if ( INCLUDE_xTimerPendFunctionCall == 1 )
{ {
/* Negative commands are pended function calls rather than timer /* Negative commands are pended function calls rather than timer
commands. */ * commands. */
if( xMessage.xMessageID < ( BaseType_t ) 0 ) if( xMessage.xMessageID < ( BaseType_t ) 0 )
{ {
const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters ); const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters );
/* The timer uses the xCallbackParameters member to request a /* The timer uses the xCallbackParameters member to request a
callback be executed. Check the callback is not NULL. */ * callback be executed. Check the callback is not NULL. */
configASSERT( pxCallback ); configASSERT( pxCallback );
/* Call the function. */ /* Call the function. */
@@ -749,11 +755,11 @@ PRIVILEGED_DATA portMUX_TYPE xTimerMux = portMUX_INITIALIZER_UNLOCKED;
#endif /* INCLUDE_xTimerPendFunctionCall */ #endif /* INCLUDE_xTimerPendFunctionCall */
/* Commands that are positive are timer commands rather than pended /* Commands that are positive are timer commands rather than pended
function calls. */ * function calls. */
if( xMessage.xMessageID >= ( BaseType_t ) 0 ) if( xMessage.xMessageID >= ( BaseType_t ) 0 )
{ {
/* The messages uses the xTimerParameters member to work on a /* The messages uses the xTimerParameters member to work on a
software timer. */ * software timer. */
pxTimer = xMessage.u.xTimerParameters.pxTimer; pxTimer = xMessage.u.xTimerParameters.pxTimer;
if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE ) /*lint !e961. The cast is only redundant when NULL is passed into the macro. */ if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdFALSE ) /*lint !e961. The cast is only redundant when NULL is passed into the macro. */