diff --git a/uart/main.cpp b/uart/main.cpp index 2874a2a..8207fdc 100644 --- a/uart/main.cpp +++ b/uart/main.cpp @@ -11,7 +11,7 @@ void newUartUsage() { using namespace uart; - Uart, Driven::INTERRUPT>> serial1; + Uart, Driven::INTERRUPT, Mode::ASYNCHRONOUS>> serial1; serial1.init(); serial1 << "New uart hi from RAM. " << F("New uart hi from flash\r\n"); @@ -43,7 +43,7 @@ void newUartUsage2() using namespace uart; using config = Config<115200, DataBits::EIGHT, Parity::NONE, StopBits::ONE>; - using uart0 = Hardware0; + using uart0 = Hardware0; Uart serial; serial.init(); @@ -56,7 +56,7 @@ void newUartUsage2() void newUartStreamOverloads() { using namespace uart; - Uart, Driven::BLOCKING>> serial; + Uart, Driven::BLOCKING, Mode::ASYNCHRONOUS>> serial; serial.init(); bool bVal = true; @@ -109,37 +109,36 @@ void newUartStreamOverloads() serial.flushTx(); } -/* namespace spi { enum class Cpol { - MODE_0, - MODE_1, + MODE_0, + MODE_1, }; enum class Cpha { - MODE_0, - MODE_1, + MODE_0, + MODE_1, }; enum class DataOrder { - MSB, - LSB, + MSB, + LSB, }; template struct Config { - static constexpr auto CPOL_MODE = cpol; - static constexpr auto CPHA_MODE = cpha; - static constexpr auto DATA_ORDER = dataOrder; + static constexpr auto CPOL_MODE = cpol; + static constexpr auto CPHA_MODE = cpha; + static constexpr auto DATA_ORDER = dataOrder; }; template struct spi { - spi() - { - Driver::init(); - } + spi() + { + Driver::init(); + } }; } // namespace spi @@ -147,44 +146,43 @@ struct spi { namespace uart { template -class Hardware0 { +class Hardware0 { public: - static void init() - { - UCSR0C |= (1 << UMSEL01) | (1 << UMSEL00); + static void init() + { + UCSR0C |= (1 << UMSEL01) | (1 << UMSEL00); - if (DATA_ORDER == spi::DataOrder::MSB) - UCSR0C &= ~(1 << UCSZ01); - else - UCSR0C |= (1 << UCSZ01); + if (DATA_ORDER == spi::DataOrder::MSB) + UCSR0C &= ~(1 << UCSZ01); + else + UCSR0C |= (1 << UCSZ01); - if (CPOL_MODE == spi::Cpol::MODE_0) - UCSR0C &= ~(1 << UCPOL0); - else - UCSR0C |= (1 << UCPOL0); + if (CPOL_MODE == spi::Cpol::MODE_0) + UCSR0C &= ~(1 << UCPOL0); + else + UCSR0C |= (1 << UCPOL0); - if (CPHA_MODE == spi::Cpha::MODE_0) - UCSR0C &= ~(1 << UCSZ00); - else - UCSR0C |= (1 << UCSZ00); - } + if (CPHA_MODE == spi::Cpha::MODE_0) + UCSR0C &= ~(1 << UCSZ00); + else + UCSR0C |= (1 << UCSZ00); + } private: - static constexpr auto CPOL_MODE = Config::CPOL_MODE; - static constexpr auto CPHA_MODE = Config::CPHA_MODE; - static constexpr auto DATA_ORDER = Config::DATA_ORDER; + static constexpr auto CPOL_MODE = Config::CPOL_MODE; + static constexpr auto CPHA_MODE = Config::CPHA_MODE; + static constexpr auto DATA_ORDER = Config::DATA_ORDER; }; } // namespace uart void spiTest() { - using config = spi::Config; - using uartspi = uart::Hardware0; + using config = spi::Config; + using uartspi = uart::Hardware0; - spi::spi uartSpi; + spi::spi uartSpi; } -*/ static inline void initUart(const uint32_t baudRate) { @@ -247,7 +245,7 @@ int main() txString(F("\r\n")); flushTx(); - // spiTest(); + spiTest(); return 0; } diff --git a/uart/uart b/uart/uart index 87e6936..c4f38cb 160000 --- a/uart/uart +++ b/uart/uart @@ -1 +1 @@ -Subproject commit 87e693605143d019f1f6eb7b5ca40d914765c2e0 +Subproject commit c4f38cbcdf722c2c41325617066f5910c4a8cfea