FreeRTOS C++ Wrappers
1.6.0
C++ interface to FreeRTOS
|
#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 | Start (TickType_t CmdTimeout=portMAX_DELAY) |
bool | StartFromISR (BaseType_t *pxHigherPriorityTaskWoken) |
bool | Stop (TickType_t CmdTimeout=portMAX_DELAY) |
bool | StopFromISR (BaseType_t *pxHigherPriorityTaskWoken) |
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) |
Static Public Member Functions | |
static TaskHandle_t | GetTimerDaemonHandle () |
Protected Member Functions | |
virtual void | Run ()=0 |
Static Private Member Functions | |
static void | TimerCallbackFunctionAdapter (TimerHandle_t xTimer) |
Private Attributes | |
TimerHandle_t | handle |
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. |
Definition at line 46 of file ctimer.cpp.
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. |
Definition at line 67 of file ctimer.cpp.
|
virtual |
Destructor
Definition at line 87 of file ctimer.cpp.
|
static |
If you need it, obtain the task handle of the FreeRTOS task that is running the timers.
Definition at line 157 of file ctimer.cpp.
bool Timer::IsActive | ( | ) |
Is the timer currently active?
Definition at line 93 of file ctimer.cpp.
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. |
Definition at line 125 of file ctimer.cpp.
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. |
Definition at line 131 of file ctimer.cpp.
|
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. |
Definition at line 138 of file ctimer.cpp.
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. |
Definition at line 146 of file ctimer.cpp.
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. |
Definition at line 99 of file ctimer.cpp.
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. |
Definition at line 105 of file ctimer.cpp.
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. |
Definition at line 112 of file ctimer.cpp.
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. |
Definition at line 118 of file ctimer.cpp.
|
staticprivate |
Adapter function that allows you to write a class specific Run() function that interfaces with FreeRTOS. Look at the implementation of the constructors and this code to see how the interface between C and C++ is performed.
Definition at line 165 of file ctimer.cpp.
|
private |