mn_timer.hpp
Go to the documentation of this file.
1 
19 #ifndef MINLIB_FREERTOS_TIMER_
20 #define MINLIB_FREERTOS_TIMER_
21 
22 #include "mn_config.hpp"
23 #include "mn_itimer.hpp"
24 
25 namespace mn {
31  class basic_timer {
32  public:
43  basic_timer(const char * strName,
44  unsigned int uiPeriod, bool bIsOneShot = true);
45 
46  virtual ~basic_timer() { destroy(); }
56  virtual int create();
57 
64  virtual int destroy(unsigned int timeout = (unsigned int) 0xffffffffUL);
65 
74  virtual int active(unsigned int timeout = (unsigned int) 0xffffffffUL);
75 
84  virtual int inactive(unsigned int timeout = (unsigned int) 0xffffffffUL);
85 
94  virtual int reset(unsigned int timeout = (unsigned int) 0xffffffffUL);
95 
103  virtual bool set_period(unsigned int uiNewPeriod, unsigned int timeout = (unsigned int) 0xffffffffUL);
104 
110  virtual unsigned int get_period() { return m_uiPeriod; }
111 
117  const char* get_name() { return m_strName; }
118 
124  bool is_oneshot() { return m_bIsOneShot; }
125 
131  virtual void* get_handle() { return m_pHandle; }
132 
137  int get_id() { return m_iTimerID; }
138 
147  virtual void set_id(int nId);
148 
155  virtual bool is_running();
156 
157  operator bool() { return is_running(); }
158  protected:
163  virtual void on_timer() = 0;
164 
168  virtual void on_enter() { }
172  virtual void on_exit() { }
173  protected:
178  static void runtimerstub(void* xTimer);
179  private:
187  unsigned int m_uiPeriod;
191  const char* m_strName;
195  void* m_pHandle;
196 
201 
202  #if( configSUPPORT_STATIC_ALLOCATION == 1 )
203  StaticTimer_t m_xTimerBuffer;
204  #endif
205  };
206 
208 }
209 
210 #endif
Definition: mn_timer.hpp:31
virtual int destroy(unsigned int timeout=(unsigned int) 0xffffffffUL)
Definition: mn_timer.cpp:65
bool m_bIsOneShot
Definition: mn_timer.hpp:183
virtual bool set_period(unsigned int uiNewPeriod, unsigned int timeout=(unsigned int) 0xffffffffUL)
Definition: mn_timer.cpp:136
virtual void * get_handle()
Definition: mn_timer.hpp:131
virtual void on_exit()
Definition: mn_timer.hpp:172
virtual int reset(unsigned int timeout=(unsigned int) 0xffffffffUL)
Definition: mn_timer.cpp:116
const char * get_name()
Definition: mn_timer.hpp:117
int get_id()
Definition: mn_timer.hpp:137
virtual int inactive(unsigned int timeout=(unsigned int) 0xffffffffUL)
Definition: mn_timer.cpp:96
int m_iTimerID
Definition: mn_timer.hpp:200
virtual void on_enter()
Definition: mn_timer.hpp:168
virtual void on_timer()=0
bool is_oneshot()
Definition: mn_timer.hpp:124
virtual unsigned int get_period()
Definition: mn_timer.hpp:110
void * m_pHandle
Definition: mn_timer.hpp:195
virtual int active(unsigned int timeout=(unsigned int) 0xffffffffUL)
Definition: mn_timer.cpp:76
virtual ~basic_timer()
Definition: mn_timer.hpp:46
virtual bool is_running()
Definition: mn_timer.cpp:177
virtual int create()
Definition: mn_timer.cpp:37
basic_timer(const char *strName, unsigned int uiPeriod, bool bIsOneShot=true)
Definition: mn_timer.cpp:30
const char * m_strName
Definition: mn_timer.hpp:191
virtual void set_id(int nId)
Definition: mn_timer.cpp:169
static void runtimerstub(void *xTimer)
Definition: mn_timer.cpp:156
unsigned int m_uiPeriod
Definition: mn_timer.hpp:187
Definition: mn_allocator_typetraits.hpp:25