From b422af0d8e3b0bcc76f8c5ae81dcf9167f21731c Mon Sep 17 00:00:00 2001 From: John Vasileff Date: Tue, 5 Nov 2024 14:09:12 -0500 Subject: [PATCH] Fix hang in Serial.flush() _state will be 0x2 for half-duplex mode, so we need to be careful with operator precedence to test only the low bit. Without this change, Serial.flush() hangs when half-duplex is enabled and no data has yet been sent. --- megaavr/cores/megatinycore/UART.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/megaavr/cores/megatinycore/UART.cpp b/megaavr/cores/megatinycore/UART.cpp index 6ee4d48b..bb6cd8fc 100644 --- a/megaavr/cores/megatinycore/UART.cpp +++ b/megaavr/cores/megatinycore/UART.cpp @@ -728,7 +728,7 @@ // If we have never written a byte, no need to flush. This special // case is needed since there is no way to force the TXCIF (transmit // complete) bit to 1 during initialization - if (!_state & 1) { + if (!(_state & 1)) { return; }