@@ -37,6 +37,41 @@ namespace rtos {
37
37
38
38
Timers are handled in the thread osTimerThread.
39
39
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
40
75
*/
41
76
class RtosTimer {
42
77
public:
@@ -45,17 +80,25 @@ class RtosTimer {
45
80
@param type osTimerOnce for one-shot or osTimerPeriodic for periodic behaviour. (default: osTimerPeriodic)
46
81
@param argument argument to the timer call back function. (default: NULL)
47
82
@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
48
85
*/
49
86
MBED_DEPRECATED_SINCE (" mbed-os-5.1" ,
50
87
" 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" )
51
90
RtosTimer (void (*func)(void const *argument), os_timer_type type=osTimerPeriodic, void *argument=NULL ) {
52
91
constructor (mbed::callback ((void (*)(void *))func, argument), type);
53
92
}
54
93
55
94
/* * Create timer.
56
95
@param func function to be executed by this timer.
57
96
@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
58
99
*/
100
+ MBED_DEPRECATED_SINCE (" mbed-os-5.2" ,
101
+ " The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details" )
59
102
RtosTimer (mbed::Callback<void ()> func, os_timer_type type=osTimerPeriodic) {
60
103
constructor (func, type);
61
104
}
@@ -67,11 +110,15 @@ class RtosTimer {
67
110
@deprecated
68
111
The RtosTimer constructor does not support cv-qualifiers. Replaced by
69
112
RtosTimer(callback(obj, method), os_timer_type).
113
+ @deprecated
114
+ The RtosTimer has been superseded by the EventQueue. See RtosTimer.h for more details
70
115
*/
71
116
template <typename T, typename M>
72
117
MBED_DEPRECATED_SINCE (" mbed-os-5.1" ,
73
118
" The RtosTimer constructor does not support cv-qualifiers. Replaced by "
74
119
" 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" )
75
122
RtosTimer (T *obj, M method, os_timer_type type=osTimerPeriodic) {
76
123
constructor (mbed::callback (obj, method), type);
77
124
}
0 commit comments