![](/media/cache/profiles/debfdc81854eac26ec993b55a659c6e1.jpg.50x50_q85.jpg)
mbed client lightswitch demo
Dependencies: mbed Socket lwip-eth lwip-sys lwip
Fork of mbed-client-classic-example-lwip by
mbed-rtos/rtos/RtosTimer.h@11:cada08fc8a70, 2016-06-09 (annotated)
- Committer:
- mbedAustin
- Date:
- Thu Jun 09 17:08:36 2016 +0000
- Revision:
- 11:cada08fc8a70
Commit for public Consumption
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 11:cada08fc8a70 | 1 | /* mbed Microcontroller Library |
mbedAustin | 11:cada08fc8a70 | 2 | * Copyright (c) 2006-2012 ARM Limited |
mbedAustin | 11:cada08fc8a70 | 3 | * |
mbedAustin | 11:cada08fc8a70 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
mbedAustin | 11:cada08fc8a70 | 5 | * of this software and associated documentation files (the "Software"), to deal |
mbedAustin | 11:cada08fc8a70 | 6 | * in the Software without restriction, including without limitation the rights |
mbedAustin | 11:cada08fc8a70 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
mbedAustin | 11:cada08fc8a70 | 8 | * copies of the Software, and to permit persons to whom the Software is |
mbedAustin | 11:cada08fc8a70 | 9 | * furnished to do so, subject to the following conditions: |
mbedAustin | 11:cada08fc8a70 | 10 | * |
mbedAustin | 11:cada08fc8a70 | 11 | * The above copyright notice and this permission notice shall be included in |
mbedAustin | 11:cada08fc8a70 | 12 | * all copies or substantial portions of the Software. |
mbedAustin | 11:cada08fc8a70 | 13 | * |
mbedAustin | 11:cada08fc8a70 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
mbedAustin | 11:cada08fc8a70 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
mbedAustin | 11:cada08fc8a70 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
mbedAustin | 11:cada08fc8a70 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
mbedAustin | 11:cada08fc8a70 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mbedAustin | 11:cada08fc8a70 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
mbedAustin | 11:cada08fc8a70 | 20 | * SOFTWARE. |
mbedAustin | 11:cada08fc8a70 | 21 | */ |
mbedAustin | 11:cada08fc8a70 | 22 | #ifndef RTOS_TIMER_H |
mbedAustin | 11:cada08fc8a70 | 23 | #define RTOS_TIMER_H |
mbedAustin | 11:cada08fc8a70 | 24 | |
mbedAustin | 11:cada08fc8a70 | 25 | #include <stdint.h> |
mbedAustin | 11:cada08fc8a70 | 26 | #include "cmsis_os.h" |
mbedAustin | 11:cada08fc8a70 | 27 | |
mbedAustin | 11:cada08fc8a70 | 28 | namespace rtos { |
mbedAustin | 11:cada08fc8a70 | 29 | |
mbedAustin | 11:cada08fc8a70 | 30 | /** The RtosTimer class allow creating and and controlling of timer functions in the system. |
mbedAustin | 11:cada08fc8a70 | 31 | A timer function is called when a time period expires whereby both on-shot and |
mbedAustin | 11:cada08fc8a70 | 32 | periodic timers are possible. A timer can be started, restarted, or stopped. |
mbedAustin | 11:cada08fc8a70 | 33 | |
mbedAustin | 11:cada08fc8a70 | 34 | Timers are handled in the thread osTimerThread. |
mbedAustin | 11:cada08fc8a70 | 35 | Callback functions run under control of this thread and may use CMSIS-RTOS API calls. |
mbedAustin | 11:cada08fc8a70 | 36 | */ |
mbedAustin | 11:cada08fc8a70 | 37 | class RtosTimer { |
mbedAustin | 11:cada08fc8a70 | 38 | public: |
mbedAustin | 11:cada08fc8a70 | 39 | /** Create and Start timer. |
mbedAustin | 11:cada08fc8a70 | 40 | @param task name of the timer call back function. |
mbedAustin | 11:cada08fc8a70 | 41 | @param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic) |
mbedAustin | 11:cada08fc8a70 | 42 | @param argument argument to the timer call back function. (default: NULL) |
mbedAustin | 11:cada08fc8a70 | 43 | */ |
mbedAustin | 11:cada08fc8a70 | 44 | RtosTimer(void (*task)(void const *argument), |
mbedAustin | 11:cada08fc8a70 | 45 | os_timer_type type=osTimerPeriodic, |
mbedAustin | 11:cada08fc8a70 | 46 | void *argument=NULL); |
mbedAustin | 11:cada08fc8a70 | 47 | |
mbedAustin | 11:cada08fc8a70 | 48 | /** Stop the timer. |
mbedAustin | 11:cada08fc8a70 | 49 | @return status code that indicates the execution status of the function. |
mbedAustin | 11:cada08fc8a70 | 50 | */ |
mbedAustin | 11:cada08fc8a70 | 51 | osStatus stop(void); |
mbedAustin | 11:cada08fc8a70 | 52 | |
mbedAustin | 11:cada08fc8a70 | 53 | /** start a timer. |
mbedAustin | 11:cada08fc8a70 | 54 | @param millisec time delay value of the timer. |
mbedAustin | 11:cada08fc8a70 | 55 | @return status code that indicates the execution status of the function. |
mbedAustin | 11:cada08fc8a70 | 56 | */ |
mbedAustin | 11:cada08fc8a70 | 57 | osStatus start(uint32_t millisec); |
mbedAustin | 11:cada08fc8a70 | 58 | |
mbedAustin | 11:cada08fc8a70 | 59 | ~RtosTimer(); |
mbedAustin | 11:cada08fc8a70 | 60 | |
mbedAustin | 11:cada08fc8a70 | 61 | private: |
mbedAustin | 11:cada08fc8a70 | 62 | osTimerId _timer_id; |
mbedAustin | 11:cada08fc8a70 | 63 | osTimerDef_t _timer; |
mbedAustin | 11:cada08fc8a70 | 64 | #ifdef CMSIS_OS_RTX |
mbedAustin | 11:cada08fc8a70 | 65 | uint32_t _timer_data[5]; |
mbedAustin | 11:cada08fc8a70 | 66 | #endif |
mbedAustin | 11:cada08fc8a70 | 67 | }; |
mbedAustin | 11:cada08fc8a70 | 68 | |
mbedAustin | 11:cada08fc8a70 | 69 | } |
mbedAustin | 11:cada08fc8a70 | 70 | |
mbedAustin | 11:cada08fc8a70 | 71 | #endif |