Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
RtosTimer Class Reference
[Rtos]
The RtosTimer class allow creating and and controlling of timer functions in the system. More...
#include <RtosTimer.h>
Inherits 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. |
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 wait_ms(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 83 of file RtosTimer.h.
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 behaviour. (default: osTimerPeriodic) argument argument to the timer call back function. (default: NULL)
Generated on Tue Jul 12 2022 20:03:34 by
