florent ollivier / Mbed 2 deprecated Gyro

Dependencies:   mbed

Committer:
flo__
Date:
Thu Mar 31 10:44:47 2022 +0000
Revision:
1:111167e39dfa
Parent:
0:b435eadf76b4
31/03/22

Who changed what in which revision?

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