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