diff --git a/uart.hpp b/uart.hpp index 594bc83..94ec3cd 100644 --- a/uart.hpp +++ b/uart.hpp @@ -49,6 +49,8 @@ static constexpr size_t maxNumDigits() template class Uart { public: + using data_t = typename Driver::data_t; + // Constructing a uart object does not initialize the driver to allow different specializations with the same // back-end to exists at the same time // Note that init must be called every time when switching specializations with the same back-end @@ -66,17 +68,17 @@ class Uart { Driver::init(); } - static void txByte(const typename Driver::data_t &byte) + static void txByte(const data_t &byte) { Driver::txByte(byte); } - static bool rxByte(typename Driver::data_t &byte) + static bool rxByte(data_t &byte) { return Driver::rxByte(byte); } - static bool peek(typename Driver::data_t &byte) + static bool peek(data_t &byte) { return Driver::peek(byte); } @@ -110,8 +112,8 @@ class Uart { static_assert(util::is_integral_v, "Only supported on integral types"); constexpr size_t numDigits = detail::maxNumDigits(); - typename Driver::data_t buffer[numDigits]; - typename Driver::data_t *bufEnd = buffer + numDigits - 1; + data_t buffer[numDigits]; + data_t *bufEnd = buffer + numDigits - 1; T digits = val; @@ -121,12 +123,12 @@ class Uart { } do { - typename Driver::data_t lastDigit = digits % Base; + data_t lastDigit = digits % Base; *bufEnd-- = '0' + lastDigit; digits /= Base; } while (digits > 0); - for (typename Driver::data_t *buf = bufEnd + 1; buf < buffer + numDigits; ++buf) + for (data_t *buf = bufEnd + 1; buf < buffer + numDigits; ++buf) txByte(*buf); }