Implemented peeking with and without data for interrupt and blocking mode
This commit is contained in:
parent
95963295e2
commit
a3d76a138d
@ -73,6 +73,15 @@ class Hardware {
|
||||
*Registers::IO_REG = byte;
|
||||
}
|
||||
|
||||
static bool peekBlocking() FORCE_INLINE
|
||||
{
|
||||
if (*Registers::CTRL_STAT_REG_A & (1 << CtrlFlagsA::RECEIVE_COMPLETE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void enableDataRegEmptyInt() FORCE_INLINE
|
||||
{
|
||||
*Registers::CTRL_STAT_REG_B |= (1 << CtrlFlagsB::DATA_REG_EMPTY_INT_ENABLE);
|
||||
|
@ -101,7 +101,17 @@ class Hardware0 {
|
||||
return HardwareImpl::rxByteBlocking(byte);
|
||||
}
|
||||
|
||||
static data_t peek() FORCE_INLINE {}
|
||||
static bool peek(data_t &byte) FORCE_INLINE
|
||||
{
|
||||
static_cast<void>(byte);
|
||||
static_assert(driven == Driven::BLOCKING, "Peek with data is not supported in blocking mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool peek() FORCE_INLINE
|
||||
{
|
||||
return HardwareImpl::peekBlocking();
|
||||
}
|
||||
|
||||
private:
|
||||
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
||||
@ -140,14 +150,27 @@ class Hardware0<mode, cfg, Driven::INTERRUPT> {
|
||||
return false;
|
||||
|
||||
uint8_t tmpTail = (sm_rxBuf.tail + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
byte = sm_rxBuf.buf[tmpTail];
|
||||
sm_rxBuf.tail = tmpTail;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static data_t peek() FORCE_INLINE {}
|
||||
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);
|
||||
}
|
||||
|
||||
private:
|
||||
using HardwareImpl = detail::Hardware<detail::Registers0, detail::ControlFlagsA0, detail::ControlFlagsB0,
|
||||
|
@ -105,7 +105,17 @@ class Hardware1 {
|
||||
return HardwareImpl::rxByteBlocking(byte);
|
||||
}
|
||||
|
||||
static data_t peek() FORCE_INLINE {}
|
||||
static bool peek(data_t &byte) FORCE_INLINE
|
||||
{
|
||||
static_cast<void>(byte);
|
||||
static_assert(driven != Driven::BLOCKING, "Peek with data is not supported in blocking mode");
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool peek() FORCE_INLINE
|
||||
{
|
||||
return HardwareImpl::peekBlocking();
|
||||
}
|
||||
|
||||
private:
|
||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||
@ -144,14 +154,27 @@ class Hardware1<mode, cfg, Driven::INTERRUPT> {
|
||||
return false;
|
||||
|
||||
uint8_t tmpTail = (sm_rxBuf.tail + 1) % RX_BUFFER_SIZE;
|
||||
|
||||
byte = sm_rxBuf.buf[tmpTail];
|
||||
sm_rxBuf.tail = tmpTail;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static data_t peek() FORCE_INLINE {}
|
||||
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);
|
||||
}
|
||||
|
||||
private:
|
||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||
|
Loading…
Reference in New Issue
Block a user