FreeRTOS Addons
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
cpp_freertos::Timer Class Referenceabstract

#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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Timer() [1/2]

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.

Exceptions
TimerCreateException
Parameters
TimerNameName of the timer for debug.
PeriodInTicksWhen does the timer expire and run your Run() method.
Periodictrue if the timer expires every PeriodInTicks. false if this is a one shot timer.

◆ Timer() [2/2]

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.

Exceptions
TimerCreateException
Parameters
PeriodInTicksWhen does the timer expire and run your Run() method.
Periodictrue if the timer expires every PeriodInTicks. false if this is a one shot timer.

◆ ~Timer()

Timer::~Timer ( )
virtual

Destructor

Member Function Documentation

◆ GetTimerDaemonHandle()

TaskHandle_t Timer::GetTimerDaemonHandle ( )
static

If you need it, obtain the task handle of the FreeRTOS task that is running the timers.

Returns
Task handle of the FreeRTOS timer task.

◆ IsActive()

bool Timer::IsActive ( )

Is the timer currently active?

Returns
true if the timer is active, false otherwise.

◆ Reset()

bool Timer::Reset ( TickType_t  CmdTimeout = portMAX_DELAY)

Reset a timer. This changes the state to active.

Parameters
CmdTimeoutHow long to wait to send this command to the timer code.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ ResetFromISR()

bool Timer::ResetFromISR ( BaseType_t *  pxHigherPriorityTaskWoken)

Reset a timer from ISR context. This changes the state to active.

Parameters
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ Run()

virtual void cpp_freertos::Timer::Run ( )
protectedpure virtual

Implementation of your actual timer code. You must override this function.

◆ SetPeriod()

bool Timer::SetPeriod ( TickType_t  NewPeriod,
TickType_t  CmdTimeout = portMAX_DELAY 
)

Change a timer's period.

Parameters
NewPeriodThe period in ticks.
CmdTimeoutHow long to wait to send this command to the timer code.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ SetPeriodFromISR()

bool Timer::SetPeriodFromISR ( TickType_t  NewPeriod,
BaseType_t *  pxHigherPriorityTaskWoken 
)

Change a timer's period from ISR context.

Parameters
NewPeriodThe period in ticks.
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ Start()

bool Timer::Start ( TickType_t  CmdTimeout = portMAX_DELAY)

Start a timer. This changes the state to active.

Parameters
CmdTimeoutHow long to wait to send this command to the timer code.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ StartFromISR()

bool Timer::StartFromISR ( BaseType_t *  pxHigherPriorityTaskWoken)

Start a timer from ISR context. This changes the state to active.

Parameters
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ Stop()

bool Timer::Stop ( TickType_t  CmdTimeout = portMAX_DELAY)

Stop a timer. This changes the state to inactive.

Parameters
CmdTimeoutHow long to wait to send this command to the timer code.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

◆ StopFromISR()

bool Timer::StopFromISR ( BaseType_t *  pxHigherPriorityTaskWoken)

Stop a timer from ISR context. This changes the state to inactive.

Parameters
pxHigherPriorityTaskWokenDid this operation result in a rescheduling event.
Returns
true if this command will be sent to the timer code, false if it will not (i.e. timeout).

The documentation for this class was generated from the following files: