|
|
|
@ -42,11 +42,11 @@ task.h is included from an application file. */
|
|
|
|
|
#error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available.
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Lint e961 and e750 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 correct
|
|
|
|
|
privileged Vs unprivileged linkage and placement. */
|
|
|
|
|
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
|
|
|
|
|
/* Lint e9021, e961 and e750 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
|
|
|
|
|
correct privileged Vs unprivileged linkage and placement. */
|
|
|
|
|
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e9021 !e961 !e750. */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* This entire source file will be skipped if the application is not configured
|
|
|
|
@ -65,7 +65,7 @@ defining trmTIMER_SERVICE_TASK_NAME in FreeRTOSConfig.h. */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* The definition of the timers themselves. */
|
|
|
|
|
typedef struct tmrTimerControl
|
|
|
|
|
typedef struct TimerDef_t
|
|
|
|
|
{
|
|
|
|
|
const char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
|
|
|
|
ListItem_t xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */
|
|
|
|
@ -128,8 +128,6 @@ which static variables must be declared volatile. */
|
|
|
|
|
/* The list in which active timers are stored. Timers are referenced in expire
|
|
|
|
|
time order, with the nearest expiry time at the front of the list. Only the
|
|
|
|
|
timer service task is allowed to access these lists. */
|
|
|
|
|
PRIVILEGED_DATA static List_t xActiveTimerList1;
|
|
|
|
|
PRIVILEGED_DATA static List_t xActiveTimerList2;
|
|
|
|
|
PRIVILEGED_DATA static List_t *pxCurrentTimerList;
|
|
|
|
|
PRIVILEGED_DATA static List_t *pxOverflowTimerList;
|
|
|
|
|
|
|
|
|
@ -283,7 +281,7 @@ BaseType_t xReturn = pdFAIL;
|
|
|
|
|
{
|
|
|
|
|
Timer_t *pxNewTimer;
|
|
|
|
|
|
|
|
|
|
pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );
|
|
|
|
|
pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) ); /*lint !e9087 !e9079 All values returned by pvPortMalloc() have at least the alignment required by the MCU's stack, and the first member of Timer_t is always a pointer to the timer's mame. */
|
|
|
|
|
|
|
|
|
|
if( pxNewTimer != NULL )
|
|
|
|
|
{
|
|
|
|
@ -323,12 +321,13 @@ BaseType_t xReturn = pdFAIL;
|
|
|
|
|
structure. */
|
|
|
|
|
volatile size_t xSize = sizeof( StaticTimer_t );
|
|
|
|
|
configASSERT( xSize == sizeof( Timer_t ) );
|
|
|
|
|
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
|
|
|
|
|
}
|
|
|
|
|
#endif /* configASSERT_DEFINED */
|
|
|
|
|
|
|
|
|
|
/* A pointer to a StaticTimer_t structure MUST be provided, use it. */
|
|
|
|
|
configASSERT( pxTimerBuffer );
|
|
|
|
|
pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */
|
|
|
|
|
pxNewTimer = ( Timer_t * ) pxTimerBuffer; /*lint !e740 !e9087 StaticTimer_t is a pointer to a Timer_t, so guaranteed to be aligned and sized correctly (checked by an assert()), so this is safe. */
|
|
|
|
|
|
|
|
|
|
if( pxNewTimer != NULL )
|
|
|
|
|
{
|
|
|
|
@ -392,7 +391,7 @@ DaemonTaskMessage_t xMessage;
|
|
|
|
|
/* Send a command to the timer service task to start the xTimer timer. */
|
|
|
|
|
xMessage.xMessageID = xCommandID;
|
|
|
|
|
xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;
|
|
|
|
|
xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
xMessage.u.xTimerParameters.pxTimer = xTimer;
|
|
|
|
|
|
|
|
|
|
if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )
|
|
|
|
|
{
|
|
|
|
@ -432,7 +431,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void )
|
|
|
|
|
|
|
|
|
|
TickType_t xTimerGetPeriod( TimerHandle_t xTimer )
|
|
|
|
|
{
|
|
|
|
|
Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
Timer_t *pxTimer = xTimer;
|
|
|
|
|
|
|
|
|
|
configASSERT( xTimer );
|
|
|
|
|
return pxTimer->xTimerPeriodInTicks;
|
|
|
|
@ -441,7 +440,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
|
|
|
|
|
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )
|
|
|
|
|
{
|
|
|
|
|
Timer_t * pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
Timer_t * pxTimer = xTimer;
|
|
|
|
|
TickType_t xReturn;
|
|
|
|
|
|
|
|
|
|
configASSERT( xTimer );
|
|
|
|
@ -452,7 +451,7 @@ TickType_t xReturn;
|
|
|
|
|
|
|
|
|
|
const char * pcTimerGetName( TimerHandle_t xTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
|
|
|
|
{
|
|
|
|
|
Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
Timer_t *pxTimer = xTimer;
|
|
|
|
|
|
|
|
|
|
configASSERT( xTimer );
|
|
|
|
|
return pxTimer->pcTimerName;
|
|
|
|
@ -462,7 +461,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow )
|
|
|
|
|
{
|
|
|
|
|
BaseType_t xResult;
|
|
|
|
|
Timer_t * const pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );
|
|
|
|
|
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
|
|
|
|
|
been performed to ensure the list is not empty. */
|
|
|
|
@ -848,7 +847,7 @@ BaseType_t xResult;
|
|
|
|
|
xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
|
|
|
|
|
|
|
|
|
|
/* Remove the timer from the list. */
|
|
|
|
|
pxTimer = ( Timer_t * ) listGET_OWNER_OF_HEAD_ENTRY( pxCurrentTimerList );
|
|
|
|
|
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. */
|
|
|
|
|
( void ) uxListRemove( &( pxTimer->xTimerListItem ) );
|
|
|
|
|
traceTIMER_EXPIRED( pxTimer );
|
|
|
|
|
|
|
|
|
@ -893,6 +892,9 @@ BaseType_t xResult;
|
|
|
|
|
|
|
|
|
|
static void prvCheckForValidListAndQueue( void )
|
|
|
|
|
{
|
|
|
|
|
PRIVILEGED_DATA static List_t xActiveTimerList1;
|
|
|
|
|
PRIVILEGED_DATA static List_t xActiveTimerList2;
|
|
|
|
|
|
|
|
|
|
/* Check that the list from which active timers are referenced, and the
|
|
|
|
|
queue used to communicate with the timer service, have been
|
|
|
|
|
initialised. */
|
|
|
|
@ -945,7 +947,7 @@ static void prvCheckForValidListAndQueue( void )
|
|
|
|
|
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )
|
|
|
|
|
{
|
|
|
|
|
BaseType_t xTimerIsInActiveList;
|
|
|
|
|
Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
Timer_t *pxTimer = xTimer;
|
|
|
|
|
|
|
|
|
|
configASSERT( xTimer );
|
|
|
|
|
|
|
|
|
@ -955,7 +957,14 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
/* Checking to see if it is in the NULL list in effect checks to see if
|
|
|
|
|
it is referenced from either the current or the overflow timer lists in
|
|
|
|
|
one go, but the logic has to be reversed, hence the '!'. */
|
|
|
|
|
xTimerIsInActiveList = ( BaseType_t ) !( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) ); /*lint !e961. Cast is only redundant when NULL is passed into the macro. */
|
|
|
|
|
if( listIS_CONTAINED_WITHIN( NULL, &( pxTimer->xTimerListItem ) ) == pdTRUE )
|
|
|
|
|
{
|
|
|
|
|
xTimerIsInActiveList = pdFALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
xTimerIsInActiveList = pdTRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
taskEXIT_CRITICAL();
|
|
|
|
|
|
|
|
|
@ -965,7 +974,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
|
|
|
|
|
void *pvTimerGetTimerID( const TimerHandle_t xTimer )
|
|
|
|
|
{
|
|
|
|
|
Timer_t * const pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
Timer_t * const pxTimer = xTimer;
|
|
|
|
|
void *pvReturn;
|
|
|
|
|
|
|
|
|
|
configASSERT( xTimer );
|
|
|
|
@ -982,7 +991,7 @@ void *pvReturn;
|
|
|
|
|
|
|
|
|
|
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )
|
|
|
|
|
{
|
|
|
|
|
Timer_t * const pxTimer = ( Timer_t * ) xTimer;
|
|
|
|
|
Timer_t * const pxTimer = xTimer;
|
|
|
|
|
|
|
|
|
|
configASSERT( xTimer );
|
|
|
|
|
|
|
|
|
|