BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Committer:
gustavatmel
Date:
Tue May 01 15:55:34 2018 +0000
Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
bluetooth

Who changed what in which revision?

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