Anasse Abdoul / Mbed 2 deprecated Test_MPU6050

Dependencies:   mbed

Committer:
anasse
Date:
Thu Mar 31 07:43:50 2022 +0000
Revision:
0:a59a3d743804
vers0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
anasse 0:a59a3d743804 1 /* mbed Microcontroller Library
anasse 0:a59a3d743804 2 * Copyright (c) 2006-2012 ARM Limited
anasse 0:a59a3d743804 3 *
anasse 0:a59a3d743804 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
anasse 0:a59a3d743804 5 * of this software and associated documentation files (the "Software"), to deal
anasse 0:a59a3d743804 6 * in the Software without restriction, including without limitation the rights
anasse 0:a59a3d743804 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
anasse 0:a59a3d743804 8 * copies of the Software, and to permit persons to whom the Software is
anasse 0:a59a3d743804 9 * furnished to do so, subject to the following conditions:
anasse 0:a59a3d743804 10 *
anasse 0:a59a3d743804 11 * The above copyright notice and this permission notice shall be included in
anasse 0:a59a3d743804 12 * all copies or substantial portions of the Software.
anasse 0:a59a3d743804 13 *
anasse 0:a59a3d743804 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
anasse 0:a59a3d743804 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
anasse 0:a59a3d743804 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
anasse 0:a59a3d743804 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
anasse 0:a59a3d743804 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
anasse 0:a59a3d743804 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
anasse 0:a59a3d743804 20 * SOFTWARE.
anasse 0:a59a3d743804 21 */
anasse 0:a59a3d743804 22 #include "rtos/RtosTimer.h"
anasse 0:a59a3d743804 23
anasse 0:a59a3d743804 24 #include <string.h>
anasse 0:a59a3d743804 25
anasse 0:a59a3d743804 26 #include "mbed.h"
anasse 0:a59a3d743804 27 #include "cmsis_os.h"
anasse 0:a59a3d743804 28 #include "platform/mbed_error.h"
anasse 0:a59a3d743804 29
anasse 0:a59a3d743804 30 namespace rtos {
anasse 0:a59a3d743804 31
anasse 0:a59a3d743804 32 void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) {
anasse 0:a59a3d743804 33 #ifdef CMSIS_OS_RTX
anasse 0:a59a3d743804 34 _timer.ptimer = (void (*)(const void *))Callback<void()>::thunk;
anasse 0:a59a3d743804 35
anasse 0:a59a3d743804 36 memset(_timer_data, 0, sizeof(_timer_data));
anasse 0:a59a3d743804 37 _timer.timer = _timer_data;
anasse 0:a59a3d743804 38 #endif
anasse 0:a59a3d743804 39 _function = func;
anasse 0:a59a3d743804 40 _timer_id = osTimerCreate(&_timer, type, &_function);
anasse 0:a59a3d743804 41 }
anasse 0:a59a3d743804 42
anasse 0:a59a3d743804 43 osStatus RtosTimer::start(uint32_t millisec) {
anasse 0:a59a3d743804 44 return osTimerStart(_timer_id, millisec);
anasse 0:a59a3d743804 45 }
anasse 0:a59a3d743804 46
anasse 0:a59a3d743804 47 osStatus RtosTimer::stop(void) {
anasse 0:a59a3d743804 48 return osTimerStop(_timer_id);
anasse 0:a59a3d743804 49 }
anasse 0:a59a3d743804 50
anasse 0:a59a3d743804 51 RtosTimer::~RtosTimer() {
anasse 0:a59a3d743804 52 osTimerDelete(_timer_id);
anasse 0:a59a3d743804 53 }
anasse 0:a59a3d743804 54
anasse 0:a59a3d743804 55 }