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