Added basic structure to support interrupt driven operation
This commit is contained in:
@@ -59,6 +59,28 @@ 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); }
|
||||
// clang-format on
|
||||
|
||||
static void (*fnDataReg1EmptyIntHandler)() = nullptr;
|
||||
static void (*fnRx1IntHandler)() = nullptr;
|
||||
static void (*fnTx1IntHandler)() = nullptr;
|
||||
|
||||
ISR(USART1_UDRE_vect)
|
||||
{
|
||||
if (fnDataReg1EmptyIntHandler)
|
||||
fnDataReg1EmptyIntHandler();
|
||||
}
|
||||
|
||||
ISR(USART1_RX_vect)
|
||||
{
|
||||
if (fnRx1IntHandler)
|
||||
fnRx1IntHandler();
|
||||
}
|
||||
|
||||
ISR(USART1_TX_vect)
|
||||
{
|
||||
if (fnTx1IntHandler)
|
||||
fnTx1IntHandler();
|
||||
}
|
||||
|
||||
#define HAS_UART1
|
||||
|
||||
#else
|
||||
@@ -82,7 +104,7 @@ class Hardware1 {
|
||||
|
||||
static void txByte(data_t byte) FORCE_INLINE
|
||||
{
|
||||
HardwareImpl::txByte(byte);
|
||||
HardwareImpl::txByteBlocking(byte);
|
||||
}
|
||||
|
||||
static data_t rxByte() FORCE_INLINE {}
|
||||
@@ -91,7 +113,51 @@ class Hardware1 {
|
||||
|
||||
private:
|
||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||
detail::ControlFlagsC1, cfg, mode>;
|
||||
detail::ControlFlagsC1, cfg, mode, driven>;
|
||||
};
|
||||
|
||||
template <Mode mode, class cfg>
|
||||
class Hardware1<mode, cfg, Driven::INTERRUPT> {
|
||||
public:
|
||||
using data_t = typename cfg::data_t;
|
||||
static constexpr auto DATA_BITS = cfg::DATA_BITS;
|
||||
|
||||
static void init() FORCE_INLINE
|
||||
{
|
||||
detail::fnDataReg1EmptyIntHandler = dataRegEmptyIntHandler;
|
||||
detail::fnRx1IntHandler = rxIntHandler;
|
||||
detail::fnTx1IntHandler = txIntHandler;
|
||||
|
||||
HardwareImpl::init();
|
||||
}
|
||||
|
||||
static void txByte(data_t byte) FORCE_INLINE
|
||||
{
|
||||
HardwareImpl::txByteBlocking(byte);
|
||||
}
|
||||
|
||||
static data_t rxByte() FORCE_INLINE {}
|
||||
|
||||
static data_t peek() FORCE_INLINE {}
|
||||
|
||||
private:
|
||||
using HardwareImpl = detail::Hardware<detail::Registers1, detail::ControlFlagsA1, detail::ControlFlagsB1,
|
||||
detail::ControlFlagsC1, cfg, mode, Driven::INTERRUPT>;
|
||||
|
||||
static void dataRegEmptyIntHandler()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void rxIntHandler()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
static void txIntHandler()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user