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 "nullptr.h"
35#include "function.h"
36#include "static_assert.h"
37#include "timer.h"
38#include "atomic.h"
39#include "error_handler.h"
40#include "placement_new.h"
41#include "delegate.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_)(),
95 uint32_t period_,
96 bool repeating_)
97 {
98 etl::timer::id::type id = etl::timer::id::NO_TIMER;
99
100 bool is_space = (registered_timers < MAX_TIMERS);
101
102 if (is_space)
103 {
104 // Search for the free space.
105 for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i)
106 {
107 timer_data& timer = timer_array[i];
108
109 if (timer.id == etl::timer::id::NO_TIMER)
110 {
111 // Create in-place.
112 new (&timer) timer_data(i, p_callback_, period_, repeating_);
113 ++registered_timers;
114 id = i;
115 break;
116 }
117 }
118 }
119
120 return id;
121 }
122
123 //*******************************************
125 //*******************************************
126 etl::timer::id::type register_timer(etl::ifunction<void>& callback_,
127 uint32_t period_,
128 bool repeating_)
129 {
130 etl::timer::id::type id = etl::timer::id::NO_TIMER;
131
132 bool is_space = (registered_timers < MAX_TIMERS);
133
134 if (is_space)
135 {
136 // Search for the free space.
137 for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i)
138 {
139 timer_data& timer = timer_array[i];
140
141 if (timer.id == etl::timer::id::NO_TIMER)
142 {
143 // Create in-place.
144 new (&timer) timer_data(i, callback_, period_, repeating_);
145 ++registered_timers;
146 id = i;
147 break;
148 }
149 }
150 }
151
152 return id;
153 }
154
155 //*******************************************
157 //*******************************************
158#if ETL_USING_CPP11
159 etl::timer::id::type register_timer(callback_type& callback_,
160 uint32_t period_,
161 bool repeating_)
162 {
163 etl::timer::id::type id = etl::timer::id::NO_TIMER;
164
165 bool is_space = (registered_timers < MAX_TIMERS);
166
167 if (is_space)
168 {
169 // Search for the free space.
170 for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i)
171 {
172 timer_data& timer = timer_array[i];
173
174 if (timer.id == etl::timer::id::NO_TIMER)
175 {
176 // Create in-place.
177 new (&timer) timer_data(i, callback_, period_, repeating_);
178 ++registered_timers;
179 id = i;
180 break;
181 }
182 }
183 }
184
185 return id;
186 }
187#endif
188
189 //*******************************************
191 //*******************************************
192 bool unregister_timer(etl::timer::id::type id_)
193 {
194 bool result = false;
195
196 if (id_ != etl::timer::id::NO_TIMER)
197 {
198 timer_data& timer = timer_array[id_];
199
200 if (timer.id != etl::timer::id::NO_TIMER)
201 {
202 if (timer.is_active())
203 {
204 ETL_DISABLE_TIMER_UPDATES;
205 active_list.remove(timer.id, false);
206 remove_callback.call_if(timer.id);
207 ETL_ENABLE_TIMER_UPDATES;
208 }
209
210 // Reset in-place.
211 new (&timer) timer_data();
212 --registered_timers;
213
214 result = true;
215 }
216 }
217
218 return result;
219 }
220
221 //*******************************************
223 //*******************************************
224 void enable(bool state_)
225 {
226 enabled = state_;
227 }
228
229 //*******************************************
231 //*******************************************
232 bool is_running() const
233 {
234 return enabled;
235 }
236
237 //*******************************************
239 //*******************************************
240 void clear()
241 {
242 ETL_DISABLE_TIMER_UPDATES;
243 active_list.clear();
244 ETL_ENABLE_TIMER_UPDATES;
245
246 for (int i = 0; i < MAX_TIMERS; ++i)
247 {
248 ::new (&timer_array[i]) timer_data();
249 }
250
251 registered_timers = 0;
252 }
253
254 //*******************************************
255 // Called by the timer service to indicate the
256 // amount of time that has elapsed since the last successful call to 'tick'.
257 // Returns true if the tick was processed,
258 // false if not.
259 //*******************************************
260 bool tick(uint32_t count)
261 {
262 if (enabled)
263 {
264 if (ETL_TIMER_UPDATES_ENABLED)
265 {
266 // We have something to do?
267 bool has_active = !active_list.empty();
268
269 if (has_active)
270 {
271 while (has_active && (count >= active_list.front().delta))
272 {
273 timer_data& timer = active_list.front();
274
275 count -= timer.delta;
276
277 active_list.remove(timer.id, true);
278 remove_callback.call_if(timer.id);
279
280 if (timer.repeating)
281 {
282 // Reinsert the timer.
283 timer.delta = timer.period;
284 active_list.insert(timer.id);
285 insert_callback.call_if(timer.id);
286 }
287
288 if (timer.p_callback != ETL_NULLPTR)
289 {
290 if (timer.cbk_type == timer_data::C_CALLBACK)
291 {
292 // Call the C callback.
293 reinterpret_cast<void(*)()>(timer.p_callback)();
294 }
295 else if(timer.cbk_type == timer_data::IFUNCTION)
296 {
297 // Call the function wrapper callback.
298 (*reinterpret_cast<etl::ifunction<void>*>(timer.p_callback))();
299 }
300 else if(timer.cbk_type == timer_data::DELEGATE)
301 {
302 // Call the delegate callback.
303 (*reinterpret_cast<callback_type*>(timer.p_callback))();
304 }
305 }
306
307 has_active = !active_list.empty();
308 }
309
310 if (has_active)
311 {
312 // Subtract any remainder from the next due timeout.
313 active_list.front().delta -= count;
314 }
315 }
316
317 return true;
318 }
319 }
320
321 return false;
322 }
323
324 //*******************************************
326 //*******************************************
327 bool start(etl::timer::id::type id_, bool immediate_ = false)
328 {
329 bool result = false;
330
331 // Valid timer id?
332 if (id_ != etl::timer::id::NO_TIMER)
333 {
334 timer_data& timer = timer_array[id_];
335
336 // Registered timer?
337 if (timer.id != etl::timer::id::NO_TIMER)
338 {
339 // Has a valid period.
340 if (timer.period != etl::timer::state::Inactive)
341 {
342 ETL_DISABLE_TIMER_UPDATES;
343 if (timer.is_active())
344 {
345 active_list.remove(timer.id, false);
346 remove_callback.call_if(timer.id);
347 }
348
349 timer.delta = immediate_ ? 0 : timer.period;
350 active_list.insert(timer.id);
351 insert_callback.call_if(timer.id);
352 ETL_ENABLE_TIMER_UPDATES;
353
354 result = true;
355 }
356 }
357 }
358
359 return result;
360 }
361
362 //*******************************************
364 //*******************************************
365 bool stop(etl::timer::id::type id_)
366 {
367 bool result = false;
368
369 // Valid timer id?
370 if (id_ != etl::timer::id::NO_TIMER)
371 {
372 timer_data& timer = timer_array[id_];
373
374 // Registered timer?
375 if (timer.id != etl::timer::id::NO_TIMER)
376 {
377 if (timer.is_active())
378 {
379 ETL_DISABLE_TIMER_UPDATES;
380 active_list.remove(timer.id, false);
381 remove_callback.call_if(timer.id);
382 ETL_ENABLE_TIMER_UPDATES;
383 }
384
385 result = true;
386 }
387 }
388
389 return result;
390 }
391
392 //*******************************************
394 //*******************************************
395 bool set_period(etl::timer::id::type id_, uint32_t period_)
396 {
397 if (stop(id_))
398 {
399 timer_array[id_].period = period_;
400 return true;
401 }
402
403 return false;
404 }
405
406 //*******************************************
408 //*******************************************
409 bool set_mode(etl::timer::id::type id_, bool repeating_)
410 {
411 if (stop(id_))
412 {
413 timer_array[id_].repeating = repeating_;
414 return true;
415 }
416
417 return false;
418 }
419
420 //*******************************************
422 //*******************************************
423 bool has_active_timer() const
424 {
425 return !active_list.empty();
426 }
427
428 //*******************************************
431 //*******************************************
432 uint32_t time_to_next() const
433 {
434 uint32_t delta = static_cast<uint32_t>(etl::timer::interval::No_Active_Interval);
435
436 if (has_active_timer())
437 {
438 delta = active_list.front().delta;
439 }
440
441 return delta;
442 }
443
444 //*******************************************
447 //*******************************************
448 bool is_active(etl::timer::id::type id_) const
449 {
450 // Valid timer id?
451 if (is_valid_timer_id(id_))
452 {
453 if (has_active_timer())
454 {
455 const timer_data& timer = timer_array[id_];
456
457 // Registered timer?
458 if (timer.id != etl::timer::id::NO_TIMER)
459 {
460 return timer.is_active();
461 }
462 }
463 }
464
465 return false;
466 }
467
468 //*******************************************
470 //*******************************************
471 void set_insert_callback(event_callback_type insert_)
472 {
473 insert_callback = insert_;
474 }
475
476 //*******************************************
478 //*******************************************
479 void set_remove_callback(event_callback_type remove_)
480 {
481 remove_callback = remove_;
482 }
483
484 //*******************************************
485 void clear_insert_callback()
486 {
487 insert_callback.clear();
488 }
489
490 //*******************************************
491 void clear_remove_callback()
492 {
493 remove_callback.clear();
494 }
495
496 protected:
497
498 //*************************************************************************
500 struct timer_data
501 {
502 typedef etl::delegate<void(void)> callback_type;
503
504 enum callback_type_id
505 {
506 C_CALLBACK,
507 IFUNCTION,
508 DELEGATE
509 };
510
511 //*******************************************
512 timer_data()
513 : p_callback(ETL_NULLPTR)
514 , period(0)
515 , delta(etl::timer::state::Inactive)
516 , id(etl::timer::id::NO_TIMER)
517 , previous(etl::timer::id::NO_TIMER)
518 , next(etl::timer::id::NO_TIMER)
519 , repeating(true)
520 , cbk_type(IFUNCTION)
521 {
522 }
523
524 //*******************************************
526 //*******************************************
527 timer_data(etl::timer::id::type id_,
528 void (*p_callback_)(),
529 uint32_t period_,
530 bool repeating_)
531 : p_callback(reinterpret_cast<void*>(p_callback_))
532 , period(period_)
533 , delta(etl::timer::state::Inactive)
534 , id(id_)
535 , previous(etl::timer::id::NO_TIMER)
536 , next(etl::timer::id::NO_TIMER)
537 , repeating(repeating_)
538 , cbk_type(C_CALLBACK)
539 {
540 }
541
542 //*******************************************
544 //*******************************************
545 timer_data(etl::timer::id::type id_,
546 etl::ifunction<void>& callback_,
547 uint32_t period_,
548 bool repeating_)
549 : p_callback(reinterpret_cast<void*>(&callback_))
550 , period(period_)
551 , delta(etl::timer::state::Inactive)
552 , id(id_)
553 , previous(etl::timer::id::NO_TIMER)
554 , next(etl::timer::id::NO_TIMER)
555 , repeating(repeating_)
556 , cbk_type(IFUNCTION)
557 {
558 }
559
560 //*******************************************
562 //*******************************************
563 timer_data(etl::timer::id::type id_,
564 callback_type& callback_,
565 uint32_t period_,
566 bool repeating_)
567 : p_callback(reinterpret_cast<void*>(&callback_)),
568 period(period_),
569 delta(etl::timer::state::Inactive),
570 id(id_),
571 previous(etl::timer::id::NO_TIMER),
572 next(etl::timer::id::NO_TIMER),
573 repeating(repeating_),
574 cbk_type(DELEGATE)
575 {
576 }
577
578 //*******************************************
580 //*******************************************
581 bool is_active() const
582 {
583 return delta != etl::timer::state::Inactive;
584 }
585
586 //*******************************************
588 //*******************************************
590 {
591 delta = etl::timer::state::Inactive;
592 }
593
594 void* p_callback;
595 uint32_t period;
596 uint32_t delta;
597 etl::timer::id::type id;
598 uint_least8_t previous;
599 uint_least8_t next;
600 bool repeating;
601 callback_type_id cbk_type;
602
603 private:
604
605 // Disabled.
606 timer_data(const timer_data& other);
607 timer_data& operator =(const timer_data& other);
608 };
609
610 //*******************************************
612 //*******************************************
613 icallback_timer(timer_data* const timer_array_, const uint_least8_t Max_Timers_)
614 : timer_array(timer_array_),
615 active_list(timer_array_),
616 enabled(false),
617#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK)
618 process_semaphore(0),
619#endif
620 registered_timers(0),
621 MAX_TIMERS(Max_Timers_)
622 {
623 }
624
625 private:
626
627 //*******************************************
629 //*******************************************
630 bool is_valid_timer_id(etl::timer::id::type id_) const
631 {
632 return (id_ < MAX_TIMERS);
633 }
634
635 //*************************************************************************
636 class timer_list
637 {
638 public:
639
640 //*******************************
641 timer_list(timer_data* ptimers_)
642 : head(etl::timer::id::NO_TIMER)
643 , tail(etl::timer::id::NO_TIMER)
644 , current(etl::timer::id::NO_TIMER)
645 , ptimers(ptimers_)
646 {
647 }
648
649 //*******************************
650 bool empty() const
651 {
652 return head == etl::timer::id::NO_TIMER;
653 }
654
655 //*******************************
656 // Inserts the timer at the correct delta position
657 //*******************************
658 void insert(etl::timer::id::type id_)
659 {
660 timer_data& timer = ptimers[id_];
661
662 if (head == etl::timer::id::NO_TIMER)
663 {
664 // No entries yet.
665 head = id_;
666 tail = id_;
667 timer.previous = etl::timer::id::NO_TIMER;
668 timer.next = etl::timer::id::NO_TIMER;
669 }
670 else
671 {
672 // We already have entries.
673 etl::timer::id::type test_id = begin();
674
675 while (test_id != etl::timer::id::NO_TIMER)
676 {
677 timer_data& test = ptimers[test_id];
678
679 // Find the correct place to insert.
680 if (timer.delta <= test.delta)
681 {
682 if (test.id == head)
683 {
684 head = timer.id;
685 }
686
687 // Insert before test.
688 timer.previous = test.previous;
689 test.previous = timer.id;
690 timer.next = test.id;
691
692 // Adjust the next delta to compensate.
693 test.delta -= timer.delta;
694
695 if (timer.previous != etl::timer::id::NO_TIMER)
696 {
697 ptimers[timer.previous].next = timer.id;
698 }
699 break;
700 }
701 else
702 {
703 timer.delta -= test.delta;
704 }
705
706 test_id = next(test_id);
707 }
708
709 // Reached the end?
710 if (test_id == etl::timer::id::NO_TIMER)
711 {
712 // Tag on to the tail.
713 ptimers[tail].next = timer.id;
714 timer.previous = tail;
715 timer.next = etl::timer::id::NO_TIMER;
716 tail = timer.id;
717 }
718 }
719 }
720
721 //*******************************
722 void remove(etl::timer::id::type id_, bool has_expired)
723 {
724 timer_data& timer = ptimers[id_];
725
726 if (head == id_)
727 {
728 head = timer.next;
729 }
730 else
731 {
732 ptimers[timer.previous].next = timer.next;
733 }
734
735 if (tail == id_)
736 {
737 tail = timer.previous;
738 }
739 else
740 {
741 ptimers[timer.next].previous = timer.previous;
742 }
743
744 if (!has_expired)
745 {
746 // Adjust the next delta.
747 if (timer.next != etl::timer::id::NO_TIMER)
748 {
749 ptimers[timer.next].delta += timer.delta;
750 }
751 }
752
753 timer.previous = etl::timer::id::NO_TIMER;
754 timer.next = etl::timer::id::NO_TIMER;
755 timer.delta = etl::timer::state::Inactive;
756 }
757
758 //*******************************
759 timer_data& front()
760 {
761 return ptimers[head];
762 }
763
764 //*******************************
765 const timer_data& front() const
766 {
767 return ptimers[head];
768 }
769
770 //*******************************
771 etl::timer::id::type begin()
772 {
773 current = head;
774 return current;
775 }
776
777 //*******************************
778 etl::timer::id::type previous(etl::timer::id::type last)
779 {
780 current = ptimers[last].previous;
781 return current;
782 }
783
784 //*******************************
785 etl::timer::id::type next(etl::timer::id::type last)
786 {
787 current = ptimers[last].next;
788 return current;
789 }
790
791 //*******************************
792 void clear()
793 {
794 etl::timer::id::type id = begin();
795
796 while (id != etl::timer::id::NO_TIMER)
797 {
798 timer_data& timer = ptimers[id];
799 id = next(id);
800 timer.next = etl::timer::id::NO_TIMER;
801 }
802
803 head = etl::timer::id::NO_TIMER;
804 tail = etl::timer::id::NO_TIMER;
805 current = etl::timer::id::NO_TIMER;
806 }
807
808 private:
809
810 etl::timer::id::type head;
811 etl::timer::id::type tail;
812 etl::timer::id::type current;
813
814 timer_data* const ptimers;
815 };
816
817 // The array of timer data structures.
818 timer_data* const timer_array;
819
820 // The list of active timers.
821 timer_list active_list;
822
823 volatile bool enabled;
824#if defined(ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK)
825
826#if defined(ETL_TIMER_SEMAPHORE_TYPE)
827 typedef ETL_TIMER_SEMAPHORE_TYPE timer_semaphore_t;
828#else
829 #if ETL_HAS_ATOMIC
830 typedef etl::atomic_uint16_t timer_semaphore_t;
831 #else
832 #error No atomic type available
833 #endif
834#endif
835
836 mutable etl::timer_semaphore_t process_semaphore;
837#endif
838 uint_least8_t registered_timers;
839
840 event_callback_type insert_callback;
841 event_callback_type remove_callback;
842
843 public:
844
845 const uint_least8_t MAX_TIMERS;
846 };
847
848 //***************************************************************************
850 //***************************************************************************
851 template <const uint_least8_t Max_Timers_>
853 {
854 public:
855
856 ETL_STATIC_ASSERT(Max_Timers_ <= 254, "No more than 254 timers are allowed");
857
858 //*******************************************
860 //*******************************************
862 : icallback_timer(timer_array, Max_Timers_)
863 {
864 }
865
866 private:
867
868 timer_data timer_array[Max_Timers_];
869 };
870}
871
872#undef ETL_DISABLE_TIMER_UPDATES
873#undef ETL_ENABLE_TIMER_UPDATES
874#undef ETL_TIMER_UPDATES_ENABLED
875
876#endif
callback_timer()
Constructor.
Definition callback_timer.h:861
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:192
bool is_running() const
Get the enable/disable state.
Definition callback_timer.h:232
bool set_period(etl::timer::id::type id_, uint32_t period_)
Sets a timer's period.
Definition callback_timer.h:395
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:471
bool start(etl::timer::id::type id_, bool immediate_=false)
Starts a timer.
Definition callback_timer.h:327
bool set_mode(etl::timer::id::type id_, bool repeating_)
Sets a timer's mode.
Definition callback_timer.h:409
uint32_t time_to_next() const
Definition callback_timer.h:432
bool has_active_timer() const
Check if there is an active timer.
Definition callback_timer.h:423
void set_remove_callback(event_callback_type remove_)
Set a callback when a timer is removed from list.
Definition callback_timer.h:479
bool stop(etl::timer::id::type id_)
Stops a timer.
Definition callback_timer.h:365
void enable(bool state_)
Enable/disable the timer.
Definition callback_timer.h:224
etl::timer::id::type register_timer(etl::ifunction< void > &callback_, uint32_t period_, bool repeating_)
Register a timer.
Definition callback_timer.h:126
bool is_active(etl::timer::id::type id_) const
Definition callback_timer.h:448
icallback_timer(timer_data *const timer_array_, const uint_least8_t Max_Timers_)
Constructor.
Definition callback_timer.h:613
void clear()
Clears the timer of data.
Definition callback_timer.h:240
Definition function.h:54
bitset_ext
Definition absolute.h:39
The configuration of a timer.
Definition callback_timer.h:501
timer_data(etl::timer::id::type id_, callback_type &callback_, uint32_t period_, bool repeating_)
ETL delegate callback.
Definition callback_timer.h:563
bool is_active() const
Returns true if the timer is active.
Definition callback_timer.h:581
void set_inactive()
Sets the timer to the inactive state.
Definition callback_timer.h:589
timer_data(etl::timer::id::type id_, etl::ifunction< void > &callback_, uint32_t period_, bool repeating_)
ETL function callback.
Definition callback_timer.h:545
timer_data(etl::timer::id::type id_, void(*p_callback_)(), uint32_t period_, bool repeating_)
C function callback.
Definition callback_timer.h:527
Definition timer.h:88
Common definitions for the timer framework.
Definition timer.h:55