Committer:
donatien
Date:
Thu May 31 15:46:30 2012 +0000
Revision:
0:e6ccf0b3d718

        

Who changed what in which revision?

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