Skip to content

Commit 048a47b

Browse files
committed
Marked the RtosTimer class as deprecated
The non-irq timer functionality provided by the RtosTimer is now duplicated by the EventQueue. See RtosTimer.h for more info.
1 parent 79abaab commit 048a47b

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

rtos/RtosTimer.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,41 @@ namespace rtos {
3737
3838
Timers are handled in the thread osTimerThread.
3939
Callback functions run under control of this thread and may use CMSIS-RTOS API calls.
40+
41+
@deprecated
42+
The RtosTimer has been superseded by the EventQueue. The RtosTimer and EventQueue duplicate
43+
the functionality of timing events outside of interrupt context, however the EventQueue
44+
has additional features to handle deferring other events to multiple contexts.
45+
46+
For an example, the following code shows a simple use of the RtosTimer:
47+
@code
48+
DigitalOut led(LED1);
49+
void blink() {
50+
led = !led;
51+
}
52+
53+
RtosTimer timer(&blink);
54+
int main() {
55+
timer.start(1000); // call blink every 1s
56+
wait_ms(5000);
57+
timer.stop(); // stop after 5s
58+
}
59+
@endcode
60+
61+
This is the above example rewritten to use the EventQueue:
62+
@code
63+
DigitalOut led(LED1);
64+
void blink() {
65+
led = !led;
66+
}
67+
68+
EventQueue queue(4*EVENTS_EVENT_SIZE);
69+
int main() {
70+
int blink_id = queue.call_every(1000, &blink); // call blink every 1s
71+
queue.dispatch(5000);
72+
queue.cancel(blink_id); // stop after 5s
73+
}
74+
@endcode
4075
*/
4176
class RtosTimer {
4277
public:
@@ -45,17 +80,25 @@ class RtosTimer {
4580
@param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
4681
@param argument argument to the timer call back function. (default: NULL)
4782
@deprecated Replaced with RtosTimer(Callback<void()>, os_timer_type)
83+
@deprecated
84+
The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details
4885
*/
4986
MBED_DEPRECATED_SINCE("mbed-os-5.1",
5087
"Replaced with RtosTimer(Callback<void()>, os_timer_type)")
88+
MBED_DEPRECATED_SINCE("mbed-os-5.2",
89+
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
5190
RtosTimer(void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL) {
5291
constructor(mbed::callback((void (*)(void *))func, argument), type);
5392
}
5493

5594
/** Create timer.
5695
@param func function to be executed by this timer.
5796
@param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
97+
@deprecated
98+
The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details
5899
*/
100+
MBED_DEPRECATED_SINCE("mbed-os-5.2",
101+
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
59102
RtosTimer(mbed::Callback<void()> func, os_timer_type type=osTimerPeriodic) {
60103
constructor(func, type);
61104
}
@@ -67,11 +110,15 @@ class RtosTimer {
67110
@deprecated
68111
The RtosTimer constructor does not support cv-qualifiers. Replaced by
69112
RtosTimer(callback(obj, method), os_timer_type).
113+
@deprecated
114+
The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details
70115
*/
71116
template <typename T, typename M>
72117
MBED_DEPRECATED_SINCE("mbed-os-5.1",
73118
"The RtosTimer constructor does not support cv-qualifiers. Replaced by "
74119
"RtosTimer(callback(obj, method), os_timer_type).")
120+
MBED_DEPRECATED_SINCE("mbed-os-5.2",
121+
"The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details")
75122
RtosTimer(T *obj, M method, os_timer_type type=osTimerPeriodic) {
76123
constructor(mbed::callback(obj, method), type);
77124
}

0 commit comments

Comments
 (0)