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