From 8bf3d1a87411d0fdade0941ff51832cd6dd0a425 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Sun, 29 May 2022 16:14:42 +0200 Subject: [PATCH] Make use of C++ standard library --- config.hpp | 6 ++++-- hardware.hpp | 6 ++++-- software.hpp | 20 +++++++++++--------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/config.hpp b/config.hpp index f3b1f79..23e45b7 100644 --- a/config.hpp +++ b/config.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "../io/io.hpp" namespace spi { @@ -44,8 +46,8 @@ struct HardwareConfig { static constexpr auto PULLUP = pullup; }; -template +template struct SoftwareConfig { static constexpr auto SCK_PIN = sckPin; static constexpr auto MISO_PIN = misoPin; diff --git a/hardware.hpp b/hardware.hpp index 4d849df..71d494a 100644 --- a/hardware.hpp +++ b/hardware.hpp @@ -1,5 +1,7 @@ #pragma once +#include + #include "../io/io.hpp" namespace spi { @@ -9,7 +11,7 @@ namespace spi { template class Hardware { public: - using word_t = uint8_t; + using word_t = std::uint8_t; static void init() { @@ -58,7 +60,7 @@ class Hardware { static void setClockDiv() { - uint8_t ui8ClockDiv = static_cast(Cfg::FREQ); + std::uint8_t ui8ClockDiv = static_cast(Cfg::FREQ); if (ui8ClockDiv & 1) { SPCR = SPCR | (1 << SPR0); diff --git a/software.hpp b/software.hpp index cec67c7..4594d9b 100644 --- a/software.hpp +++ b/software.hpp @@ -2,12 +2,14 @@ #include "../clock.hpp" -#include +#include +#include + +#include #include #include "../io/io.hpp" -#include "../util/type.hpp" #include "../util/util.hpp" namespace spi { @@ -27,10 +29,10 @@ class Software { public: static_assert(Cfg::BITS >= 1 && Cfg::BITS <= 64, "Word size must be in range [1-64]"); // clang-format off - using word_t = util::conditional_t>>; + using word_t = std::conditional_t>>; // clang-format on static void init() @@ -76,7 +78,7 @@ class Software { _delay_us(DELAY_US); } }, - util::make_index_sequence{}); + std::make_index_sequence{}); enableInterrupts(oldInterruptState); @@ -96,14 +98,14 @@ class Software { static constexpr auto DELAY_US = calcClockDelay(); - static inline uint8_t disableInterrupts() + static inline std::uint8_t disableInterrupts() { const auto oldInterruptState = SREG; cli(); return oldInterruptState; } - static inline void enableInterrupts(const uint8_t oldInterruptState) + static inline void enableInterrupts(const std::uint8_t oldInterruptState) { SREG = oldInterruptState; }