Ethernetwebsoc
Dependencies: C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip
mbed-rtos/rtos/RtosTimer.h@0:0ed2a7c7190c, 2013-05-31 (annotated)
- Committer:
- GordonSin
- Date:
- Fri May 31 04:09:54 2013 +0000
- Revision:
- 0:0ed2a7c7190c
31/5/2013;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
GordonSin | 0:0ed2a7c7190c | 1 | /* Copyright (c) 2012 mbed.org */ |
GordonSin | 0:0ed2a7c7190c | 2 | #ifndef TIMER_H |
GordonSin | 0:0ed2a7c7190c | 3 | #define TIMER_H |
GordonSin | 0:0ed2a7c7190c | 4 | |
GordonSin | 0:0ed2a7c7190c | 5 | #include <stdint.h> |
GordonSin | 0:0ed2a7c7190c | 6 | #include "cmsis_os.h" |
GordonSin | 0:0ed2a7c7190c | 7 | |
GordonSin | 0:0ed2a7c7190c | 8 | namespace rtos { |
GordonSin | 0:0ed2a7c7190c | 9 | |
GordonSin | 0:0ed2a7c7190c | 10 | /*! The RtosTimer class allow creating and and controlling of timer functions in the system. |
GordonSin | 0:0ed2a7c7190c | 11 | A timer function is called when a time period expires whereby both on-shot and |
GordonSin | 0:0ed2a7c7190c | 12 | periodic timers are possible. A timer can be started, restarted, or stopped. |
GordonSin | 0:0ed2a7c7190c | 13 | |
GordonSin | 0:0ed2a7c7190c | 14 | Timers are handled in the thread osTimerThread. |
GordonSin | 0:0ed2a7c7190c | 15 | Callback functions run under control of this thread and may use CMSIS-RTOS API calls. |
GordonSin | 0:0ed2a7c7190c | 16 | */ |
GordonSin | 0:0ed2a7c7190c | 17 | class RtosTimer { |
GordonSin | 0:0ed2a7c7190c | 18 | public: |
GordonSin | 0:0ed2a7c7190c | 19 | /*! Create and Start timer. |
GordonSin | 0:0ed2a7c7190c | 20 | \param task name of the timer call back function. |
GordonSin | 0:0ed2a7c7190c | 21 | \param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic) |
GordonSin | 0:0ed2a7c7190c | 22 | \param argument argument to the timer call back function. (default: NULL) |
GordonSin | 0:0ed2a7c7190c | 23 | */ |
GordonSin | 0:0ed2a7c7190c | 24 | RtosTimer(void (*task)(void const *argument), |
GordonSin | 0:0ed2a7c7190c | 25 | os_timer_type type=osTimerPeriodic, |
GordonSin | 0:0ed2a7c7190c | 26 | void *argument=NULL); |
GordonSin | 0:0ed2a7c7190c | 27 | |
GordonSin | 0:0ed2a7c7190c | 28 | /*! Stop the timer. |
GordonSin | 0:0ed2a7c7190c | 29 | \return status code that indicates the execution status of the function. |
GordonSin | 0:0ed2a7c7190c | 30 | */ |
GordonSin | 0:0ed2a7c7190c | 31 | osStatus stop(void); |
GordonSin | 0:0ed2a7c7190c | 32 | |
GordonSin | 0:0ed2a7c7190c | 33 | /*! start a timer. |
GordonSin | 0:0ed2a7c7190c | 34 | \param millisec time delay value of the timer. |
GordonSin | 0:0ed2a7c7190c | 35 | \return status code that indicates the execution status of the function. |
GordonSin | 0:0ed2a7c7190c | 36 | */ |
GordonSin | 0:0ed2a7c7190c | 37 | osStatus start(uint32_t millisec); |
GordonSin | 0:0ed2a7c7190c | 38 | |
GordonSin | 0:0ed2a7c7190c | 39 | ~RtosTimer(); |
GordonSin | 0:0ed2a7c7190c | 40 | |
GordonSin | 0:0ed2a7c7190c | 41 | private: |
GordonSin | 0:0ed2a7c7190c | 42 | osTimerId _timer_id; |
GordonSin | 0:0ed2a7c7190c | 43 | osTimerDef_t _timer; |
GordonSin | 0:0ed2a7c7190c | 44 | #ifdef CMSIS_OS_RTX |
GordonSin | 0:0ed2a7c7190c | 45 | uint32_t _timer_data[5]; |
GordonSin | 0:0ed2a7c7190c | 46 | #endif |
GordonSin | 0:0ed2a7c7190c | 47 | }; |
GordonSin | 0:0ed2a7c7190c | 48 | |
GordonSin | 0:0ed2a7c7190c | 49 | } |
GordonSin | 0:0ed2a7c7190c | 50 | |
GordonSin | 0:0ed2a7c7190c | 51 | #endif |