Embedded Template Library 1.0
Loading...
Searching...
No Matches
callback_timer.h
1/******************************************************************************
2The MIT License(MIT)
3
4Embedded Template Library.
5https://github.com/ETLCPP/etl
6https://www.etlcpp.com
7
8Copyright(c) 2017 John Wellbelove
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files(the "Software"), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions :
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27******************************************************************************/
28
29#ifndef ETL_CALLBACK_TIMER_INCLUDED
30#define ETL_CALLBACK_TIMER_INCLUDED
31
32#include "platform.h"
33#include "algorithm.h"
34#include "atomic.h"
35#include "delegate.h"
36#include "error_handler.h"
37#include "function.h"
38#include "nullptr.h"
39#include "placement_new.h"
40#include "static_assert.h"
41#include "timer.h"
42
43#include <stdint.h>
44
45#if defined(ETL_IN_UNIT_TEST) && ETL_NOT_USING_STL
46 #define ETL_DISABLE_TIMER_UPDATES
47 #define ETL_ENABLE_TIMER_UPDATES
48 #define ETL_TIMER_UPDATES_ENABLED true
49
50 #undef ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
51 #undef ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK
52#else
53 #if !defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && !defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK)
54 #error ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK not defined
55 #endif
56
57 #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK) && defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK)
58 #error Only define one of ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK or ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK
59 #endif
60
61 #if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK)
62 #define ETL_DISABLE_TIMER_UPDATES (++process_semaphore)
63 #define ETL_ENABLE_TIMER_UPDATES (--process_semaphore)
64 #define ETL_TIMER_UPDATES_ENABLED (process_semaphore.load() == 0)
65 #endif
66#endif
67
68#if defined(ETL_CALLBACK_TIMER_USE_INTERRUPT_LOCK)
69 #if !defined(ETL_CALLBACK_TIMER_DISABLE_INTERRUPTS) || !defined(ETL_CALLBACK_TIMER_ENABLE_INTERRUPTS)
70 #error ETL_CALLBACK_TIMER_DISABLE_INTERRUPTS and/or ETL_CALLBACK_TIMER_ENABLE_INTERRUPTS not defined
71 #endif
72
73 #define ETL_DISABLE_TIMER_UPDATES ETL_CALLBACK_TIMER_DISABLE_INTERRUPTS
74 #define ETL_ENABLE_TIMER_UPDATES ETL_CALLBACK_TIMER_ENABLE_INTERRUPTS
75 #define ETL_TIMER_UPDATES_ENABLED true
76#endif
77
78namespace etl
79{
80 //***************************************************************************
82 //***************************************************************************
84 {
85 public:
86
87 typedef etl::delegate<void(void)> callback_type;
88
89 typedef etl::delegate<void(etl::timer::id::type)> event_callback_type;
90
91 //*******************************************
93 //*******************************************
94 etl::timer::id::type register_timer(void (*p_callback_)(), uint32_t period_, bool repeating_)
95 {
96 etl::timer::id::type id = etl::timer::id::NO_TIMER;
97
98 bool is_space = (registered_timers < MAX_TIMERS);
99
100 if (is_space)
101 {
102 // Search for the free space.
103 for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i)
104 {
105 timer_data& timer = timer_array[i];
106
107 if (timer.id == etl::timer::id::NO_TIMER)
108 {
109 // Create in-place.
110 new (&timer) timer_data(i, p_callback_, period_, repeating_);
111 ++registered_timers;
112 id = i;
113 break;
114 }
115 }
116 }
117
118 return id;
119 }
120
121 //*******************************************
123 //*******************************************
124 etl::timer::id::type register_timer(etl::ifunction<void>& callback_, uint32_t period_, bool repeating_)
125 {
126 etl::timer::id::type id = etl::timer::id::NO_TIMER;
127
128 bool is_space = (registered_timers < MAX_TIMERS);
129
130 if (is_space)
131 {
132 // Search for the free space.
133 for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i)
134 {
135 timer_data& timer = timer_array[i];
136
137 if (timer.id == etl::timer::id::NO_TIMER)
138 {
139 // Create in-place.
140 new (&timer) timer_data(i, callback_, period_, repeating_);
141 ++registered_timers;
142 id = i;
143 break;
144 }
145 }
146 }
147
148 return id;
149 }
150
151 //*******************************************
153 //*******************************************
154#if ETL_USING_CPP11
155 etl::timer::id::type register_timer(callback_type& callback_, uint32_t period_, bool repeating_)
156 {
157 etl::timer::id::type id = etl::timer::id::NO_TIMER;
158
159 bool is_space = (registered_timers < MAX_TIMERS);
160
161 if (is_space)
162 {
163 // Search for the free space.
164 for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i)
165 {
166 timer_data& timer = timer_array[i];
167
168 if (timer.id == etl::timer::id::NO_TIMER)
169 {
170 // Create in-place.
171 new (&timer) timer_data(i, callback_, period_, repeating_);
172 ++registered_timers;
173 id = i;
174 break;
175 }
176 }
177 }
178
179 return id;
180 }
181#endif
182
183 //*******************************************
185 //*******************************************
186 bool unregister_timer(etl::timer::id::type id_)
187 {
188 bool result = false;
189
190 if (id_ != etl::timer::id::NO_TIMER)
191 {
192 timer_data& timer = timer_array[id_];
193
194 if (timer.id != etl::timer::id::NO_TIMER)
195 {
196 if (timer.is_active())
197 {
198 ETL_DISABLE_TIMER_UPDATES;
199 active_list.remove(timer.id, false);
200 remove_callback.call_if(timer.id);
201 ETL_ENABLE_TIMER_UPDATES;
202 }
203
204 // Reset in-place.
205 new (&timer) timer_data();
206 --registered_timers;
207
208 result = true;
209 }
210 }
211
212 return result;
213 }
214
215 //*******************************************
217 //*******************************************
218 void enable(bool state_)
219 {
220 enabled = state_;
221 }
222
223 //*******************************************
225 //*******************************************
226 bool is_running() const
227 {
228 return enabled;
229 }
230
231 //*******************************************
233 //*******************************************
234 void clear()
235 {
236 ETL_DISABLE_TIMER_UPDATES;
237 active_list.clear();
238 ETL_ENABLE_TIMER_UPDATES;
239
240 for (int i = 0; i < MAX_TIMERS; ++i)
241 {
242 ::new (&timer_array[i]) timer_data();
243 }
244
245 registered_timers = 0;
246 }
247
248 //*******************************************
249 // Called by the timer service to indicate the
250 // amount of time that has elapsed since the last successful call to 'tick'.
251 // Returns true if the tick was processed,
252 // false if not.
253 //*******************************************
254 bool tick(uint32_t count)
255 {
256 if (enabled)
257 {
258 if (ETL_TIMER_UPDATES_ENABLED)
259 {
260 // We have something to do?
261 bool has_active = !active_list.empty();
262
263 if (has_active)
264 {
265 while (has_active && (count >= active_list.front().delta))
266 {
267 timer_data& timer = active_list.front();
268
269 count -= timer.delta;
270
271 active_list.remove(timer.id, true);
272 remove_callback.call_if(timer.id);
273
274 if (timer.repeating)
275 {
276 // Reinsert the timer.
277 timer.delta = timer.period;
278 active_list.insert(timer.id);
279 insert_callback.call_if(timer.id);
280 }
281
282 if (timer.p_callback != ETL_NULLPTR)
283 {
284 if (timer.cbk_type == timer_data::C_CALLBACK)
285 {
286 // Call the C callback.
287 reinterpret_cast<void (*)()>(timer.p_callback)();
288 }
289 else if (timer.cbk_type == timer_data::IFUNCTION)
290 {
291 // Call the function wrapper callback.
292 (*reinterpret_cast<etl::ifunction<void>*>(timer.p_callback))();
293 }
294 else if (timer.cbk_type == timer_data::DELEGATE)
295 {
296 // Call the delegate callback.
297 (*reinterpret_cast<callback_type*>(timer.p_callback))();
298 }
299 }
300
301 has_active = !active_list.empty();
302 }
303
304 if (has_active)
305 {
306 // Subtract any remainder from the next due timeout.
307 active_list.front().delta -= count;
308 }
309 }
310
311 return true;
312 }
313 }
314
315 return false;
316 }
317
318 //*******************************************
320 //*******************************************
321 bool start(etl::timer::id::type id_, bool immediate_ = false)
322 {
323 bool result = false;
324
325 // Valid timer id?
326 if (id_ != etl::timer::id::NO_TIMER)
327 {
328 timer_data& timer = timer_array[id_];
329
330 // Registered timer?
331 if (timer.id != etl::timer::id::NO_TIMER)
332 {
333 // Has a valid period.
334 if (timer.period != etl::timer::state::Inactive)
335 {
336 ETL_DISABLE_TIMER_UPDATES;
337 if (timer.is_active())
338 {
339 active_list.remove(timer.id, false);
340 remove_callback.call_if(timer.id);
341 }
342
343 timer.delta = immediate_ ? 0 : timer.period;
344 active_list.insert(timer.id);
345 insert_callback.call_if(timer.id);
346 ETL_ENABLE_TIMER_UPDATES;
347
348 result = true;
349 }
350 }
351 }
352
353 return result;
354 }
355
356 //*******************************************
358 //*******************************************
359 bool stop(etl::timer::id::type id_)
360 {
361 bool result = false;
362
363 // Valid timer id?
364 if (id_ != etl::timer::id::NO_TIMER)
365 {
366 timer_data& timer = timer_array[id_];
367
368 // Registered timer?
369 if (timer.id != etl::timer::id::NO_TIMER)
370 {
371 if (timer.is_active())
372 {
373 ETL_DISABLE_TIMER_UPDATES;
374 active_list.remove(timer.id, false);
375 remove_callback.call_if(timer.id);
376 ETL_ENABLE_TIMER_UPDATES;
377 }
378
379 result = true;
380 }
381 }
382
383 return result;
384 }
385
386 //*******************************************
388 //*******************************************
389 bool set_period(etl::timer::id::type id_, uint32_t period_)
390 {
391 if (stop(id_))
392 {
393 timer_array[id_].period = period_;
394 return true;
395 }
396
397 return false;
398 }
399
400 //*******************************************
402 //*******************************************
403 bool set_mode(etl::timer::id::type id_, bool repeating_)
404 {
405 if (stop(id_))
406 {
407 timer_array[id_].repeating = repeating_;
408 return true;
409 }
410
411 return false;
412 }
413
414 //*******************************************
416 //*******************************************
417 bool has_active_timer() const
418 {
419 return !active_list.empty();
420 }
421
422 //*******************************************
426 //*******************************************
427 uint32_t time_to_next() const
428 {
429 uint32_t delta = static_cast<uint32_t>(etl::timer::interval::No_Active_Interval);
430
431 if (has_active_timer())
432 {
433 delta = active_list.front().delta;
434 }
435
436 return delta;
437 }
438
439 //*******************************************
442 //*******************************************
443 bool is_active(etl::timer::id::type id_) const
444 {
445 // Valid timer id?
446 if (is_valid_timer_id(id_))
447 {
448 if (has_active_timer())
449 {
450 const timer_data& timer = timer_array[id_];
451
452 // Registered timer?
453 if (timer.id != etl::timer::id::NO_TIMER)
454 {
455 return timer.is_active();
456 }
457 }
458 }
459
460 return false;
461 }
462
463 //*******************************************
465 //*******************************************
466 void set_insert_callback(event_callback_type insert_)
467 {
468 insert_callback = insert_;
469 }
470
471 //*******************************************
473 //*******************************************
474 void set_remove_callback(event_callback_type remove_)
475 {
476 remove_callback = remove_;
477 }
478
479 //*******************************************
480 void clear_insert_callback()
481 {
482 insert_callback.clear();
483 }
484
485 //*******************************************
486 void clear_remove_callback()
487 {
488 remove_callback.clear();
489 }
490
491 protected:
492
493 //*************************************************************************
495 struct timer_data
496 {
497 typedef etl::delegate<void(void)> callback_type;
498
499 enum callback_type_id
500 {
501 C_CALLBACK,
502 IFUNCTION,
503 DELEGATE
504 };
505
506 //*******************************************
507 timer_data()
508 : p_callback(ETL_NULLPTR)
509 , period(0)
510 , delta(etl::timer::state::Inactive)
511 , id(etl::timer::id::NO_TIMER)
512 , previous(etl::timer::id::NO_TIMER)
513 , next(etl::timer::id::NO_TIMER)
514 , repeating(true)
515 , cbk_type(IFUNCTION)
516 {
517 }
518
519 //*******************************************
521 //*******************************************
522 timer_data(etl::timer::id::type id_, void (*p_callback_)(), uint32_t period_, bool repeating_)
523 : p_callback(reinterpret_cast<void*>(p_callback_))
524 , period(period_)
525 , delta(etl::timer::state::Inactive)
526 , id(id_)
527 , previous(etl::timer::id::NO_TIMER)
528 , next(etl::timer::id::NO_TIMER)
529 , repeating(repeating_)
530 , cbk_type(C_CALLBACK)
531 {
532 }
533
534 //*******************************************
536 //*******************************************
537 timer_data(etl::timer::id::type id_, etl::ifunction<void>& callback_, uint32_t period_, bool repeating_)
538 : p_callback(reinterpret_cast<void*>(&callback_))
539 , period(period_)
540 , delta(etl::timer::state::Inactive)
541 , id(id_)
542 , previous(etl::timer::id::NO_TIMER)
543 , next(etl::timer::id::NO_TIMER)
544 , repeating(repeating_)
545 , cbk_type(IFUNCTION)
546 {
547 }
548
549 //*******************************************
551 //*******************************************
552 timer_data(etl::timer::id::type id_, callback_type& callback_, uint32_t period_, bool repeating_)
553 : p_callback(reinterpret_cast<void*>(&callback_))
554 , period(period_)
555 , delta(etl::timer::state::Inactive)
556 , id(id_)
557 , previous(etl::timer::id::NO_TIMER)
558 , next(etl::timer::id::NO_TIMER)
559 , repeating(repeating_)
560 , cbk_type(DELEGATE)
561 {
562 }
563
564 //*******************************************
566 //*******************************************
567 bool is_active() const
568 {
569 return delta != etl::timer::state::Inactive;
570 }
571
572 //*******************************************
574 //*******************************************
576 {
577 delta = etl::timer::state::Inactive;
578 }
579
580 void* p_callback;
581 uint32_t period;
582 uint32_t delta;
583 etl::timer::id::type id;
584 uint_least8_t previous;
585 uint_least8_t next;
586 bool repeating;
587 callback_type_id cbk_type;
588
589 private:
590
591 // Disabled.
592 timer_data(const timer_data& other);
593 timer_data& operator=(const timer_data& other);
594 };
595
596 //*******************************************
598 //*******************************************
599 icallback_timer(timer_data* const timer_array_, const uint_least8_t Max_Timers_)
600 : timer_array(timer_array_)
601 , active_list(timer_array_)
602 , enabled(false)
603 ,
604#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK)
605 process_semaphore(0)
606 ,
607#endif
608 registered_timers(0)
609 , MAX_TIMERS(Max_Timers_)
610 {
611 }
612
613 private:
614
615 //*******************************************
617 //*******************************************
618 bool is_valid_timer_id(etl::timer::id::type id_) const
619 {
620 return (id_ < MAX_TIMERS);
621 }
622
623 //*************************************************************************
624 class timer_list
625 {
626 public:
627
628 //*******************************
629 timer_list(timer_data* ptimers_)
630 : head(etl::timer::id::NO_TIMER)
631 , tail(etl::timer::id::NO_TIMER)
632 , current(etl::timer::id::NO_TIMER)
633 , ptimers(ptimers_)
634 {
635 }
636
637 //*******************************
638 bool empty() const
639 {
640 return head == etl::timer::id::NO_TIMER;
641 }
642
643 //*******************************
644 // Inserts the timer at the correct delta position
645 //*******************************
646 void insert(etl::timer::id::type id_)
647 {
648 timer_data& timer = ptimers[id_];
649
650 if (head == etl::timer::id::NO_TIMER)
651 {
652 // No entries yet.
653 head = id_;
654 tail = id_;
655 timer.previous = etl::timer::id::NO_TIMER;
656 timer.next = etl::timer::id::NO_TIMER;
657 }
658 else
659 {
660 // We already have entries.
661 etl::timer::id::type test_id = begin();
662
663 while (test_id != etl::timer::id::NO_TIMER)
664 {
665 timer_data& test = ptimers[test_id];
666
667 // Find the correct place to insert.
668 if (timer.delta <= test.delta)
669 {
670 if (test.id == head)
671 {
672 head = timer.id;
673 }
674
675 // Insert before test.
676 timer.previous = test.previous;
677 test.previous = timer.id;
678 timer.next = test.id;
679
680 // Adjust the next delta to compensate.
681 test.delta -= timer.delta;
682
683 if (timer.previous != etl::timer::id::NO_TIMER)
684 {
685 ptimers[timer.previous].next = timer.id;
686 }
687 break;
688 }
689 else
690 {
691 timer.delta -= test.delta;
692 }
693
694 test_id = next(test_id);
695 }
696
697 // Reached the end?
698 if (test_id == etl::timer::id::NO_TIMER)
699 {
700 // Tag on to the tail.
701 ptimers[tail].next = timer.id;
702 timer.previous = tail;
703 timer.next = etl::timer::id::NO_TIMER;
704 tail = timer.id;
705 }
706 }
707 }
708
709 //*******************************
710 void remove(etl::timer::id::type id_, bool has_expired)
711 {
712 timer_data& timer = ptimers[id_];
713
714 if (head == id_)
715 {
716 head = timer.next;
717 }
718 else
719 {
720 ptimers[timer.previous].next = timer.next;
721 }
722
723 if (tail == id_)
724 {
725 tail = timer.previous;
726 }
727 else
728 {
729 ptimers[timer.next].previous = timer.previous;
730 }
731
732 if (!has_expired)
733 {
734 // Adjust the next delta.
735 if (timer.next != etl::timer::id::NO_TIMER)
736 {
737 ptimers[timer.next].delta += timer.delta;
738 }
739 }
740
741 timer.previous = etl::timer::id::NO_TIMER;
742 timer.next = etl::timer::id::NO_TIMER;
743 timer.delta = etl::timer::state::Inactive;
744 }
745
746 //*******************************
747 timer_data& front()
748 {
749 return ptimers[head];
750 }
751
752 //*******************************
753 const timer_data& front() const
754 {
755 return ptimers[head];
756 }
757
758 //*******************************
759 etl::timer::id::type begin()
760 {
761 current = head;
762 return current;
763 }
764
765 //*******************************
766 etl::timer::id::type previous(etl::timer::id::type last)
767 {
768 current = ptimers[last].previous;
769 return current;
770 }
771
772 //*******************************
773 etl::timer::id::type next(etl::timer::id::type last)
774 {
775 current = ptimers[last].next;
776 return current;
777 }
778
779 //*******************************
780 void clear()
781 {
782 etl::timer::id::type id = begin();
783
784 while (id != etl::timer::id::NO_TIMER)
785 {
786 timer_data& timer = ptimers[id];
787 id = next(id);
788 timer.next = etl::timer::id::NO_TIMER;
789 }
790
791 head = etl::timer::id::NO_TIMER;
792 tail = etl::timer::id::NO_TIMER;
793 current = etl::timer::id::NO_TIMER;
794 }
795
796 private:
797
798 etl::timer::id::type head;
799 etl::timer::id::type tail;
800 etl::timer::id::type current;
801
802 timer_data* const ptimers;
803 };
804
805 // The array of timer data structures.
806 timer_data* const timer_array;
807
808 // The list of active timers.
809 timer_list active_list;
810
811 volatile bool enabled;
812#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK)
813
814 #if defined(ETL_TIMER_SEMAPHORE_TYPE)
815 typedef ETL_TIMER_SEMAPHORE_TYPE timer_semaphore_t;
816 #else
817 #if ETL_HAS_ATOMIC
818 typedef etl::atomic_uint16_t timer_semaphore_t;
819 #else
820 #error No atomic type available
821 #endif
822 #endif
823
824 mutable etl::timer_semaphore_t process_semaphore;
825#endif
826 uint_least8_t registered_timers;
827
828 event_callback_type insert_callback;
829 event_callback_type remove_callback;
830
831 public:
832
833 const uint_least8_t MAX_TIMERS;
834 };
835
836 //***************************************************************************
838 //***************************************************************************
839 template <const uint_least8_t Max_Timers_>
841 {
842 public:
843
844 ETL_STATIC_ASSERT(Max_Timers_ <= 254, "No more than 254 timers are allowed");
845
846 //*******************************************
848 //*******************************************
850 : icallback_timer(timer_array, Max_Timers_)
851 {
852 }
853
854 private:
855
856 timer_data timer_array[Max_Timers_];
857 };
858} // namespace etl
859
860#undef ETL_DISABLE_TIMER_UPDATES
861#undef ETL_ENABLE_TIMER_UPDATES
862#undef ETL_TIMER_UPDATES_ENABLED
863
864#endif
callback_timer()
Constructor.
Definition callback_timer.h:849
Declaration.
Definition delegate_cpp03.h:191
Interface for callback timer.
Definition callback_timer.h:84
bool unregister_timer(etl::timer::id::type id_)
Register a timer.
Definition callback_timer.h:186
bool is_running() const
Get the enable/disable state.
Definition callback_timer.h:226
bool set_period(etl::timer::id::type id_, uint32_t period_)
Sets a timer's period.
Definition callback_timer.h:389
etl::timer::id::type register_timer(void(*p_callback_)(), uint32_t period_, bool repeating_)
Register a timer.
Definition callback_timer.h:94
void set_insert_callback(event_callback_type insert_)
Set a callback when a timer is inserted on list.
Definition callback_timer.h:466
bool start(etl::timer::id::type id_, bool immediate_=false)
Starts a timer.
Definition callback_timer.h:321
bool set_mode(etl::timer::id::type id_, bool repeating_)
Sets a timer's mode.
Definition callback_timer.h:403
uint32_t time_to_next() const
Definition callback_timer.h:427
bool has_active_timer() const
Check if there is an active timer.
Definition callback_timer.h:417
void set_remove_callback(event_callback_type remove_)
Set a callback when a timer is removed from list.
Definition callback_timer.h:474
bool stop(etl::timer::id::type id_)
Stops a timer.
Definition callback_timer.h:359
void enable(bool state_)
Enable/disable the timer.
Definition callback_timer.h:218
etl::timer::id::type register_timer(etl::ifunction< void > &callback_, uint32_t period_, bool repeating_)
Register a timer.
Definition callback_timer.h:124
bool is_active(etl::timer::id::type id_) const
Definition callback_timer.h:443
icallback_timer(timer_data *const timer_array_, const uint_least8_t Max_Timers_)
Constructor.
Definition callback_timer.h:599
void clear()
Clears the timer of data.
Definition callback_timer.h:234
Definition function.h:54
bitset_ext
Definition absolute.h:40
The configuration of a timer.
Definition callback_timer.h:496
timer_data(etl::timer::id::type id_, callback_type &callback_, uint32_t period_, bool repeating_)
ETL delegate callback.
Definition callback_timer.h:552
bool is_active() const
Returns true if the timer is active.
Definition callback_timer.h:567
void set_inactive()
Sets the timer to the inactive state.
Definition callback_timer.h:575
timer_data(etl::timer::id::type id_, etl::ifunction< void > &callback_, uint32_t period_, bool repeating_)
ETL function callback.
Definition callback_timer.h:537
timer_data(etl::timer::id::type id_, void(*p_callback_)(), uint32_t period_, bool repeating_)
C function callback.
Definition callback_timer.h:522
Definition timer.h:88
Common definitions for the timer framework.
Definition timer.h:55