Committer:
PA
Date:
Thu Jun 21 14:04:44 2012 +0000
Revision:
0:7ae810ca8a42

        

Who changed what in which revision?

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