IC Eurobot 2012 Program published from Shuto's account

Dependents:   Eurobot2012_Primary

Committer:
narshu
Date:
Tue Aug 07 10:25:51 2012 +0000
Revision:
0:62626fd22b30
[mbed] converted /Eurobot_2012_Primary/rtos

Who changed what in which revision?

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