Ok
Dependencies: mbed_rtos_types Mutex mbed_rtos_storage mbed Semaphore
RtosTimer Class Reference
[RtosTimer class]
The RtosTimer class allow creating and and controlling of timer functions in the system. More...
#include <RtosTimer.h>
Inherits mbed::NonCopyable< RtosTimer >.
Public Member Functions | |
| MBED_DEPRECATED_SINCE ("mbed-os-5.1","Replaced with RtosTimer(Callback<void()>, os_timer_type)") MBED_DEPRECATED_SINCE("mbed-os-5.2" | |
| Create timer. | |
| MBED_DEPRECATED_SINCE ("mbed-os-5.2","The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details") RtosTimer(mbed | |
| Create timer. | |
| template<typename T , typename M > | |
| MBED_DEPRECATED_SINCE ("mbed-os-5.1","The RtosTimer constructor does not support cv-qualifiers. Replaced by ""RtosTimer(callback(obj, method), os_timer_type).") MBED_DEPRECATED_SINCE("mbed-os-5.2" | |
| Create timer. | |
| osStatus | stop (void) |
| Stop the timer. | |
| osStatus | start (uint32_t millisec) |
| Start or restart the timer. | |
| ~RtosTimer () | |
| RtosTimer destructor. | |
Detailed Description
The RtosTimer class allow creating and and controlling of timer functions in the system.
A timer function is called when a time period expires whereby both on-shot and periodic timers are possible. A timer can be started, restarted, or stopped.
Timers are handled in the thread osTimerThread. Callback functions run under control of this thread and may use CMSIS-RTOS API calls.
For an example, the following code shows a simple use of the RtosTimer:
DigitalOut led(LED1); void blink() { led = !led; } RtosTimer timer(&blink); int main() { timer.start(1000); // call blink every 1s ThisThread::sleep_for(5000); timer.stop(); // stop after 5s }
This is the above example rewritten to use the EventQueue:
DigitalOut led(LED1); void blink() { led = !led; } EventQueue queue(4*EVENTS_EVENT_SIZE); int main() { int blink_id = queue.call_every(1000, &blink); // call blink every 1s queue.dispatch(5000); queue.cancel(blink_id); // stop after 5s }
- Note:
- Memory considerations: The timer control structures will be created on current thread's stack, both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
Definition at line 89 of file RtosTimer.h.
Constructor & Destructor Documentation
Member Function Documentation
| MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1" | , |
| "Replaced with RtosTimer(Callback<void()>, os_timer_type)" | |||
| ) |
Create timer.
- Parameters:
-
func function to be executed by this timer. type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior. (default: osTimerPeriodic) argument argument to the timer call back function. (default: nullptr)
- Note:
- You cannot call this function from ISR context.
| MBED_DEPRECATED_SINCE | ( | "mbed-os-5.2" | , |
| "The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details" | |||
| ) |
Create timer.
- Parameters:
-
func function to be executed by this timer. type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior. (default: osTimerPeriodic)
- Note:
- You cannot call this function from ISR context.
Definition at line 118 of file RtosTimer.h.
| MBED_DEPRECATED_SINCE | ( | "mbed-os-5.1" | , |
| "The RtosTimer constructor does not support cv-qualifiers. Replaced by ""RtosTimer(callback(obj, method), os_timer_type)." | |||
| ) |
Create timer.
- Parameters:
-
obj pointer to the object to call the member function on. method member function to be executed by this timer. type osTimerOnce for one-shot or osTimerPeriodic for periodic behavior. (default: osTimerPeriodic)
- Note:
- You cannot call this function from ISR context.
| osStatus start | ( | uint32_t | millisec ) |
Start or restart the timer.
- Parameters:
-
millisec non-zero value of the timer.
- Returns:
- status code that indicates the execution status of the function: osOK the timer has been started or restarted. osErrorISR start cannot be called from interrupt service routines. osErrorParameter internal error or incorrect parameter value. osErrorResource internal error (the timer is in an invalid timer state).
- Note:
- You cannot call this function from ISR context.
| osStatus stop | ( | void | ) |
Stop the timer.
- Returns:
- status code that indicates the execution status of the function: osOK the timer has been stopped. osErrorISR stop cannot be called from interrupt service routines. osErrorParameter internal error. osErrorResource the timer is not running.
- Note:
- You cannot call this function from ISR context.
Generated on Tue Jul 12 2022 22:06:19 by
1.7.2