help :(

Dependencies:   FFT

Committer:
annieluo2
Date:
Wed Dec 02 18:02:03 2020 +0000
Revision:
0:d6c9b09b4042
boo

Who changed what in which revision?

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