Wrapper around the FreeRTOS timer functions. More...
#include <FreeRTOSTimer.h>
Public Member Functions | |
FreeRTOSTimer (char *name, TickType_t period, UBaseType_t reload, void *data, void(*callback)(FreeRTOSTimer *pTimer)) | |
Construct a timer. More... | |
virtual | ~FreeRTOSTimer () |
Destroy a class instance. More... | |
void | changePeriod (TickType_t newPeriod, TickType_t blockTime=portMAX_DELAY) |
Change the period of the timer. More... | |
void * | getData () |
Get the user supplied data associated with the timer. More... | |
const char * | getName () |
Get the name of the timer. More... | |
TickType_t | getPeriod () |
Return the period of the timer. More... | |
void | reset (TickType_t blockTime=portMAX_DELAY) |
Reset the timer to the period and start it ticking. | |
void | start (TickType_t blockTime=portMAX_DELAY) |
Start the timer ticking. | |
void | stop (TickType_t blockTime=portMAX_DELAY) |
Stop the timer from ticking. | |
Wrapper around the FreeRTOS timer functions.
FreeRTOSTimer::FreeRTOSTimer | ( | char * | name, |
TickType_t | period, | ||
UBaseType_t | reload, | ||
void * | data, | ||
void(*)(FreeRTOSTimer *pTimer) | callback | ||
) |
Construct a timer.
We construct a timer that will fire after the given period has elapsed. The period is measured in ticks. When the timer fires, the callback function is invoked within the scope/context of the timer demon thread. As such it must not block. Once the timer has fired, if the reload flag is true, then the timer will be automatically restarted.
Note that the timer does not start immediately. It starts ticking after the start() method has been called.
The signature of the callback function is:
[in] | name | The name of the timer. |
[in] | period | The period of the timer in ticks. |
[in] | reload | True if the timer is to restart once fired. |
[in] | data | Data to be passed to the callback. |
[in] | callback | Callback function to be fired when the timer expires. |
|
virtual |
Destroy a class instance.
The timer is deleted.
void FreeRTOSTimer::changePeriod | ( | TickType_t | newPeriod, |
TickType_t | blockTime = portMAX_DELAY |
||
) |
Change the period of the timer.
[in] | newPeriod | The new period of the timer in ticks. |
void * FreeRTOSTimer::getData | ( | ) |
Get the user supplied data associated with the timer.
const char * FreeRTOSTimer::getName | ( | ) |
Get the name of the timer.
TickType_t FreeRTOSTimer::getPeriod | ( | ) |
Return the period of the timer.