Compare commits
5 Commits
04b6782ec4
...
119de32445
| Author | SHA1 | Date | |
|---|---|---|---|
| 119de32445 | |||
| 8f88cdccea | |||
| dfb076cda8 | |||
| 6d9ef6e4be | |||
| bcd18db494 |
28
hardware.hpp
28
hardware.hpp
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "../clock.hpp"
|
#include "../clock.hpp"
|
||||||
|
|
||||||
#include "../type/type.hpp"
|
#include "../util/type.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -63,12 +63,15 @@ class Hardware {
|
|||||||
constexpr auto EnableRx = calcRxState<true>();
|
constexpr auto EnableRx = calcRxState<true>();
|
||||||
constexpr auto EnableTx = calcTxState<true>();
|
constexpr auto EnableTx = calcTxState<true>();
|
||||||
constexpr auto InterruptVal = calcInterrupt();
|
constexpr auto InterruptVal = calcInterrupt();
|
||||||
constexpr auto DoubleSpeedVal = calcDoubleSpeedVal<UseDoubleSpeed>();
|
|
||||||
|
|
||||||
constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal;
|
constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal;
|
||||||
constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal;
|
constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal;
|
||||||
|
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() |= DoubleSpeedVal;
|
if constexpr (UseDoubleSpeed)
|
||||||
|
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() |= (1 << CtrlFlagsA::SPEED_2X);
|
||||||
|
else
|
||||||
|
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() &= ~(1 << CtrlFlagsA::SPEED_2X);
|
||||||
|
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB;
|
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB;
|
||||||
*getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC;
|
*getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC;
|
||||||
}
|
}
|
||||||
@@ -266,17 +269,6 @@ class Hardware {
|
|||||||
|
|
||||||
return interruptVal;
|
return interruptVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool DoubleSpeed>
|
|
||||||
static constexpr auto calcDoubleSpeedVal()
|
|
||||||
{
|
|
||||||
uint8_t doubleSpeedVal = 0;
|
|
||||||
|
|
||||||
if constexpr (DoubleSpeed)
|
|
||||||
doubleSpeedVal = (1 << CtrlFlagsA::SPEED_2X);
|
|
||||||
|
|
||||||
return doubleSpeedVal;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>
|
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>
|
||||||
@@ -302,7 +294,7 @@ class BlockingHardware {
|
|||||||
|
|
||||||
static bool peek(data_t &) FORCE_INLINE
|
static bool peek(data_t &) FORCE_INLINE
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<data_t>, "Peek with data is not supported in blocking mode");
|
static_assert(util::always_false_v<data_t>, "Peek with data is not supported in blocking mode");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,9 +376,9 @@ class InterruptHardware {
|
|||||||
protected:
|
protected:
|
||||||
static void rxIntHandler() FORCE_INLINE
|
static void rxIntHandler() FORCE_INLINE
|
||||||
{
|
{
|
||||||
auto data = HardwareImpl::rxByteInterrupt();
|
const auto data = HardwareImpl::rxByteInterrupt();
|
||||||
|
|
||||||
uint8_t tmpHead = (sm_rxBuf.head + 1) % RX_BUFFER_SIZE;
|
const uint8_t tmpHead = (sm_rxBuf.head + 1) % RX_BUFFER_SIZE;
|
||||||
|
|
||||||
if (tmpHead != sm_rxBuf.tail) {
|
if (tmpHead != sm_rxBuf.tail) {
|
||||||
sm_rxBuf.head = tmpHead;
|
sm_rxBuf.head = tmpHead;
|
||||||
@@ -399,7 +391,7 @@ class InterruptHardware {
|
|||||||
static void dataRegEmptyIntHandler() FORCE_INLINE
|
static void dataRegEmptyIntHandler() FORCE_INLINE
|
||||||
{
|
{
|
||||||
if (sm_txBuf.head != sm_txBuf.tail) {
|
if (sm_txBuf.head != sm_txBuf.tail) {
|
||||||
uint8_t tmpTail = (sm_txBuf.tail + 1) % TX_BUFFER_SIZE;
|
const uint8_t tmpTail = (sm_txBuf.tail + 1) % TX_BUFFER_SIZE;
|
||||||
sm_txBuf.tail = tmpTail;
|
sm_txBuf.tail = tmpTail;
|
||||||
HardwareImpl::txByteInterrupt(sm_txBuf.buf[tmpTail]);
|
HardwareImpl::txByteInterrupt(sm_txBuf.buf[tmpTail]);
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#ifndef UART_HARDWARE_0_HPP
|
#pragma once
|
||||||
#define UART_HARDWARE_0_HPP
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -82,8 +81,10 @@ constexpr int operator<<(const int &lhs, const ControlFlagsB0 &rhs) { return lhs
|
|||||||
constexpr int operator<<(const int &lhs, const ControlFlagsC0 &rhs) { return lhs << static_cast<int>(rhs); }
|
constexpr int operator<<(const int &lhs, const ControlFlagsC0 &rhs) { return lhs << static_cast<int>(rhs); }
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
extern void (*fnRx0IntHandler)();
|
#if defined(__AVR_ATmega328P__)
|
||||||
extern void (*fnDataReg0EmptyIntHandler)();
|
#define USART0_RX_vect USART_RX_vect
|
||||||
|
#define USART0_UDRE_vect USART_UDRE_vect
|
||||||
|
#endif
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error "This chip is not supported"
|
#error "This chip is not supported"
|
||||||
@@ -100,70 +101,56 @@ template <class cfg, Mode mode>
|
|||||||
class Hardware0<cfg, Driven::INTERRUPT, mode>
|
class Hardware0<cfg, Driven::INTERRUPT, mode>
|
||||||
: public detail::InterruptHardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
: public detail::InterruptHardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
||||||
detail::ControlFlagsC0, cfg, mode> {
|
detail::ControlFlagsC0, cfg, mode> {
|
||||||
using detail::InterruptHardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
|
||||||
detail::ControlFlagsC0, cfg, mode>::rxIntHandler;
|
|
||||||
|
|
||||||
using detail::InterruptHardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
|
||||||
detail::ControlFlagsC0, cfg, mode>::dataRegEmptyIntHandler;
|
|
||||||
|
|
||||||
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
|
||||||
detail::ControlFlagsC0, cfg, Driven::INTERRUPT, mode>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init() FORCE_INLINE
|
static void init() FORCE_INLINE
|
||||||
{
|
{
|
||||||
detail::fnRx0IntHandler = rxIntHandler;
|
|
||||||
detail::fnDataReg0EmptyIntHandler = dataRegEmptyIntHandler;
|
|
||||||
|
|
||||||
HardwareImpl::init();
|
HardwareImpl::init();
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
||||||
|
detail::ControlFlagsC0, cfg, Driven::INTERRUPT, mode>;
|
||||||
|
|
||||||
|
using InterruptHardwareImpl = detail::InterruptHardware<detail::Registers0, detail::ControlFlagsA0,
|
||||||
|
detail::ControlFlagsB0, detail::ControlFlagsC0, cfg, mode>;
|
||||||
|
|
||||||
|
// Must be friends with Uart interface to call these private handlers
|
||||||
|
template <class Driver>
|
||||||
|
friend class Uart;
|
||||||
|
|
||||||
|
static void rxIntHandler() FORCE_INLINE
|
||||||
|
{
|
||||||
|
InterruptHardwareImpl::rxIntHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dataRegEmptyIntHandler() FORCE_INLINE
|
||||||
|
{
|
||||||
|
InterruptHardwareImpl::dataRegEmptyIntHandler();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace uart
|
} // namespace uart
|
||||||
|
|
||||||
#undef FORCE_INLINE
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef UART0_INT_VECTORS
|
// Forward declare interrupt functions to allow adding them as friends
|
||||||
|
extern "C" {
|
||||||
#include <avr/interrupt.h>
|
void USART0_RX_vect() __attribute__((signal));
|
||||||
|
void USART0_UDRE_vect() __attribute__((signal));
|
||||||
namespace uart {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega328P__)
|
|
||||||
|
|
||||||
#if defined(__AVR_ATmega328P__)
|
|
||||||
#define USART0_RX_vect USART_RX_vect
|
|
||||||
#define USART0_UDRE_vect USART_UDRE_vect
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void (*fnRx0IntHandler)() = nullptr;
|
|
||||||
void (*fnDataReg0EmptyIntHandler)() = nullptr;
|
|
||||||
|
|
||||||
ISR(USART0_RX_vect)
|
|
||||||
{
|
|
||||||
if (fnRx0IntHandler)
|
|
||||||
fnRx0IntHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(USART0_UDRE_vect)
|
// clang-format off
|
||||||
{
|
#define REGISTER_UART0_INT_VECTORS(uart_type) \
|
||||||
if (fnDataReg0EmptyIntHandler)
|
ISR(USART0_RX_vect) \
|
||||||
fnDataReg0EmptyIntHandler();
|
{ \
|
||||||
}
|
uart_type::rxIntHandler(); \
|
||||||
|
} \
|
||||||
|
ISR(USART0_UDRE_vect) \
|
||||||
|
{ \
|
||||||
|
uart_type::dataRegEmptyIntHandler(); \
|
||||||
|
} \
|
||||||
|
struct _##uart_type {}
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
#else
|
#undef FORCE_INLINE
|
||||||
#error "This chip is not supported"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace uart
|
|
||||||
|
|
||||||
#undef UART0_INT_VECTORS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#ifndef UART_HARDWARE_1_HPP
|
#pragma once
|
||||||
#define UART_HARDWARE_1_HPP
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -82,9 +81,6 @@ constexpr int operator<<(const int &lhs, const ControlFlagsB1 &rhs) { return lhs
|
|||||||
constexpr int operator<<(const int &lhs, const ControlFlagsC1 &rhs) { return lhs << static_cast<int>(rhs); }
|
constexpr int operator<<(const int &lhs, const ControlFlagsC1 &rhs) { return lhs << static_cast<int>(rhs); }
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
extern void (*fnRx1IntHandler)();
|
|
||||||
extern void (*fnDataReg1EmptyIntHandler)();
|
|
||||||
|
|
||||||
#define HAS_UART1
|
#define HAS_UART1
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -102,65 +98,63 @@ template <class cfg, Mode mode>
|
|||||||
class Hardware1<cfg, Driven::INTERRUPT, mode>
|
class Hardware1<cfg, Driven::INTERRUPT, mode>
|
||||||
: public detail::InterruptHardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
: public detail::InterruptHardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||||
detail::ControlFlagsC1, cfg, mode> {
|
detail::ControlFlagsC1, cfg, mode> {
|
||||||
using detail::InterruptHardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
|
||||||
detail::ControlFlagsC1, cfg, mode>::rxIntHandler;
|
|
||||||
|
|
||||||
using detail::InterruptHardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
|
||||||
detail::ControlFlagsC1, cfg, mode>::dataRegEmptyIntHandler;
|
|
||||||
|
|
||||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
|
||||||
detail::ControlFlagsC1, cfg, Driven::INTERRUPT, mode>;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void init() FORCE_INLINE
|
static void init() FORCE_INLINE
|
||||||
{
|
{
|
||||||
detail::fnRx1IntHandler = rxIntHandler;
|
|
||||||
detail::fnDataReg1EmptyIntHandler = dataRegEmptyIntHandler;
|
|
||||||
|
|
||||||
HardwareImpl::init();
|
HardwareImpl::init();
|
||||||
sei();
|
sei();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||||
|
detail::ControlFlagsC1, cfg, Driven::INTERRUPT, mode>;
|
||||||
|
|
||||||
|
using InterruptHardwareImpl = detail::InterruptHardware<detail::Registers1, detail::ControlFlagsA1,
|
||||||
|
detail::ControlFlagsB1, detail::ControlFlagsC1, cfg, mode>;
|
||||||
|
|
||||||
|
// Must be friends with Uart interface to call these private handlers
|
||||||
|
template <class Driver>
|
||||||
|
friend class Uart;
|
||||||
|
|
||||||
|
static void rxIntHandler() FORCE_INLINE
|
||||||
|
{
|
||||||
|
InterruptHardwareImpl::rxIntHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dataRegEmptyIntHandler() FORCE_INLINE
|
||||||
|
{
|
||||||
|
InterruptHardwareImpl::dataRegEmptyIntHandler();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace uart
|
} // namespace uart
|
||||||
|
|
||||||
#undef FORCE_INLINE
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef UART1_INT_VECTORS
|
#ifdef HAS_UART1
|
||||||
|
|
||||||
#include <avr/interrupt.h>
|
// Forward declare interrupt functions to allow adding them as friends
|
||||||
|
extern "C" {
|
||||||
namespace uart {
|
void USART1_RX_vect() __attribute__((signal));
|
||||||
namespace detail {
|
void USART1_UDRE_vect() __attribute__((signal));
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1284P__)
|
|
||||||
|
|
||||||
void (*fnRx1IntHandler)() = nullptr;
|
|
||||||
void (*fnDataReg1EmptyIntHandler)() = nullptr;
|
|
||||||
|
|
||||||
ISR(USART1_RX_vect)
|
|
||||||
{
|
|
||||||
if (fnRx1IntHandler)
|
|
||||||
fnRx1IntHandler();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ISR(USART1_UDRE_vect)
|
// clang-format off
|
||||||
{
|
#define REGISTER_UART1_INT_VECTORS(uart_type) \
|
||||||
if (fnDataReg1EmptyIntHandler)
|
ISR(USART1_RX_vect) \
|
||||||
fnDataReg1EmptyIntHandler();
|
{ \
|
||||||
}
|
uart_type::rxIntHandler(); \
|
||||||
|
} \
|
||||||
|
ISR(USART1_UDRE_vect) \
|
||||||
|
{ \
|
||||||
|
uart_type::dataRegEmptyIntHandler(); \
|
||||||
|
} \
|
||||||
|
struct _##uart_type { \
|
||||||
|
}
|
||||||
|
// clang-format off
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // namespace detail
|
#undef FORCE_INLINE
|
||||||
} // namespace uart
|
|
||||||
|
|
||||||
#undef UART1_INT_VECTORS
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
#include "../io/io.hpp"
|
#include "../io/io.hpp"
|
||||||
#include "../type/type.hpp"
|
#include "../util/type.hpp"
|
||||||
|
|
||||||
namespace uart {
|
namespace uart {
|
||||||
|
|
||||||
template <io::P rxPin, io::P txPin, class cfg = Config<>>
|
template <io::P rxPin, io::P txPin, class cfg = Config<>>
|
||||||
class Software {
|
class Software {
|
||||||
static_assert(type::always_false_v<cfg>, "Not implemented");
|
static_assert(util::always_false_v<cfg>, "Not implemented");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using data_t = typename cfg::data_t;
|
using data_t = typename cfg::data_t;
|
||||||
|
|||||||
63
uart.hpp
63
uart.hpp
@@ -5,9 +5,7 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "software.hpp"
|
#include "software.hpp"
|
||||||
|
|
||||||
#undef UART0_INT_VECTORS
|
|
||||||
#include "hardware0.hpp"
|
#include "hardware0.hpp"
|
||||||
#undef UART1_INT_VECTORS
|
|
||||||
#include "hardware1.hpp"
|
#include "hardware1.hpp"
|
||||||
|
|
||||||
#include "../flash/flash.hpp"
|
#include "../flash/flash.hpp"
|
||||||
@@ -35,8 +33,8 @@ static constexpr size_t cntDigits()
|
|||||||
template <typename T, size_t Base>
|
template <typename T, size_t Base>
|
||||||
static constexpr size_t maxNumDigits()
|
static constexpr size_t maxNumDigits()
|
||||||
{
|
{
|
||||||
constexpr T MinVal = type::numeric_limits<T>::min();
|
constexpr T MinVal = util::numeric_limits<T>::min();
|
||||||
constexpr T MaxVal = type::numeric_limits<T>::max();
|
constexpr T MaxVal = util::numeric_limits<T>::max();
|
||||||
|
|
||||||
constexpr T MinDigits = cntDigits<T, MinVal, Base>();
|
constexpr T MinDigits = cntDigits<T, MinVal, Base>();
|
||||||
constexpr T MaxDigits = cntDigits<T, MaxVal, Base>();
|
constexpr T MaxDigits = cntDigits<T, MaxVal, Base>();
|
||||||
@@ -114,7 +112,7 @@ class Uart {
|
|||||||
template <typename T, size_t Base = 10, size_t Padding = 0, char PadChar = '0', bool LowerCase = true>
|
template <typename T, size_t Base = 10, size_t Padding = 0, char PadChar = '0', bool LowerCase = true>
|
||||||
static void txNumber(const T &val)
|
static void txNumber(const T &val)
|
||||||
{
|
{
|
||||||
static_assert(type::is_integral_v<T>, "Only supported on integral types");
|
static_assert(util::is_integral_v<T>, "Only supported on integral types");
|
||||||
static_assert(Base >= 2, "Numbers with base less than 2 make no sense");
|
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(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");
|
static_assert(Padding <= detail::maxNumDigits<T, Base>(), "Cannot pad more than maximum length of number");
|
||||||
@@ -236,19 +234,19 @@ class Uart {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(float) const
|
Uart &operator<<(float) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(double) const
|
Uart &operator<<(double) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator<<(long double) const
|
Uart &operator<<(long double) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
Uart &operator<<(const bool &val)
|
Uart &operator<<(const bool &val)
|
||||||
@@ -270,91 +268,110 @@ class Uart {
|
|||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(char &) const
|
Uart &operator>>(char &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned char &) const
|
Uart &operator>>(unsigned char &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(short &) const
|
Uart &operator>>(short &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned short &) const
|
Uart &operator>>(unsigned short &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(int &) const
|
Uart &operator>>(int &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned int &) const
|
Uart &operator>>(unsigned int &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long &) const
|
Uart &operator>>(long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned long &) const
|
Uart &operator>>(unsigned long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long long &) const
|
Uart &operator>>(long long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(unsigned long long &) const
|
Uart &operator>>(unsigned long long &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(float &) const
|
Uart &operator>>(float &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(double &) const
|
Uart &operator>>(double &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(long double &) const
|
Uart &operator>>(long double &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not supported by hardware");
|
static_assert(util::always_false_v<Ts...>, "Not supported by hardware");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(bool &) const
|
Uart &operator>>(bool &) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename... Ts>
|
template <typename... Ts>
|
||||||
Uart &operator>>(const void *&) const
|
Uart &operator>>(const void *&) const
|
||||||
{
|
{
|
||||||
static_assert(type::always_false_v<Ts...>, "Not implemented");
|
static_assert(util::always_false_v<Ts...>, "Not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
static void rxIntHandler() FORCE_INLINE
|
||||||
|
{
|
||||||
|
Driver::rxIntHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dataRegEmptyIntHandler() FORCE_INLINE
|
||||||
|
{
|
||||||
|
Driver::dataRegEmptyIntHandler();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user