From c8c4e7f4ec7b51b1e87f6d1c60aa0d5c97691c4c Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Mon, 5 Aug 2024 12:39:11 +0200 Subject: [PATCH 1/2] Start process of syntax modernization --- .../functions/math_functions_hypergeometric.h | 46 +++++++-------- ref_app/src/util/STL/impl/alloc_traits.h | 3 + ref_app/src/util/STL/impl/ptr_traits.h | 2 + ref_app/src/util/memory/util_factory.h | 8 +-- ref_app/src/util/memory/util_ring_allocator.h | 58 +++++++++---------- ref_app/src/util/utility/util_bit_mask.h | 44 ++++++++++---- .../util/utility/util_linear_interpolate.h | 19 +++--- ref_app/src/util/utility/util_narrow_cast.h | 8 +-- ref_app/src/util/utility/util_stopwatch.h | 33 +++++++---- .../micros/stm32l432/make/stm32l432_flags.gmk | 4 +- 10 files changed, 131 insertions(+), 94 deletions(-) diff --git a/ref_app/src/math/functions/math_functions_hypergeometric.h b/ref_app/src/math/functions/math_functions_hypergeometric.h index 45b0d83ed..4470df035 100644 --- a/ref_app/src/math/functions/math_functions_hypergeometric.h +++ b/ref_app/src/math/functions/math_functions_hypergeometric.h @@ -1,12 +1,15 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2014 - 2018. +// Copyright Christopher Kormanyos 2014 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MATH_FUNCTIONS_HYPERGEOMETRIC_2014_04_29_H_ - #define MATH_FUNCTIONS_HYPERGEOMETRIC_2014_04_29_H_ +#ifndef MATH_FUNCTIONS_HYPERGEOMETRIC_2014_04_29_H + #define MATH_FUNCTIONS_HYPERGEOMETRIC_2014_04_29_H + + #include + #include #include #include @@ -17,17 +20,14 @@ #include #include - #include - #include - namespace math { namespace functions { template - T hypergeometric_0f1(T b, + auto hypergeometric_0f1(T b, T x, - T tolerance = std::numeric_limits::epsilon() * T(10)) + T tolerance = std::numeric_limits::epsilon() * T(10)) -> T { // Compute the Taylor series representation of hypergeometric_0f1. // There are no checks on input range or parameter boundaries. @@ -70,22 +70,22 @@ } template - T hypergeometric_2f1(T a, + auto hypergeometric_2f1(T a, T b, T c, T x, - T tolerance = std::numeric_limits::epsilon() * T(10)) + T tolerance = std::numeric_limits::epsilon() * T(10)) -> T { // Compute the Taylor series representation of hypergeometric_2f1. // There are no checks on input range or parameter boundaries. - T x_pow_n_div_n_fact (x); - T pochhammer_sequence_a(a); - T pochhammer_sequence_b(b); - T pochhammer_sequence_c(c); - T ap (a); - T bp (b); - T cp (c); + T x_pow_n_div_n_fact { x }; + T pochhammer_sequence_a { a }; + T pochhammer_sequence_b { b }; + T pochhammer_sequence_c { c }; + T ap { a }; + T bp { b }; + T cp { c }; T hypergeometric_2f1_result = T(1) + (((pochhammer_sequence_a * pochhammer_sequence_b) / pochhammer_sequence_c) * x_pow_n_div_n_fact); @@ -125,12 +125,12 @@ template - T hypergeometric_pfq(iterator_a_type coefficients_a_begin, + auto hypergeometric_pfq(iterator_a_type coefficients_a_begin, iterator_a_type coefficients_a_end, iterator_b_type coefficients_b_begin, iterator_b_type coefficients_b_end, T x, - T tolerance = std::numeric_limits::epsilon() * T(10)) + T tolerance = std::numeric_limits::epsilon() * T(10)) -> T { const std::ptrdiff_t count_of_a_terms = std::distance(coefficients_a_begin, coefficients_a_end); const std::ptrdiff_t count_of_b_terms = std::distance(coefficients_b_begin, coefficients_b_end); @@ -161,10 +161,10 @@ T x_pow_n_div_n_fact(x); // Define an allocator type for use in the containers below. - typedef util::ring_allocator allocator_type; + using allocator_type = util::ring_allocator; // Define a container type for the upcoming calculation. - typedef util::dynamic_array container_type; + using container_type = util::dynamic_array; // The pochhammer symbols for the multiplications in the series expansion // will be stored in non-constant STL vectors. @@ -192,7 +192,7 @@ T hypergeometric_pfq_result = my_one + first_term; - std::uint_fast16_t n; + std::uint_fast16_t n { }; // Calculate the maximum number of iterations allowed. const std::uint_fast16_t max_iteration = static_cast(std::numeric_limits::digits10 * 10); @@ -247,4 +247,4 @@ } } // namespace math::functions -#endif // MATH_FUNCTIONS_HYPERGEOMETRIC_2014_04_29_H_ +#endif // MATH_FUNCTIONS_HYPERGEOMETRIC_2014_04_29_H diff --git a/ref_app/src/util/STL/impl/alloc_traits.h b/ref_app/src/util/STL/impl/alloc_traits.h index b83b726ad..be8bd3d62 100644 --- a/ref_app/src/util/STL/impl/alloc_traits.h +++ b/ref_app/src/util/STL/impl/alloc_traits.h @@ -34,6 +34,9 @@ #include + #include + + namespace std { template diff --git a/ref_app/src/util/STL/impl/ptr_traits.h b/ref_app/src/util/STL/impl/ptr_traits.h index eeac46613..eb3ad05fa 100644 --- a/ref_app/src/util/STL/impl/ptr_traits.h +++ b/ref_app/src/util/STL/impl/ptr_traits.h @@ -32,6 +32,8 @@ #ifndef PTR_TRAITS_2021_01_26_H_ #define PTR_TRAITS_2021_01_26_H_ + #include + namespace std { template diff --git a/ref_app/src/util/memory/util_factory.h b/ref_app/src/util/memory/util_factory.h index a2ca57fa1..f6b68c770 100644 --- a/ref_app/src/util/memory/util_factory.h +++ b/ref_app/src/util/memory/util_factory.h @@ -65,7 +65,7 @@ /* -// See also link at GodBolt: https://godbolt.org/z/7fjcGTbWj +// See also link at GodBolt: https://godbolt.org/z/WrTTa8Eq9 #include @@ -74,8 +74,8 @@ class something : public util::factory_product { public: - something() { } - virtual ~something() { } + something() = default; + virtual ~something() = default; private: virtual void init() { } @@ -88,7 +88,7 @@ class another : public util::factory_product : my_m(m), my_n(n) { } - ~another() override { } + ~another() override = default; auto get_m() const -> int { return my_m; } auto get_n() const -> int { return my_n; } diff --git a/ref_app/src/util/memory/util_ring_allocator.h b/ref_app/src/util/memory/util_ring_allocator.h index 543156c74..1c3539a22 100644 --- a/ref_app/src/util/memory/util_ring_allocator.h +++ b/ref_app/src/util/memory/util_ring_allocator.h @@ -1,26 +1,26 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2021. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_RING_ALLOCATOR_2010_02_23_H_ - #define UTIL_RING_ALLOCATOR_2010_02_23_H_ +#ifndef UTIL_RING_ALLOCATOR_2010_02_23_H + #define UTIL_RING_ALLOCATOR_2010_02_23_H + + #include #include #include #include - #include - namespace util { class ring_allocator_base { public: - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; + using size_type = std::size_t; + using difference_type = std::ptrdiff_t; virtual ~ring_allocator_base() = default; @@ -41,7 +41,7 @@ // The ring allocator's memory allocation. template - static void* do_allocate(size_type chunk_size) + static auto do_allocate(size_type chunk_size) -> void* { ALIGNAS(16) static buffer_type buffer; @@ -80,14 +80,14 @@ }; // Global comparison operators (required by the standard). - inline bool operator==(const ring_allocator_base&, - const ring_allocator_base&) noexcept + inline auto operator==(const ring_allocator_base&, + const ring_allocator_base&) noexcept -> bool { return true; } - inline bool operator!=(const ring_allocator_base&, - const ring_allocator_base&) noexcept + inline auto operator!=(const ring_allocator_base&, + const ring_allocator_base&) noexcept -> bool { return false; } @@ -100,9 +100,9 @@ class ring_allocator : public ring_allocator_base { public: - typedef void value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; + using value_type = void; + using pointer = value_type*; + using const_pointer = const value_type*; template struct rebind @@ -119,11 +119,11 @@ static_assert(sizeof(T) <= buffer_type::size, "The size of the allocation object can not exceed the buffer size."); - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef value_type& reference; - typedef const value_type& const_reference; + using value_type = T; + using pointer = value_type*; + using const_pointer = const value_type*; + using reference = value_type&; + using const_reference = const value_type&; ring_allocator() noexcept = default; @@ -138,16 +138,16 @@ using other = ring_allocator; }; - size_type max_size() const noexcept + auto max_size() const noexcept -> size_type { return buffer_type::size / sizeof(value_type); } - pointer address( reference x) const { return &x; } - const_pointer address(const_reference x) const { return &x; } + auto address( reference x) const -> pointer { return &x; } + auto address(const_reference x) const -> const_pointer { return &x; } - pointer allocate(size_type count, - typename ring_allocator::const_pointer = nullptr) + auto allocate(size_type count, + typename ring_allocator::const_pointer = nullptr) -> pointer { const size_type chunk_size = count * sizeof(value_type); @@ -156,15 +156,15 @@ return static_cast(p); } - void construct(pointer p, const value_type& x) noexcept + auto construct(pointer p, const value_type& x) noexcept -> void { new(static_cast(p)) value_type(x); } - void destroy(pointer p) noexcept { p->~value_type(); } + auto destroy(pointer p) noexcept -> void { p->~value_type(); } - void deallocate(pointer, size_type) noexcept { } + auto deallocate(pointer, size_type) noexcept -> void { } }; } -#endif // UTIL_RING_ALLOCATOR_2010_02_23_H_ +#endif // UTIL_RING_ALLOCATOR_2010_02_23_H diff --git a/ref_app/src/util/utility/util_bit_mask.h b/ref_app/src/util/utility/util_bit_mask.h index 46ad21b77..a7334235a 100644 --- a/ref_app/src/util/utility/util_bit_mask.h +++ b/ref_app/src/util/utility/util_bit_mask.h @@ -1,24 +1,28 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2018. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_BIT_MASK_2010_06_13_H_ - #define UTIL_BIT_MASK_2010_06_13_H_ +#ifndef UTIL_BIT_MASK_2010_06_13_H + #define UTIL_BIT_MASK_2010_06_13_H #include namespace util { template + const unsigned BitPos, + const unsigned BitCnt> struct bit_mask_multi_value { + private: // This bit mask contains bit_cnt continuous bits starting at bit_pos. + static constexpr unsigned bit_pos = BitPos; + static constexpr unsigned bit_cnt = BitCnt; + // Ensure that the data_type is an integer type. static_assert(std::numeric_limits::is_integer == true, "the data_type of the bit_mask template must be an integer type"); @@ -28,18 +32,29 @@ "the data_type of the bit_mask template must be unsigned"); // Ensure that the requested bit mask is in range. - static_assert((bit_pos + bit_cnt) <= unsigned(std::numeric_limits::digits), + static_assert((bit_pos + bit_cnt) <= unsigned { std::numeric_limits::digits }, "the requested bit_mask value exceeds the maximum value of the data_type"); - static const data_type value = static_cast(static_cast(static_cast(~static_cast(0U)) >> (std::numeric_limits::digits - (bit_cnt + 1U))) << bit_pos); + public: + static constexpr data_type value = + static_cast + ( + static_cast + ( + static_cast(~static_cast(0U)) >> static_cast(static_cast(std::numeric_limits::digits) - (bit_cnt + 1U)) + ) << bit_pos + ); }; template - struct bit_mask_multi_value + const unsigned BitPos> + struct bit_mask_multi_value { + private: // This bit mask contains one bit at bit_pos. + static constexpr unsigned bit_pos = BitPos; + // Ensure that the data_type is an integer type. static_assert(std::numeric_limits::is_integer == true, "the data_type of the bit_mask template must be an integer type"); @@ -52,15 +67,19 @@ static_assert((bit_pos + 1) <= unsigned(std::numeric_limits::digits), "the requested bit_mask value exceeds the maximum value of the data_type"); - static const data_type value = static_cast(static_cast(1U) << bit_pos); + public: + static constexpr data_type value = static_cast(static_cast(1U) << bit_pos); }; template + const unsigned BitPos> struct bit_mask_single_value { + private: // This bit mask contains one bit at bit_pos. + static constexpr unsigned bit_pos = BitPos; + // Ensure that the data_type is an integer type. static_assert(std::numeric_limits::is_integer == true, "the data_type of the bit_mask template must be an integer type"); @@ -73,8 +92,9 @@ static_assert((bit_pos + 1) <= unsigned(std::numeric_limits::digits), "the requested bit_mask value exceeds the maximum value of the data_type"); + public: static const data_type value = static_cast(static_cast(1U) << bit_pos); }; } -#endif // UTIL_BIT_MASK_2010_06_13_H_ +#endif // UTIL_BIT_MASK_2010_06_13_H diff --git a/ref_app/src/util/utility/util_linear_interpolate.h b/ref_app/src/util/utility/util_linear_interpolate.h index d345335bc..69bb179f7 100644 --- a/ref_app/src/util/utility/util_linear_interpolate.h +++ b/ref_app/src/util/utility/util_linear_interpolate.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2020. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_LINEAR_INTERPOLATE_2008_11_22_H_ - #define UTIL_LINEAR_INTERPOLATE_2008_11_22_H_ +#ifndef UTIL_LINEAR_INTERPOLATE_2008_11_22_H + #define UTIL_LINEAR_INTERPOLATE_2008_11_22_H #include @@ -15,18 +15,17 @@ template - y_type linear_interpolate(point_iterator pts_begin, - point_iterator pts_end, - const x_type& x, - const y_type& offset) + auto linear_interpolate(point_iterator pts_begin, + point_iterator pts_end, + const x_type& x, + const y_type& offset) -> y_type { if(pts_begin == pts_end) { // There are no data points to interpolate. return y_type(); } - else if( (x <= pts_begin->x) - || ((pts_begin + 1U) == pts_end)) + else if((x <= pts_begin->x) || ((pts_begin + 1U) == pts_end)) { // We are beneath the lower x-range or there // is only one data point to interpolate. @@ -58,4 +57,4 @@ } } -#endif // UTIL_LINEAR_INTERPOLATE_2008_11_22_H_ +#endif // UTIL_LINEAR_INTERPOLATE_2008_11_22_H diff --git a/ref_app/src/util/utility/util_narrow_cast.h b/ref_app/src/util/utility/util_narrow_cast.h index 7659d71b5..6b4416a61 100644 --- a/ref_app/src/util/utility/util_narrow_cast.h +++ b/ref_app/src/util/utility/util_narrow_cast.h @@ -5,18 +5,18 @@ // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_NARROW_CAST_2020_09_24_H_ - #define UTIL_NARROW_CAST_2020_09_24_H_ +#ifndef UTIL_NARROW_CAST_2020_09_24_H + #define UTIL_NARROW_CAST_2020_09_24_H #include namespace util { template - constexpr T narrow_cast(U&& u) noexcept + constexpr auto narrow_cast(U&& u) noexcept -> T { return static_cast(std::forward(u)); } } -#endif // UTIL_NARROW_CAST_2020_09_24_H_ +#endif // UTIL_NARROW_CAST_2020_09_24_H diff --git a/ref_app/src/util/utility/util_stopwatch.h b/ref_app/src/util/utility/util_stopwatch.h index 1b146d017..a5fed1dca 100644 --- a/ref_app/src/util/utility/util_stopwatch.h +++ b/ref_app/src/util/utility/util_stopwatch.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2014. +// Copyright Christopher Kormanyos 2014 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_STOPWATCH_2014_01_07_H_ - #define UTIL_STOPWATCH_2014_01_07_H_ +#ifndef UTIL_STOPWATCH_2014_01_07_H + #define UTIL_STOPWATCH_2014_01_07_H namespace util { @@ -14,17 +14,21 @@ class stopwatch final { public: - typedef typename clock_type::duration duration_type; + using duration_type = typename clock_type::duration; + + using time_point_type = typename clock_type::time_point; stopwatch() : my_start(clock_type::now()) { } - stopwatch(typename clock_type::time_point start) : my_start(start) { } + explicit stopwatch(time_point_type start) : my_start(start) { } stopwatch(const stopwatch& other) : my_start(other.my_start) { } - ~stopwatch() { } + stopwatch(stopwatch&& other) noexcept : my_start(other.my_start) { } + + ~stopwatch() = default; - stopwatch& operator=(const stopwatch& other) + auto operator=(const stopwatch& other) -> stopwatch& { if(this != &other) { @@ -34,18 +38,25 @@ return *this; } - duration_type elapsed() const + auto operator=(stopwatch&& other) noexcept -> stopwatch& + { + my_start = other.my_start; + + return *this; + } + + auto elapsed() const -> duration_type { return clock_type::now() - my_start; } - void reset() + auto reset() -> void { my_start = clock_type::now(); } private: - typename clock_type::time_point my_start; + time_point_type my_start; }; } @@ -53,4 +64,4 @@ // const auto elapsed = std::chrono::duration_cast(my_stopwatch.elapsed()).count(); // const auto elapsed = std::chrono::duration_cast>(my_stopwatch.elapsed()).count(); -#endif // UTIL_STOPWATCH_2014_01_07_H_ +#endif // UTIL_STOPWATCH_2014_01_07_H diff --git a/ref_app/target/micros/stm32l432/make/stm32l432_flags.gmk b/ref_app/target/micros/stm32l432/make/stm32l432_flags.gmk index aa05bcdfa..df78e65fc 100644 --- a/ref_app/target/micros/stm32l432/make/stm32l432_flags.gmk +++ b/ref_app/target/micros/stm32l432/make/stm32l432_flags.gmk @@ -40,4 +40,6 @@ TGT_AFLAGS = TGT_LDFLAGS = -nostartfiles \ -Wl,--gc-sections \ -Wl,-Map,$(APP).map \ - -T $(LINKER_DEFINITION_FILE) + -T $(LINKER_DEFINITION_FILE) \ + --specs=nano.specs \ + --specs=nosys.specs From fc85e0f534f8e3932d6f74e7b5dfb9e4780162dc Mon Sep 17 00:00:00 2001 From: ckormanyos Date: Tue, 6 Aug 2024 08:52:11 +0200 Subject: [PATCH 2/2] More modernize avr-mcal and some utils --- readme.md | 3 +- ref_app/ref_app.vcxproj | 1 - ref_app/ref_app.vcxproj.filters | 3 - ref_app/src/mcal/avr/mcal_cpu.cpp | 2 +- ref_app/src/mcal/avr/mcal_cpu.h | 12 +- ref_app/src/mcal/avr/mcal_eep.cpp | 25 +- ref_app/src/mcal/avr/mcal_eep.h | 19 +- ref_app/src/mcal/avr/mcal_gpt.h | 2 +- ref_app/src/mcal/avr/mcal_irq.cpp | 4 +- ref_app/src/mcal/avr/mcal_irq.h | 14 +- ref_app/src/mcal/avr/mcal_led.cpp | 4 +- ref_app/src/mcal/avr/mcal_led.h | 2 +- ref_app/src/mcal/avr/mcal_memory_progmem.h | 8 +- ...al_memory_sram_parallel_cypress_cy62158e.h | 31 +- ref_app/src/mcal/avr/mcal_osc.cpp | 4 +- ref_app/src/mcal/avr/mcal_osc.h | 6 +- ref_app/src/mcal/avr/mcal_port.cpp | 4 +- ref_app/src/mcal/avr/mcal_port.h | 48 +-- .../mcal_port_expander_microchip_mcp23s17.h | 36 +- ref_app/src/mcal/avr/mcal_port_pin_dummy.h | 22 +- ref_app/src/mcal/avr/mcal_port_word.h | 20 +- ref_app/src/mcal/avr/mcal_pwm.cpp | 2 +- ref_app/src/mcal/avr/mcal_pwm.h | 2 +- ref_app/src/mcal/avr/mcal_reg.h | 112 +++--- ref_app/src/mcal/avr/mcal_ser.h | 12 +- ref_app/src/mcal/avr/mcal_spi.cpp | 6 +- ref_app/src/mcal/avr/mcal_spi.h | 16 +- ref_app/src/mcal/avr/mcal_wdg.cpp | 6 +- ref_app/src/mcal/avr/mcal_wdg.h | 18 +- ref_app/src/mcal/host/mcal_port.h | 14 +- .../src/util/utility/util_circular_buffer.h | 374 ------------------ ref_app/src/util/utility/util_communication.h | 4 +- ref_app/src/util/utility/util_countof.h | 42 +- ref_app/src/util/utility/util_display.h | 2 +- ref_app/src/util/utility/util_nothing.h | 28 +- ref_app/src/util/utility/util_point.h | 55 +-- ref_app/src/util/utility/util_stopwatch.h | 2 + ref_app/src/util/utility/util_swdm.h | 43 +- .../utility/util_two_part_data_manipulation.h | 17 +- ref_app/src/util/utility/util_utype_helper.h | 80 ++-- 40 files changed, 384 insertions(+), 721 deletions(-) delete mode 100644 ref_app/src/util/utility/util_circular_buffer.h diff --git a/readme.md b/readme.md index e1f9e2e71..43843d6fb 100644 --- a/readme.md +++ b/readme.md @@ -456,7 +456,8 @@ while core 0 enters an endless, idle loop. Ozone debug files are supplied for this system for those interested. Reverse engineering of the complicated (and scantly documented) dual-core startup originated in and have been taken from (with many thanks) -[Chalandi/Blinky_Pico_dual_core_nosdk](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk). +from the `Blinky_Pico_dual_core_nosdk` +[repo](https://github.com/Chalandi/Blinky_Pico_dual_core_nosdk). Target `v850es_fx2` uses a classic Renesas(R) V850es/Fx2 core. The upd703231 microcontroller derivative on an F-Line _Drive_ _It_ diff --git a/ref_app/ref_app.vcxproj b/ref_app/ref_app.vcxproj index b0632ea7a..f996cf13f 100644 --- a/ref_app/ref_app.vcxproj +++ b/ref_app/ref_app.vcxproj @@ -2836,7 +2836,6 @@ - diff --git a/ref_app/ref_app.vcxproj.filters b/ref_app/ref_app.vcxproj.filters index 0c8b5a57c..062153ca0 100644 --- a/ref_app/ref_app.vcxproj.filters +++ b/ref_app/ref_app.vcxproj.filters @@ -1206,9 +1206,6 @@ src\util\memory - - src\util\utility - src\mcal\stm32f100 diff --git a/ref_app/src/mcal/avr/mcal_cpu.cpp b/ref_app/src/mcal/avr/mcal_cpu.cpp index 384c9e3ca..a2338eec7 100644 --- a/ref_app/src/mcal/avr/mcal_cpu.cpp +++ b/ref_app/src/mcal/avr/mcal_cpu.cpp @@ -10,7 +10,7 @@ #include #include -void mcal::cpu::init() +auto mcal::cpu::init() -> void { mcal::wdg::init(nullptr); mcal::port::init(nullptr); diff --git a/ref_app/src/mcal/avr/mcal_cpu.h b/ref_app/src/mcal/avr/mcal_cpu.h index 38fec8dfa..cdc8287b1 100644 --- a/ref_app/src/mcal/avr/mcal_cpu.h +++ b/ref_app/src/mcal/avr/mcal_cpu.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2020. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_CPU_2009_02_14_H_ - #define MCAL_CPU_2009_02_14_H_ +#ifndef MCAL_CPU_2009_02_14_H + #define MCAL_CPU_2009_02_14_H #include @@ -16,10 +16,10 @@ { void init(); - inline void post_init() { } + inline auto post_init() -> void { } - inline void nop() noexcept { asm volatile("nop"); } + inline auto nop() noexcept -> void { asm volatile("nop"); } } } -#endif // MCAL_CPU_2009_02_14_H_ +#endif // MCAL_CPU_2009_02_14_H diff --git a/ref_app/src/mcal/avr/mcal_eep.cpp b/ref_app/src/mcal/avr/mcal_eep.cpp index 5d4af0e7c..780ca0e26 100644 --- a/ref_app/src/mcal/avr/mcal_eep.cpp +++ b/ref_app/src/mcal/avr/mcal_eep.cpp @@ -1,25 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +// Copyright Christopher Kormanyos 2018 - 2024. +// Distributed under the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) +// + #include #include #include -namespace +namespace local { - bool mcal_eep_is_busy() + auto mcal_eep_is_busy() -> bool; + + auto mcal_eep_is_busy() -> bool { return (mcal::reg::reg_access_static::bit_get() == true); } -} +} // namespace local -void mcal::eep::init(const config_type*) +auto mcal::eep::init(const config_type*) -> void { } -void mcal::eep::write(const address_type addr, const std::uint8_t data) +auto mcal::eep::write(const address_type addr, const std::uint8_t data) -> void { - while(mcal_eep_is_busy()) + while(local::mcal_eep_is_busy()) { mcal::cpu::nop(); } @@ -45,9 +54,9 @@ void mcal::eep::write(const address_type addr, const std::uint8_t data) UINT8_C(1)>::bit_set(); } -std::uint8_t mcal::eep::read(const address_type addr) +auto mcal::eep::read(const address_type addr) -> std::uint8_t { - while(mcal_eep_is_busy()) + while(local::mcal_eep_is_busy()) { mcal::cpu::nop(); } diff --git a/ref_app/src/mcal/avr/mcal_eep.h b/ref_app/src/mcal/avr/mcal_eep.h index bc5d608f3..aa875539a 100644 --- a/ref_app/src/mcal/avr/mcal_eep.h +++ b/ref_app/src/mcal/avr/mcal_eep.h @@ -1,5 +1,12 @@ -#ifndef MCAL_EEP_2018_12_15_H_ - #define MCAL_EEP_2018_12_15_H_ +/////////////////////////////////////////////////////////////////////////////// +// Copyright Christopher Kormanyos 2018 - 2024. +// Distributed under the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MCAL_EEP_2018_12_15_H + #define MCAL_EEP_2018_12_15_H #include @@ -10,11 +17,11 @@ using config_type = void; using address_type = std::uint_fast16_t; - void init(const config_type*); + auto init(const config_type*) -> void; - void write(const address_type addr, const std::uint8_t data); - std::uint8_t read (const address_type addr); + auto write(const address_type addr, const std::uint8_t data)-> void; + auto read (const address_type addr) -> std::uint8_t; } } -#endif // MCAL_EEP_2018_12_15_H_ +#endif // MCAL_EEP_2018_12_15_H diff --git a/ref_app/src/mcal/avr/mcal_gpt.h b/ref_app/src/mcal/avr/mcal_gpt.h index 54c43cd77..12896218b 100644 --- a/ref_app/src/mcal/avr/mcal_gpt.h +++ b/ref_app/src/mcal/avr/mcal_gpt.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/ref_app/src/mcal/avr/mcal_irq.cpp b/ref_app/src/mcal/avr/mcal_irq.cpp index 7a4cd6701..d66f1b5dc 100644 --- a/ref_app/src/mcal/avr/mcal_irq.cpp +++ b/ref_app/src/mcal/avr/mcal_irq.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -7,7 +7,7 @@ #include -void mcal::irq::init(const config_type*) +auto mcal::irq::init(const config_type*) -> void { mcal::irq::enable_all(); } diff --git a/ref_app/src/mcal/avr/mcal_irq.h b/ref_app/src/mcal/avr/mcal_irq.h index ff9a53cec..9fa6ff14c 100644 --- a/ref_app/src/mcal/avr/mcal_irq.h +++ b/ref_app/src/mcal/avr/mcal_irq.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_IRQ_2010_04_10_H_ - #define MCAL_IRQ_2010_04_10_H_ +#ifndef MCAL_IRQ_2010_04_10_H + #define MCAL_IRQ_2010_04_10_H namespace mcal { @@ -14,11 +14,11 @@ { typedef void config_type; - void init(const config_type*); + auto init(const config_type*) -> void; - inline void enable_all () noexcept { asm volatile("sei"); } - inline void disable_all() noexcept { asm volatile("cli"); } + inline auto enable_all () noexcept -> void { asm volatile("sei"); } + inline auto disable_all() noexcept -> void { asm volatile("cli"); } } } -#endif // MCAL_IRQ_2010_04_10_H_ +#endif // MCAL_IRQ_2010_04_10_H diff --git a/ref_app/src/mcal/avr/mcal_led.cpp b/ref_app/src/mcal/avr/mcal_led.cpp index 1cc6623ee..2f99688e9 100644 --- a/ref_app/src/mcal/avr/mcal_led.cpp +++ b/ref_app/src/mcal/avr/mcal_led.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2020. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,7 +8,7 @@ #include #include -mcal::led::led_base& mcal::led::led0() +auto mcal::led::led0() -> mcal::led::led_base& { using led0_port_type = mcal::port::port_pin led_base&; } } diff --git a/ref_app/src/mcal/avr/mcal_memory_progmem.h b/ref_app/src/mcal/avr/mcal_memory_progmem.h index 50df07fa1..8570aa447 100644 --- a/ref_app/src/mcal/avr/mcal_memory_progmem.h +++ b/ref_app/src/mcal/avr/mcal_memory_progmem.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2019 - 2023. +// Copyright Christopher Kormanyos 2019 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_MEMORY_PROGMEM_2019_08_17_H_ - #define MCAL_MEMORY_PROGMEM_2019_08_17_H_ +#ifndef MCAL_MEMORY_PROGMEM_2019_08_17_H + #define MCAL_MEMORY_PROGMEM_2019_08_17_H #include @@ -59,4 +59,4 @@ } #endif -#endif // MCAL_MEMORY_PROGMEM_2019_08_17_H_ +#endif // MCAL_MEMORY_PROGMEM_2019_08_17_H diff --git a/ref_app/src/mcal/avr/mcal_memory_sram_parallel_cypress_cy62158e.h b/ref_app/src/mcal/avr/mcal_memory_sram_parallel_cypress_cy62158e.h index 189168cbe..4e6f7f045 100644 --- a/ref_app/src/mcal/avr/mcal_memory_sram_parallel_cypress_cy62158e.h +++ b/ref_app/src/mcal/avr/mcal_memory_sram_parallel_cypress_cy62158e.h @@ -1,5 +1,12 @@ -#ifndef MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H_ - #define MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H_ +/////////////////////////////////////////////////////////////////////////////// +// Copyright Christopher Kormanyos 2020 - 2024. +// Distributed under the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt +// or copy at http://www.boost.org/LICENSE_1_0.txt) +// + +#ifndef MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H + #define MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H #include #include @@ -28,7 +35,7 @@ private: // The CY62158E MoBL(R)is a high performance CMOS static RAM // organized as 1024K words by 8 bits (i.e., 1 Mbyte). - static void nibble_port_pin_functions(const std::uint8_t nibble_value) + static auto nibble_port_pin_functions(const std::uint8_t nibble_value) -> void { switch(nibble_value) { @@ -52,7 +59,7 @@ } public: - memory_sram_parallel_cypress_cy62158e() : my_word16_addr_04_to_19(0U) + memory_sram_parallel_cypress_cy62158e() { // Initialize the parallel sram control pins. sram_parallel_port_pin_ce1_not_type::set_pin_high(); @@ -92,7 +99,7 @@ ~memory_sram_parallel_cypress_cy62158e() = default; - void write(const std::uint32_t address_to_write, const std::uint8_t source_byte_to_write) + auto write(const std::uint32_t address_to_write, const std::uint8_t source_byte_to_write) -> void { // According to Document Number: 38-05684 Rev. *L: // To write to the device, take Chip Enables (CE1_NOT LOW and CE2 @@ -151,9 +158,9 @@ sram_parallel_port_word08_data_type::set_direction_input(); } - void write_n(const std::uint32_t address_to_write, + auto write_n(const std::uint32_t address_to_write, const std::size_t count, - const std::uint8_t* source_input_to_write) + const std::uint8_t* source_input_to_write) -> void { // Write n bytes, when n can be 1 but should // be greater than 1 for improved efficiency. @@ -226,7 +233,7 @@ sram_parallel_port_word08_data_type::set_direction_input(); } - std::uint8_t read(const std::uint32_t address_to_read) + auto read(const std::uint32_t address_to_read) -> std::uint8_t { // According to Document Number: 38-05684 Rev. *L: // To read from the device, take Chip Enables (CE1_NOT LOW and CE2 @@ -280,9 +287,9 @@ return byte_to_read; } - void read_n(const std::uint32_t address_to_read, + auto read_n(const std::uint32_t address_to_read, const std::size_t count, - std::uint8_t* dest_to_store_read_data) + std::uint8_t* dest_to_store_read_data) -> void { // Read n bytes, when n can be 1 but should // be greater than 1 for improved efficiency. @@ -349,9 +356,9 @@ } private: - std::uint16_t my_word16_addr_04_to_19; + std::uint16_t my_word16_addr_04_to_19 { }; }; } } } // namespace mcal::memory::sram -#endif // MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H_ +#endif // MCAL_MEMORY_SRAM_PARALLEL_CYPRESS_CY62158E_2020_05_01_H diff --git a/ref_app/src/mcal/avr/mcal_osc.cpp b/ref_app/src/mcal/avr/mcal_osc.cpp index 2b8e55588..0eb46b376 100644 --- a/ref_app/src/mcal/avr/mcal_osc.cpp +++ b/ref_app/src/mcal/avr/mcal_osc.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -7,6 +7,6 @@ #include -void mcal::osc::init(const config_type*) +auto mcal::osc::init(const config_type*) -> void { } diff --git a/ref_app/src/mcal/avr/mcal_osc.h b/ref_app/src/mcal/avr/mcal_osc.h index fc622665f..0b7590878 100644 --- a/ref_app/src/mcal/avr/mcal_osc.h +++ b/ref_app/src/mcal/avr/mcal_osc.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -12,9 +12,9 @@ { namespace osc { - typedef void config_type; + using config_type = void; - void init(const config_type*); + auto init(const config_type*) -> void; } } diff --git a/ref_app/src/mcal/avr/mcal_port.cpp b/ref_app/src/mcal/avr/mcal_port.cpp index 6b8071d3d..03d133c43 100644 --- a/ref_app/src/mcal/avr/mcal_port.cpp +++ b/ref_app/src/mcal/avr/mcal_port.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -7,6 +7,6 @@ #include -void mcal::port::init(const config_type*) +auto mcal::port::init(const config_type*) -> void { } diff --git a/ref_app/src/mcal/avr/mcal_port.h b/ref_app/src/mcal/avr/mcal_port.h index 86a871371..8a1c34905 100644 --- a/ref_app/src/mcal/avr/mcal_port.h +++ b/ref_app/src/mcal/avr/mcal_port.h @@ -1,31 +1,31 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_PORT_2012_06_27_H_ - #define MCAL_PORT_2012_06_27_H_ +#ifndef MCAL_PORT_2012_06_27_H + #define MCAL_PORT_2012_06_27_H #include #include - void mcal_port_pin_expander_set_direction_output(const uint8_t bpos); - void mcal_port_pin_expander_set_direction_input (const uint8_t bpos); - void mcal_port_pin_expander_set_pin_high (const uint8_t bpos); - void mcal_port_pin_expander_set_pin_low (const uint8_t bpos); - bool mcal_port_pin_expander_read_input_value (const uint8_t bpos); - void mcal_port_pin_expander_toggle_pin (const uint8_t bpos); + auto mcal_port_pin_expander_set_direction_output(const uint8_t bpos) -> void; + auto mcal_port_pin_expander_set_direction_input (const uint8_t bpos) -> void; + auto mcal_port_pin_expander_set_pin_high (const uint8_t bpos) -> void; + auto mcal_port_pin_expander_set_pin_low (const uint8_t bpos) -> void; + auto mcal_port_pin_expander_read_input_value (const uint8_t bpos) -> bool; + auto mcal_port_pin_expander_toggle_pin (const uint8_t bpos) -> void; namespace mcal { namespace port { - typedef void config_type; + using config_type = void; - void init(const config_type*); + auto init(const config_type*) -> void; template void { // Set the port pin's direction to output. // C++: @@ -55,7 +55,7 @@ asm volatile("sbi %[myport],%[mybit]" : : [myport]"I"(pdir_address - sfr_offset), [mybit]"I"(bpos_value)); } - static void set_direction_input() noexcept + static auto set_direction_input() noexcept -> void { // Set the port pin's direction to input. // C++: @@ -66,7 +66,7 @@ asm volatile("cbi %[myport],%[mybit]" : : [myport]"I"(pdir_address - sfr_offset), [mybit]"I"(bpos_value)); } - static void set_pin_high() noexcept + static auto set_pin_high() noexcept -> void { // Set the port output value to high. // C++: @@ -77,7 +77,7 @@ asm volatile("sbi %[myport],%[mybit]" : : [myport]"I"(port_address - sfr_offset), [mybit]"I"(bpos_value)); } - static void set_pin_low() noexcept + static auto set_pin_low() noexcept -> void { // Set the port output value to low. // C++: @@ -88,7 +88,7 @@ asm volatile("cbi %[myport],%[mybit]" : : [myport]"I"(port_address - sfr_offset), [mybit]"I"(bpos_value)); } - static bool read_input_value() noexcept + static auto read_input_value() noexcept -> bool { // Read the port input value. return mcal::reg::reg_access_static::bit_get(); } - static void toggle_pin() noexcept + static auto toggle_pin() noexcept -> void { // Toggle the port output value. mcal::reg::reg_access_static void { mcal_port_pin_expander_set_direction_output(bpos); } + static auto set_direction_input () -> void { mcal_port_pin_expander_set_direction_input (bpos); } + static auto set_pin_high () -> void { mcal_port_pin_expander_set_pin_high (bpos); } + static auto set_pin_low () -> void { mcal_port_pin_expander_set_pin_low (bpos); } + static auto read_input_value () -> bool { return mcal_port_pin_expander_read_input_value (bpos); } + static auto toggle_pin () -> void { mcal_port_pin_expander_toggle_pin (bpos); } }; } } -#endif // MCAL_PORT_2012_06_27_H_ +#endif // MCAL_PORT_2012_06_27_H diff --git a/ref_app/src/mcal/avr/mcal_port_expander_microchip_mcp23s17.h b/ref_app/src/mcal/avr/mcal_port_expander_microchip_mcp23s17.h index 7e99f8a36..b0c1d0543 100644 --- a/ref_app/src/mcal/avr/mcal_port_expander_microchip_mcp23s17.h +++ b/ref_app/src/mcal/avr/mcal_port_expander_microchip_mcp23s17.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020. +// Copyright Christopher Kormanyos 2020 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_PORT_WORD_EXPANDER_MICROCHIP_MCP23S17_2020_04_21_H_ - #define MCAL_PORT_WORD_EXPANDER_MICROCHIP_MCP23S17_2020_04_21_H_ +#ifndef MCAL_PORT_WORD_EXPANDER_MICROCHIP_MCP23S17_2020_04_21_H + #define MCAL_PORT_WORD_EXPANDER_MICROCHIP_MCP23S17_2020_04_21_H #include #include @@ -16,6 +16,9 @@ template class port_regs_expander_microchip_mcp23s17 { + public: + virtual ~port_regs_expander_microchip_mcp23s17() = default; + protected: static constexpr std::uint8_t reg_iodira = UINT8_C(0x00); // MCP23x17 I/O Direction Register static constexpr std::uint8_t reg_iodirb = UINT8_C(0x01); // 1 = Input (default), 0 = Output @@ -74,7 +77,7 @@ my_com.deselect(); } - std::uint16_t read__word(const std::uint8_t reg) + auto read__word(const std::uint8_t reg) -> std::uint16_t { std::uint8_t byte_to_read_lo = std::uint8_t(); std::uint8_t byte_to_read_hi = std::uint8_t(); @@ -91,7 +94,7 @@ return util::make_long(byte_to_read_lo, byte_to_read_hi); } - void write_word(const std::uint8_t reg, const std::uint16_t word_to_write) noexcept + auto write_word(const std::uint8_t reg, const std::uint16_t word_to_write) noexcept -> void { my_com.select(); my_com.send(my_cmd_write); @@ -116,18 +119,20 @@ port_word_expander_microchip_mcp23s17(util::communication_base& com) noexcept : base_class_type(com) { } - void set_port(const std::uint16_t port_value) noexcept + ~port_word_expander_microchip_mcp23s17() override = default; + + auto set_port(const std::uint16_t port_value) noexcept -> void { base_class_type::write_word(base_class_type::reg_gpioa, port_value); } - void set_direction_output() noexcept + auto set_direction_output() noexcept -> void { // Set all ports to output (default is input 0xFFFF). base_class_type::write_word(base_class_type::reg_iodira, UINT16_C(0x0000)); } - void set_direction_input() noexcept + auto set_direction_input() noexcept -> void { // Set all ports to input (default is input 0xFFFF). base_class_type::write_word(base_class_type::reg_iodira, UINT16_C(0xFFFF)); @@ -151,10 +156,9 @@ port_pin_expander_microchip_mcp23s17(util::communication_base& com) noexcept : base_class_type(com) { } + ~port_pin_expander_microchip_mcp23s17() override = default; - virtual ~port_pin_expander_microchip_mcp23s17() = default; - - void set_direction_output(const std::uint8_t bpos) noexcept + auto set_direction_output(const std::uint8_t bpos) noexcept -> void { const std::uint16_t dir = base_class_type::read__word(base_class_type::reg_iodira); @@ -162,7 +166,7 @@ std::uint16_t(dir & std::uint16_t(~std::uint16_t(1ULL << bpos)))); } - void set_direction_input(const std::uint8_t bpos) noexcept + auto set_direction_input(const std::uint8_t bpos) noexcept -> void { const std::uint16_t dir = base_class_type::read__word(base_class_type::reg_iodira); @@ -170,7 +174,7 @@ std::uint16_t(dir | std::uint16_t(1ULL << bpos))); } - void set_pin_high(const std::uint8_t bpos) noexcept + auto set_pin_high(const std::uint8_t bpos) noexcept -> void { const std::uint16_t val = base_class_type::read__word(base_class_type::reg_gpioa); @@ -186,14 +190,14 @@ std::uint16_t(val & std::uint16_t(~std::uint16_t(1ULL << bpos)))); } - bool read_input_value(const std::uint8_t bpos) noexcept + auto read_input_value(const std::uint8_t bpos) noexcept -> bool { const std::uint16_t val = base_class_type::read__word(base_class_type::reg_gpioa); return (std::uint_fast8_t((val >> bpos) & UINT8_C(1)) != UINT8_C(0)); } - void toggle_pin(const std::uint8_t bpos) noexcept + auto toggle_pin(const std::uint8_t bpos) noexcept -> void { const std::uint16_t val = base_class_type::read__word(base_class_type::reg_gpioa); @@ -204,4 +208,4 @@ } } // namespace mcal::port -#endif // MCAL_PORT_WORD_EXPANDER_MICROCHIP_MCP23S17_2020_04_21_H_ +#endif // MCAL_PORT_WORD_EXPANDER_MICROCHIP_MCP23S17_2020_04_21_H diff --git a/ref_app/src/mcal/avr/mcal_port_pin_dummy.h b/ref_app/src/mcal/avr/mcal_port_pin_dummy.h index 625c8769e..0b36dcdce 100644 --- a/ref_app/src/mcal/avr/mcal_port_pin_dummy.h +++ b/ref_app/src/mcal/avr/mcal_port_pin_dummy.h @@ -1,27 +1,27 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020. +// Copyright Christopher Kormanyos 2020 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef PORT_PIN_DUMMY_2020_05_05_H_ - #define PORT_PIN_DUMMY_2020_05_05_H_ +#ifndef PORT_PIN_DUMMY_2020_05_05_H + #define PORT_PIN_DUMMY_2020_05_05_H namespace mcal { namespace port { class port_pin_dummy { public: - static void init () noexcept { } - static void set_direction_output() noexcept { } - static void set_direction_input () noexcept { } - static void set_pin_high () noexcept { } - static void set_pin_low () noexcept { } - static bool read_input_value () noexcept { return false; } - static void toggle_pin () noexcept { } + static auto init () noexcept -> void { } + static auto set_direction_output() noexcept -> void { } + static auto set_direction_input () noexcept -> void { } + static auto set_pin_high () noexcept -> void { } + static auto set_pin_low () noexcept -> void { } + static auto read_input_value () noexcept -> bool { return false; } + static auto toggle_pin () noexcept -> void { } }; } } // namespace mcal::port -#endif // PORT_PIN_DUMMY_2020_05_05_H_ +#endif // PORT_PIN_DUMMY_2020_05_05_H diff --git a/ref_app/src/mcal/avr/mcal_port_word.h b/ref_app/src/mcal/avr/mcal_port_word.h index 0d9d4aa43..2b1b3e95f 100644 --- a/ref_app/src/mcal/avr/mcal_port_word.h +++ b/ref_app/src/mcal/avr/mcal_port_word.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2020. +// Copyright Christopher Kormanyos 2020 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_PORT_WORD_2020_05_06_H_ - #define MCAL_PORT_WORD_2020_05_06_H_ +#ifndef MCAL_PORT_WORD_2020_05_06_H + #define MCAL_PORT_WORD_2020_05_06_H #include @@ -30,13 +30,13 @@ static constexpr address_uintptr_type pinp_address = port_address - address_uintptr_type(2U); public: - static void set_port(const register_value_type value_to_write) + static auto set_port(const register_value_type value_to_write) -> void { mcal::reg::reg_access_dynamic::reg_set(port_address, value_to_write); } - static void set_direction_output() + static auto set_direction_output() -> void { mcal::reg::reg_access_static::reg_set(); } - static void set_direction_input() + static auto set_direction_input() -> void { mcal::reg::reg_access_static void { mcal_port_word_expander_set_port(value_to_write); } - static void set_direction_output() + static auto set_direction_output() -> void { mcal_port_word_expander_set_direction_output(); } - static void set_direction_input() + static auto set_direction_input() -> void { mcal_port_word_expander_set_direction_input(); } @@ -84,4 +84,4 @@ } } // namespace mcal::port -#endif // MCAL_PORT_WORD_2020_05_06_H_ +#endif // MCAL_PORT_WORD_2020_05_06_H diff --git a/ref_app/src/mcal/avr/mcal_pwm.cpp b/ref_app/src/mcal/avr/mcal_pwm.cpp index 2054cd193..fa873e2dc 100644 --- a/ref_app/src/mcal/avr/mcal_pwm.cpp +++ b/ref_app/src/mcal/avr/mcal_pwm.cpp @@ -7,6 +7,6 @@ #include -void mcal::pwm::init(const mcal::pwm::config_type*) +auto mcal::pwm::init(const mcal::pwm::config_type*) -> void { } diff --git a/ref_app/src/mcal/avr/mcal_pwm.h b/ref_app/src/mcal/avr/mcal_pwm.h index 6b7678bc0..6c7b28907 100644 --- a/ref_app/src/mcal/avr/mcal_pwm.h +++ b/ref_app/src/mcal/avr/mcal_pwm.h @@ -14,7 +14,7 @@ { using config_type = void; - void init(const config_type*); + auto init(const config_type*) -> void; } } diff --git a/ref_app/src/mcal/avr/mcal_reg.h b/ref_app/src/mcal/avr/mcal_reg.h index 8b109b7de..21466f49d 100644 --- a/ref_app/src/mcal/avr/mcal_reg.h +++ b/ref_app/src/mcal/avr/mcal_reg.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2020. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_REG_2010_04_10_H_ - #define MCAL_REG_2010_04_10_H_ +#ifndef MCAL_REG_2010_04_10_H + #define MCAL_REG_2010_04_10_H #include @@ -17,76 +17,76 @@ constexpr std::uint8_t sfr_offset = 0x20U; // Bit-position values. - constexpr std::uint8_t bval0 = 1U; - constexpr std::uint8_t bval1 = 1U << 1U; - constexpr std::uint8_t bval2 = 1U << 2U; - constexpr std::uint8_t bval3 = 1U << 3U; - constexpr std::uint8_t bval4 = 1U << 4U; - constexpr std::uint8_t bval5 = 1U << 5U; - constexpr std::uint8_t bval6 = 1U << 6U; - constexpr std::uint8_t bval7 = 1U << 7U; + constexpr std::uint8_t bval0 { 1U }; + constexpr std::uint8_t bval1 { 1U << 1U }; + constexpr std::uint8_t bval2 { 1U << 2U }; + constexpr std::uint8_t bval3 { 1U << 3U }; + constexpr std::uint8_t bval4 { 1U << 4U }; + constexpr std::uint8_t bval5 { 1U << 5U }; + constexpr std::uint8_t bval6 { 1U << 6U }; + constexpr std::uint8_t bval7 { 1U << 7U }; // System registers. - constexpr std::uint8_t mcusr = 0x14U + sfr_offset; - constexpr std::uint8_t prr = 0x64U; + constexpr std::uint8_t mcusr { 0x14U + sfr_offset }; + constexpr std::uint8_t prr { 0x64U }; // Port registers. - constexpr std::uint8_t pinb = 0x03U + sfr_offset; - constexpr std::uint8_t ddrb = 0x04U + sfr_offset; - constexpr std::uint8_t portb = 0x05U + sfr_offset; - constexpr std::uint8_t pinc = 0x06U + sfr_offset; - constexpr std::uint8_t ddrc = 0x07U + sfr_offset; - constexpr std::uint8_t portc = 0x08U + sfr_offset; - constexpr std::uint8_t pind = 0x09U + sfr_offset; - constexpr std::uint8_t ddrd = 0x0AU + sfr_offset; - constexpr std::uint8_t portd = 0x0BU + sfr_offset; - constexpr std::uint8_t pine = 0x0CU + sfr_offset; - constexpr std::uint8_t ddre = 0x0DU + sfr_offset; - constexpr std::uint8_t porte = 0x0EU + sfr_offset; + constexpr std::uint8_t pinb { 0x03U + sfr_offset }; + constexpr std::uint8_t ddrb { 0x04U + sfr_offset }; + constexpr std::uint8_t portb { 0x05U + sfr_offset }; + constexpr std::uint8_t pinc { 0x06U + sfr_offset }; + constexpr std::uint8_t ddrc { 0x07U + sfr_offset }; + constexpr std::uint8_t portc { 0x08U + sfr_offset }; + constexpr std::uint8_t pind { 0x09U + sfr_offset }; + constexpr std::uint8_t ddrd { 0x0AU + sfr_offset }; + constexpr std::uint8_t portd { 0x0BU + sfr_offset }; + constexpr std::uint8_t pine { 0x0CU + sfr_offset }; + constexpr std::uint8_t ddre { 0x0DU + sfr_offset }; + constexpr std::uint8_t porte { 0x0EU + sfr_offset }; // Timer registers - constexpr std::uint8_t tifr0 = 0x15U + sfr_offset; - constexpr std::uint8_t tccr0a = 0x24U + sfr_offset; - constexpr std::uint8_t tccr0b = 0x25U + sfr_offset; - constexpr std::uint8_t tcnt0 = 0x26U + sfr_offset; - constexpr std::uint8_t ocr0a = 0x27U + sfr_offset; - constexpr std::uint8_t timsk0 = 0x6EU; + constexpr std::uint8_t tifr0 { 0x15U + sfr_offset }; + constexpr std::uint8_t tccr0a { 0x24U + sfr_offset }; + constexpr std::uint8_t tccr0b { 0x25U + sfr_offset }; + constexpr std::uint8_t tcnt0 { 0x26U + sfr_offset }; + constexpr std::uint8_t ocr0a { 0x27U + sfr_offset }; + constexpr std::uint8_t timsk0 { 0x6EU }; - constexpr std::uint8_t tifr1 = 0x16U + sfr_offset; - constexpr std::uint8_t tccr1a = 0x80U; - constexpr std::uint8_t tccr1b = 0x81U; - constexpr std::uint8_t tcnt1l = 0x84U; - constexpr std::uint8_t tcnt1h = 0x85U; - constexpr std::uint8_t icr1 = 0x86U; // 16-bit register - constexpr std::uint8_t ocr1a = 0x88U; // 16-bit register - constexpr std::uint8_t ocr1b = 0x8AU; // 16-bit register - constexpr std::uint8_t timsk1 = 0x6FU; + constexpr std::uint8_t tifr1 { 0x16U + sfr_offset }; + constexpr std::uint8_t tccr1a { 0x80U }; + constexpr std::uint8_t tccr1b { 0x81U }; + constexpr std::uint8_t tcnt1l { 0x84U }; + constexpr std::uint8_t tcnt1h { 0x85U }; + constexpr std::uint8_t icr1 { 0x86U }; // 16-bit register + constexpr std::uint8_t ocr1a { 0x88U }; // 16-bit register + constexpr std::uint8_t ocr1b { 0x8AU }; // 16-bit register + constexpr std::uint8_t timsk1 { 0x6FU }; - constexpr std::uint8_t tifr2 = 0x17U + sfr_offset; - constexpr std::uint8_t tccr2a = 0xB0U; - constexpr std::uint8_t tccr2b = 0xB1U; - constexpr std::uint8_t tcnt2 = 0xB2U; - constexpr std::uint8_t ocr2a = 0xB3U; - constexpr std::uint8_t timsk2 = 0x70U; + constexpr std::uint8_t tifr2 { 0x17U + sfr_offset }; + constexpr std::uint8_t tccr2a { 0xB0U }; + constexpr std::uint8_t tccr2b { 0xB1U }; + constexpr std::uint8_t tcnt2 { 0xB2U }; + constexpr std::uint8_t ocr2a { 0xB3U }; + constexpr std::uint8_t timsk2 { 0x70U }; // SPI(TM) registers. - constexpr std::uint8_t spcr = 0x2CU + sfr_offset; - constexpr std::uint8_t spsr = 0x2DU + sfr_offset; - constexpr std::uint8_t spdr = 0x2EU + sfr_offset; + constexpr std::uint8_t spcr { 0x2CU + sfr_offset }; + constexpr std::uint8_t spsr { 0x2DU + sfr_offset }; + constexpr std::uint8_t spdr { 0x2EU + sfr_offset }; // Watchdog registers - constexpr std::uint8_t wdtcsr = 0x60U; + constexpr std::uint8_t wdtcsr { 0x60U }; // Eeprom registers - constexpr std::uint8_t eecr = 0x1FU + sfr_offset; - constexpr std::uint8_t eedr = 0x20U + sfr_offset; - constexpr std::uint8_t eear = 0x21U + sfr_offset; - constexpr std::uint8_t eearl = 0x21U + sfr_offset; - constexpr std::uint8_t eearh = 0x22U + sfr_offset; + constexpr std::uint8_t eecr { 0x1FU + sfr_offset }; + constexpr std::uint8_t eedr { 0x20U + sfr_offset }; + constexpr std::uint8_t eear { 0x21U + sfr_offset }; + constexpr std::uint8_t eearl { 0x21U + sfr_offset }; + constexpr std::uint8_t eearh { 0x22U + sfr_offset }; } } #include #include -#endif // MCAL_REG_2010_04_10_H_ +#endif // MCAL_REG_2010_04_10_H diff --git a/ref_app/src/mcal/avr/mcal_ser.h b/ref_app/src/mcal/avr/mcal_ser.h index 3515a81d3..10b706f50 100644 --- a/ref_app/src/mcal/avr/mcal_ser.h +++ b/ref_app/src/mcal/avr/mcal_ser.h @@ -1,21 +1,21 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2020. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_SER_2011_10_20_H_ - #define MCAL_SER_2011_10_20_H_ +#ifndef MCAL_SER_2011_10_20_H + #define MCAL_SER_2011_10_20_H namespace mcal { namespace ser { - typedef void config_type; + using config_type = void; - inline void init(const config_type*) { } + inline auto init(const config_type*) -> void { } } } -#endif // MCAL_SER_2011_10_20_H_ +#endif // MCAL_SER_2011_10_20_H diff --git a/ref_app/src/mcal/avr/mcal_spi.cpp b/ref_app/src/mcal/avr/mcal_spi.cpp index ef165839c..cce60154f 100644 --- a/ref_app/src/mcal/avr/mcal_spi.cpp +++ b/ref_app/src/mcal/avr/mcal_spi.cpp @@ -1,14 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2012 - 2020. +// Copyright Christopher Kormanyos 2012 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include -#include #include -void mcal::spi::init(const config_type*) +auto mcal::spi::init(const config_type*) -> void { } diff --git a/ref_app/src/mcal/avr/mcal_spi.h b/ref_app/src/mcal/avr/mcal_spi.h index cc669666b..19d930705 100644 --- a/ref_app/src/mcal/avr/mcal_spi.h +++ b/ref_app/src/mcal/avr/mcal_spi.h @@ -1,23 +1,19 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2012 - 2020. +// Copyright Christopher Kormanyos 2012 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_SPI_2012_05_24_H_ - #define MCAL_SPI_2012_05_24_H_ - - #include +#ifndef MCAL_SPI_2012_05_24_H + #define MCAL_SPI_2012_05_24_H namespace mcal { namespace spi { - typedef void config_type; - - void init(const config_type*); + using config_type = void; - util::communication_base& spi0(); + auto init(const config_type*) -> void; } } -#endif // MCAL_SPI_2012_05_24_H_ +#endif // MCAL_SPI_2012_05_24_H diff --git a/ref_app/src/mcal/avr/mcal_wdg.cpp b/ref_app/src/mcal/avr/mcal_wdg.cpp index ef63031ff..1539f38f0 100644 --- a/ref_app/src/mcal/avr/mcal_wdg.cpp +++ b/ref_app/src/mcal/avr/mcal_wdg.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -8,7 +8,7 @@ #include #include -void mcal::wdg::init(const config_type*) +auto mcal::wdg::init(const config_type*) -> void { // Read the MCU status register. volatile const std::uint8_t mcu_status_register = @@ -44,7 +44,7 @@ void mcal::wdg::init(const config_type*) std::uint8_t(0x08U) | std::uint8_t(0x07U)>::reg_set(); } -void mcal::wdg::secure::trigger() +auto mcal::wdg::secure::trigger() -> void { asm volatile("wdr"); } diff --git a/ref_app/src/mcal/avr/mcal_wdg.h b/ref_app/src/mcal/avr/mcal_wdg.h index 19353b106..23a37e965 100644 --- a/ref_app/src/mcal/avr/mcal_wdg.h +++ b/ref_app/src/mcal/avr/mcal_wdg.h @@ -1,16 +1,16 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef MCAL_WDT_2010_04_10_H_ - #define MCAL_WDT_2010_04_10_H_ +#ifndef MCAL_WDT_2010_04_10_H + #define MCAL_WDT_2010_04_10_H extern "C" void __my_startup() __attribute__((section(".startup"), used, noinline)); - namespace sys { namespace idle { void task_func(); } } + namespace sys { namespace idle { auto task_func() -> void; } } namespace util { template class timer; } @@ -18,22 +18,22 @@ { namespace wdg { - typedef void config_type; + using config_type = void; - void init(const config_type*); + auto init(const config_type*) -> void; struct secure final { private: - friend void ::sys::idle::task_func(); + friend auto ::sys::idle::task_func() -> void; friend void ::__my_startup(); template friend class util::timer; - static void trigger(); + static auto trigger() -> void; }; } } -#endif // MCAL_WDT_2010_04_10_H_ +#endif // MCAL_WDT_2010_04_10_H diff --git a/ref_app/src/mcal/host/mcal_port.h b/ref_app/src/mcal/host/mcal_port.h index 43447f387..7fcb3e967 100644 --- a/ref_app/src/mcal/host/mcal_port.h +++ b/ref_app/src/mcal/host/mcal_port.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2023. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -19,12 +19,12 @@ class port_pin { public: - static auto set_direction_output()noexcept -> void { } - static auto set_direction_input ()noexcept -> void { } - static auto set_pin_high ()noexcept -> void { } - static auto set_pin_low ()noexcept -> void { } - static auto read_input_value ()noexcept -> bool { return false; } - static auto toggle_pin ()noexcept -> void { } + static constexpr auto set_direction_output() noexcept -> void { } + static constexpr auto set_direction_input () noexcept -> void { } + static constexpr auto set_pin_high () noexcept -> void { } + static constexpr auto set_pin_low () noexcept -> void { } + static constexpr auto read_input_value () noexcept -> bool { return false; } + static constexpr auto toggle_pin () noexcept -> void { } }; } } diff --git a/ref_app/src/util/utility/util_circular_buffer.h b/ref_app/src/util/utility/util_circular_buffer.h deleted file mode 100644 index 8b9b5265d..000000000 --- a/ref_app/src/util/utility/util_circular_buffer.h +++ /dev/null @@ -1,374 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2015. -// Distributed under the Boost Software License, -// Version 1.0. (See accompanying file LICENSE_1_0.txt -// or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#ifndef UTIL_CIRCULAR_BUFFER_2007_11_22_H_ - #define UTIL_CIRCULAR_BUFFER_2007_11_22_H_ - - #include - #include - #include - - namespace util - { - // Forward declaration of the circular_buffer class. - template - class circular_buffer; - - namespace circular_buffer_detail - { - template - struct circular_iterator : public std::iterator - { - public: - typedef std::iterator iterator_type; - - typedef typename iterator_type::value_type value_type; - typedef typename iterator_type::pointer pointer; - typedef typename iterator_type::reference reference; - typedef const reference const_reference; - typedef typename std::size_t size_type; - typedef typename iterator_type::difference_type difference_type; - - explicit circular_iterator(const pointer pb, - const pointer pc = pb) : buffer_pointer (pb), - circular_pointer(pc) { } - - ~circular_iterator() { } - - circular_iterator& operator=(const circular_iterator& other_iterator) - { - if(this != &other_iterator) - { - buffer_pointer = other_iterator.buffer_pointer; - circular_pointer = other_iterator.circular_pointer; - } - - return *this; - } - - const_reference operator*() const - { - return *circular_pointer; - } - - reference operator*() - { - return *const_cast(circular_pointer); - } - - circular_iterator& operator++() - { - ++circular_pointer; - - if(circular_pointer > (buffer_pointer + difference_type(N))) - { - circular_pointer = buffer_pointer; - } - - return *this; - } - - circular_iterator& operator--() - { - --circular_pointer; - - if(circular_pointer < buffer_pointer) - { - circular_pointer = buffer_pointer + difference_type(N); - } - - return *this; - } - - circular_iterator operator++(int) - { - circular_iterator tmp = *this; - - ++(*this); - - return tmp; - } - - circular_iterator operator--(int) - { - circular_iterator tmp = *this; - - --(*this); - - return tmp; - } - - circular_iterator& operator+=(difference_type n) - { - if(n > difference_type(0)) - { - circular_pointer += n; - - if(circular_pointer > (buffer_pointer + difference_type(N))) - { - circular_pointer -= difference_type(N); - } - } - else if(n < 0) - { - *this -= -n; - } - - return *this; - } - - circular_iterator& operator-=(difference_type n) - { - if(n > difference_type(0)) - { - circular_pointer -= n; - - if(circular_pointer < buffer_pointer) - { - circular_pointer += difference_type(N); - } - } - else if(n < 0) - { - *this += -n; - } - - return *this; - } - - private: - pointer buffer_pointer; - pointer circular_pointer; - - circular_iterator(); - - friend inline circular_iterator operator+(const circular_iterator& a, difference_type n) { return circular_iterator(a) += n; } - friend inline circular_iterator operator-(const circular_iterator& a, difference_type n) { return circular_iterator(a) -= n; } - - friend inline bool operator==(const circular_iterator& a, const circular_iterator& b) { return (a.circular_pointer == b.circular_pointer); } - friend inline bool operator!=(const circular_iterator& a, const circular_iterator& b) { return (a.circular_pointer != b.circular_pointer); } - - // TBD: Implement operator<(). - // TBD: Implement the remaining operators. - }; - } - - template - class circular_buffer - { - public: - static_assert(N > std::size_t(0U), - "Error: The circular_buffer class requires more than zero elements."); - - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - typedef value_type& reference; - typedef const value_type& const_reference; - - typedef circular_buffer_detail::circular_iterator > iterator; - typedef circular_buffer_detail::circular_iterator > const_iterator; - - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; - - circular_buffer() : buffer (), - my_size(difference_type(0)), - first (buffer + difference_type(N)), - last (buffer + difference_type(N)) - { - std::fill(buffer, buffer + difference_type(N), value_type()); - } - - explicit circular_buffer(const size_type count, - const value_type value = value_type()) : buffer (), - my_size(difference_type(count)), - first (buffer + difference_type(N - count)), - last (buffer + difference_type(N)) - { - std::fill(buffer, buffer + difference_type(N - count), value_type()); - - std::fill(buffer + difference_type(N - count), buffer + difference_type(N), value); - } - - circular_buffer(const circular_buffer& other) : buffer (), - my_size(difference_type(other.size())), - first (buffer + difference_type(other.first - other.buffer)), - last (buffer + difference_type(other.last - other.buffer)) - { - std::copy(other.buffer, other.buffer + difference_type(N), buffer); - } - - ~circular_buffer() { } - - circular_buffer& operator=(const circular_buffer& other) - { - if(this != &other) - { - std::copy(other.buffer, other.buffer + difference_type(N), buffer); - - my_size = difference_type(other.size()); - - first = buffer + difference_type(other.first - other.buffer); - last = buffer + difference_type(other.last - other.buffer); - } - - return *this; - } - - static size_type capacity() { return N; } - - bool empty() const - { - return (my_size == difference_type(0U)); - } - - size_type size() const - { - return size_type(my_size); - } - - void clear() - { - first = buffer; - last = buffer + difference_type(N); - my_size = difference_type(0); - } - - void push_front(const value_type value) - { - --first; - - if(first < buffer) - { - first = buffer + difference_type(N - 1U); - } - - *first = value; - - if(my_size < difference_type(N)) - { - ++my_size; - } - } - - void pop_back() - { - if(my_size > difference_type(0)) - { - --my_size; - - // TBD: Do we actually need to manually call the destructor here? - last->~value_type(); - - --last; - - if(last <= buffer) - { - last = buffer + difference_type(N); - } - } - } - - iterator begin () { return iterator (buffer, first); } - const_iterator begin () const { return const_iterator(buffer, first); } - const_iterator cbegin() const { return const_iterator(buffer, first); } - iterator end () { return iterator (buffer, last); } - const_iterator end () const { return const_iterator(buffer, last); } - const_iterator cend () const { return const_iterator(buffer, last); } - - reverse_iterator rbegin () { return std::reverse_iterator (iterator (buffer, last)); } - const_reverse_iterator rbegin () const { return std::reverse_iterator(const_iterator(buffer, last)); } - const_reverse_iterator crbegin() const { return std::reverse_iterator(const_iterator(buffer, last)); } - reverse_iterator rend () { return std::reverse_iterator (iterator (buffer, first)); } - const_reverse_iterator rend () const { return std::reverse_iterator(const_iterator(buffer, first)); } - const_reverse_iterator crend () const { return std::reverse_iterator(const_iterator(buffer, first)); } - - reference front () { return *begin(); } - const_reference front () const { return *begin(); } - reference back () { return *(end() - iterator::difference_type(1)); } - const_reference back () const { return *(cend() - const_iterator::difference_type(1)); } - - private: - value_type buffer[N]; - difference_type my_size; - pointer first; - pointer last; - }; - } - - /* - #include - #include - #include - #include - - template - void do_something() - { - circular_buffer_type cb(1U, 1U); - - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - cb.push_front(2U); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - cb.push_front(3U); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - - cb.pop_back(); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - cb.pop_back(); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - cb.pop_back(); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - - cb.push_front(101U); - cb.push_front(102U); - cb.push_front(103U); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - - for(auto it = cb.cbegin(); it != cb.cbegin() + cb.size(); ++it) { std::cout << *it << std::endl; } - for(auto it = cb.crbegin(); it != cb.crend(); ++it) { std::cout << *it << std::endl; } - - cb.pop_back(); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - - cb.pop_back(); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - - cb.push_front(42U); - std::cout << cb.size() << ", " << cb.front() << ", " << cb.back() << std::endl; - - circular_buffer_type other_cb; - - other_cb = cb; - - volatile unsigned debug = 0U; - - static_cast(debug); - } - - int main() - { - do_something>(); - } -*/ - -#endif // UTIL_CIRCULAR_BUFFER_2007_11_22_H_ diff --git a/ref_app/src/util/utility/util_communication.h b/ref_app/src/util/utility/util_communication.h index f0a62ac15..5ee9788e1 100644 --- a/ref_app/src/util/utility/util_communication.h +++ b/ref_app/src/util/utility/util_communication.h @@ -8,13 +8,13 @@ #ifndef UTIL_COMMUNICATION_2012_05_31_H #define UTIL_COMMUNICATION_2012_05_31_H + #include + #include #include #include #include - #include - namespace util { class communication_base : private util::noncopyable diff --git a/ref_app/src/util/utility/util_countof.h b/ref_app/src/util/utility/util_countof.h index c50414f95..4776b2662 100644 --- a/ref_app/src/util/utility/util_countof.h +++ b/ref_app/src/util/utility/util_countof.h @@ -1,46 +1,26 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2014. +// Copyright Christopher Kormanyos 2014 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_COUNTOF_2014_09_29_H_ - #define UTIL_COUNTOF_2014_09_29_H_ +#ifndef UTIL_COUNTOF_2014_09_29_H + #define UTIL_COUNTOF_2014_09_29_H #include namespace util { - #if defined(__GNUC__) + template + inline constexpr auto countof(T(&c_array)[N]) -> std::size_t + { + static_assert(N > std::size_t(0U), "Error: util::countof requires an array size larger than zero."); - template - inline constexpr std::size_t countof(T(&c_array)[N]) - { - static_assert(N > std::size_t(0U), - "Sorry, util::countof requires an array size larger than zero."); + static_assert(sizeof(c_array[0U]) > std::size_t(0U), "Error: util::countof requires an element size larger than zero."); - static_assert(sizeof(c_array[0U]) > std::size_t(0U), - "Sorry, util::countof requires an element size larger than zero."); - - return sizeof(c_array) / sizeof(c_array[0U]); - } - - #else - - template - inline std::size_t countof(T(&c_array)[N]) - { - static_assert(N > std::size_t(0U), - "Sorry, util::countof requires an array size larger than zero."); - - static_assert(sizeof(c_array[0U]) > std::size_t(0U), - "Sorry, util::countof requires an element size larger than zero."); - - return sizeof(c_array) / sizeof(c_array[0U]); - } - - #endif + return sizeof(c_array) / sizeof(c_array[0U]); + } } -#endif // UTIL_COUNTOF_2014_09_29_H_ +#endif // UTIL_COUNTOF_2014_09_29_H diff --git a/ref_app/src/util/utility/util_display.h b/ref_app/src/util/utility/util_display.h index f5b2df40c..b3176185f 100644 --- a/ref_app/src/util/utility/util_display.h +++ b/ref_app/src/util/utility/util_display.h @@ -35,7 +35,7 @@ using timer_type = util::timer; - static void blocking_delay(const typename timer_type::tick_type blocking_delay_value) + static auto blocking_delay(const typename timer_type::tick_type blocking_delay_value) -> void { timer_type::blocking_delay(blocking_delay_value); } diff --git a/ref_app/src/util/utility/util_nothing.h b/ref_app/src/util/utility/util_nothing.h index cf3fbb457..00f767069 100644 --- a/ref_app/src/util/utility/util_nothing.h +++ b/ref_app/src/util/utility/util_nothing.h @@ -1,33 +1,35 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2018. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_NOTHING_2010_06_13_H_ - #define UTIL_NOTHING_2010_06_13_H_ +#ifndef UTIL_NOTHING_2010_06_13_H + #define UTIL_NOTHING_2010_06_13_H namespace util { // This is a structure that is used to represent *nothing*. struct nothing final { - nothing() = default; + constexpr nothing() = default; - nothing(const nothing&) { } + constexpr nothing(const nothing&) { } + constexpr nothing(nothing&&) noexcept { } ~nothing() = default; - nothing& operator=(const nothing&) { return *this; } + constexpr auto operator=(const nothing&) -> nothing& { return *this; } + constexpr auto operator=(nothing&&) noexcept -> nothing& { return *this; } }; - inline bool operator==(const nothing&, const nothing&) { return true; } - inline bool operator!=(const nothing&, const nothing&) { return false; } - inline bool operator< (const nothing&, const nothing&) { return false; } - inline bool operator<=(const nothing&, const nothing&) { return false; } - inline bool operator> (const nothing&, const nothing&) { return false; } - inline bool operator>=(const nothing&, const nothing&) { return false; } + inline constexpr auto operator==(const nothing&, const nothing&) noexcept -> bool { return true; } + inline constexpr auto operator!=(const nothing&, const nothing&) noexcept -> bool { return false; } + inline constexpr auto operator< (const nothing&, const nothing&) noexcept -> bool { return false; } + inline constexpr auto operator<=(const nothing&, const nothing&) noexcept -> bool { return false; } + inline constexpr auto operator> (const nothing&, const nothing&) noexcept -> bool { return false; } + inline constexpr auto operator>=(const nothing&, const nothing&) noexcept -> bool { return false; } } -#endif // UTIL_NOTHING_2010_06_13_H_ +#endif // UTIL_NOTHING_2010_06_13_H diff --git a/ref_app/src/util/utility/util_point.h b/ref_app/src/util/utility/util_point.h index c645b8a57..5e881298c 100644 --- a/ref_app/src/util/utility/util_point.h +++ b/ref_app/src/util/utility/util_point.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2014. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_POINT_2008_11_22_H_ - #define UTIL_POINT_2008_11_22_H_ +#ifndef UTIL_POINT_2008_11_22_H + #define UTIL_POINT_2008_11_22_H namespace util { @@ -14,57 +14,62 @@ typename y_type = x_type> struct point { - x_type x; - y_type y; + x_type x { }; + y_type y { }; - point(const x_type& x0 = x_type(), - const y_type& y0 = y_type()) : x(x0), - y(y0) { } + explicit constexpr point(const x_type& x0 = x_type(), + const y_type& y0 = y_type()) : x { x0 }, + y { y0 } { } - point(const point& other) + constexpr point(const point& other) : x { other.x }, + y { other.y } { } + + constexpr point(point&& other) noexcept : x { other.x }, + y { other.y } { } + + ~point() = default; + + constexpr auto operator=(const point& other) -> point& { if(this != &other) { x = other.x; y = other.y; } - } - ~point() { } + return *this; + } - point& operator=(const point& other) + constexpr auto operator=(point&& other) noexcept -> point& { - if(this != &other) - { - x = other.x; - y = other.y; - } + x = other.x; + y = other.y; return *this; } - bool operator<(const point& other) const + constexpr auto operator<(const point& other) const -> bool { return (x < other.x); } }; template - bool operator==(const point& left, const point& right) + constexpr auto operator==(const point& left, const point& right) -> bool { return ( (left.x == right.x) && (left.y == right.y)); } template - bool operator!=(const point& left, const point& right) + constexpr auto operator!=(const point& left, const point& right) -> bool { return ( (left.x != right.x) || (left.y != right.y)); } template - bool operator<(const point& left, const point& right) + constexpr auto operator<(const point& left, const point& right) -> bool { return ((left.x < right.x) ? true @@ -74,22 +79,22 @@ } template - bool operator<=(const point& left, const point& right) + constexpr auto operator<=(const point& left, const point& right) -> bool { return ((right < left) == false); } template - bool operator>(const point& left, const point& right) + constexpr auto operator>(const point& left, const point& right) -> bool { return (right < left); } template - bool operator>=(const point& left, const point& right) + constexpr auto operator>=(const point& left, const point& right) -> bool { return ((left < right) == false); } } -#endif // UTIL_POINT_2008_11_22_H_ +#endif // UTIL_POINT_2008_11_22_H diff --git a/ref_app/src/util/utility/util_stopwatch.h b/ref_app/src/util/utility/util_stopwatch.h index a5fed1dca..44157b99b 100644 --- a/ref_app/src/util/utility/util_stopwatch.h +++ b/ref_app/src/util/utility/util_stopwatch.h @@ -8,6 +8,8 @@ #ifndef UTIL_STOPWATCH_2014_01_07_H #define UTIL_STOPWATCH_2014_01_07_H + #include + namespace util { template diff --git a/ref_app/src/util/utility/util_swdm.h b/ref_app/src/util/utility/util_swdm.h index 5fe4f32c5..3e95bc48e 100644 --- a/ref_app/src/util/utility/util_swdm.h +++ b/ref_app/src/util/utility/util_swdm.h @@ -128,13 +128,42 @@ // /////////////////////////////////////////////////////////////////////////////// -#ifndef UTIL_SWDM_2016_04_11_H_ -#define UTIL_SWDM_2016_04_11_H_ +#ifndef UTIL_SWDM_2016_04_11_H +#define UTIL_SWDM_2016_04_11_H + +#if defined(__has_include) + #if(__has_include()) + #include + + #define UTIL_SWDM_HAS_USER_DEFINED_PORT + #endif +#endif -#include -#include #include +#include + +#if !defined(UTIL_SWDM_HAS_USER_DEFINED_PORT) +class dummy_port +{ + public: + static constexpr auto set_direction_output() noexcept -> void { } + static constexpr auto set_direction_input () noexcept -> void { } + static constexpr auto set_pin_high () noexcept -> void { } + static constexpr auto set_pin_low () noexcept -> void { } + static constexpr auto read_input_value () noexcept -> bool { return false; } + static constexpr auto toggle_pin () noexcept -> void { } +}; + +namespace mcal { namespace debug { + +using debug_monitor_port_type = dummy_port; + +} // namespace debug +} // namespace mcal + +#endif + // Defines the oversampling rate // The effective baud rate is the service_tick_rate / SWD_OVERSAMPLING_COUNT // For a service_tick_rate of 1 ms, the baud rate is 250 for 4 times oversampling @@ -699,8 +728,8 @@ class swdm : private util::noncopyable } private: - static const std::uint_fast8_t request_sync_field = UINT8_C(0x55); // Request sync field - static const std::uint_fast8_t response_sync_field = UINT8_C(0xAA); // Response sync field + static constexpr std::uint_fast8_t request_sync_field = UINT8_C(0x55); // Request sync field + static constexpr std::uint_fast8_t response_sync_field = UINT8_C(0xAA); // Response sync field typedef enum enum_state_type { @@ -744,4 +773,4 @@ class swdm : private util::noncopyable } // namespace util -#endif // UTIL_SWDM_2016_04_11_H_ +#endif // UTIL_SWDM_2016_04_11_H diff --git a/ref_app/src/util/utility/util_two_part_data_manipulation.h b/ref_app/src/util/utility/util_two_part_data_manipulation.h index 7d3254997..fcedbda15 100644 --- a/ref_app/src/util/utility/util_two_part_data_manipulation.h +++ b/ref_app/src/util/utility/util_two_part_data_manipulation.h @@ -1,21 +1,22 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2021. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_TWO_PART_DATA_MANIPULATION_2010_06_13_H_ - #define UTIL_TWO_PART_DATA_MANIPULATION_2010_06_13_H_ +#ifndef UTIL_TWO_PART_DATA_MANIPULATION_2010_06_13_H + #define UTIL_TWO_PART_DATA_MANIPULATION_2010_06_13_H - #include #include + #include + namespace util { template(std::numeric_limits::digits * 2)>::exact_type> - inline unsigned_long_type make_long(unsigned_short_type lo, unsigned_short_type hi) + inline constexpr auto make_long(unsigned_short_type lo, unsigned_short_type hi) -> unsigned_long_type { // Ensure that the unsigned_short_type is an integer type. static_assert(std::numeric_limits::is_integer == true, @@ -42,7 +43,7 @@ template(std::numeric_limits::digits * 2)>::exact_type> - inline unsigned_short_type lo_part(unsigned_long_type val) + inline constexpr auto lo_part(unsigned_long_type val) -> unsigned_short_type { // Ensure that the unsigned_short_type is an integer type. static_assert(std::numeric_limits::is_integer == true, @@ -69,7 +70,7 @@ template(std::numeric_limits::digits * 2)>::exact_type> - inline unsigned_short_type hi_part(unsigned_long_type val) + inline constexpr auto hi_part(unsigned_long_type val) -> unsigned_short_type { // Ensure that the unsigned_short_type is an integer type. static_assert(std::numeric_limits::is_integer == true, @@ -95,4 +96,4 @@ } } -#endif // UTIL_TWO_PART_DATA_MANIPULATION_2010_06_13_H_ +#endif // UTIL_TWO_PART_DATA_MANIPULATION_2010_06_13_H diff --git a/ref_app/src/util/utility/util_utype_helper.h b/ref_app/src/util/utility/util_utype_helper.h index b25081836..7a0d37ac1 100644 --- a/ref_app/src/util/utility/util_utype_helper.h +++ b/ref_app/src/util/utility/util_utype_helper.h @@ -1,12 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// -// Copyright Christopher Kormanyos 2007 - 2021. +// Copyright Christopher Kormanyos 2007 - 2024. // Distributed under the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) // -#ifndef UTIL_UTYPE_HELPER_2012_01_23_H_ - #define UTIL_UTYPE_HELPER_2012_01_23_H_ +#ifndef UTIL_UTYPE_HELPER_2012_01_23_H + #define UTIL_UTYPE_HELPER_2012_01_23_H #include @@ -17,44 +17,44 @@ static_assert(utype_bit_count <= 64U, "the bit count of the unsigned type can not exceed 64"); - typedef std::uint64_t exact_type; + using exact_type = std::uint64_t; }; - template<> struct utype_helper<0U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<1U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<2U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<3U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<4U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<5U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<6U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<7U> { typedef std::uint8_t exact_type; }; - template<> struct utype_helper<8U> { typedef std::uint8_t exact_type; }; - - template<> struct utype_helper<9U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<10U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<11U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<12U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<13U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<14U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<15U> { typedef std::uint16_t exact_type; }; - template<> struct utype_helper<16U> { typedef std::uint16_t exact_type; }; - - template<> struct utype_helper<17U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<18U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<19U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<20U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<21U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<22U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<23U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<24U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<25U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<26U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<27U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<28U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<29U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<30U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<31U> { typedef std::uint32_t exact_type; }; - template<> struct utype_helper<32U> { typedef std::uint32_t exact_type; }; + template<> struct utype_helper<0U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<1U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<2U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<3U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<4U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<5U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<6U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<7U> { using exact_type = std::uint8_t; }; + template<> struct utype_helper<8U> { using exact_type = std::uint8_t; }; + + template<> struct utype_helper<9U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<10U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<11U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<12U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<13U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<14U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<15U> { using exact_type = std::uint16_t; }; + template<> struct utype_helper<16U> { using exact_type = std::uint16_t; }; + + template<> struct utype_helper<17U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<18U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<19U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<20U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<21U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<22U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<23U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<24U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<25U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<26U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<27U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<28U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<29U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<30U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<31U> { using exact_type = std::uint32_t; }; + template<> struct utype_helper<32U> { using exact_type = std::uint32_t; }; } -#endif // UTIL_UTYPE_HELPER_2012_01_23_H_ +#endif // UTIL_UTYPE_HELPER_2012_01_23_H