mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
machine.UART refactor (#3832)
* add gosched calls to UART * add UART.flush() stubs for all supported architectures * add comment un uart.go on flush functionality * uart.writeByte as base of UART usage * fix NXP having duplicate WriteByte * fix writeByte not returning error on some platforms * add flush method for fe310 device * check for error in WriteByte call to writeByte
This commit is contained in:
committed by
GitHub
parent
c83f712c17
commit
a7b205c26c
@@ -86,9 +86,10 @@ func (uart *UART) SetBaudRate(br uint32) {
|
||||
}
|
||||
|
||||
// WriteByte writes a byte of data to the UART.
|
||||
func (uart *UART) WriteByte(c byte) error {
|
||||
func (uart *UART) writeByte(c byte) error {
|
||||
// wait until buffer is not full
|
||||
for uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_TXFF) {
|
||||
gosched()
|
||||
}
|
||||
|
||||
// write data
|
||||
@@ -96,6 +97,12 @@ func (uart *UART) WriteByte(c byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (uart *UART) flush() {
|
||||
for uart.Bus.UARTFR.HasBits(rp.UART0_UARTFR_BUSY) {
|
||||
gosched()
|
||||
}
|
||||
}
|
||||
|
||||
// SetFormat for number of data bits, stop bits, and parity for the UART.
|
||||
func (uart *UART) SetFormat(databits, stopbits uint8, parity UARTParity) error {
|
||||
var pen, pev uint8
|
||||
|
||||
Reference in New Issue
Block a user