From 95963295e26af6b1457157a0909e29dad90ae3f6 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Fri, 2 Aug 2019 17:54:34 +0200 Subject: [PATCH] Implemented blocking rx --- hardware.hpp | 10 ++++++++++ hardware0.hpp | 2 +- hardware1.hpp | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/hardware.hpp b/hardware.hpp index 786abfc..96f3c2e 100644 --- a/hardware.hpp +++ b/hardware.hpp @@ -45,6 +45,16 @@ class Hardware { *Registers::CTRL_STAT_REG_C = controlRegC; } + static bool rxByteBlocking(typename cfg::data_t &byte) FORCE_INLINE + { + if (*Registers::CTRL_STAT_REG_A & (1 << CtrlFlagsA::RECEIVE_COMPLETE)) { + byte = *Registers::IO_REG; + return true; + } + + return false; + } + static typename cfg::data_t rxByteInterrupt() FORCE_INLINE { return *Registers::IO_REG; diff --git a/hardware0.hpp b/hardware0.hpp index 941c190..62ab024 100644 --- a/hardware0.hpp +++ b/hardware0.hpp @@ -98,7 +98,7 @@ class Hardware0 { static bool rxByte(data_t &byte) FORCE_INLINE { - return false; + return HardwareImpl::rxByteBlocking(byte); } static data_t peek() FORCE_INLINE {} diff --git a/hardware1.hpp b/hardware1.hpp index 1cff4f1..0f0f60e 100644 --- a/hardware1.hpp +++ b/hardware1.hpp @@ -102,7 +102,7 @@ class Hardware1 { static bool rxByte(data_t &byte) FORCE_INLINE { - return false; + return HardwareImpl::rxByteBlocking(byte); } static data_t peek() FORCE_INLINE {}