Compare commits
2 Commits
b6c1c3b51b
...
8153696309
| Author | SHA1 | Date | |
|---|---|---|---|
| 8153696309 | |||
| 9f9f7a8de5 |
17
hardware.hpp
17
hardware.hpp
@@ -64,9 +64,24 @@ class Hardware {
|
|||||||
return *Registers::IO_REG;
|
return *Registers::IO_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool txEmpty() FORCE_INLINE
|
||||||
|
{
|
||||||
|
return *Registers::CTRL_STAT_REG_A & (1 << CtrlFlagsA::DATA_REG_EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool txComplete() FORCE_INLINE
|
||||||
|
{
|
||||||
|
return *Registers::CTRL_STAT_REG_A & (1 << CtrlFlagsA::TRANSMIT_COMPLETE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void clearTxComplete() FORCE_INLINE
|
||||||
|
{
|
||||||
|
*Registers::CTRL_STAT_REG_A |= (1 << CtrlFlagsA::TRANSMIT_COMPLETE);
|
||||||
|
}
|
||||||
|
|
||||||
static void txByteBlocking(const typename cfg::data_t &byte) FORCE_INLINE
|
static void txByteBlocking(const typename cfg::data_t &byte) FORCE_INLINE
|
||||||
{
|
{
|
||||||
while (!(*Registers::CTRL_STAT_REG_A & (1 << CtrlFlagsA::DATA_REG_EMPTY)))
|
while (!txEmpty())
|
||||||
;
|
;
|
||||||
|
|
||||||
*Registers::IO_REG = byte;
|
*Registers::IO_REG = byte;
|
||||||
|
|||||||
@@ -105,6 +105,15 @@ class Hardware0 {
|
|||||||
return HardwareImpl::peekBlocking();
|
return HardwareImpl::peekBlocking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void flushTx() FORCE_INLINE
|
||||||
|
{
|
||||||
|
while (!HardwareImpl::txEmpty())
|
||||||
|
;
|
||||||
|
while (!HardwareImpl::txComplete())
|
||||||
|
;
|
||||||
|
HardwareImpl::clearTxComplete();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
||||||
detail::ControlFlagsC0, cfg, mode, driven>;
|
detail::ControlFlagsC0, cfg, mode, driven>;
|
||||||
@@ -164,6 +173,17 @@ class Hardware0<mode, cfg, Driven::INTERRUPT> {
|
|||||||
return (sm_rxBuf.head != sm_rxBuf.tail);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
||||||
detail::ControlFlagsC0, cfg, mode, Driven::INTERRUPT>;
|
detail::ControlFlagsC0, cfg, mode, Driven::INTERRUPT>;
|
||||||
|
|||||||
@@ -109,6 +109,15 @@ class Hardware1 {
|
|||||||
return HardwareImpl::peekBlocking();
|
return HardwareImpl::peekBlocking();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void flushTx() FORCE_INLINE
|
||||||
|
{
|
||||||
|
while (!HardwareImpl::txEmpty())
|
||||||
|
;
|
||||||
|
while (!HardwareImpl::txComplete())
|
||||||
|
;
|
||||||
|
HardwareImpl::clearTxComplete();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||||
detail::ControlFlagsC1, cfg, mode, driven>;
|
detail::ControlFlagsC1, cfg, mode, driven>;
|
||||||
@@ -168,6 +177,17 @@ class Hardware1<mode, cfg, Driven::INTERRUPT> {
|
|||||||
return (sm_rxBuf.head != sm_rxBuf.tail);
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||||
detail::ControlFlagsC1, cfg, mode, Driven::INTERRUPT>;
|
detail::ControlFlagsC1, cfg, mode, Driven::INTERRUPT>;
|
||||||
|
|||||||
5
uart.hpp
5
uart.hpp
@@ -88,6 +88,11 @@ class Uart {
|
|||||||
return Driver::peek();
|
return Driver::peek();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void flushTx()
|
||||||
|
{
|
||||||
|
Driver::flushTx();
|
||||||
|
}
|
||||||
|
|
||||||
static void txString(const char *str)
|
static void txString(const char *str)
|
||||||
{
|
{
|
||||||
static_assert(Driver::DATA_BITS == DataBits::EIGHT, "Strings are only supported with 8 data bits");
|
static_assert(Driver::DATA_BITS == DataBits::EIGHT, "Strings are only supported with 8 data bits");
|
||||||
|
|||||||
Reference in New Issue
Block a user