The code from https://github.com/vpcola/Nucleo

Committer:
sinrab
Date:
Wed Oct 08 11:00:24 2014 +0000
Revision:
0:5464d5e415e5
The code from https://github.com/vpcola/Nucleo

Who changed what in which revision?

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