Fork of official mbed Real Time Operating System based on the RTX implementation of the CMSIS-RTOS API open standard.
Dependents: Final_Coffee_Roaster
Fork of mbed-rtos by
rtos/RtosTimer.cpp@6:350b53afb889, 2012-11-23 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 6:350b53afb889 | 1 | #include "RtosTimer.h" |
emilmont | 6:350b53afb889 | 2 | |
emilmont | 6:350b53afb889 | 3 | #include <string.h> |
emilmont | 6:350b53afb889 | 4 | |
emilmont | 6:350b53afb889 | 5 | #include "cmsis_os.h" |
emilmont | 6:350b53afb889 | 6 | #include "error.h" |
emilmont | 6:350b53afb889 | 7 | |
emilmont | 6:350b53afb889 | 8 | namespace rtos { |
emilmont | 6:350b53afb889 | 9 | |
emilmont | 6:350b53afb889 | 10 | RtosTimer::RtosTimer(void (*periodic_task)(void const *argument), os_timer_type type, void *argument) { |
emilmont | 6:350b53afb889 | 11 | #ifdef CMSIS_OS_RTX |
emilmont | 6:350b53afb889 | 12 | _timer.ptimer = periodic_task; |
emilmont | 6:350b53afb889 | 13 | |
emilmont | 6:350b53afb889 | 14 | memset(_timer_data, 0, sizeof(_timer_data)); |
emilmont | 6:350b53afb889 | 15 | _timer.timer = _timer_data; |
emilmont | 6:350b53afb889 | 16 | #endif |
emilmont | 6:350b53afb889 | 17 | _timer_id = osTimerCreate(&_timer, type, argument); |
emilmont | 6:350b53afb889 | 18 | } |
emilmont | 6:350b53afb889 | 19 | |
emilmont | 6:350b53afb889 | 20 | osStatus RtosTimer::start(uint32_t millisec) { |
emilmont | 6:350b53afb889 | 21 | return osTimerStart(_timer_id, millisec); |
emilmont | 6:350b53afb889 | 22 | } |
emilmont | 6:350b53afb889 | 23 | |
emilmont | 6:350b53afb889 | 24 | osStatus RtosTimer::stop(void) { |
emilmont | 6:350b53afb889 | 25 | return osTimerStop(_timer_id); |
emilmont | 6:350b53afb889 | 26 | } |
emilmont | 6:350b53afb889 | 27 | |
emilmont | 6:350b53afb889 | 28 | RtosTimer::~RtosTimer() { |
emilmont | 6:350b53afb889 | 29 | osTimerDelete(_timer_id); |
emilmont | 6:350b53afb889 | 30 | } |
emilmont | 6:350b53afb889 | 31 | |
emilmont | 6:350b53afb889 | 32 | } |