mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
TimerHandle_t is now type safe instead of void *.
Remove casts that are no longer required not type safe handles are used.
This commit is contained in:
parent
3d8681de9e
commit
4a8c4c9eaf
|
@ -315,7 +315,7 @@ List_t * const pxConstList = ( pxList ); \
|
||||||
* @param pxListItem The list item we want to know if is in the list.
|
* @param pxListItem The list item we want to know if is in the list.
|
||||||
* @return pdTRUE if the list item is in the list, otherwise pdFALSE.
|
* @return pdTRUE if the list item is in the list, otherwise pdFALSE.
|
||||||
*/
|
*/
|
||||||
#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? pdTRUE : pdFALSE )
|
#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( ( pxListItem )->pxContainer == ( pxList ) ) ? ( pdTRUE ) : ( pdFALSE ) )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the list a list item is contained within (referenced from).
|
* Return the list a list item is contained within (referenced from).
|
||||||
|
|
|
@ -82,10 +82,10 @@
|
||||||
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
|
const uint32_t * const pulStack = ( uint32_t * ) pxCurrentTCB->pxStack; \
|
||||||
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \
|
const uint32_t ulCheckValue = ( uint32_t ) 0xa5a5a5a5; \
|
||||||
\
|
\
|
||||||
if( ( pulStack[ 0 ] != ulCheckValue ) || \
|
if( ( pulStack[ 0 ] != ulCheckValue ) || \
|
||||||
( pulStack[ 1 ] != ulCheckValue ) || \
|
( pulStack[ 1 ] != ulCheckValue ) || \
|
||||||
( pulStack[ 2 ] != ulCheckValue ) || \
|
( pulStack[ 2 ] != ulCheckValue ) || \
|
||||||
( pulStack[ 3 ] != ulCheckValue ) ) \
|
( pulStack[ 3 ] != ulCheckValue ) ) \
|
||||||
{ \
|
{ \
|
||||||
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
|
vApplicationStackOverflowHook( ( TaskHandle_t ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -73,7 +73,8 @@ or interrupt version of the queue send function should be used. */
|
||||||
* reference the subject timer in calls to other software timer API functions
|
* reference the subject timer in calls to other software timer API functions
|
||||||
* (for example, xTimerStart(), xTimerReset(), etc.).
|
* (for example, xTimerStart(), xTimerReset(), etc.).
|
||||||
*/
|
*/
|
||||||
typedef void * TimerHandle_t;
|
struct TimerDef_t;
|
||||||
|
typedef struct TimerDef_t * TimerHandle_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defines the prototype to which timer callback functions must conform.
|
* Defines the prototype to which timer callback functions must conform.
|
||||||
|
|
|
@ -367,7 +367,7 @@ StreamBuffer_t * pxStreamBuffer = xStreamBuffer;
|
||||||
|
|
||||||
BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
|
BaseType_t xStreamBufferReset( StreamBufferHandle_t xStreamBuffer )
|
||||||
{
|
{
|
||||||
StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */
|
StreamBuffer_t * const pxStreamBuffer = xStreamBuffer;
|
||||||
BaseType_t xReturn = pdFAIL, xIsMessageBuffer;
|
BaseType_t xReturn = pdFAIL, xIsMessageBuffer;
|
||||||
|
|
||||||
#if( configUSE_TRACE_FACILITY == 1 )
|
#if( configUSE_TRACE_FACILITY == 1 )
|
||||||
|
|
|
@ -2824,7 +2824,7 @@ BaseType_t xSwitchRequired = pdFALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xTCB = ( TCB_t * ) xTask;
|
xTCB = xTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save the hook function in the TCB. A critical section is required as
|
/* Save the hook function in the TCB. A critical section is required as
|
||||||
|
@ -2851,7 +2851,7 @@ BaseType_t xSwitchRequired = pdFALSE;
|
||||||
/* If xTask is NULL then we are calling our own task hook. */
|
/* If xTask is NULL then we are calling our own task hook. */
|
||||||
if( xTask == NULL )
|
if( xTask == NULL )
|
||||||
{
|
{
|
||||||
xTCB = ( TCB_t * ) pxCurrentTCB;
|
xTCB = pxCurrentTCB;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3209,7 +3209,7 @@ void vTaskMissedYield( void )
|
||||||
|
|
||||||
if( xTask != NULL )
|
if( xTask != NULL )
|
||||||
{
|
{
|
||||||
pxTCB = ( TCB_t * ) xTask;
|
pxTCB = xTask;
|
||||||
uxReturn = pxTCB->uxTaskNumber;
|
uxReturn = pxTCB->uxTaskNumber;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -3231,7 +3231,7 @@ void vTaskMissedYield( void )
|
||||||
|
|
||||||
if( xTask != NULL )
|
if( xTask != NULL )
|
||||||
{
|
{
|
||||||
pxTCB = ( TCB_t * ) xTask;
|
pxTCB = xTask;
|
||||||
pxTCB->uxTaskNumber = uxHandle;
|
pxTCB->uxTaskNumber = uxHandle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4598,7 +4598,7 @@ TickType_t uxReturn;
|
||||||
uint8_t ucOriginalNotifyState;
|
uint8_t ucOriginalNotifyState;
|
||||||
|
|
||||||
configASSERT( xTaskToNotify );
|
configASSERT( xTaskToNotify );
|
||||||
pxTCB = ( TCB_t * ) xTaskToNotify;
|
pxTCB = xTaskToNotify;
|
||||||
|
|
||||||
taskENTER_CRITICAL();
|
taskENTER_CRITICAL();
|
||||||
{
|
{
|
||||||
|
@ -4732,7 +4732,7 @@ TickType_t uxReturn;
|
||||||
http://www.freertos.org/RTOS-Cortex-M3-M4.html */
|
http://www.freertos.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
pxTCB = ( TCB_t * ) xTaskToNotify;
|
pxTCB = xTaskToNotify;
|
||||||
|
|
||||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||||
{
|
{
|
||||||
|
@ -4860,7 +4860,7 @@ TickType_t uxReturn;
|
||||||
http://www.freertos.org/RTOS-Cortex-M3-M4.html */
|
http://www.freertos.org/RTOS-Cortex-M3-M4.html */
|
||||||
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
portASSERT_IF_INTERRUPT_PRIORITY_INVALID();
|
||||||
|
|
||||||
pxTCB = ( TCB_t * ) xTaskToNotify;
|
pxTCB = xTaskToNotify;
|
||||||
|
|
||||||
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
uxSavedInterruptStatus = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||||
{
|
{
|
||||||
|
|
|
@ -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.
|
#error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Lint e961 and e750 are suppressed as a MISRA exception justified because the
|
/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified
|
||||||
MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined for the
|
because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be defined
|
||||||
header files above, but not in this file, in order to generate the correct
|
for the header files above, but not in this file, in order to generate the
|
||||||
privileged Vs unprivileged linkage and placement. */
|
correct privileged Vs unprivileged linkage and placement. */
|
||||||
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750. */
|
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e9021 !e961 !e750. */
|
||||||
|
|
||||||
|
|
||||||
/* This entire source file will be skipped if the application is not configured
|
/* 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
|
#endif
|
||||||
|
|
||||||
/* The definition of the timers themselves. */
|
/* 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. */
|
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. */
|
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
|
/* 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
|
time order, with the nearest expiry time at the front of the list. Only the
|
||||||
timer service task is allowed to access these lists. */
|
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 *pxCurrentTimerList;
|
||||||
PRIVILEGED_DATA static List_t *pxOverflowTimerList;
|
PRIVILEGED_DATA static List_t *pxOverflowTimerList;
|
||||||
|
|
||||||
|
@ -283,7 +281,7 @@ BaseType_t xReturn = pdFAIL;
|
||||||
{
|
{
|
||||||
Timer_t *pxNewTimer;
|
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 )
|
if( pxNewTimer != NULL )
|
||||||
{
|
{
|
||||||
|
@ -323,12 +321,13 @@ BaseType_t xReturn = pdFAIL;
|
||||||
structure. */
|
structure. */
|
||||||
volatile size_t xSize = sizeof( StaticTimer_t );
|
volatile size_t xSize = sizeof( StaticTimer_t );
|
||||||
configASSERT( xSize == sizeof( Timer_t ) );
|
configASSERT( xSize == sizeof( Timer_t ) );
|
||||||
|
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
|
||||||
}
|
}
|
||||||
#endif /* configASSERT_DEFINED */
|
#endif /* configASSERT_DEFINED */
|
||||||
|
|
||||||
/* A pointer to a StaticTimer_t structure MUST be provided, use it. */
|
/* A pointer to a StaticTimer_t structure MUST be provided, use it. */
|
||||||
configASSERT( pxTimerBuffer );
|
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 )
|
if( pxNewTimer != NULL )
|
||||||
{
|
{
|
||||||
|
@ -392,7 +391,7 @@ DaemonTaskMessage_t xMessage;
|
||||||
/* Send a command to the timer service task to start the xTimer timer. */
|
/* Send a command to the timer service task to start the xTimer timer. */
|
||||||
xMessage.xMessageID = xCommandID;
|
xMessage.xMessageID = xCommandID;
|
||||||
xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;
|
xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;
|
||||||
xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer;
|
xMessage.u.xTimerParameters.pxTimer = xTimer;
|
||||||
|
|
||||||
if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )
|
if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )
|
||||||
{
|
{
|
||||||
|
@ -432,7 +431,7 @@ TaskHandle_t xTimerGetTimerDaemonTaskHandle( void )
|
||||||
|
|
||||||
TickType_t xTimerGetPeriod( TimerHandle_t xTimer )
|
TickType_t xTimerGetPeriod( TimerHandle_t xTimer )
|
||||||
{
|
{
|
||||||
Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
Timer_t *pxTimer = xTimer;
|
||||||
|
|
||||||
configASSERT( xTimer );
|
configASSERT( xTimer );
|
||||||
return pxTimer->xTimerPeriodInTicks;
|
return pxTimer->xTimerPeriodInTicks;
|
||||||
|
@ -441,7 +440,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
||||||
|
|
||||||
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )
|
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer )
|
||||||
{
|
{
|
||||||
Timer_t * pxTimer = ( Timer_t * ) xTimer;
|
Timer_t * pxTimer = xTimer;
|
||||||
TickType_t xReturn;
|
TickType_t xReturn;
|
||||||
|
|
||||||
configASSERT( xTimer );
|
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. */
|
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 );
|
configASSERT( xTimer );
|
||||||
return pxTimer->pcTimerName;
|
return pxTimer->pcTimerName;
|
||||||
|
@ -462,7 +461,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
||||||
static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow )
|
static void prvProcessExpiredTimer( const TickType_t xNextExpireTime, const TickType_t xTimeNow )
|
||||||
{
|
{
|
||||||
BaseType_t xResult;
|
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
|
/* 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. */
|
||||||
|
@ -848,7 +847,7 @@ BaseType_t xResult;
|
||||||
xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
|
xNextExpireTime = listGET_ITEM_VALUE_OF_HEAD_ENTRY( pxCurrentTimerList );
|
||||||
|
|
||||||
/* Remove the timer from the list. */
|
/* 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 ) );
|
( void ) uxListRemove( &( pxTimer->xTimerListItem ) );
|
||||||
traceTIMER_EXPIRED( pxTimer );
|
traceTIMER_EXPIRED( pxTimer );
|
||||||
|
|
||||||
|
@ -893,6 +892,9 @@ BaseType_t xResult;
|
||||||
|
|
||||||
static void prvCheckForValidListAndQueue( void )
|
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
|
/* Check that the list from which active timers are referenced, and the
|
||||||
queue used to communicate with the timer service, have been
|
queue used to communicate with the timer service, have been
|
||||||
initialised. */
|
initialised. */
|
||||||
|
@ -945,7 +947,7 @@ static void prvCheckForValidListAndQueue( void )
|
||||||
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )
|
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer )
|
||||||
{
|
{
|
||||||
BaseType_t xTimerIsInActiveList;
|
BaseType_t xTimerIsInActiveList;
|
||||||
Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
Timer_t *pxTimer = xTimer;
|
||||||
|
|
||||||
configASSERT( 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
|
/* 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
|
it is referenced from either the current or the overflow timer lists in
|
||||||
one go, but the logic has to be reversed, hence the '!'. */
|
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();
|
taskEXIT_CRITICAL();
|
||||||
|
|
||||||
|
@ -965,7 +974,7 @@ Timer_t *pxTimer = ( Timer_t * ) xTimer;
|
||||||
|
|
||||||
void *pvTimerGetTimerID( const TimerHandle_t xTimer )
|
void *pvTimerGetTimerID( const TimerHandle_t xTimer )
|
||||||
{
|
{
|
||||||
Timer_t * const pxTimer = ( Timer_t * ) xTimer;
|
Timer_t * const pxTimer = xTimer;
|
||||||
void *pvReturn;
|
void *pvReturn;
|
||||||
|
|
||||||
configASSERT( xTimer );
|
configASSERT( xTimer );
|
||||||
|
@ -982,7 +991,7 @@ void *pvReturn;
|
||||||
|
|
||||||
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )
|
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )
|
||||||
{
|
{
|
||||||
Timer_t * const pxTimer = ( Timer_t * ) xTimer;
|
Timer_t * const pxTimer = xTimer;
|
||||||
|
|
||||||
configASSERT( xTimer );
|
configASSERT( xTimer );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue