2019-07-27 18:55:17 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-05-29 16:15:11 +02:00
|
|
|
#include <limits>
|
|
|
|
|
|
|
|
#include <cstdint>
|
2019-08-03 15:00:41 +02:00
|
|
|
|
2019-07-28 12:15:19 +02:00
|
|
|
#include "config.hpp"
|
2019-07-27 18:55:17 +02:00
|
|
|
#include "software.hpp"
|
|
|
|
|
2019-08-15 18:58:25 +02:00
|
|
|
#include "hardware0.hpp"
|
|
|
|
#include "hardware1.hpp"
|
|
|
|
|
2019-07-27 18:55:17 +02:00
|
|
|
#include "../flash/flash.hpp"
|
2022-05-29 16:15:11 +02:00
|
|
|
#include "../util/util.hpp"
|
2019-07-28 17:32:51 +02:00
|
|
|
|
2019-07-27 18:55:17 +02:00
|
|
|
namespace uart {
|
|
|
|
|
2019-08-03 15:00:41 +02:00
|
|
|
namespace detail {
|
|
|
|
|
2022-05-29 16:15:11 +02:00
|
|
|
template <typename T, T Limit, std::size_t Base>
|
|
|
|
static constexpr std::size_t cntDigits()
|
2019-08-03 15:00:41 +02:00
|
|
|
{
|
2020-04-05 03:23:12 +02:00
|
|
|
T num = Limit;
|
2022-05-29 16:15:11 +02:00
|
|
|
std::size_t cnt = 0;
|
2019-08-03 15:00:41 +02:00
|
|
|
|
|
|
|
do {
|
2019-08-03 17:32:38 +02:00
|
|
|
num /= Base;
|
2019-08-03 15:00:41 +02:00
|
|
|
++cnt;
|
|
|
|
} while (num > 0);
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
|
2022-05-29 16:15:11 +02:00
|
|
|
template <typename T, std::size_t Base>
|
|
|
|
static constexpr std::size_t maxNumDigits()
|
2019-08-03 15:00:41 +02:00
|
|
|
{
|
2022-05-29 16:15:11 +02:00
|
|
|
constexpr T MinVal = std::numeric_limits<T>::min();
|
|
|
|
constexpr T MaxVal = std::numeric_limits<T>::max();
|
2019-08-03 19:49:01 +02:00
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
constexpr T MinDigits = cntDigits<T, MinVal, Base>();
|
|
|
|
constexpr T MaxDigits = cntDigits<T, MaxVal, Base>();
|
2019-08-03 15:00:41 +02:00
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
return (MinDigits < MaxDigits) ? MaxDigits : MinDigits;
|
2019-08-03 15:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace detail
|
|
|
|
|
2019-07-28 12:15:19 +02:00
|
|
|
template <class Driver>
|
2019-07-28 17:57:49 +02:00
|
|
|
class Uart {
|
2019-07-27 18:55:17 +02:00
|
|
|
public:
|
2019-08-03 16:13:52 +02:00
|
|
|
using data_t = typename Driver::data_t;
|
|
|
|
|
2019-08-03 11:14:01 +02:00
|
|
|
// 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
|
|
|
|
Uart() = default;
|
2019-07-27 18:55:17 +02:00
|
|
|
|
|
|
|
// Moving and copying uart objects is not supported
|
2019-07-28 17:57:49 +02:00
|
|
|
Uart(const Uart &) = delete;
|
|
|
|
Uart(Uart &&) = delete;
|
|
|
|
Uart &operator=(const Uart &) = delete;
|
|
|
|
Uart &operator=(Uart &&) = delete;
|
2019-07-27 18:55:17 +02:00
|
|
|
|
2019-08-03 11:14:01 +02:00
|
|
|
// Before using the uart init must be called
|
|
|
|
static void init()
|
|
|
|
{
|
|
|
|
Driver::init();
|
|
|
|
}
|
|
|
|
|
2019-08-03 16:13:52 +02:00
|
|
|
static void txByte(const data_t &byte)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-07-28 12:15:19 +02:00
|
|
|
Driver::txByte(byte);
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:13:52 +02:00
|
|
|
static bool rxByte(data_t &byte)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-02 17:36:07 +02:00
|
|
|
return Driver::rxByte(byte);
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:13:52 +02:00
|
|
|
static bool peek(data_t &byte)
|
2019-08-02 18:20:06 +02:00
|
|
|
{
|
|
|
|
return Driver::peek(byte);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool peek()
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-07-28 12:15:19 +02:00
|
|
|
return Driver::peek();
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 17:52:28 +02:00
|
|
|
static void flushTx()
|
|
|
|
{
|
|
|
|
Driver::flushTx();
|
|
|
|
}
|
|
|
|
|
2019-08-02 16:41:34 +02:00
|
|
|
static void txString(const char *str)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-07-28 12:15:19 +02:00
|
|
|
static_assert(Driver::DATA_BITS == DataBits::EIGHT, "Strings are only supported with 8 data bits");
|
2019-07-27 18:55:17 +02:00
|
|
|
|
|
|
|
while (char ch = *str++)
|
|
|
|
txByte(ch);
|
|
|
|
}
|
|
|
|
|
2019-08-02 16:41:34 +02:00
|
|
|
static void txString(const ::detail::FlashString *str)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-07-28 12:15:19 +02:00
|
|
|
static_assert(Driver::DATA_BITS == DataBits::EIGHT, "Strings are only supported with 8 data bits");
|
2019-07-27 18:55:17 +02:00
|
|
|
|
|
|
|
const char *strIt = reinterpret_cast<const char *>(str);
|
|
|
|
|
|
|
|
while (char ch = pgm_read_byte(strIt++))
|
|
|
|
txByte(ch);
|
|
|
|
}
|
|
|
|
|
2022-05-29 16:15:11 +02:00
|
|
|
template <typename T, std::size_t Base = 10, std::size_t Padding = 0, char PadChar = '0', bool LowerCase = true>
|
2019-08-03 17:32:38 +02:00
|
|
|
static void txNumber(const T &val)
|
2019-08-03 15:00:41 +02:00
|
|
|
{
|
2022-05-29 16:15:11 +02:00
|
|
|
static_assert(std::is_integral_v<T>, "Only supported on integral types");
|
2019-08-07 19:59:48 +02:00
|
|
|
static_assert(Base >= 2, "Numbers with base less than 2 make no sense");
|
|
|
|
static_assert(Base <= 16, "Numbers with base higher than 16 are not supported");
|
|
|
|
static_assert(Padding <= detail::maxNumDigits<T, Base>(), "Cannot pad more than maximum length of number");
|
2019-08-03 15:00:41 +02:00
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
constexpr char AlphaChar = (LowerCase) ? 'a' : 'A';
|
2022-05-29 16:15:11 +02:00
|
|
|
constexpr std::size_t NumDigits = detail::maxNumDigits<T, Base>();
|
2019-08-03 19:49:01 +02:00
|
|
|
|
2019-08-03 15:00:41 +02:00
|
|
|
T digits = val;
|
|
|
|
|
|
|
|
if (digits < 0) {
|
|
|
|
digits = -digits;
|
|
|
|
txByte('-');
|
|
|
|
}
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
data_t buffer[NumDigits];
|
|
|
|
data_t *bufEnd = buffer + NumDigits - 1;
|
2020-04-05 03:28:45 +02:00
|
|
|
|
2019-08-03 15:00:41 +02:00
|
|
|
do {
|
2020-04-05 03:30:22 +02:00
|
|
|
const data_t lastDigit = digits % Base;
|
2020-04-05 03:36:05 +02:00
|
|
|
*bufEnd-- = (lastDigit < 10) ? ('0' + lastDigit) : (AlphaChar + lastDigit - 10);
|
2019-08-03 15:00:41 +02:00
|
|
|
digits /= Base;
|
|
|
|
} while (digits > 0);
|
|
|
|
|
2019-08-03 19:49:01 +02:00
|
|
|
if (Padding > 0) {
|
2022-05-29 16:15:11 +02:00
|
|
|
std::size_t strLen = buffer + NumDigits - (bufEnd + 1);
|
2019-08-03 19:49:01 +02:00
|
|
|
|
|
|
|
if (Padding > strLen) {
|
2022-05-29 16:15:11 +02:00
|
|
|
for (std::size_t i = Padding; i > strLen && bufEnd >= buffer; --i) {
|
2019-08-03 19:49:01 +02:00
|
|
|
*bufEnd-- = PadChar;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
for (data_t *buf = bufEnd + 1; buf < buffer + NumDigits; ++buf)
|
2019-08-03 15:00:41 +02:00
|
|
|
txByte(*buf);
|
|
|
|
}
|
|
|
|
|
2019-07-27 18:55:17 +02:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Output stream overloads
|
|
|
|
|
2019-08-02 16:41:34 +02:00
|
|
|
Uart &operator<<(const char *str)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
|
|
|
txString(str);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-08-02 16:41:34 +02:00
|
|
|
Uart &operator<<(const ::detail::FlashString *str)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
|
|
|
txString(str);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-08-03 16:17:07 +02:00
|
|
|
Uart &operator<<(const char &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:17:07 +02:00
|
|
|
txByte(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:52:57 +02:00
|
|
|
Uart &operator<<(const signed char &val)
|
|
|
|
{
|
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2019-08-03 16:17:07 +02:00
|
|
|
Uart &operator<<(const unsigned char &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:17:07 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:17:07 +02:00
|
|
|
Uart &operator<<(const short &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:17:07 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 21:44:28 +02:00
|
|
|
Uart &operator<<(const unsigned short &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:52:57 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator<<(const int &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 15:00:41 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:11:21 +02:00
|
|
|
Uart &operator<<(const unsigned int &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:11:21 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:52:57 +02:00
|
|
|
Uart &operator<<(const long &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:52:57 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 21:44:28 +02:00
|
|
|
Uart &operator<<(const unsigned long &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:52:57 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 21:44:28 +02:00
|
|
|
Uart &operator<<(const long long &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:52:57 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 21:44:28 +02:00
|
|
|
Uart &operator<<(const unsigned long long &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:52:57 +02:00
|
|
|
txNumber(val);
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator<<(float) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator<<(double) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator<<(long double) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:11:21 +02:00
|
|
|
Uart &operator<<(const bool &val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 16:11:21 +02:00
|
|
|
txString(val ? F("true") : F("false"));
|
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 16:52:57 +02:00
|
|
|
Uart &operator<<(const void *val)
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2019-08-03 17:32:38 +02:00
|
|
|
txString(F("0x"));
|
2022-05-29 16:15:11 +02:00
|
|
|
txNumber<std::uint16_t, 16, 4, '0', false>(reinterpret_cast<std::uint16_t>(val));
|
2019-08-03 16:52:57 +02:00
|
|
|
return *this;
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Input stream overloads
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(char &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(unsigned char &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(short &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(unsigned short &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(int &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(unsigned int &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(long &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(unsigned long &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(long long &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(unsigned long long &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(float &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(double &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(long double &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(bool &) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
|
|
|
|
2019-07-28 10:35:11 +02:00
|
|
|
template <typename... Ts>
|
2019-08-03 15:00:41 +02:00
|
|
|
Uart &operator>>(const void *&) const
|
2019-07-27 18:55:17 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
2019-07-27 18:55:17 +02:00
|
|
|
}
|
2020-04-13 16:43:04 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend void ::USART0_RX_vect();
|
|
|
|
friend void ::USART0_UDRE_vect();
|
|
|
|
|
|
|
|
#ifdef HAS_UART1
|
|
|
|
friend void ::USART1_RX_vect();
|
|
|
|
friend void ::USART1_UDRE_vect();
|
|
|
|
#endif
|
|
|
|
|
2022-05-29 16:15:11 +02:00
|
|
|
[[gnu::always_inline]] static void rxIntHandler()
|
2020-04-13 16:43:04 +02:00
|
|
|
{
|
|
|
|
Driver::rxIntHandler();
|
|
|
|
}
|
|
|
|
|
2022-05-29 16:15:11 +02:00
|
|
|
[[gnu::always_inline]] static void dataRegEmptyIntHandler()
|
2020-04-13 16:43:04 +02:00
|
|
|
{
|
|
|
|
Driver::dataRegEmptyIntHandler();
|
|
|
|
}
|
2019-07-27 18:55:17 +02:00
|
|
|
};
|
|
|
|
|
2019-07-28 17:58:23 +02:00
|
|
|
template <typename cfg = Config<>>
|
2019-08-05 20:05:59 +02:00
|
|
|
using Uart0 = Uart<Hardware0<cfg, Driven::INTERRUPT, Mode::ASYNCHRONOUS>>;
|
2019-07-28 17:58:23 +02:00
|
|
|
|
2019-07-30 21:43:52 +02:00
|
|
|
#ifdef HAS_UART1
|
|
|
|
template <typename cfg = Config<>>
|
2019-08-05 20:05:59 +02:00
|
|
|
using Uart1 = Uart<Hardware1<cfg, Driven::INTERRUPT, Mode::ASYNCHRONOUS>>;
|
2019-07-30 21:43:52 +02:00
|
|
|
#endif
|
|
|
|
|
2019-07-27 18:55:17 +02:00
|
|
|
} // namespace uart
|
2019-07-28 17:32:51 +02:00
|
|
|
|
2019-07-30 21:43:52 +02:00
|
|
|
#undef HAS_UART1
|