Skip to content

FUnktion to empty UART Buffer manually #1257

@brinzebuah

Description

@brinzebuah

Hi, i would like to add a function to the UART, to empty the Buffer manually. I hade some problems with the DebugStream while using FreeRTOS, because the Interrupts didn't got time and so the Buffer just filled until the System breaks. I added a function to clear the Buffer manually. I think this gives the user more flexibility to handle the UART and wanted to ask you about feedback.

In modm/platform/uart/stm32/uart.hpp.in:

%% if options["buffer.tx"]
	static void
	emptyBuffer();
%% endif

In modm/platform/uart/stm32/uart.cpp.in:

%% if options["buffer.tx"]
void
{{ name }}::emptyBuffer()
{
	while(!txBuffer.isEmpty())
	{	
		if ({{ hal }}::isTransmitRegisterEmpty()) {
			{{ hal }}::write(txBuffer.get());
			txBuffer.pop();
		}
	}
	{{ hal }}::disableInterrupt({{ hal }}::Interrupt::TxEmpty);
	{{ hal }}::acknowledgeInterruptFlags({{ hal }}::InterruptFlag::OverrunError);
}
%% endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions