From 39b1f8b6f55184efe2dd0b7fecf121ed6c8f3809 Mon Sep 17 00:00:00 2001 From: ardnew Date: Thu, 12 Nov 2020 14:32:25 -0600 Subject: [PATCH] teensy40: UART: add missing godocs, rename Flush to Sync --- src/machine/machine_mimxrt1062_uart.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/machine/machine_mimxrt1062_uart.go b/src/machine/machine_mimxrt1062_uart.go index 56107b38..90777d6f 100644 --- a/src/machine/machine_mimxrt1062_uart.go +++ b/src/machine/machine_mimxrt1062_uart.go @@ -157,13 +157,19 @@ func (uart *UART) Configure(config UARTConfig) { uart.configured = true } +// Disable disables the UART interface. +// +// If any buffered data has not yet been transmitted, Disable waits until +// transmission completes before disabling the interface. The receiver UART's +// interrupt is also disabled, and the RX/TX pins are reconfigured for GPIO +// input (pull-up). func (uart *UART) Disable() { // first ensure the device is enabled if uart.configured { // wait for any buffered data to send - uart.Flush() + uart.Sync() // stop trapping RX interrupts uart.Interrupt.Disable() @@ -181,13 +187,15 @@ func (uart *UART) Disable() { uart.configured = false } -// Flush blocks the calling goroutine until all data in the output buffer has -// been written out. -func (uart *UART) Flush() { +// Sync blocks the calling goroutine until all data in the output buffer has +// been transmitted. +func (uart *UART) Sync() error { for uart.isTransmitting() { } + return nil } +// WriteByte writes a single byte of data to the UART interface. func (uart *UART) WriteByte(c byte) error { if nil == uart.txBuffer { uart.txBuffer = NewRingBuffer()