First Commit

Dependents:   uLCD_Multiscreen

Committer:
Mkuchnik3
Date:
Wed Mar 11 21:31:16 2015 +0000
Revision:
0:8b4ab67d92b2
First Commit

Who changed what in which revision?

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