J&W / Mbed 2 deprecated Rejestrator

Dependencies:   mbed Rejestrator

Dependents:   Rejestrator

Committer:
Waldek
Date:
Sat Apr 18 17:01:57 2015 +0000
Revision:
0:fa31f8461c63
working version, stop

Who changed what in which revision?

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