Official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.

Dependents:   denki-yohou_b TestY201 Network-RTOS NTPClient_HelloWorld ... more

Deprecated

This is the mbed 2 rtos library. mbed OS 5 integrates the mbed library with mbed-rtos. With this, we have provided thread safety for all mbed APIs. If you'd like to learn about using mbed OS 5, please see the docs.

Committer:
emilmont
Date:
Fri Nov 23 09:57:31 2012 +0000
Revision:
6:350b53afb889
Child:
8:88a1a9c26ae3
Merge RTOS C++ API and RTX under the same library; Update RTX to version 4.60; Add proper Thread destructor;

Who changed what in which revision?

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