Fixed blocking on full rx buffer and implemented support for ATmega328P

This commit is contained in:
2019-08-14 18:58:21 +02:00
parent 8d028aa635
commit e326e40b38
5 changed files with 18 additions and 9 deletions

View File

@@ -15,7 +15,7 @@ namespace uart {
namespace detail {
#if defined(__AVR_ATmega1284P__)
#if defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega328P__)
/*
The following works in avr-gcc 5.4.0, but is not legal C++, because ptr's are not legal constexpr's
@@ -213,11 +213,15 @@ class Hardware0<cfg, Driven::INTERRUPT, mode> {
static void rxIntHandler()
{
auto data = HardwareImpl::rxByteInterrupt();
uint8_t tmpHead = (sm_rxBuf.head + 1) % RX_BUFFER_SIZE;
if (tmpHead != sm_rxBuf.tail) {
sm_rxBuf.head = tmpHead;
sm_rxBuf.buf[tmpHead] = HardwareImpl::rxByteInterrupt();
sm_rxBuf.buf[tmpHead] = data;
} else {
// TODO: Handle overflow
}
}