#include <mn_timer.hpp>
Public Member Functions | |
| basic_timer (const char *strName, unsigned int uiPeriod, bool bIsOneShot=true) | |
| virtual | ~basic_timer () | 
| virtual int | create () | 
| virtual int | destroy (unsigned int timeout=(unsigned int) 0xffffffffUL) | 
| virtual int | active (unsigned int timeout=(unsigned int) 0xffffffffUL) | 
| virtual int | inactive (unsigned int timeout=(unsigned int) 0xffffffffUL) | 
| virtual int | reset (unsigned int timeout=(unsigned int) 0xffffffffUL) | 
| virtual bool | set_period (unsigned int uiNewPeriod, unsigned int timeout=(unsigned int) 0xffffffffUL) | 
| virtual unsigned int | get_period () | 
| const char * | get_name () | 
| bool | is_oneshot () | 
| virtual void * | get_handle () | 
| int | get_id () | 
| virtual void | set_id (int nId) | 
| virtual bool | is_running () | 
| operator bool () | |
Protected Member Functions | |
| virtual void | on_timer ()=0 | 
| virtual void | on_enter () | 
| virtual void | on_exit () | 
Static Protected Member Functions | |
| static void | runtimerstub (void *xTimer) | 
Private Attributes | |
| bool | m_bIsOneShot | 
| unsigned int | m_uiPeriod | 
| const char * | m_strName | 
| void * | m_pHandle | 
| int | m_iTimerID | 
Detailed Description
Wrapper class around FreeRTOS's implementation of a timer.
Constructor & Destructor Documentation
◆ basic_timer()
| mn::basic_timer::basic_timer | ( | const char * | strName, | 
| unsigned int | uiPeriod, | ||
| bool | bIsOneShot = true  | 
        ||
| ) | 
Construct a timer.
- Parameters
 - 
  
strName Name of the timer. uiPeriod When does the timer expire and run your Run() method. bIsOneShot true if this is a one shot timer. false if the timer expires every PeriodInTicks.  
◆ ~basic_timer()
      
  | 
  inlinevirtual | 
Member Function Documentation
◆ active()
      
  | 
  virtual | 
Start the timer.
- Parameters
 - 
  
timeout How long to wait  
- Returns
 - ERR_TIMER_OK All okay, no error ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first ERR_TIMER_AKTIVATE if it will not (i.e. timeout).
 
◆ create()
      
  | 
  virtual | 
Create the timer
- Note
 - Timers are not active after they are created, you need to activate them via active, reset, etc.
 
- Returns
 - ERR_TIMER_OK No error, ERR_TIMER_ALREADYINIT The timer are allready created and ERR_TIMER_CANTCREATE on error on create the FreeRTOS Timer
 
◆ destroy()
      
  | 
  virtual | 
destroy the timer
- Parameters
 - 
  
timeout How long to wait  
- Returns
 - ERR_TIMER_OK No error, ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first
 
◆ get_handle()
      
  | 
  inlinevirtual | 
Get the FreeRTOS handle
- Returns
 - the FreeRTOS handle
 
◆ get_id()
      
  | 
  inline | 
Returns the ID assigned to the timer.
- Returns
 - The ID assigned to the timer being queried.
 
◆ get_name()
      
  | 
  inline | 
Get the timer's name
- Returns
 - The timer's name
 
◆ get_period()
      
  | 
  inlinevirtual | 
Get the timer's period
- Returns
 - The timer's period
 
◆ inactive()
      
  | 
  virtual | 
Stop the timer
- Parameters
 - 
  
timeout How long to wait  
- Returns
 - ERR_TIMER_OK All okay, no error ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first ERR_TIMER_INAKTIVATE if it will not (i.e. timeout).
 
◆ is_oneshot()
      
  | 
  inline | 
Is the timer is one shotted?
- Returns
 - true The timer is one shotted and false when not
 
◆ is_running()
      
  | 
  virtual | 
Queries a timer to see if it is active or dormant.
- Returns
 - false will be returned if the timer is dormant. And true will be returned if the timer is active.
 
◆ on_enter()
      
  | 
  inlineprotectedvirtual | 
You can override this functions, call befor on_timer
◆ on_exit()
      
  | 
  inlineprotectedvirtual | 
You can override this functions, call after on_timer
◆ on_timer()
      
  | 
  protectedpure virtual | 
Implementation of your actual timer code. You must override this function.
◆ operator bool()
      
  | 
  inline | 
◆ reset()
      
  | 
  virtual | 
Reset the timer
- Parameters
 - 
  
timeout How long to wait  
- Returns
 - ERR_TIMER_OK All okay, no error ERR_TIMER_NOTCREATED the timer are not created, plaese call create() first ERR_TIMER_RESET if it will not (i.e. timeout).
 
◆ runtimerstub()
      
  | 
  staticprotected | 
Adapter function that allows you to write a class specific on_timer() function that interfaces with FreeRTOS.
◆ set_id()
      
  | 
  virtual | 
Sets the ID assigned to the timer.
If the same callback function is assigned to multiple timers then the timer ID can be used as time specific (timer local) storage.
- Parameters
 - 
  
nId The ID to assign to the timer.  
◆ set_period()
      
  | 
  virtual | 
Change a timer's period.
- Parameters
 - 
  
uiNewPeriod The new period in ticks. timeout How long to wait  
- Returns
 - true no error, false if it will not (i.e. timeout).
 
Member Data Documentation
◆ m_bIsOneShot
      
  | 
  private | 
A saved / cached copy of what the timers's mode is.
◆ m_iTimerID
      
  | 
  private | 
A saved / cached copy of what the timers's ID is.
◆ m_pHandle
      
  | 
  private | 
Reference to the underlying timer handle.
◆ m_strName
      
  | 
  private | 
A saved / cached copy of what the timers's name is.
◆ m_uiPeriod
      
  | 
  private | 
A saved / cached copy of what the timers's period is.
The documentation for this class was generated from the following files: