Department of Electrical Eng University of Moratuwa / Mbed 2 deprecated bilateral_tunned_final

Dependencies:   mbed

Committer:
eembed
Date:
Thu Aug 01 08:00:33 2019 +0000
Revision:
0:5459cdde6298
first commit

Who changed what in which revision?

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