diff --git a/include/etl/callback_service.h b/include/etl/callback_service.h index 203bcc60..a8711d5d 100644 --- a/include/etl/callback_service.h +++ b/include/etl/callback_service.h @@ -41,11 +41,11 @@ namespace etl { //*************************************************************************** /// An indexed callback service. - /// \tparam RANGE The number of callbacks to handle. - /// \tparam OFFSET The lowest callback id value. - /// The callback ids must range between OFFSET and OFFSET + RANGE - 1. + /// \tparam Range The number of callbacks to handle. + /// \tparam Offset The lowest callback id value. + /// The callback ids must range between Offset and Offset + Range - 1. //*************************************************************************** - template + template class callback_service { public: @@ -70,10 +70,10 @@ namespace etl template void register_callback(etl::ifunction& callback) { - ETL_STATIC_ASSERT(Id < (OFFSET + RANGE), "Callback Id out of range"); - ETL_STATIC_ASSERT(Id >= OFFSET, "Callback Id out of range"); + ETL_STATIC_ASSERT(Id < (Offset + Range), "Callback Id out of range"); + ETL_STATIC_ASSERT(Id >= Offset, "Callback Id out of range"); - lookup[Id - OFFSET] = &callback; + lookup[Id - Offset] = &callback; } //************************************************************************* @@ -84,9 +84,9 @@ namespace etl //************************************************************************* void register_callback(size_t id, etl::ifunction& callback) { - if ((id >= OFFSET) && (id < (OFFSET + RANGE))) + if ((id >= Offset) && (id < (Offset + Range))) { - lookup[id - OFFSET] = &callback; + lookup[id - Offset] = &callback; } } @@ -107,10 +107,10 @@ namespace etl template void callback() { - ETL_STATIC_ASSERT(Id < (OFFSET + RANGE), "Callback Id out of range"); - ETL_STATIC_ASSERT(Id >= OFFSET, "Callback Id out of range"); + ETL_STATIC_ASSERT(Id < (Offset + Range), "Callback Id out of range"); + ETL_STATIC_ASSERT(Id >= Offset, "Callback Id out of range"); - (*lookup[Id - OFFSET])(Id); + (*lookup[Id - Offset])(Id); } //************************************************************************* @@ -119,9 +119,9 @@ namespace etl //************************************************************************* void callback(size_t id) { - if ((id >= OFFSET) && (id < (OFFSET + RANGE))) + if ((id >= Offset) && (id < (Offset + Range))) { - (*lookup[id - OFFSET])(id); + (*lookup[id - Offset])(id); } else { @@ -144,15 +144,15 @@ namespace etl } /// The default callback for unhandled ids. - etl::function_mp, + etl::function_mp, size_t, - &callback_service::unhandled> unhandled_callback; + &callback_service::unhandled> unhandled_callback; /// Pointer to the user defined 'unhandled' callback. etl::ifunction* p_unhandled; /// Lookup table of callbacks. - etl::array*, RANGE> lookup; + etl::array*, Range> lookup; }; } diff --git a/include/etl/callback_timer.h b/include/etl/callback_timer.h index 55a54930..c725922d 100644 --- a/include/etl/callback_timer.h +++ b/include/etl/callback_timer.h @@ -761,7 +761,7 @@ namespace etl //******************************************* /// Constructor. //******************************************* - icallback_timer(callback_timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + icallback_timer(callback_timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_), active_list(timer_array_), enabled(false), @@ -769,7 +769,7 @@ namespace etl process_semaphore(0), #endif registered_timers(0), - MAX_TIMERS(MAX_TIMERS_) + MAX_TIMERS(Max_Timers_) { } @@ -814,24 +814,24 @@ namespace etl //*************************************************************************** /// The callback timer //*************************************************************************** - template + template class callback_timer : public etl::icallback_timer { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254, "No more than 254 timers are allowed"); //******************************************* /// Constructor. //******************************************* callback_timer() - : icallback_timer(timer_array, MAX_TIMERS_) + : icallback_timer(timer_array, Max_Timers_) { } private: - callback_timer_data timer_array[MAX_TIMERS_]; + callback_timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/callback_timer_atomic.h b/include/etl/callback_timer_atomic.h index f3e53b4b..d2c63a47 100644 --- a/include/etl/callback_timer_atomic.h +++ b/include/etl/callback_timer_atomic.h @@ -62,12 +62,12 @@ namespace etl { etl::timer::id::type id = etl::timer::id::NO_TIMER; - bool is_space = (number_of_registered_timers < MAX_TIMERS); + bool is_space = (number_of_registered_timers < Max_Timers); if (is_space) { // Search for the free space. - for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint_least8_t i = 0U; i < Max_Timers; ++i) { timer_data& timer = timer_array[i]; @@ -141,7 +141,7 @@ namespace etl active_list.clear(); --process_semaphore; - for (uint8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint8_t i = 0U; i < Max_Timers; ++i) { ::new (&timer_array[i]) timer_data(); } @@ -424,13 +424,13 @@ namespace etl //******************************************* /// Constructor. //******************************************* - icallback_timer_atomic(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + icallback_timer_atomic(timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_) , active_list(timer_array_) , enabled(false) , process_semaphore(0U) , number_of_registered_timers(0U) - , MAX_TIMERS(MAX_TIMERS_) + , Max_Timers(Max_Timers_) { } @@ -441,7 +441,7 @@ namespace etl //******************************************* bool is_valid_timer_id(etl::timer::id::type id_) const { - return (id_ < MAX_TIMERS); + return (id_ < Max_Timers); } //************************************************************************* @@ -640,30 +640,30 @@ namespace etl public: - const uint_least8_t MAX_TIMERS; + const uint_least8_t Max_Timers; }; //*************************************************************************** /// The callback timer //*************************************************************************** - template + template class callback_timer_atomic : public etl::icallback_timer_atomic { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254U, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254U, "No more than 254 timers are allowed"); //******************************************* /// Constructor. //******************************************* callback_timer_atomic() - : icallback_timer_atomic(timer_array, MAX_TIMERS_) + : icallback_timer_atomic(timer_array, Max_Timers_) { } private: - typename etl::icallback_timer_atomic::timer_data timer_array[MAX_TIMERS_]; + typename etl::icallback_timer_atomic::timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/callback_timer_deferred_locked.h b/include/etl/callback_timer_deferred_locked.h index 91466dab..2cd97d10 100644 --- a/include/etl/callback_timer_deferred_locked.h +++ b/include/etl/callback_timer_deferred_locked.h @@ -40,12 +40,12 @@ namespace etl //*************************************************************************** /// The deferred callback timer //*************************************************************************** - template + template class callback_timer_deferred_locked : public etl::icallback_timer_locked { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254U, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254U, "No more than 254 timers are allowed"); typedef icallback_timer_locked::callback_type callback_type; typedef icallback_timer_locked::try_lock_type try_lock_type; @@ -77,7 +77,7 @@ namespace etl /// Constructor. //******************************************* callback_timer_deferred_locked() - : icallback_timer_locked(timer_array, MAX_TIMERS_) + : icallback_timer_locked(timer_array, Max_Timers_) { } @@ -85,7 +85,7 @@ namespace etl /// Constructor. //******************************************* callback_timer_deferred_locked(try_lock_type try_lock_, lock_type lock_, unlock_type unlock_) - : icallback_timer_locked(timer_array, MAX_TIMERS_) + : icallback_timer_locked(timer_array, Max_Timers_) { this->set_locks(try_lock_, lock_, unlock_); } @@ -211,9 +211,9 @@ namespace etl private: - priority_queue handler_queue; - uint_least8_t timer_priorities[MAX_TIMERS_]; - timer_data timer_array[MAX_TIMERS_]; + priority_queue handler_queue; + uint_least8_t timer_priorities[Max_Timers_]; + timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/callback_timer_interrupt.h b/include/etl/callback_timer_interrupt.h index b744a123..22058cdc 100644 --- a/include/etl/callback_timer_interrupt.h +++ b/include/etl/callback_timer_interrupt.h @@ -61,12 +61,12 @@ namespace etl { etl::timer::id::type id = etl::timer::id::NO_TIMER; - bool is_space = (number_of_registered_timers < MAX_TIMERS); + bool is_space = (number_of_registered_timers < Max_Timers); if (is_space) { // Search for the free space. - for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint_least8_t i = 0U; i < Max_Timers; ++i) { timer_data& timer = timer_array[i]; @@ -148,7 +148,7 @@ namespace etl number_of_registered_timers = 0; } - for (uint8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint8_t i = 0U; i < Max_Timers; ++i) { ::new (&timer_array[i]) timer_data(); } @@ -425,12 +425,12 @@ namespace etl //******************************************* /// Constructor. //******************************************* - icallback_timer_interrupt(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + icallback_timer_interrupt(timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_) , active_list(timer_array_) , enabled(false) , number_of_registered_timers(0U) - , MAX_TIMERS(MAX_TIMERS_) + , Max_Timers(Max_Timers_) { } @@ -441,7 +441,7 @@ namespace etl //******************************************* bool is_valid_timer_id(etl::timer::id::type id_) const { - return (id_ < MAX_TIMERS); + return (id_ < Max_Timers); } //************************************************************************* @@ -639,18 +639,18 @@ namespace etl public: - const uint_least8_t MAX_TIMERS; + const uint_least8_t Max_Timers; }; //*************************************************************************** /// The callback timer //*************************************************************************** - template + template class callback_timer_interrupt : public etl::icallback_timer_interrupt { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254U, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254U, "No more than 254 timers are allowed"); typedef typename icallback_timer_interrupt::callback_type callback_type; @@ -658,13 +658,13 @@ namespace etl /// Constructor. //******************************************* callback_timer_interrupt() - : icallback_timer_interrupt(timer_array, MAX_TIMERS_) + : icallback_timer_interrupt(timer_array, Max_Timers_) { } private: - typename icallback_timer_interrupt::timer_data timer_array[MAX_TIMERS_]; + typename icallback_timer_interrupt::timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/callback_timer_locked.h b/include/etl/callback_timer_locked.h index ff1fcc95..861f2101 100644 --- a/include/etl/callback_timer_locked.h +++ b/include/etl/callback_timer_locked.h @@ -63,12 +63,12 @@ namespace etl { etl::timer::id::type id = etl::timer::id::NO_TIMER; - bool is_space = (number_of_registered_timers < MAX_TIMERS); + bool is_space = (number_of_registered_timers < Max_Timers); if (is_space) { // Search for the free space. - for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint_least8_t i = 0U; i < Max_Timers; ++i) { timer_data& timer = timer_array[i]; @@ -142,7 +142,7 @@ namespace etl active_list.clear(); unlock(); - for (uint8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint8_t i = 0U; i < Max_Timers; ++i) { ::new (&timer_array[i]) timer_data(); } @@ -388,12 +388,12 @@ namespace etl //******************************************* /// Constructor. //******************************************* - icallback_timer_locked(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + icallback_timer_locked(timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_), active_list(timer_array_), enabled(false), number_of_registered_timers(0U), - MAX_TIMERS(MAX_TIMERS_) + Max_Timers(Max_Timers_) { } @@ -588,7 +588,7 @@ namespace etl //******************************************* bool is_valid_timer_id(etl::timer::id::type id_) const { - return (id_ < MAX_TIMERS); + return (id_ < Max_Timers); } // The array of timer data structures. @@ -611,18 +611,18 @@ namespace etl template friend class callback_timer_deferred_locked; - const uint_least8_t MAX_TIMERS; + const uint_least8_t Max_Timers; }; //*************************************************************************** /// The callback timer //*************************************************************************** - template + template class callback_timer_locked : public etl::icallback_timer_locked { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254U, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254U, "No more than 254 timers are allowed"); typedef icallback_timer_locked::callback_type callback_type; typedef icallback_timer_locked::try_lock_type try_lock_type; @@ -633,7 +633,7 @@ namespace etl /// Constructor. //******************************************* callback_timer_locked() - : icallback_timer_locked(timer_array, MAX_TIMERS_) + : icallback_timer_locked(timer_array, Max_Timers_) { } @@ -641,7 +641,7 @@ namespace etl /// Constructor. //******************************************* callback_timer_locked(try_lock_type try_lock_, lock_type lock_, unlock_type unlock_) - : icallback_timer_locked(timer_array, MAX_TIMERS_) + : icallback_timer_locked(timer_array, Max_Timers_) { this->set_locks(try_lock_, lock_, unlock_); } @@ -700,7 +700,7 @@ namespace etl private: - timer_data timer_array[MAX_TIMERS_]; + timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/message_timer.h b/include/etl/message_timer.h index f272877b..7ddc55fc 100644 --- a/include/etl/message_timer.h +++ b/include/etl/message_timer.h @@ -352,7 +352,7 @@ namespace etl { etl::timer::id::type id = etl::timer::id::NO_TIMER; - bool is_space = (registered_timers < MAX_TIMERS); + bool is_space = (registered_timers < Max_Timers); if (is_space) { @@ -360,7 +360,7 @@ namespace etl if (!router_.is_null_router()) { // Search for the free space. - for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint_least8_t i = 0U; i < Max_Timers; ++i) { etl::message_timer_data& timer = timer_array[i]; @@ -435,7 +435,7 @@ namespace etl active_list.clear(); ETL_ENABLE_TIMER_UPDATES; - for (int i = 0; i < MAX_TIMERS; ++i) + for (int i = 0; i < Max_Timers; ++i) { new (&timer_array[i]) message_timer_data(); } @@ -624,7 +624,7 @@ namespace etl //******************************************* /// Constructor. //******************************************* - imessage_timer(message_timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + imessage_timer(message_timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_), active_list(timer_array_), enabled(false), @@ -632,7 +632,7 @@ namespace etl process_semaphore(0), #endif registered_timers(0), - MAX_TIMERS(MAX_TIMERS_) + Max_Timers(Max_Timers_) { } @@ -671,30 +671,30 @@ namespace etl public: - const uint_least8_t MAX_TIMERS; + const uint_least8_t Max_Timers; }; //*************************************************************************** /// The message timer //*************************************************************************** - template + template class message_timer : public etl::imessage_timer { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254, "No more than 254 timers are allowed"); //******************************************* /// Constructor. //******************************************* message_timer() - : imessage_timer(timer_array, MAX_TIMERS_) + : imessage_timer(timer_array, Max_Timers_) { } private: - message_timer_data timer_array[MAX_TIMERS_]; + message_timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/message_timer_atomic.h b/include/etl/message_timer_atomic.h index 2710ea29..a8826da2 100644 --- a/include/etl/message_timer_atomic.h +++ b/include/etl/message_timer_atomic.h @@ -407,13 +407,13 @@ namespace etl //******************************************* /// Constructor. //******************************************* - imessage_timer_atomic(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + imessage_timer_atomic(timer_data* const timer_array_, const uint_least8_t Max_Timers) : timer_array(timer_array_) , active_list(timer_array_) , enabled(false) , process_semaphore(0U) , registered_timers(0U) - , MAX_TIMERS(MAX_TIMERS_) + , MAX_TIMERS(Max_Timers) { } @@ -628,24 +628,24 @@ namespace etl //*************************************************************************** /// The message timer //*************************************************************************** - template + template class message_timer_atomic : public etl::imessage_timer_atomic { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers <= 254, "No more than 254 timers are allowed"); //******************************************* /// Constructor. //******************************************* message_timer_atomic() - : imessage_timer_atomic(timer_array, MAX_TIMERS_) + : imessage_timer_atomic(timer_array, Max_Timers) { } private: - typename etl::imessage_timer_atomic::timer_data timer_array[MAX_TIMERS_]; + typename etl::imessage_timer_atomic::timer_data timer_array[Max_Timers]; }; } diff --git a/include/etl/message_timer_interrupt.h b/include/etl/message_timer_interrupt.h index 6f26789a..5fc0281d 100644 --- a/include/etl/message_timer_interrupt.h +++ b/include/etl/message_timer_interrupt.h @@ -67,7 +67,7 @@ namespace etl { etl::timer::id::type id = etl::timer::id::NO_TIMER; - bool is_space = (number_of_registered_timers < MAX_TIMERS); + bool is_space = (number_of_registered_timers < Max_Timers); if (is_space) { @@ -75,7 +75,7 @@ namespace etl if (!router_.is_null_router()) { // Search for the free space. - for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint_least8_t i = 0U; i < Max_Timers; ++i) { timer_data& timer = timer_array[i]; @@ -157,7 +157,7 @@ namespace etl active_list.clear(); } - for (int i = 0; i < MAX_TIMERS; ++i) + for (int i = 0; i < Max_Timers; ++i) { new (&timer_array[i]) timer_data(); } @@ -415,12 +415,12 @@ namespace etl //******************************************* /// Constructor. //******************************************* - imessage_timer_interrupt(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + imessage_timer_interrupt(timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_) , active_list(timer_array_) , enabled(false) , number_of_registered_timers(0U) - , MAX_TIMERS(MAX_TIMERS_) + , Max_Timers(Max_Timers_) { } @@ -628,18 +628,18 @@ namespace etl public: - const uint_least8_t MAX_TIMERS; + const uint_least8_t Max_Timers; }; //*************************************************************************** /// The message timer //*************************************************************************** - template + template class message_timer_interrupt : public etl::imessage_timer_interrupt { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254, "No more than 254 timers are allowed"); typedef typename imessage_timer_interrupt::callback_type callback_type; @@ -647,13 +647,13 @@ namespace etl /// Constructor. //******************************************* message_timer_interrupt() - : imessage_timer_interrupt(timer_array, MAX_TIMERS_) + : imessage_timer_interrupt(timer_array, Max_Timers_) { } private: - typename etl::imessage_timer_interrupt::timer_data timer_array[MAX_TIMERS_]; + typename etl::imessage_timer_interrupt::timer_data timer_array[Max_Timers_]; }; } diff --git a/include/etl/message_timer_locked.h b/include/etl/message_timer_locked.h index 5639dc2f..9f0e2a2c 100644 --- a/include/etl/message_timer_locked.h +++ b/include/etl/message_timer_locked.h @@ -69,7 +69,7 @@ namespace etl { etl::timer::id::type id = etl::timer::id::NO_TIMER; - bool is_space = (number_of_registered_timers < MAX_TIMERS); + bool is_space = (number_of_registered_timers < Max_Timers); if (is_space) { @@ -77,7 +77,7 @@ namespace etl if (!router_.is_null_router()) { // Search for the free space. - for (uint_least8_t i = 0U; i < MAX_TIMERS; ++i) + for (uint_least8_t i = 0U; i < Max_Timers; ++i) { timer_data& timer = timer_array[i]; @@ -152,7 +152,7 @@ namespace etl active_list.clear(); unlock(); - for (int i = 0; i < MAX_TIMERS; ++i) + for (int i = 0; i < Max_Timers; ++i) { new (&timer_array[i]) timer_data(); } @@ -423,12 +423,12 @@ namespace etl //******************************************* /// Constructor. //******************************************* - imessage_timer_locked(timer_data* const timer_array_, const uint_least8_t MAX_TIMERS_) + imessage_timer_locked(timer_data* const timer_array_, const uint_least8_t Max_Timers_) : timer_array(timer_array_) , active_list(timer_array_) , enabled(false) , number_of_registered_timers(0U) - , MAX_TIMERS(MAX_TIMERS_) + , Max_Timers(Max_Timers_) { } @@ -640,18 +640,18 @@ namespace etl public: - const uint_least8_t MAX_TIMERS; + const uint_least8_t Max_Timers; }; //*************************************************************************** /// The message timer //*************************************************************************** - template + template class message_timer_locked : public etl::imessage_timer_locked { public: - ETL_STATIC_ASSERT(MAX_TIMERS_ <= 254, "No more than 254 timers are allowed"); + ETL_STATIC_ASSERT(Max_Timers_ <= 254, "No more than 254 timers are allowed"); typedef imessage_timer_locked::callback_type callback_type; typedef imessage_timer_locked::try_lock_type try_lock_type; @@ -662,7 +662,7 @@ namespace etl /// Constructor. //******************************************* message_timer_locked() - : imessage_timer_locked(timer_array, MAX_TIMERS_) + : imessage_timer_locked(timer_array, Max_Timers_) { } @@ -670,14 +670,14 @@ namespace etl /// Constructor. //******************************************* message_timer_locked(try_lock_type try_lock_, lock_type lock_, unlock_type unlock_) - : imessage_timer_locked(timer_array, MAX_TIMERS_) + : imessage_timer_locked(timer_array, Max_Timers_) { this->set_locks(try_lock_, lock_, unlock_); } private: - timer_data timer_array[MAX_TIMERS_]; + timer_data timer_array[Max_Timers_]; }; }