Erste version der Software für der Prototyp

Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

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