Skip to content

Commit

Permalink
[stm32] Fix UART transmission with buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jun 24, 2024
1 parent 8c43f84 commit cf7769b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/modm/platform/uart/stm32/uart_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ class BufferedUart<Hal, UartTxBuffer<SIZE>, Buffers...>: public BufferedUart<Hal
static bool
write(uint8_t data)
{
if (transmitBufferSize() == 0 and txBuffer.isEmpty())
Hal::write(data);
if (isWriteFinished()) Hal::write(data);
else
{
if (not txBuffer.push(data)) return false;
Expand Down Expand Up @@ -148,14 +147,15 @@ class BufferedUart<Hal, UartRxBuffer<SIZE>, Buffers...>: public BufferedUart<Hal
static bool
InterruptCallback(bool first)
{
if constexpr (Parent::TxBufferSize) Parent::InterruptCallback(false);

if (Hal::isReceiveRegisterNotEmpty())
{
uint8_t data;
Hal::read(data);
rxBuffer.push(data);
}

if constexpr (Parent::TxBufferSize) Parent::InterruptCallback(false);

if (first) Hal::acknowledgeInterruptFlags(Hal::InterruptFlag::OverrunError);
return true;
}
Expand Down

0 comments on commit cf7769b

Please sign in to comment.