Opencv 3.1 project on GR-PEACH board
Fork of gr-peach-opencv-project by
mbed-rtos/rtos/RtosTimer.h@170:54ff26da7eb6, 2017-07-04 (annotated)
- Committer:
- thedo
- Date:
- Tue Jul 04 06:23:13 2017 +0000
- Revision:
- 170:54ff26da7eb6
- Parent:
- 166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 166:3a9487d57a5c | 1 | /* mbed Microcontroller Library |
thedo | 166:3a9487d57a5c | 2 | * Copyright (c) 2006-2012 ARM Limited |
thedo | 166:3a9487d57a5c | 3 | * |
thedo | 166:3a9487d57a5c | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
thedo | 166:3a9487d57a5c | 5 | * of this software and associated documentation files (the "Software"), to deal |
thedo | 166:3a9487d57a5c | 6 | * in the Software without restriction, including without limitation the rights |
thedo | 166:3a9487d57a5c | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
thedo | 166:3a9487d57a5c | 8 | * copies of the Software, and to permit persons to whom the Software is |
thedo | 166:3a9487d57a5c | 9 | * furnished to do so, subject to the following conditions: |
thedo | 166:3a9487d57a5c | 10 | * |
thedo | 166:3a9487d57a5c | 11 | * The above copyright notice and this permission notice shall be included in |
thedo | 166:3a9487d57a5c | 12 | * all copies or substantial portions of the Software. |
thedo | 166:3a9487d57a5c | 13 | * |
thedo | 166:3a9487d57a5c | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
thedo | 166:3a9487d57a5c | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
thedo | 166:3a9487d57a5c | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
thedo | 166:3a9487d57a5c | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
thedo | 166:3a9487d57a5c | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
thedo | 166:3a9487d57a5c | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
thedo | 166:3a9487d57a5c | 20 | * SOFTWARE. |
thedo | 166:3a9487d57a5c | 21 | */ |
thedo | 166:3a9487d57a5c | 22 | #ifndef RTOS_TIMER_H |
thedo | 166:3a9487d57a5c | 23 | #define RTOS_TIMER_H |
thedo | 166:3a9487d57a5c | 24 | |
thedo | 166:3a9487d57a5c | 25 | #include <stdint.h> |
thedo | 166:3a9487d57a5c | 26 | #include "cmsis_os.h" |
thedo | 166:3a9487d57a5c | 27 | #include "platform/Callback.h" |
thedo | 166:3a9487d57a5c | 28 | #include "platform/toolchain.h" |
thedo | 166:3a9487d57a5c | 29 | |
thedo | 166:3a9487d57a5c | 30 | namespace rtos { |
thedo | 166:3a9487d57a5c | 31 | /** \addtogroup rtos */ |
thedo | 166:3a9487d57a5c | 32 | /** @{*/ |
thedo | 166:3a9487d57a5c | 33 | |
thedo | 166:3a9487d57a5c | 34 | /** The RtosTimer class allow creating and and controlling of timer functions in the system. |
thedo | 166:3a9487d57a5c | 35 | A timer function is called when a time period expires whereby both on-shot and |
thedo | 166:3a9487d57a5c | 36 | periodic timers are possible. A timer can be started, restarted, or stopped. |
thedo | 166:3a9487d57a5c | 37 | |
thedo | 166:3a9487d57a5c | 38 | Timers are handled in the thread osTimerThread. |
thedo | 166:3a9487d57a5c | 39 | Callback functions run under control of this thread and may use CMSIS-RTOS API calls. |
thedo | 166:3a9487d57a5c | 40 | */ |
thedo | 166:3a9487d57a5c | 41 | class RtosTimer { |
thedo | 166:3a9487d57a5c | 42 | public: |
thedo | 166:3a9487d57a5c | 43 | /** Create timer. |
thedo | 166:3a9487d57a5c | 44 | @param func function to be executed by this timer. |
thedo | 166:3a9487d57a5c | 45 | @param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic) |
thedo | 166:3a9487d57a5c | 46 | @param argument argument to the timer call back function. (default: NULL) |
thedo | 166:3a9487d57a5c | 47 | @deprecated Replaced with RtosTimer(Callback<void()>, os_timer_type) |
thedo | 166:3a9487d57a5c | 48 | */ |
thedo | 166:3a9487d57a5c | 49 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
thedo | 166:3a9487d57a5c | 50 | "Replaced with RtosTimer(Callback<void()>, os_timer_type)") |
thedo | 166:3a9487d57a5c | 51 | RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) { |
thedo | 166:3a9487d57a5c | 52 | constructor(mbed::callback((void (*)(void *))func, argument), type); |
thedo | 166:3a9487d57a5c | 53 | } |
thedo | 166:3a9487d57a5c | 54 | |
thedo | 166:3a9487d57a5c | 55 | /** Create timer. |
thedo | 166:3a9487d57a5c | 56 | @param func function to be executed by this timer. |
thedo | 166:3a9487d57a5c | 57 | @param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic) |
thedo | 166:3a9487d57a5c | 58 | */ |
thedo | 166:3a9487d57a5c | 59 | RtosTimer(mbed::Callback<void()> func, os_timer_type type=osTimerPeriodic) { |
thedo | 166:3a9487d57a5c | 60 | constructor(func, type); |
thedo | 166:3a9487d57a5c | 61 | } |
thedo | 166:3a9487d57a5c | 62 | |
thedo | 166:3a9487d57a5c | 63 | /** Create timer. |
thedo | 166:3a9487d57a5c | 64 | @param obj pointer to the object to call the member function on. |
thedo | 166:3a9487d57a5c | 65 | @param method member function to be executed by this timer. |
thedo | 166:3a9487d57a5c | 66 | @param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic) |
thedo | 166:3a9487d57a5c | 67 | @deprecated |
thedo | 166:3a9487d57a5c | 68 | The RtosTimer constructor does not support cv-qualifiers. Replaced by |
thedo | 166:3a9487d57a5c | 69 | RtosTimer(callback(obj, method), os_timer_type). |
thedo | 166:3a9487d57a5c | 70 | */ |
thedo | 166:3a9487d57a5c | 71 | template <typename T, typename M> |
thedo | 166:3a9487d57a5c | 72 | MBED_DEPRECATED_SINCE("mbed-os-5.1", |
thedo | 166:3a9487d57a5c | 73 | "The RtosTimer constructor does not support cv-qualifiers. Replaced by " |
thedo | 166:3a9487d57a5c | 74 | "RtosTimer(callback(obj, method), os_timer_type).") |
thedo | 166:3a9487d57a5c | 75 | RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) { |
thedo | 166:3a9487d57a5c | 76 | constructor(mbed::callback(obj, method), type); |
thedo | 166:3a9487d57a5c | 77 | } |
thedo | 166:3a9487d57a5c | 78 | |
thedo | 166:3a9487d57a5c | 79 | /** Stop the timer. |
thedo | 166:3a9487d57a5c | 80 | @return status code that indicates the execution status of the function. |
thedo | 166:3a9487d57a5c | 81 | */ |
thedo | 166:3a9487d57a5c | 82 | osStatus stop(void); |
thedo | 166:3a9487d57a5c | 83 | |
thedo | 166:3a9487d57a5c | 84 | /** Start the timer. |
thedo | 166:3a9487d57a5c | 85 | @param millisec time delay value of the timer. |
thedo | 166:3a9487d57a5c | 86 | @return status code that indicates the execution status of the function. |
thedo | 166:3a9487d57a5c | 87 | */ |
thedo | 166:3a9487d57a5c | 88 | osStatus start(uint32_t millisec); |
thedo | 166:3a9487d57a5c | 89 | |
thedo | 166:3a9487d57a5c | 90 | ~RtosTimer(); |
thedo | 166:3a9487d57a5c | 91 | |
thedo | 166:3a9487d57a5c | 92 | private: |
thedo | 166:3a9487d57a5c | 93 | // Required to share definitions without |
thedo | 166:3a9487d57a5c | 94 | // delegated constructors |
thedo | 166:3a9487d57a5c | 95 | void constructor(mbed::Callback<void()> func, os_timer_type type); |
thedo | 166:3a9487d57a5c | 96 | |
thedo | 166:3a9487d57a5c | 97 | mbed::Callback<void()> _function; |
thedo | 166:3a9487d57a5c | 98 | osTimerId _timer_id; |
thedo | 166:3a9487d57a5c | 99 | osTimerDef_t _timer; |
thedo | 166:3a9487d57a5c | 100 | #if defined(CMSIS_OS_RTX) && !defined(__MBED_CMSIS_RTOS_CM) |
thedo | 166:3a9487d57a5c | 101 | uint32_t _timer_data[5]; |
thedo | 166:3a9487d57a5c | 102 | #else |
thedo | 166:3a9487d57a5c | 103 | uint32_t _timer_data[6]; |
thedo | 166:3a9487d57a5c | 104 | #endif |
thedo | 166:3a9487d57a5c | 105 | }; |
thedo | 166:3a9487d57a5c | 106 | |
thedo | 166:3a9487d57a5c | 107 | } |
thedo | 166:3a9487d57a5c | 108 | |
thedo | 166:3a9487d57a5c | 109 | #endif |
thedo | 166:3a9487d57a5c | 110 | |
thedo | 166:3a9487d57a5c | 111 | /** @}*/ |