Pierre Provent / USBHost

Dependents:   TEST_USB_Nucleo_F429ZI Essais_USB_Nucleo_F429ZI SID_V3_Nucleo_F429ZI SID_V4_Nucleo_F429ZI_copy

Committer:
pierreprovent
Date:
Fri Sep 25 10:17:49 2020 +0000
Revision:
0:77ca32e8e04e
Programme acquisition en enregistrement sur clef USB carte Nucleo F429ZI cours ELE118 Cnam

Who changed what in which revision?

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