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

@@ -84,8 +84,6 @@ extern void (*fnDataReg1EmptyIntHandler)();
#define HAS_UART1
#else
#error "This chip is not supported"
#endif
} // namespace detail
@@ -217,11 +215,15 @@ class Hardware1<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
}
}