sends analog data over TTN
Fork of mbed-rtos by
rtos/RtosTimer.cpp@119:19af2d39a542, 2016-08-10 (annotated)
- Committer:
- Kojto
- Date:
- Wed Aug 10 16:09:20 2016 +0100
- Revision:
- 119:19af2d39a542
- Parent:
- 40:bd07334df5b1
- Child:
- 123:58563e6cba1e
RTOS rev119
Compatible with the mbed library v123
Changes:
- new targets: NRF52 and NUC472
- mbed singleton mutex addition
- main thread with timers fix
- Thread - mutex addition for synchronization
- Semaphore - default count argument set to 0
- RTOSTimer - add new ctor with Callback
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
emilmont | 8:88a1a9c26ae3 | 1 | /* mbed Microcontroller Library |
emilmont | 8:88a1a9c26ae3 | 2 | * Copyright (c) 2006-2012 ARM Limited |
emilmont | 8:88a1a9c26ae3 | 3 | * |
emilmont | 8:88a1a9c26ae3 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
emilmont | 8:88a1a9c26ae3 | 5 | * of this software and associated documentation files (the "Software"), to deal |
emilmont | 8:88a1a9c26ae3 | 6 | * in the Software without restriction, including without limitation the rights |
emilmont | 8:88a1a9c26ae3 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
emilmont | 8:88a1a9c26ae3 | 8 | * copies of the Software, and to permit persons to whom the Software is |
emilmont | 8:88a1a9c26ae3 | 9 | * furnished to do so, subject to the following conditions: |
emilmont | 8:88a1a9c26ae3 | 10 | * |
emilmont | 8:88a1a9c26ae3 | 11 | * The above copyright notice and this permission notice shall be included in |
emilmont | 8:88a1a9c26ae3 | 12 | * all copies or substantial portions of the Software. |
emilmont | 8:88a1a9c26ae3 | 13 | * |
emilmont | 8:88a1a9c26ae3 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
emilmont | 8:88a1a9c26ae3 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
emilmont | 8:88a1a9c26ae3 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
emilmont | 8:88a1a9c26ae3 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
emilmont | 8:88a1a9c26ae3 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
emilmont | 8:88a1a9c26ae3 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
emilmont | 8:88a1a9c26ae3 | 20 | * SOFTWARE. |
emilmont | 8:88a1a9c26ae3 | 21 | */ |
emilmont | 8:88a1a9c26ae3 | 22 | #include "RtosTimer.h" |
emilmont | 8:88a1a9c26ae3 | 23 | |
emilmont | 8:88a1a9c26ae3 | 24 | #include <string.h> |
emilmont | 8:88a1a9c26ae3 | 25 | |
Kojto | 119:19af2d39a542 | 26 | #include "mbed.h" |
emilmont | 8:88a1a9c26ae3 | 27 | #include "cmsis_os.h" |
mbed_official | 40:bd07334df5b1 | 28 | #include "mbed_error.h" |
emilmont | 8:88a1a9c26ae3 | 29 | |
emilmont | 8:88a1a9c26ae3 | 30 | namespace rtos { |
emilmont | 8:88a1a9c26ae3 | 31 | |
Kojto | 119:19af2d39a542 | 32 | void RtosTimer::constructor(mbed::Callback<void()> func, os_timer_type type) { |
emilmont | 8:88a1a9c26ae3 | 33 | #ifdef CMSIS_OS_RTX |
Kojto | 119:19af2d39a542 | 34 | _timer.ptimer = (void (*)(const void *))Callback<void()>::thunk; |
mbed_official | 31:015df9e602b6 | 35 | |
emilmont | 8:88a1a9c26ae3 | 36 | memset(_timer_data, 0, sizeof(_timer_data)); |
emilmont | 8:88a1a9c26ae3 | 37 | _timer.timer = _timer_data; |
emilmont | 8:88a1a9c26ae3 | 38 | #endif |
Kojto | 119:19af2d39a542 | 39 | _function = func; |
Kojto | 119:19af2d39a542 | 40 | _timer_id = osTimerCreate(&_timer, type, &_function); |
emilmont | 8:88a1a9c26ae3 | 41 | } |
emilmont | 8:88a1a9c26ae3 | 42 | |
emilmont | 8:88a1a9c26ae3 | 43 | osStatus RtosTimer::start(uint32_t millisec) { |
emilmont | 8:88a1a9c26ae3 | 44 | return osTimerStart(_timer_id, millisec); |
emilmont | 8:88a1a9c26ae3 | 45 | } |
emilmont | 8:88a1a9c26ae3 | 46 | |
emilmont | 8:88a1a9c26ae3 | 47 | osStatus RtosTimer::stop(void) { |
emilmont | 8:88a1a9c26ae3 | 48 | return osTimerStop(_timer_id); |
emilmont | 8:88a1a9c26ae3 | 49 | } |
emilmont | 8:88a1a9c26ae3 | 50 | |
emilmont | 8:88a1a9c26ae3 | 51 | RtosTimer::~RtosTimer() { |
emilmont | 8:88a1a9c26ae3 | 52 | osTimerDelete(_timer_id); |
emilmont | 8:88a1a9c26ae3 | 53 | } |
emilmont | 8:88a1a9c26ae3 | 54 | |
emilmont | 8:88a1a9c26ae3 | 55 | } |