Maintain legacy RTOS behavior before mbed-5

Fork of mbed-rtos by mbed official

Committer:
mbed_official
Date:
Thu May 05 20:45:13 2016 +0100
Revision:
112:53ace74b190c
Parent:
31:015df9e602b6
Child:
119:19af2d39a542
Synchronized with git revision 860fdd282b0dc3631a6c46b39442d4ab5343e534

Full URL: https://github.com/mbedmicro/mbed/commit/860fdd282b0dc3631a6c46b39442d4ab5343e534/

rtx update to v4.79

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 8:88a1a9c26ae3 1 /* mbed Microcontroller Library
emilmont 8:88a1a9c26ae3 2 * Copyright (c) 2006-2012 ARM Limited
emilmont 8:88a1a9c26ae3 3 *
emilmont 8:88a1a9c26ae3 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
emilmont 8:88a1a9c26ae3 5 * of this software and associated documentation files (the "Software"), to deal
emilmont 8:88a1a9c26ae3 6 * in the Software without restriction, including without limitation the rights
emilmont 8:88a1a9c26ae3 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
emilmont 8:88a1a9c26ae3 8 * copies of the Software, and to permit persons to whom the Software is
emilmont 8:88a1a9c26ae3 9 * furnished to do so, subject to the following conditions:
emilmont 8:88a1a9c26ae3 10 *
emilmont 8:88a1a9c26ae3 11 * The above copyright notice and this permission notice shall be included in
emilmont 8:88a1a9c26ae3 12 * all copies or substantial portions of the Software.
emilmont 8:88a1a9c26ae3 13 *
emilmont 8:88a1a9c26ae3 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
emilmont 8:88a1a9c26ae3 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
emilmont 8:88a1a9c26ae3 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
emilmont 8:88a1a9c26ae3 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
emilmont 8:88a1a9c26ae3 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
emilmont 8:88a1a9c26ae3 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
emilmont 8:88a1a9c26ae3 20 * SOFTWARE.
emilmont 8:88a1a9c26ae3 21 */
emilmont 8:88a1a9c26ae3 22 #ifndef RTOS_TIMER_H
emilmont 8:88a1a9c26ae3 23 #define RTOS_TIMER_H
emilmont 8:88a1a9c26ae3 24
emilmont 8:88a1a9c26ae3 25 #include <stdint.h>
emilmont 8:88a1a9c26ae3 26 #include "cmsis_os.h"
emilmont 8:88a1a9c26ae3 27
emilmont 8:88a1a9c26ae3 28 namespace rtos {
emilmont 8:88a1a9c26ae3 29
emilmont 8:88a1a9c26ae3 30 /** The RtosTimer class allow creating and and controlling of timer functions in the system.
emilmont 8:88a1a9c26ae3 31 A timer function is called when a time period expires whereby both on-shot and
emilmont 8:88a1a9c26ae3 32 periodic timers are possible. A timer can be started, restarted, or stopped.
emilmont 8:88a1a9c26ae3 33
emilmont 8:88a1a9c26ae3 34 Timers are handled in the thread osTimerThread.
mbed_official 31:015df9e602b6 35 Callback functions run under control of this thread and may use CMSIS-RTOS API calls.
emilmont 8:88a1a9c26ae3 36 */
emilmont 8:88a1a9c26ae3 37 class RtosTimer {
emilmont 8:88a1a9c26ae3 38 public:
emilmont 8:88a1a9c26ae3 39 /** Create and Start timer.
emilmont 8:88a1a9c26ae3 40 @param task name of the timer call back function.
emilmont 8:88a1a9c26ae3 41 @param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
emilmont 8:88a1a9c26ae3 42 @param argument argument to the timer call back function. (default: NULL)
emilmont 8:88a1a9c26ae3 43 */
emilmont 8:88a1a9c26ae3 44 RtosTimer(void (*task)(void const *argument),
emilmont 8:88a1a9c26ae3 45 os_timer_type type=osTimerPeriodic,
emilmont 8:88a1a9c26ae3 46 void *argument=NULL);
mbed_official 31:015df9e602b6 47
emilmont 8:88a1a9c26ae3 48 /** Stop the timer.
mbed_official 31:015df9e602b6 49 @return status code that indicates the execution status of the function.
emilmont 8:88a1a9c26ae3 50 */
emilmont 8:88a1a9c26ae3 51 osStatus stop(void);
mbed_official 31:015df9e602b6 52
emilmont 8:88a1a9c26ae3 53 /** start a timer.
emilmont 8:88a1a9c26ae3 54 @param millisec time delay value of the timer.
mbed_official 31:015df9e602b6 55 @return status code that indicates the execution status of the function.
emilmont 8:88a1a9c26ae3 56 */
emilmont 8:88a1a9c26ae3 57 osStatus start(uint32_t millisec);
mbed_official 31:015df9e602b6 58
emilmont 8:88a1a9c26ae3 59 ~RtosTimer();
emilmont 8:88a1a9c26ae3 60
emilmont 8:88a1a9c26ae3 61 private:
emilmont 8:88a1a9c26ae3 62 osTimerId _timer_id;
emilmont 8:88a1a9c26ae3 63 osTimerDef_t _timer;
mbed_official 112:53ace74b190c 64 #if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM)
emilmont 8:88a1a9c26ae3 65 uint32_t _timer_data[5];
mbed_official 112:53ace74b190c 66 #else
mbed_official 112:53ace74b190c 67 uint32_t _timer_data[6];
emilmont 8:88a1a9c26ae3 68 #endif
emilmont 8:88a1a9c26ae3 69 };
emilmont 8:88a1a9c26ae3 70
emilmont 8:88a1a9c26ae3 71 }
emilmont 8:88a1a9c26ae3 72
emilmont 8:88a1a9c26ae3 73 #endif