|
FreeRTOS-Cpp
|
Base class that provides the standard task interface to FreeRTOS::Timer and FreeRTOS::StaticTimer. More...
#include <FreeRTOS/Timer.hpp>

Public Member Functions | |
| TimerBase (const TimerBase &)=delete | |
| TimerBase & | operator= (const TimerBase &)=delete |
| virtual void | timerEntry () final |
| Function that acts as the entry point of the timer instance. | |
| bool | isValid () const |
| Function that checks the value of the timer handle. This function should be called to ensure the timer was created successfully. | |
| bool | isActive () const |
Function that calls BaseType_t xTimerIsTimerActive(
TimerHandle_t xTimer ) | |
| bool | start (const TickType_t blockTime=0) const |
Function that calls BaseType_t xTimerStart( TimerHandle_t
xTimer, TickType_t xBlockTime ) | |
| bool | startFromISR (bool &higherPriorityTaskWoken) const |
Function that calls BaseType_t xTimerStartFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | startFromISR () const |
Function that calls BaseType_t xTimerStartFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | stop (const TickType_t blockTime=0) const |
Function that calls BaseType_t xTimerStop( TimerHandle_t xTimer,
TickType_t xBlockTime ) | |
| bool | stopFromISR (bool &higherPriorityTaskWoken) const |
Function that calls BaseType_t xTimerStopFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | stopFromISR () const |
Function that calls BaseType_t xTimerStopFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | changePeriod (const TickType_t newPeriod, const TickType_t blockTime=0) const |
Function that calls BaseType_t xTimerChangePeriod( TimerHandle_t
xTimer, TickType_t xNewPeriod, TickType_t xBlockTime ) | |
| bool | changePeriodFromISR (bool &higherPriorityTaskWoken, const TickType_t newPeriod) const |
Function that calls BaseType_t xTimerChangePeriodFromISR(
TimerHandle_t xTimer, TickType_t xNewPeriod, BaseType_t
*pxHigherPriorityTaskWoken ) | |
| bool | changePeriodFromISR (const TickType_t newPeriod) const |
Function that calls BaseType_t xTimerChangePeriodFromISR(
TimerHandle_t xTimer, TickType_t xNewPeriod, BaseType_t
*pxHigherPriorityTaskWoken ) | |
| bool | deleteTimer (const TickType_t blockTime=0) |
Function that calls BaseType_t xTimerDelete( TimerHandle_t
xTimer, TickType_t xBlockTime ) | |
| bool | reset (const TickType_t blockTime=0) const |
Function that calls BaseType_t xTimerReset( TimerHandle_t
xTimer, TickType_t xBlockTime ) | |
| bool | resetFromISR (bool &higherPriorityTaskWoken) const |
Function that calls BaseType_t xTimerResetFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken ) | |
| bool | resetFromISR () const |
Function that calls BaseType_t xTimerResetFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken ) | |
| void | setReloadMode (const bool autoReload) const |
Function that calls void vTimerSetReloadMode( TimerHandle_t
xTimer, const UBaseType_t xAutoReload ) | |
| const char * | getName () const |
Function that calls const char * pcTimerGetName( TimerHandle_t
xTimer ) | |
| TickType_t | getPeriod () const |
Function that calls TickType_t xTimerGetPeriod( TimerHandle_t
xTimer ) | |
| TickType_t | getExpiryTime () const |
Function that calls TickType_t xTimerGetExpiryTime(
TimerHandle_t xTimer ) | |
| bool | getReloadMode () const |
Function that calls UBaseType_t uxTimerGetReloadMode(
TimerHandle_t xTimer ) | |
| void | setDeleteBlockTime (const TickType_t deleteBlockTime=0) |
| Set the delete block time. This value is used when the destructor calls deleteTimer(). | |
| TickType_t | getDeleteBlockTime () const |
| Set the delete block time. This value is used when the destructor calls deleteTimer(). | |
Protected Member Functions | |
| virtual void | timerFunction ()=0 |
| Abstraction function that acts as the entry point of the timer callback for the user. | |
Private Member Functions | |
| TimerBase (const TickType_t deleteBlockTime=0) | |
| Construct a new TimerBase object. This default constructor is deliberately private as this class is not intended to be instantiated or derived from by the user. Use FreeRTOS::Timer or FreeRTOS::StaticTimer as a base class for creating a task. | |
| ~TimerBase () | |
| Destroy the TimerBase object. | |
| TimerBase (TimerBase &&) noexcept=default | |
| TimerBase & | operator= (TimerBase &&) noexcept=default |
Private Attributes | |
| TimerHandle_t | handle = NULL |
| TickType_t | deleteBlockTime |
Friends | |
| class | Timer |
| class | StaticTimer |
Base class that provides the standard task interface to FreeRTOS::Timer and FreeRTOS::StaticTimer.
|
inlineexplicitprivate |
Construct a new TimerBase object. This default constructor is deliberately private as this class is not intended to be instantiated or derived from by the user. Use FreeRTOS::Timer or FreeRTOS::StaticTimer as a base class for creating a task.
| deleteBlockTime | Set the delete block time. This value is used when the destructor calls deleteTimer(). |
|
inlineprivate |
Destroy the TimerBase object.
|
inline |
Function that calls BaseType_t xTimerChangePeriod( TimerHandle_t
xTimer, TickType_t xNewPeriod, TickType_t xBlockTime )
changePeriod() changes the period of a timer.
changePeriod() can be called to change the period of an active or dormant state timer. Changing the period of a dormant timers will also start the timer.
| newPeriod | The new period for timer. Timer periods are specified 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 newPeriod should be set to 100. Alternatively, if the timer must expire after 500ms, then newPeriod can be set to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or equal to 1000. |
| blockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the change period command to be successfully sent to the timer command queue, should the queue already be full when changePeriod() was called. blockTime is ignored if changePeriod() is called before the RTOS scheduler is started. |
Example Usage
|
inline |
Function that calls BaseType_t xTimerChangePeriodFromISR(
TimerHandle_t xTimer, TickType_t xNewPeriod, BaseType_t
*pxHigherPriorityTaskWoken )
A version of changePeriod() that can be called from an interrupt service routine.
| newPeriod | The new period for timer. Timer periods are specified 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 newPeriod should be set to 100. Alternatively, if the timer must expire after 500ms, then newPeriod can be set to ( 500 / portTICK_PERIOD_MS ) provided configTICK_RATE_HZ is less than or equal to 1000. |
| higherPriorityTaskWoken | The timer service/daemon task spends most of its time in the Blocked state, waiting for messages to arrive on the timer command queue. Calling changePeriodFromISR() writes a message to the timer command queue, so has the potential to transition the timer service/ daemon task out of the Blocked state. If calling changePeriodFromISR() causes the timer service/daemon task to leave the Blocked state, and the timer service/daemon task has a priority equal to or greater than the currently executing task (the task that was interrupted), then higherPriorityTaskWoken will get set to true internally within the changePeriodFromISR() function. If changePeriodFromISR() sets this value to true, then a context switch should be performed before the interrupt exits. |
Example Usage
|
inline |
Function that calls BaseType_t xTimerChangePeriodFromISR(
TimerHandle_t xTimer, TickType_t xNewPeriod, BaseType_t
*pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls BaseType_t xTimerDelete( TimerHandle_t
xTimer, TickType_t xBlockTime )
deleteTimer() deletes a timer from the FreeRTOS timer task.
| blockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the delete command to be successfully sent to the timer command queue, should the queue already be full when deleteTimer() was called. blockTime is ignored if deleteTimer() is called before the RTOS scheduler is started. |
Example Usage
|
inline |
Set the delete block time. This value is used when the destructor calls deleteTimer().
|
inline |
Function that calls TickType_t xTimerGetExpiryTime(
TimerHandle_t xTimer )
Returns the time at which the software timer will expire, which is the time at which the timer's callback function will execute.
If the value returned by getExpiryTime() is less than the current time then the timer will expire after the tick count has overflowed and wrapped back to 0. Overflows are handled in the RTOS implementation itself, so a timer's callback function will execute at the correct time whether it is before or after the tick count overflows.
Example Usage
|
inline |
Function that calls const char * pcTimerGetName( TimerHandle_t
xTimer )
Returns the human readable text name of a software timer.
Text names are assigned to timers in the constructor.
Example Usage
|
inline |
Function that calls TickType_t xTimerGetPeriod( TimerHandle_t
xTimer )
Returns the period of a software timer. The period is specified in ticks.
The period of a timer is initially set using the period parameter of the constructor. It can then be changed using the changePeriod() and changePeriodFromISR() API functions.
Example Usage
|
inline |
Function that calls UBaseType_t uxTimerGetReloadMode(
TimerHandle_t xTimer )
Queries the 'mode' of the software timer.
The mode can be either an auto-reloaded timer, which automatically resets itself each time it expires, or a one-shot timer, which will expire only once unless it is manually restarted.
|
inline |
Function that calls BaseType_t xTimerIsTimerActive(
TimerHandle_t xTimer )
Queries a software timer to see if it is active or dormant.
A timer will be dormant if:
Example Usage
|
inline |
Function that checks the value of the timer handle. This function should be called to ensure the timer was created successfully.
|
inline |
Function that calls BaseType_t xTimerReset( TimerHandle_t
xTimer, TickType_t xBlockTime )
reset() re-starts a timer. If the timer had already been started and was already in the active state, then reset() will cause the timer to re-evaluate its expiry time so that it is relative to when reset() was called. If the timer was in the dormant state then reset() has equivalent functionality to the start() API function.
Resetting a timer ensures the timer is in the active state. If the timer is not stopped, deleted, or reset in the mean time, the callback function associated with the timer will get called 'n' ticks after reset() was called, where 'n' is the timers defined period.
It is valid to call reset() before the RTOS scheduler has been started, but when this is done the timer will not actually start until the RTOS scheduler is started, and the timers expiry time will be relative to when the RTOS scheduler is started, not relative to when reset() was called.
| blockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the reset command to be successfully sent to the timer command queue, should the queue already be full when reset() was called. blockTime is ignored if reset() is called before the RTOS scheduler is started. |
Example Usage
|
inline |
Function that calls BaseType_t xTimerResetFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls BaseType_t xTimerResetFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken )
A version of reset() that can be called from an interrupt service routine.
| higherPriorityTaskWoken | The timer service/daemon task spends most of its time in the Blocked state, waiting for messages to arrive on the timer command queue. Calling resetFromISR() writes a message to the timer command queue, so has the potential to transition the timer service/daemon task out of the Blocked state. If calling resetFromISR() causes the timer service/daemon task to leave the Blocked state, and the timer service/daemon task has a priority equal to or greater than the currently executing task (the task that was interrupted), then higherPriorityTaskWoken will get set to true internally within the resetFromISR() function. If resetFromISR() sets this value to true, then a context switch should be performed before the interrupt exits. |
Example Usage
|
inline |
Set the delete block time. This value is used when the destructor calls deleteTimer().
| deleteBlockTime | Delete block time to be set in ticks. |
|
inline |
Function that calls void vTimerSetReloadMode( TimerHandle_t
xTimer, const UBaseType_t xAutoReload )
Updates the 'mode' of a software timer to be either an auto reload timer or a one-shot timer.
An auto reload timer resets itself each time it expires, causing the timer to expire (and therefore execute its callback) periodically.
A one shot timer does not automatically reset itself, so will only expire (and therefore execute its callback) once unless it is manually restarted.
| autoReload | Set autoReload to true to set the timer into auto reload mode, or false to set the timer into one shot mode. |
|
inline |
Function that calls BaseType_t xTimerStart( TimerHandle_t
xTimer, TickType_t xBlockTime )
start() starts a timer. If the timer had already been started and was already in the active state, then start() has equivalent functionality to the reset() API function.
Starting a timer ensures the timer is in the active state. If the timer is not stopped, deleted, or reset in the mean time, timerFunction() will get called 'n 'ticks after start() was called, where 'n' is the timers defined period.
It is valid to call start() before the RTOS scheduler has been started, but when this is done the timer will not actually start until the RTOS scheduler is started, and the timers expiry time will be relative to when the RTOS scheduler is started, not relative to when start() was called.
| blockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the start command to be successfully sent to the timer command queue, should the queue already be full when start() was called. blockTime is ignored if start() is called before the RTOS scheduler is started. |
Example Usage
|
inline |
Function that calls BaseType_t xTimerStartFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls BaseType_t xTimerStartFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken )
A version of start() that can be called from an interrupt service routine.
| higherPriorityTaskWoken | The timer service/daemon task spends most of its time in the Blocked state, waiting for messages to arrive on the timer command queue. Calling startFromISR() writes a message to the timer command queue, so has the potential to transition the timer service/daemon task out of the Blocked state. If calling startFromISR() causes the timer service/daemon task to leave the Blocked state, and the timer service/ daemon task has a priority equal to or greater than the currently executing task (the task that was interrupted), then higherPriorityTaskWoken will get set to true internally within the startFromISR() function. If startFromISR() sets this value to true, then a context switch should be performed before the interrupt exits. |
Example Usage
|
inline |
Function that calls BaseType_t xTimerStop( TimerHandle_t xTimer,
TickType_t xBlockTime )
stop() stops a timer that was previously started using either of the start(), reset(), startFromISR(), resetFromISR(), changePeriod() and changePeriodFromISR() API functions.
Stopping a timer ensures the timer is not in the active state.
| blockTime | Specifies the time, in ticks, that the calling task should be held in the Blocked state to wait for the stop command to be successfully sent to the timer command queue, should the queue already be full when stop() was called. blockTime is ignored if stop() is called before the RTOS scheduler is started. |
Example Usage
|
inline |
Function that calls BaseType_t xTimerStopFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Function that calls BaseType_t xTimerStopFromISR( TimerHandle_t
xTimer, BaseType_t *pxHigherPriorityTaskWoken )
A version of stop() that can be called from an interrupt service routine.
| higherPriorityTaskWoken | The timer service/daemon task spends most of its time in the Blocked state, waiting for messages to arrive on the timer command queue. Calling stopFromISR() writes a message to the timer command queue, so has the potential to transition the timer service/daemon task out of the Blocked state. If calling stopFromISR() causes the timer service/daemon task to leave the Blocked state, and the timer service/ daemon task has a priority equal to or greater than the currently executing task (the task that was interrupted), then higherPriorityTaskWoken will get set to true internally within the stopFromISR() function. If stopFromISR() sets this value to true, then a context switch should be performed before the interrupt exits. |
Example Usage
|
inlinefinalvirtual |
Function that acts as the entry point of the timer instance.
callTimerFunction() and should not be called or referenced by the user.
|
protectedpure virtual |
Abstraction function that acts as the entry point of the timer callback for the user.