FreeRTOS Addons
|
#include <timer.hpp>
Public Member Functions | |
Timer (const char *const TimerName, TickType_t PeriodInTicks, bool Periodic=true) | |
Timer (TickType_t PeriodInTicks, bool Periodic=true) | |
virtual | ~Timer () |
bool | IsActive () |
bool | Reset (TickType_t CmdTimeout=portMAX_DELAY) |
bool | ResetFromISR (BaseType_t *pxHigherPriorityTaskWoken) |
bool | SetPeriod (TickType_t NewPeriod, TickType_t CmdTimeout=portMAX_DELAY) |
bool | SetPeriodFromISR (TickType_t NewPeriod, BaseType_t *pxHigherPriorityTaskWoken) |
bool | Start (TickType_t CmdTimeout=portMAX_DELAY) |
bool | StartFromISR (BaseType_t *pxHigherPriorityTaskWoken) |
bool | Stop (TickType_t CmdTimeout=portMAX_DELAY) |
bool | StopFromISR (BaseType_t *pxHigherPriorityTaskWoken) |
Static Public Member Functions | |
static TaskHandle_t | GetTimerDaemonHandle () |
Protected Member Functions | |
virtual void | Run ()=0 |
Wrapper class around FreeRTOS's implementation of a timer.
This is an abstract base class. To use this, you need to subclass it. All of your timers should be derived from the Timer class. Then implement the virtual Run function. This is a similar design to Java threading.
Timer::Timer | ( | const char *const | TimerName, |
TickType_t | PeriodInTicks, | ||
bool | Periodic = true |
||
) |
Construct a named timer. Timers are not active after they are created, you need to activate them via Start, Reset, etc.
TimerCreateException |
TimerName | Name of the timer for debug. |
PeriodInTicks | When does the timer expire and run your Run() method. |
Periodic | true if the timer expires every PeriodInTicks. false if this is a one shot timer. |
Timer::Timer | ( | TickType_t | PeriodInTicks, |
bool | Periodic = true |
||
) |
Construct an unnamed timer. Timers are not active after they are created, you need to activate them via Start, Reset, etc.
TimerCreateException |
PeriodInTicks | When does the timer expire and run your Run() method. |
Periodic | true if the timer expires every PeriodInTicks. false if this is a one shot timer. |
|
virtual |
Destructor
|
static |
If you need it, obtain the task handle of the FreeRTOS task that is running the timers.
bool Timer::IsActive | ( | ) |
Is the timer currently active?
bool Timer::Reset | ( | TickType_t | CmdTimeout = portMAX_DELAY | ) |
Reset a timer. This changes the state to active.
CmdTimeout | How long to wait to send this command to the timer code. |
bool Timer::ResetFromISR | ( | BaseType_t * | pxHigherPriorityTaskWoken | ) |
Reset a timer from ISR context. This changes the state to active.
pxHigherPriorityTaskWoken | Did this operation result in a rescheduling event. |
|
protectedpure virtual |
Implementation of your actual timer code. You must override this function.
bool Timer::SetPeriod | ( | TickType_t | NewPeriod, |
TickType_t | CmdTimeout = portMAX_DELAY |
||
) |
Change a timer's period.
NewPeriod | The period in ticks. |
CmdTimeout | How long to wait to send this command to the timer code. |
bool Timer::SetPeriodFromISR | ( | TickType_t | NewPeriod, |
BaseType_t * | pxHigherPriorityTaskWoken | ||
) |
Change a timer's period from ISR context.
NewPeriod | The period in ticks. |
pxHigherPriorityTaskWoken | Did this operation result in a rescheduling event. |
bool Timer::Start | ( | TickType_t | CmdTimeout = portMAX_DELAY | ) |
Start a timer. This changes the state to active.
CmdTimeout | How long to wait to send this command to the timer code. |
bool Timer::StartFromISR | ( | BaseType_t * | pxHigherPriorityTaskWoken | ) |
Start a timer from ISR context. This changes the state to active.
pxHigherPriorityTaskWoken | Did this operation result in a rescheduling event. |
bool Timer::Stop | ( | TickType_t | CmdTimeout = portMAX_DELAY | ) |
Stop a timer. This changes the state to inactive.
CmdTimeout | How long to wait to send this command to the timer code. |
bool Timer::StopFromISR | ( | BaseType_t * | pxHigherPriorityTaskWoken | ) |
Stop a timer from ISR context. This changes the state to inactive.
pxHigherPriorityTaskWoken | Did this operation result in a rescheduling event. |