This is a fork due to permission issues
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of 6_songs-from-the-cloud by
mbed-client/mbed-rtos/rtos/RtosTimer.cpp@0:f7c60d3e7b8a, 2016-05-18 (annotated)
- Committer:
- maclobdell
- Date:
- Wed May 18 19:06:32 2016 +0000
- Revision:
- 0:f7c60d3e7b8a
clean version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maclobdell | 0:f7c60d3e7b8a | 1 | /* mbed Microcontroller Library |
maclobdell | 0:f7c60d3e7b8a | 2 | * Copyright (c) 2006-2012 ARM Limited |
maclobdell | 0:f7c60d3e7b8a | 3 | * |
maclobdell | 0:f7c60d3e7b8a | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
maclobdell | 0:f7c60d3e7b8a | 5 | * of this software and associated documentation files (the "Software"), to deal |
maclobdell | 0:f7c60d3e7b8a | 6 | * in the Software without restriction, including without limitation the rights |
maclobdell | 0:f7c60d3e7b8a | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
maclobdell | 0:f7c60d3e7b8a | 8 | * copies of the Software, and to permit persons to whom the Software is |
maclobdell | 0:f7c60d3e7b8a | 9 | * furnished to do so, subject to the following conditions: |
maclobdell | 0:f7c60d3e7b8a | 10 | * |
maclobdell | 0:f7c60d3e7b8a | 11 | * The above copyright notice and this permission notice shall be included in |
maclobdell | 0:f7c60d3e7b8a | 12 | * all copies or substantial portions of the Software. |
maclobdell | 0:f7c60d3e7b8a | 13 | * |
maclobdell | 0:f7c60d3e7b8a | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
maclobdell | 0:f7c60d3e7b8a | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
maclobdell | 0:f7c60d3e7b8a | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
maclobdell | 0:f7c60d3e7b8a | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
maclobdell | 0:f7c60d3e7b8a | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
maclobdell | 0:f7c60d3e7b8a | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
maclobdell | 0:f7c60d3e7b8a | 20 | * SOFTWARE. |
maclobdell | 0:f7c60d3e7b8a | 21 | */ |
maclobdell | 0:f7c60d3e7b8a | 22 | #include "RtosTimer.h" |
maclobdell | 0:f7c60d3e7b8a | 23 | |
maclobdell | 0:f7c60d3e7b8a | 24 | #include <string.h> |
maclobdell | 0:f7c60d3e7b8a | 25 | |
maclobdell | 0:f7c60d3e7b8a | 26 | #include "cmsis_os.h" |
maclobdell | 0:f7c60d3e7b8a | 27 | #include "mbed_error.h" |
maclobdell | 0:f7c60d3e7b8a | 28 | |
maclobdell | 0:f7c60d3e7b8a | 29 | namespace rtos { |
maclobdell | 0:f7c60d3e7b8a | 30 | |
maclobdell | 0:f7c60d3e7b8a | 31 | RtosTimer::RtosTimer(void (*periodic_task)(void const *argument), os_timer_type type, void *argument) { |
maclobdell | 0:f7c60d3e7b8a | 32 | #ifdef CMSIS_OS_RTX |
maclobdell | 0:f7c60d3e7b8a | 33 | _timer.ptimer = periodic_task; |
maclobdell | 0:f7c60d3e7b8a | 34 | |
maclobdell | 0:f7c60d3e7b8a | 35 | memset(_timer_data, 0, sizeof(_timer_data)); |
maclobdell | 0:f7c60d3e7b8a | 36 | _timer.timer = _timer_data; |
maclobdell | 0:f7c60d3e7b8a | 37 | #endif |
maclobdell | 0:f7c60d3e7b8a | 38 | _timer_id = osTimerCreate(&_timer, type, argument); |
maclobdell | 0:f7c60d3e7b8a | 39 | } |
maclobdell | 0:f7c60d3e7b8a | 40 | |
maclobdell | 0:f7c60d3e7b8a | 41 | osStatus RtosTimer::start(uint32_t millisec) { |
maclobdell | 0:f7c60d3e7b8a | 42 | return osTimerStart(_timer_id, millisec); |
maclobdell | 0:f7c60d3e7b8a | 43 | } |
maclobdell | 0:f7c60d3e7b8a | 44 | |
maclobdell | 0:f7c60d3e7b8a | 45 | osStatus RtosTimer::stop(void) { |
maclobdell | 0:f7c60d3e7b8a | 46 | return osTimerStop(_timer_id); |
maclobdell | 0:f7c60d3e7b8a | 47 | } |
maclobdell | 0:f7c60d3e7b8a | 48 | |
maclobdell | 0:f7c60d3e7b8a | 49 | RtosTimer::~RtosTimer() { |
maclobdell | 0:f7c60d3e7b8a | 50 | osTimerDelete(_timer_id); |
maclobdell | 0:f7c60d3e7b8a | 51 | } |
maclobdell | 0:f7c60d3e7b8a | 52 | |
maclobdell | 0:f7c60d3e7b8a | 53 | } |