2019-08-02 09:21:47 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-08-03 20:20:20 +02:00
|
|
|
#include "../clock.hpp"
|
2019-08-02 20:23:54 +02:00
|
|
|
|
2020-05-16 17:42:52 +02:00
|
|
|
#include "../util/type.hpp"
|
2019-08-02 20:23:54 +02:00
|
|
|
|
2020-04-12 23:57:16 +02:00
|
|
|
#include <math.h>
|
2020-04-07 03:50:29 +02:00
|
|
|
#include <stdint.h>
|
2019-08-14 19:49:42 +02:00
|
|
|
|
2019-08-02 09:21:47 +02:00
|
|
|
#define FORCE_INLINE __attribute__((always_inline))
|
|
|
|
|
|
|
|
namespace uart {
|
|
|
|
|
|
|
|
enum class Mode {
|
|
|
|
ASYNCHRONOUS,
|
|
|
|
SYNCHRONOUS_MASTER,
|
|
|
|
SYNCHRONOUS_SLAVE,
|
|
|
|
SPI,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class Driven {
|
|
|
|
INTERRUPT,
|
|
|
|
BLOCKING,
|
|
|
|
};
|
|
|
|
|
|
|
|
namespace detail {
|
|
|
|
|
2019-08-10 14:12:10 +02:00
|
|
|
using reg_ptr_t = volatile uint8_t *;
|
|
|
|
|
|
|
|
template <uintptr_t Address>
|
|
|
|
static inline reg_ptr_t getRegPtr()
|
|
|
|
{
|
|
|
|
return reinterpret_cast<reg_ptr_t>(Address);
|
|
|
|
}
|
|
|
|
|
2019-08-14 19:49:42 +02:00
|
|
|
template <typename data_t, uint8_t Size>
|
|
|
|
struct RingBuffer {
|
|
|
|
uint8_t head;
|
|
|
|
uint8_t tail;
|
|
|
|
data_t buf[Size];
|
|
|
|
};
|
|
|
|
|
2019-08-05 20:05:59 +02:00
|
|
|
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Driven driven,
|
|
|
|
Mode mode>
|
2019-08-02 09:21:47 +02:00
|
|
|
class Hardware {
|
|
|
|
public:
|
|
|
|
static void init() FORCE_INLINE
|
|
|
|
{
|
2020-04-12 23:57:16 +02:00
|
|
|
constexpr auto AbsDoubleError = fabs(calcBaudError<true>());
|
|
|
|
constexpr auto AbsNormalError = fabs(calcBaudError<false>());
|
|
|
|
static_assert(AbsDoubleError <= 3.0 || AbsNormalError <= 3.0, "Baud rate error over 3%, probably unusable");
|
|
|
|
|
|
|
|
constexpr auto UseDoubleSpeed = (AbsDoubleError < AbsNormalError);
|
|
|
|
constexpr auto BaudVal = calcBaudVal<UseDoubleSpeed>();
|
2019-08-02 09:21:47 +02:00
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
*getRegPtr<Registers::BAUD_REG_H_ADDR>() = static_cast<uint8_t>(BaudVal >> 8);
|
|
|
|
*getRegPtr<Registers::BAUD_REG_L_ADDR>() = static_cast<uint8_t>(BaudVal);
|
2019-08-02 09:21:47 +02:00
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
constexpr auto DataBitsValues = calcDataBits();
|
|
|
|
constexpr auto ParityVal = calcParity();
|
|
|
|
constexpr auto StopBitsVal = calcStopBits();
|
|
|
|
constexpr auto ModeVal = calcMode();
|
|
|
|
constexpr auto EnableRx = calcRxState<true>();
|
|
|
|
constexpr auto EnableTx = calcTxState<true>();
|
|
|
|
constexpr auto InterruptVal = calcInterrupt();
|
2019-08-02 09:21:47 +02:00
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
constexpr uint8_t ControlRegB = DataBitsValues.regBVal | EnableRx | EnableTx | InterruptVal;
|
|
|
|
constexpr uint8_t ControlRegC = DataBitsValues.regCVal | ParityVal | StopBitsVal | ModeVal;
|
2019-08-02 09:21:47 +02:00
|
|
|
|
2020-04-13 13:06:11 +02:00
|
|
|
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);
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() = ControlRegB;
|
|
|
|
*getRegPtr<Registers::CTRL_STAT_REG_C_ADDR>() = ControlRegC;
|
2019-08-02 09:21:47 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 17:54:34 +02:00
|
|
|
static bool rxByteBlocking(typename cfg::data_t &byte) FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
if (*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() & (1 << CtrlFlagsA::RECEIVE_COMPLETE)) {
|
|
|
|
byte = *getRegPtr<Registers::IO_REG_ADDR>();
|
2019-08-02 17:54:34 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-02 17:36:07 +02:00
|
|
|
static typename cfg::data_t rxByteInterrupt() FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
return *getRegPtr<Registers::IO_REG_ADDR>();
|
2019-08-02 17:36:07 +02:00
|
|
|
}
|
|
|
|
|
2019-08-03 18:45:51 +02:00
|
|
|
static bool txEmpty() FORCE_INLINE
|
2019-08-03 17:52:28 +02:00
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
return *getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() & (1 << CtrlFlagsA::DATA_REG_EMPTY);
|
2019-08-03 18:45:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool txComplete() FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
return *getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() & (1 << CtrlFlagsA::TRANSMIT_COMPLETE);
|
2019-08-03 18:45:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clearTxComplete() FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() |= (1 << CtrlFlagsA::TRANSMIT_COMPLETE);
|
2019-08-03 17:52:28 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 16:41:53 +02:00
|
|
|
static void txByteBlocking(const typename cfg::data_t &byte) FORCE_INLINE
|
2019-08-02 09:21:47 +02:00
|
|
|
{
|
2019-08-03 18:45:51 +02:00
|
|
|
while (!txEmpty())
|
2019-08-02 09:21:47 +02:00
|
|
|
;
|
|
|
|
|
2019-08-10 14:12:10 +02:00
|
|
|
*getRegPtr<Registers::IO_REG_ADDR>() = byte;
|
2019-08-02 09:21:47 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 16:41:53 +02:00
|
|
|
static void txByteInterrupt(volatile const typename cfg::data_t &byte) FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
*getRegPtr<Registers::IO_REG_ADDR>() = byte;
|
2019-08-02 16:41:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 18:20:06 +02:00
|
|
|
static bool peekBlocking() FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
if (*getRegPtr<Registers::CTRL_STAT_REG_A_ADDR>() & (1 << CtrlFlagsA::RECEIVE_COMPLETE)) {
|
2019-08-02 18:20:06 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-08-02 16:41:53 +02:00
|
|
|
static void enableDataRegEmptyInt() FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() |= (1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
2019-08-02 16:41:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void disableDataRegEmptyInt() FORCE_INLINE
|
|
|
|
{
|
2019-08-10 14:12:10 +02:00
|
|
|
*getRegPtr<Registers::CTRL_STAT_REG_B_ADDR>() &= ~(1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
2019-08-02 16:41:53 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 09:21:47 +02:00
|
|
|
private:
|
|
|
|
struct DataBitsVal {
|
|
|
|
uint8_t regCVal = 0;
|
|
|
|
uint8_t regBVal = 0;
|
|
|
|
};
|
|
|
|
|
2020-04-12 23:57:16 +02:00
|
|
|
template <bool DoubleSpeed = true>
|
|
|
|
static constexpr auto calcBaudVal()
|
2019-08-02 09:21:47 +02:00
|
|
|
{
|
2020-04-12 23:57:16 +02:00
|
|
|
if constexpr (DoubleSpeed) {
|
|
|
|
constexpr auto BaudVal = static_cast<uint16_t>(round(F_CPU / (8.0 * cfg::BAUD_RATE) - 1));
|
|
|
|
return BaudVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr auto BaudVal = static_cast<uint16_t>(round(F_CPU / (16.0 * cfg::BAUD_RATE) - 1));
|
2020-04-05 03:36:05 +02:00
|
|
|
return BaudVal;
|
2019-08-02 09:21:47 +02:00
|
|
|
}
|
|
|
|
|
2020-04-12 23:57:16 +02:00
|
|
|
template <uint16_t BaudVal, bool DoubleSpeed = true>
|
|
|
|
static constexpr auto calcBaudRate()
|
|
|
|
{
|
|
|
|
if constexpr (DoubleSpeed) {
|
|
|
|
constexpr auto BaudRate = static_cast<uint32_t>(round(F_CPU / (8.0 * (BaudVal + 1))));
|
|
|
|
return BaudRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr auto BaudRate = static_cast<uint32_t>(round(F_CPU / (16.0 * (BaudVal + 1))));
|
|
|
|
return BaudRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <bool DoubleSpeed = true>
|
|
|
|
static constexpr auto calcBaudError()
|
|
|
|
{
|
|
|
|
constexpr auto BaudVal = calcBaudVal<DoubleSpeed>();
|
|
|
|
constexpr auto ClosestBaudRate = calcBaudRate<BaudVal, DoubleSpeed>();
|
|
|
|
constexpr auto BaudError = (static_cast<double>(ClosestBaudRate) / cfg::BAUD_RATE - 1) * 100;
|
|
|
|
return BaudError;
|
|
|
|
}
|
|
|
|
|
2019-08-02 09:21:47 +02:00
|
|
|
static constexpr auto calcDataBits()
|
|
|
|
{
|
|
|
|
DataBitsVal dataBitsVal;
|
|
|
|
|
|
|
|
switch (cfg::DATA_BITS) {
|
|
|
|
case DataBits::FIVE:
|
|
|
|
dataBitsVal.regCVal = 0;
|
|
|
|
break;
|
|
|
|
case DataBits::SIX:
|
|
|
|
dataBitsVal.regCVal = (1 << CtrlFlagsC::CHAR_SIZE_0);
|
|
|
|
break;
|
|
|
|
case DataBits::SEVEN:
|
|
|
|
dataBitsVal.regCVal = (1 << CtrlFlagsC::CHAR_SIZE_1);
|
|
|
|
break;
|
|
|
|
case DataBits::EIGHT:
|
|
|
|
dataBitsVal.regCVal = (1 << CtrlFlagsC::CHAR_SIZE_1) | (1 << CtrlFlagsC::CHAR_SIZE_0);
|
|
|
|
break;
|
|
|
|
case DataBits::NINE:
|
|
|
|
dataBitsVal.regCVal = (1 << CtrlFlagsC::CHAR_SIZE_1) | (1 << CtrlFlagsC::CHAR_SIZE_0);
|
|
|
|
dataBitsVal.regBVal = (1 << CtrlFlagsB::CHAR_SIZE_2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return dataBitsVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr auto calcParity()
|
|
|
|
{
|
|
|
|
uint8_t parityVal = 0;
|
|
|
|
|
|
|
|
if (cfg::PARITY == Parity::EVEN)
|
|
|
|
parityVal = (1 << CtrlFlagsC::PARITY_MODE_1);
|
|
|
|
else if (cfg::PARITY == Parity::ODD)
|
|
|
|
parityVal = (1 << CtrlFlagsC::PARITY_MODE_1) | (1 << CtrlFlagsC::PARITY_MODE_0);
|
|
|
|
|
|
|
|
return parityVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr auto calcStopBits()
|
|
|
|
{
|
|
|
|
uint8_t stopBitsVal = 0;
|
|
|
|
|
|
|
|
if (cfg::STOP_BITS == StopBits::TWO)
|
|
|
|
stopBitsVal = (1 << CtrlFlagsC::STOP_BIT_SEL);
|
|
|
|
|
|
|
|
return stopBitsVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
static constexpr auto calcMode()
|
|
|
|
{
|
|
|
|
static_assert(mode != Mode::SPI, "SPI mode can not be used with uart");
|
|
|
|
|
|
|
|
uint8_t modeVal = 0;
|
|
|
|
|
|
|
|
if (mode == Mode::SYNCHRONOUS_MASTER || mode == Mode::SYNCHRONOUS_SLAVE) {
|
|
|
|
modeVal = (1 << CtrlFlagsC::MODE_SEL_0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return modeVal;
|
|
|
|
}
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
template <bool Enable>
|
2019-08-02 09:21:47 +02:00
|
|
|
static constexpr auto calcRxState()
|
|
|
|
{
|
|
|
|
uint8_t enableVal = 0;
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
if (Enable)
|
2019-08-02 09:21:47 +02:00
|
|
|
enableVal = (1 << CtrlFlagsB::RX_ENABLE);
|
|
|
|
|
|
|
|
return enableVal;
|
|
|
|
}
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
template <bool Enable>
|
2019-08-02 09:21:47 +02:00
|
|
|
static constexpr auto calcTxState()
|
|
|
|
{
|
|
|
|
uint8_t enableVal = 0;
|
|
|
|
|
2020-04-05 03:36:05 +02:00
|
|
|
if (Enable)
|
2019-08-02 09:21:47 +02:00
|
|
|
enableVal = (1 << CtrlFlagsB::TX_ENABLE);
|
|
|
|
|
|
|
|
return enableVal;
|
|
|
|
}
|
2019-08-02 12:08:16 +02:00
|
|
|
|
|
|
|
static constexpr auto calcInterrupt()
|
|
|
|
{
|
|
|
|
uint8_t interruptVal = 0;
|
|
|
|
|
|
|
|
if (driven == Driven::INTERRUPT)
|
2019-08-14 18:58:21 +02:00
|
|
|
interruptVal = (1 << CtrlFlagsB::RX_INT_ENABLE);
|
2019-08-02 12:08:16 +02:00
|
|
|
|
|
|
|
return interruptVal;
|
|
|
|
}
|
2019-08-02 09:21:47 +02:00
|
|
|
};
|
|
|
|
|
2019-08-14 19:49:42 +02:00
|
|
|
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>
|
|
|
|
class BlockingHardware {
|
|
|
|
public:
|
|
|
|
using data_t = typename cfg::data_t;
|
|
|
|
static constexpr auto DATA_BITS = cfg::DATA_BITS;
|
|
|
|
|
|
|
|
static void init() FORCE_INLINE
|
|
|
|
{
|
|
|
|
HardwareImpl::init();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void txByte(const data_t &byte) FORCE_INLINE
|
|
|
|
{
|
|
|
|
HardwareImpl::txByteBlocking(byte);
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool rxByte(data_t &byte) FORCE_INLINE
|
|
|
|
{
|
|
|
|
return HardwareImpl::rxByteBlocking(byte);
|
|
|
|
}
|
|
|
|
|
2019-08-14 19:55:06 +02:00
|
|
|
static bool peek(data_t &) FORCE_INLINE
|
2019-08-14 19:49:42 +02:00
|
|
|
{
|
2020-05-16 17:42:52 +02:00
|
|
|
static_assert(util::always_false_v<data_t>, "Peek with data is not supported in blocking mode");
|
2019-08-14 19:49:42 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool peek() FORCE_INLINE
|
|
|
|
{
|
|
|
|
return HardwareImpl::peekBlocking();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void flushTx() FORCE_INLINE
|
|
|
|
{
|
|
|
|
while (!HardwareImpl::txEmpty())
|
|
|
|
;
|
|
|
|
while (!HardwareImpl::txComplete())
|
|
|
|
;
|
|
|
|
HardwareImpl::clearTxComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
using HardwareImpl = Hardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, Driven::BLOCKING, mode>;
|
2019-08-02 17:13:53 +02:00
|
|
|
};
|
|
|
|
|
2019-08-14 19:49:42 +02:00
|
|
|
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>
|
|
|
|
class InterruptHardware {
|
|
|
|
public:
|
|
|
|
using data_t = typename cfg::data_t;
|
|
|
|
static constexpr auto DATA_BITS = cfg::DATA_BITS;
|
|
|
|
|
|
|
|
static void txByte(const data_t &byte) FORCE_INLINE
|
|
|
|
{
|
|
|
|
uint8_t tmpHead = (sm_txBuf.head + 1) % TX_BUFFER_SIZE;
|
|
|
|
while (tmpHead == sm_txBuf.tail)
|
|
|
|
;
|
|
|
|
|
|
|
|
sm_txBuf.buf[tmpHead] = byte;
|
|
|
|
sm_txBuf.head = tmpHead;
|
|
|
|
|
|
|
|
HardwareImpl::enableDataRegEmptyInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool rxByte(data_t &byte) FORCE_INLINE
|
|
|
|
{
|
|
|
|
if (sm_rxBuf.head == sm_rxBuf.tail)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uint8_t tmpTail = (sm_rxBuf.tail + 1) % RX_BUFFER_SIZE;
|
|
|
|
byte = sm_rxBuf.buf[tmpTail];
|
|
|
|
sm_rxBuf.tail = tmpTail;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool peek(data_t &byte) FORCE_INLINE
|
|
|
|
{
|
|
|
|
if (sm_rxBuf.head == sm_rxBuf.tail)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
uint8_t tmpTail = (sm_rxBuf.tail + 1) % RX_BUFFER_SIZE;
|
|
|
|
byte = sm_rxBuf.buf[tmpTail];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool peek() FORCE_INLINE
|
|
|
|
{
|
|
|
|
return (sm_rxBuf.head != sm_rxBuf.tail);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void flushTx() FORCE_INLINE
|
|
|
|
{
|
|
|
|
while (sm_txBuf.head != sm_txBuf.tail)
|
|
|
|
;
|
|
|
|
while (!HardwareImpl::txEmpty())
|
|
|
|
;
|
|
|
|
while (!HardwareImpl::txComplete())
|
|
|
|
;
|
|
|
|
HardwareImpl::clearTxComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2019-08-15 18:07:11 +02:00
|
|
|
static void rxIntHandler() FORCE_INLINE
|
2019-08-14 19:49:42 +02:00
|
|
|
{
|
2020-04-13 16:41:16 +02:00
|
|
|
const auto data = HardwareImpl::rxByteInterrupt();
|
2019-08-14 19:49:42 +02:00
|
|
|
|
2020-04-13 16:41:16 +02:00
|
|
|
const uint8_t tmpHead = (sm_rxBuf.head + 1) % RX_BUFFER_SIZE;
|
2019-08-14 19:49:42 +02:00
|
|
|
|
|
|
|
if (tmpHead != sm_rxBuf.tail) {
|
|
|
|
sm_rxBuf.head = tmpHead;
|
|
|
|
sm_rxBuf.buf[tmpHead] = data;
|
|
|
|
} else {
|
|
|
|
// TODO: Handle overflow
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dataRegEmptyIntHandler() FORCE_INLINE
|
|
|
|
{
|
|
|
|
if (sm_txBuf.head != sm_txBuf.tail) {
|
2020-04-13 16:41:16 +02:00
|
|
|
const uint8_t tmpTail = (sm_txBuf.tail + 1) % TX_BUFFER_SIZE;
|
2019-08-14 19:49:42 +02:00
|
|
|
sm_txBuf.tail = tmpTail;
|
|
|
|
HardwareImpl::txByteInterrupt(sm_txBuf.buf[tmpTail]);
|
|
|
|
} else
|
|
|
|
HardwareImpl::disableDataRegEmptyInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
using HardwareImpl = Hardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, Driven::INTERRUPT, mode>;
|
|
|
|
|
|
|
|
static constexpr auto TX_BUFFER_SIZE = 16;
|
|
|
|
static constexpr auto RX_BUFFER_SIZE = 16;
|
|
|
|
|
|
|
|
static volatile RingBuffer<data_t, TX_BUFFER_SIZE> sm_txBuf;
|
|
|
|
static volatile RingBuffer<data_t, RX_BUFFER_SIZE> sm_rxBuf;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>
|
|
|
|
volatile RingBuffer<typename InterruptHardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, mode>::data_t,
|
|
|
|
InterruptHardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, mode>::TX_BUFFER_SIZE>
|
|
|
|
InterruptHardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, mode>::sm_txBuf = {0, 0, {0}};
|
|
|
|
|
|
|
|
template <class Registers, typename CtrlFlagsA, typename CtrlFlagsB, typename CtrlFlagsC, class cfg, Mode mode>
|
|
|
|
volatile RingBuffer<typename InterruptHardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, mode>::data_t,
|
|
|
|
InterruptHardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, mode>::RX_BUFFER_SIZE>
|
|
|
|
InterruptHardware<Registers, CtrlFlagsA, CtrlFlagsB, CtrlFlagsC, cfg, mode>::sm_rxBuf = {0, 0, {0}};
|
|
|
|
|
2019-08-02 09:21:47 +02:00
|
|
|
} // namespace detail
|
|
|
|
|
|
|
|
} // namespace uart
|
|
|
|
|
|
|
|
#undef FORCE_INLINE
|