Data Structures | |
struct | tmrCallbackParameters |
struct | tmrTimerControl |
struct | tmrTimerParameters |
struct | tmrTimerQueueMessage |
Macros | |
#define | configTIMER_SERVICE_TASK_NAME "Tmr Svc" |
#define | MPU_WRAPPERS_INCLUDED_FROM_API_FILE |
#define | tmrNO_DELAY ( TickType_t ) 0U |
Typedefs | |
typedef struct tmrCallbackParameters | CallbackParameters_t |
typedef struct tmrTimerQueueMessage | DaemonTaskMessage_t |
typedef xTIMER | Timer_t |
typedef struct tmrTimerParameters | TimerParameter_t |
typedef struct tmrTimerControl | xTIMER |
Functions | |
const char * | pcTimerGetName (TimerHandle_t xTimer) |
const char * const pcTimerGetName( TimerHandle_t xTimer ); More... | |
static void | prvCheckForValidListAndQueue (static void prvTimerTask void) |
static void | prvCheckForValidListAndQueue (void) |
static TickType_t | prvGetNextExpireTime (BaseType_t *const pxListWasEmpty) |
static void | prvInitialiseNewTimer (const char *const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void *const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, Timer_t *pxNewTimer) |
static BaseType_t | prvInsertTimerInActiveList (Timer_t *const pxTimer, const TickType_t xNextExpiryTime, const TickType_t xTimeNow, const TickType_t xCommandTime) |
static void | prvProcessExpiredTimer (const TickType_t xNextExpireTime, const TickType_t xTimeNow) |
static void | prvProcessReceivedCommands (void) |
static void | prvProcessTimerOrBlockTask (const TickType_t xNextExpireTime, BaseType_t xListWasEmpty) |
static TickType_t | prvSampleTimeNow (BaseType_t *const pxTimerListsWereSwitched) |
static void | prvSwitchTimerLists (void) |
static void | prvTimerTask (void *pvParameters) |
void * | pvTimerGetTimerID (const TimerHandle_t xTimer) |
TimerHandle_t xTimerCreate( const char * const pcTimerName, TickType_t xTimerPeriodInTicks, UBaseType_t uxAutoReload, void * pvTimerID, TimerCallbackFunction_t pxCallbackFunction );. More... | |
UBaseType_t | uxTimerGetTimerNumber (TimerHandle_t xTimer) |
void | vTimerSetTimerID (TimerHandle_t xTimer, void *pvNewID) |
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID ); More... | |
void | vTimerSetTimerNumber (TimerHandle_t xTimer, UBaseType_t uxTimerNumber) |
TimerHandle_t | xTimerCreate (const char *const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void *const pvTimerID, TimerCallbackFunction_t pxCallbackFunction) |
BaseType_t | xTimerGenericCommand (TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t *const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait) |
TickType_t | xTimerGetExpiryTime (TimerHandle_t xTimer) |
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );. More... | |
TickType_t | xTimerGetPeriod (TimerHandle_t xTimer) |
TickType_t xTimerGetPeriod( TimerHandle_t xTimer );. More... | |
TaskHandle_t | xTimerGetTimerDaemonTaskHandle (void) |
TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );. More... | |
BaseType_t | xTimerIsTimerActive (TimerHandle_t xTimer) |
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );. More... | |
BaseType_t | xTimerPendFunctionCall (PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait) |
BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait );. More... | |
BaseType_t | xTimerPendFunctionCallFromISR (PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken) |
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken );. More... | |
Variables | |
static PRIVILEGED_DATA List_t * | pxCurrentTimerList |
static PRIVILEGED_DATA List_t * | pxOverflowTimerList |
static PRIVILEGED_DATA List_t | xActiveTimerList1 |
static PRIVILEGED_DATA List_t | xActiveTimerList2 |
static PRIVILEGED_DATA QueueHandle_t | xTimerQueue = NULL |
static PRIVILEGED_DATA TaskHandle_t | xTimerTaskHandle = NULL |
#define configTIMER_SERVICE_TASK_NAME "Tmr Svc" |
Referenced by prvCheckForValidListAndQueue().
#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE |
#define tmrNO_DELAY ( TickType_t ) 0U |
Referenced by prvProcessExpiredTimer(), prvProcessReceivedCommands(), prvSwitchTimerLists(), and xTimerGenericCommand().
typedef struct tmrCallbackParameters CallbackParameters_t |
typedef struct tmrTimerQueueMessage DaemonTaskMessage_t |
typedef struct tmrTimerParameters TimerParameter_t |
typedef struct tmrTimerControl xTIMER |
const char* pcTimerGetName | ( | TimerHandle_t | xTimer | ) |
const char * const pcTimerGetName( TimerHandle_t xTimer );
Returns the name that was assigned to a timer when the timer was created.
xTimer | The handle of the timer being queried. |
References configASSERT, and tmrTimerControl::pcTimerName.
|
static |
|
static |
|
static |
References listGET_ITEM_VALUE_OF_HEAD_ENTRY, listLIST_IS_EMPTY, pdFALSE, and pxCurrentTimerList.
Referenced by prvTimerTask().
|
static |
References configASSERT, tmrTimerControl::pcTimerName, prvCheckForValidListAndQueue(), tmrTimerControl::pvTimerID, tmrTimerControl::pxCallbackFunction, traceTIMER_CREATE, tmrTimerControl::uxAutoReload, vListInitialiseItem(), tmrTimerControl::xTimerListItem, and tmrTimerControl::xTimerPeriodInTicks.
Referenced by xTimerCreate().
|
static |
|
static |
References configASSERT, listGET_OWNER_OF_HEAD_ENTRY, mtCOVERAGE_TEST_MARKER, pdFALSE, pdTRUE, prvInsertTimerInActiveList(), tmrTimerControl::pxCallbackFunction, pxCurrentTimerList, tmrCOMMAND_START_DONT_TRACE, tmrNO_DELAY, traceTIMER_EXPIRED, tmrTimerControl::uxAutoReload, uxListRemove(), xTimerGenericCommand(), tmrTimerControl::xTimerListItem, and tmrTimerControl::xTimerPeriodInTicks.
Referenced by prvProcessTimerOrBlockTask().
|
static |
References configASSERT, listIS_CONTAINED_WITHIN, mtCOVERAGE_TEST_MARKER, pdFAIL, pdFALSE, pdTRUE, prvInsertTimerInActiveList(), prvSampleTimeNow(), tmrCallbackParameters::pvParameter1, tmrTimerControl::pxCallbackFunction, tmrCallbackParameters::pxCallbackFunction, tmrTimerParameters::pxTimer, tmrCOMMAND_CHANGE_PERIOD, tmrCOMMAND_CHANGE_PERIOD_FROM_ISR, tmrCOMMAND_DELETE, tmrCOMMAND_RESET, tmrCOMMAND_RESET_FROM_ISR, tmrCOMMAND_START, tmrCOMMAND_START_DONT_TRACE, tmrCOMMAND_START_FROM_ISR, tmrCOMMAND_STOP, tmrCOMMAND_STOP_FROM_ISR, tmrNO_DELAY, traceTIMER_COMMAND_RECEIVED, traceTIMER_EXPIRED, tmrTimerQueueMessage::u, tmrCallbackParameters::ulParameter2, uxListRemove(), vPortFree(), tmrTimerQueueMessage::xCallbackParameters, tmrTimerQueueMessage::xMessageID, tmrTimerParameters::xMessageValue, xQueueReceive(), xTimerGenericCommand(), tmrTimerControl::xTimerListItem, tmrTimerQueueMessage::xTimerParameters, tmrTimerControl::xTimerPeriodInTicks, and xTimerQueue.
Referenced by prvTimerTask().
|
static |
|
static |
References pdFALSE, pdTRUE, PRIVILEGED_DATA, prvSwitchTimerLists(), and xTaskGetTickCount().
Referenced by prvProcessReceivedCommands(), and prvProcessTimerOrBlockTask().
|
static |
References configASSERT, listGET_ITEM_VALUE_OF_HEAD_ENTRY, listGET_OWNER_OF_HEAD_ENTRY, listLIST_IS_EMPTY, listSET_LIST_ITEM_OWNER, listSET_LIST_ITEM_VALUE, mtCOVERAGE_TEST_MARKER, pdFALSE, pdTRUE, tmrTimerControl::pxCallbackFunction, pxCurrentTimerList, pxOverflowTimerList, tmrCOMMAND_START_DONT_TRACE, tmrNO_DELAY, traceTIMER_EXPIRED, uxListRemove(), vListInsert(), xTimerGenericCommand(), and tmrTimerControl::xTimerListItem.
Referenced by prvSampleTimeNow().
|
static |
References prvGetNextExpireTime(), prvProcessReceivedCommands(), and prvProcessTimerOrBlockTask().
Referenced by prvCheckForValidListAndQueue().
void* pvTimerGetTimerID | ( | const TimerHandle_t | xTimer | ) |
TimerHandle_t xTimerCreate( const char * const pcTimerName, TickType_t xTimerPeriodInTicks, UBaseType_t uxAutoReload, void * pvTimerID, TimerCallbackFunction_t pxCallbackFunction );.
Creates a new software timer instance, and returns a handle by which the created software timer can be referenced.
Internally, within the FreeRTOS implementation, software timers use a block of memory, in which the timer data structure is stored. If a software timer is created using xTimerCreate() then the required memory is automatically dynamically allocated inside the xTimerCreate() function. (see http://www.freertos.org/a00111.html). If a software timer is created using xTimerCreateStatic() then the application writer must provide the memory that will get used by the software timer. xTimerCreateStatic() therefore allows a software timer to be created without using any dynamic memory allocation.
Timers are created in the dormant state. The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the active state.
pcTimerName | A text name that is assigned to the timer. This is done purely to assist debugging. The kernel itself only ever references a timer by its handle, and never by its name. |
xTimerPeriodInTicks | The timer period. The time is defined in tick periods so the constant portTICK_PERIOD_MS can be used to convert a time that has been specified in milliseconds. For example, if the timer must expire after 100 ticks, then xTimerPeriodInTicks should be set to 100. Alternatively, if the timer must expire after 500ms, then xPeriod can be set to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or equal to 1000. |
uxAutoReload | If uxAutoReload is set to pdTRUE then the timer will expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and enter the dormant state after it expires. |
pvTimerID | An identifier that is assigned to the timer being created. Typically this would be used in the timer callback function to identify which timer expired when the same callback function is assigned to more than one timer. |
pxCallbackFunction | The function to call when the timer expires. Callback functions must have the prototype defined by TimerCallbackFunction_t, which is "void vCallbackFunction( TimerHandle_t xTimer );". |
Example usage:
* #define NUM_TIMERS 5 * * // An array to hold handles to the created timers. * TimerHandle_t xTimers[ NUM_TIMERS ]; * * // An array to hold a count of the number of times each timer expires. * int32_t lExpireCounters[ NUM_TIMERS ] = { 0 }; * * // Define a callback function that will be used by multiple timer instances. * // The callback function does nothing but count the number of times the * // associated timer expires, and stop the timer once the timer has expired * // 10 times. * void vTimerCallback( TimerHandle_t pxTimer ) * { * int32_t lArrayIndex; * const int32_t xMaxExpiryCountBeforeStopping = 10; * * // Optionally do something if the pxTimer parameter is NULL. * configASSERT( pxTimer ); * * // Which timer expired? * lArrayIndex = ( int32_t ) pvTimerGetTimerID( pxTimer ); * * // Increment the number of times that pxTimer has expired. * lExpireCounters[ lArrayIndex ] += 1; * * // If the timer has expired 10 times then stop it from running. * if( lExpireCounters[ lArrayIndex ] == xMaxExpiryCountBeforeStopping ) * { * // Do not use a block time if calling a timer API function from a * // timer callback function, as doing so could cause a deadlock! * xTimerStop( pxTimer, 0 ); * } * } * * void main( void ) * { * int32_t x; * * // Create then start some timers. Starting the timers before the scheduler * // has been started means the timers will start running immediately that * // the scheduler starts. * for( x = 0; x < NUM_TIMERS; x++ ) * { * xTimers[ x ] = xTimerCreate( "Timer", // Just a text name, not used by the kernel. * ( 100 * x ), // The timer period in ticks. * pdTRUE, // The timers will auto-reload themselves when they expire. * ( void * ) x, // Assign each timer a unique id equal to its array index. * vTimerCallback // Each timer calls the same callback when it expires. * ); * * if( xTimers[ x ] == NULL ) * { * // The timer was not created. * } * else * { * // Start the timer. No block time is specified, and even if one was * // it would be ignored because the scheduler has not yet been * // started. * if( xTimerStart( xTimers[ x ], 0 ) != pdPASS ) * { * // The timer could not be set into the Active state. * } * } * } * * // ... * // Create tasks here. * // ... * * // Starting the scheduler will start the timers running as they have already * // been set into the active state. * vTaskStartScheduler(); * * // Should not reach here. * for( ;; ); * } *
TimerHandle_t xTimerCreateStatic(const char * const pcTimerName, TickType_t xTimerPeriodInTicks, UBaseType_t uxAutoReload, void * pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer );
Creates a new software timer instance, and returns a handle by which the created software timer can be referenced.
Internally, within the FreeRTOS implementation, software timers use a block of memory, in which the timer data structure is stored. If a software timer is created using xTimerCreate() then the required memory is automatically dynamically allocated inside the xTimerCreate() function. (see http://www.freertos.org/a00111.html). If a software timer is created using xTimerCreateStatic() then the application writer must provide the memory that will get used by the software timer. xTimerCreateStatic() therefore allows a software timer to be created without using any dynamic memory allocation.
Timers are created in the dormant state. The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the active state.
pcTimerName | A text name that is assigned to the timer. This is done purely to assist debugging. The kernel itself only ever references a timer by its handle, and never by its name. |
xTimerPeriodInTicks | The timer period. The time is defined in tick periods so the constant portTICK_PERIOD_MS can be used to convert a time that has been specified in milliseconds. For example, if the timer must expire after 100 ticks, then xTimerPeriodInTicks should be set to 100. Alternatively, if the timer must expire after 500ms, then xPeriod can be set to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or equal to 1000. |
uxAutoReload | If uxAutoReload is set to pdTRUE then the timer will expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. If uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and enter the dormant state after it expires. |
pvTimerID | An identifier that is assigned to the timer being created. Typically this would be used in the timer callback function to identify which timer expired when the same callback function is assigned to more than one timer. |
pxCallbackFunction | The function to call when the timer expires. Callback functions must have the prototype defined by TimerCallbackFunction_t, which is "void vCallbackFunction( TimerHandle_t xTimer );". |
pxTimerBuffer | Must point to a variable of type StaticTimer_t, which will be then be used to hold the software timer's data structures, removing the need for the memory to be allocated dynamically. |
Example usage:
* * // The buffer used to hold the software timer's data structure. * static StaticTimer_t xTimerBuffer; * * // A variable that will be incremented by the software timer's callback * // function. * UBaseType_t uxVariableToIncrement = 0; * * // A software timer callback function that increments a variable passed to * // it when the software timer was created. After the 5th increment the * // callback function stops the software timer. * static void prvTimerCallback( TimerHandle_t xExpiredTimer ) * { * UBaseType_t *puxVariableToIncrement; * BaseType_t xReturned; * * // Obtain the address of the variable to increment from the timer ID. * puxVariableToIncrement = ( UBaseType_t * ) pvTimerGetTimerID( xExpiredTimer ); * * // Increment the variable to show the timer callback has executed. * ( *puxVariableToIncrement )++; * * // If this callback has executed the required number of times, stop the * // timer. * if( *puxVariableToIncrement == 5 ) * { * // This is called from a timer callback so must not block. * xTimerStop( xExpiredTimer, staticDONT_BLOCK ); * } * } * * * void main( void ) * { * // Create the software time. xTimerCreateStatic() has an extra parameter * // than the normal xTimerCreate() API function. The parameter is a pointer * // to the StaticTimer_t structure that will hold the software timer * // structure. If the parameter is passed as NULL then the structure will be * // allocated dynamically, just as if xTimerCreate() had been called. * xTimer = xTimerCreateStatic( "T1", // Text name for the task. Helps debugging only. Not used by FreeRTOS. * xTimerPeriod, // The period of the timer in ticks. * pdTRUE, // This is an auto-reload timer. * ( void * ) &uxVariableToIncrement, // A variable incremented by the software timer's callback function * prvTimerCallback, // The function to execute when the timer expires. * &xTimerBuffer ); // The buffer that will hold the software timer structure. * * // The scheduler has not started yet so a block time is not used. * xReturned = xTimerStart( xTimer, 0 ); * * // ... * // Create tasks here. * // ... * * // Starting the scheduler will start the timers running as they have already * // been set into the active state. * vTaskStartScheduler(); * * // Should not reach here. * for( ;; ); * } *
void *pvTimerGetTimerID( TimerHandle_t xTimer );
Returns the ID assigned to the timer.
IDs are assigned to timers using the pvTimerID parameter of the call to xTimerCreated() that was used to create the timer, and by calling the vTimerSetTimerID() API function.
If the same callback function is assigned to multiple timers then the timer ID can be used as time specific (timer local) storage.
xTimer | The timer being queried. |
Example usage:
See the xTimerCreate() API function example usage scenario.
References configASSERT, tmrTimerControl::pvTimerID, taskENTER_CRITICAL, and taskEXIT_CRITICAL.
UBaseType_t uxTimerGetTimerNumber | ( | TimerHandle_t | xTimer | ) |
void vTimerSetTimerID | ( | TimerHandle_t | xTimer, |
void * | pvNewID | ||
) |
void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID );
Sets the ID assigned to the timer.
IDs are assigned to timers using the pvTimerID parameter of the call to xTimerCreated() that was used to create the timer.
If the same callback function is assigned to multiple timers then the timer ID can be used as time specific (timer local) storage.
xTimer | The timer being updated. |
pvNewID | The ID to assign to the timer. |
Example usage:
See the xTimerCreate() API function example usage scenario.
References configASSERT, tmrTimerControl::pvTimerID, taskENTER_CRITICAL, and taskEXIT_CRITICAL.
void vTimerSetTimerNumber | ( | TimerHandle_t | xTimer, |
UBaseType_t | uxTimerNumber | ||
) |
TimerHandle_t xTimerCreate | ( | const char *const | pcTimerName, |
const TickType_t | xTimerPeriodInTicks, | ||
const UBaseType_t | uxAutoReload, | ||
void *const | pvTimerID, | ||
TimerCallbackFunction_t | pxCallbackFunction | ||
) |
References pdFALSE, prvInitialiseNewTimer(), and pvPortMalloc().
BaseType_t xTimerGenericCommand | ( | TimerHandle_t | xTimer, |
const BaseType_t | xCommandID, | ||
const TickType_t | xOptionalValue, | ||
BaseType_t *const | pxHigherPriorityTaskWoken, | ||
const TickType_t | xTicksToWait | ||
) |
References configASSERT, mtCOVERAGE_TEST_MARKER, pdFAIL, tmrTimerParameters::pxTimer, taskSCHEDULER_RUNNING, tmrFIRST_FROM_ISR_COMMAND, tmrNO_DELAY, traceTIMER_COMMAND_SEND, tmrTimerQueueMessage::u, tmrTimerQueueMessage::xMessageID, tmrTimerParameters::xMessageValue, xQueueSendToBack, xQueueSendToBackFromISR, xTaskGetSchedulerState(), tmrTimerQueueMessage::xTimerParameters, and xTimerQueue.
Referenced by prvProcessExpiredTimer(), prvProcessReceivedCommands(), and prvSwitchTimerLists().
TickType_t xTimerGetExpiryTime | ( | TimerHandle_t | xTimer | ) |
TickType_t xTimerGetExpiryTime( TimerHandle_t xTimer );.
Returns the time in ticks at which the timer will expire. If this is less than the current tick count then the expiry time has overflowed from the current time.
xTimer | The handle of the timer being queried. |
References configASSERT, listGET_LIST_ITEM_VALUE, and tmrTimerControl::xTimerListItem.
TickType_t xTimerGetPeriod | ( | TimerHandle_t | xTimer | ) |
TickType_t xTimerGetPeriod( TimerHandle_t xTimer );.
Returns the period of a timer.
xTimer | The handle of the timer being queried. |
References configASSERT, and tmrTimerControl::xTimerPeriodInTicks.
TaskHandle_t xTimerGetTimerDaemonTaskHandle | ( | void | ) |
TaskHandle_t xTimerGetTimerDaemonTaskHandle( void );.
Simply returns the handle of the timer service/daemon task. It it not valid to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started.
References configASSERT, and xTimerTaskHandle.
BaseType_t xTimerIsTimerActive | ( | TimerHandle_t | xTimer | ) |
BaseType_t xTimerIsTimerActive( TimerHandle_t xTimer );.
Queries a timer to see if it is active or dormant.
A timer will be dormant if: 1) It has been created but not started, or 2) It is an expired one-shot timer that has not been restarted.
Timers are created in the dormant state. The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the active state.
xTimer | The timer being queried. |
Example usage:
* // This function assumes xTimer has already been created. * void vAFunction( TimerHandle_t xTimer ) * { * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )" * { * // xTimer is active, do something. * } * else * { * // xTimer is not active, do something else. * } * } *
References configASSERT, listIS_CONTAINED_WITHIN, taskENTER_CRITICAL, taskEXIT_CRITICAL, and tmrTimerControl::xTimerListItem.
BaseType_t xTimerPendFunctionCall | ( | PendedFunction_t | xFunctionToPend, |
void * | pvParameter1, | ||
uint32_t | ulParameter2, | ||
TickType_t | xTicksToWait | ||
) |
BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait );.
Used to defer the execution of a function to the RTOS daemon task (the timer service task, hence this function is implemented in timers.c and is prefixed with 'Timer').
xFunctionToPend | The function to execute from the timer service/ daemon task. The function must conform to the PendedFunction_t prototype. |
pvParameter1 | The value of the callback function's first parameter. The parameter has a void * type to allow it to be used to pass any type. For example, unsigned longs can be cast to a void *, or the void * can be used to point to a structure. |
ulParameter2 | The value of the callback function's second parameter. |
xTicksToWait | Calling this function will result in a message being sent to the timer daemon task on a queue. xTicksToWait is the amount of time the calling task should remain in the Blocked state (so not using any processing time) for space to become available on the timer queue if the queue is found to be full. |
References configASSERT, tmrCallbackParameters::pvParameter1, tmrCallbackParameters::pxCallbackFunction, tmrCOMMAND_EXECUTE_CALLBACK, tracePEND_FUNC_CALL, tmrTimerQueueMessage::u, tmrCallbackParameters::ulParameter2, tmrTimerQueueMessage::xCallbackParameters, tmrTimerQueueMessage::xMessageID, xQueueSendToBack, and xTimerQueue.
BaseType_t xTimerPendFunctionCallFromISR | ( | PendedFunction_t | xFunctionToPend, |
void * | pvParameter1, | ||
uint32_t | ulParameter2, | ||
BaseType_t * | pxHigherPriorityTaskWoken | ||
) |
BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken );.
Used from application interrupt service routines to defer the execution of a function to the RTOS daemon task (the timer service task, hence this function is implemented in timers.c and is prefixed with 'Timer').
Ideally an interrupt service routine (ISR) is kept as short as possible, but sometimes an ISR either has a lot of processing to do, or needs to perform processing that is not deterministic. In these cases xTimerPendFunctionCallFromISR() can be used to defer processing of a function to the RTOS daemon task.
A mechanism is provided that allows the interrupt to return directly to the task that will subsequently execute the pended callback function. This allows the callback function to execute contiguously in time with the interrupt - just as if the callback had executed in the interrupt itself.
xFunctionToPend | The function to execute from the timer service/ daemon task. The function must conform to the PendedFunction_t prototype. |
pvParameter1 | The value of the callback function's first parameter. The parameter has a void * type to allow it to be used to pass any type. For example, unsigned longs can be cast to a void *, or the void * can be used to point to a structure. |
ulParameter2 | The value of the callback function's second parameter. |
pxHigherPriorityTaskWoken | As mentioned above, calling this function will result in a message being sent to the timer daemon task. If the priority of the timer daemon task (which is set using configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of the currently running task (the task the interrupt interrupted) then *pxHigherPriorityTaskWoken will be set to pdTRUE within xTimerPendFunctionCallFromISR(), indicating that a context switch should be requested before the interrupt exits. For that reason *pxHigherPriorityTaskWoken must be initialised to pdFALSE. See the example code below. |
Example usage:
* * // The callback function that will execute in the context of the daemon task. * // Note callback functions must all use this same prototype. * void vProcessInterface( void *pvParameter1, uint32_t ulParameter2 ) * { * BaseType_t xInterfaceToService; * * // The interface that requires servicing is passed in the second * // parameter. The first parameter is not used in this case. * xInterfaceToService = ( BaseType_t ) ulParameter2; * * // ...Perform the processing here... * } * * // An ISR that receives data packets from multiple interfaces * void vAnISR( void ) * { * BaseType_t xInterfaceToService, xHigherPriorityTaskWoken; * * // Query the hardware to determine which interface needs processing. * xInterfaceToService = prvCheckInterfaces(); * * // The actual processing is to be deferred to a task. Request the * // vProcessInterface() callback function is executed, passing in the * // number of the interface that needs processing. The interface to * // service is passed in the second parameter. The first parameter is * // not used in this case. * xHigherPriorityTaskWoken = pdFALSE; * xTimerPendFunctionCallFromISR( vProcessInterface, NULL, ( uint32_t ) xInterfaceToService, &xHigherPriorityTaskWoken ); * * // If xHigherPriorityTaskWoken is now set to pdTRUE then a context * // switch should be requested. The macro used is port specific and will * // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to * // the documentation page for the port being used. * portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); * * } *
References tmrCallbackParameters::pvParameter1, tmrCallbackParameters::pxCallbackFunction, tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR, tracePEND_FUNC_CALL_FROM_ISR, tmrTimerQueueMessage::u, tmrCallbackParameters::ulParameter2, tmrTimerQueueMessage::xCallbackParameters, tmrTimerQueueMessage::xMessageID, xQueueSendFromISR, and xTimerQueue.
Referenced by xEventGroupClearBitsFromISR(), and xEventGroupSetBitsFromISR().
|
static |
|
static |
|
static |
Referenced by prvCheckForValidListAndQueue().
|
static |
Referenced by prvCheckForValidListAndQueue().
|
static |
|
static |
Referenced by prvCheckForValidListAndQueue(), and xTimerGetTimerDaemonTaskHandle().