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:
Patricio Whittingslow
2023-07-15 11:24:53 -03:00
committed by GitHub
parent c83f712c17
commit a7b205c26c
14 changed files with 69 additions and 19 deletions
+5 -2
View File
@@ -97,7 +97,7 @@ func (i2c *I2C) stop() {
}
// writeByte writes a single byte to the I2C bus.
func (i2c *I2C) writeByte(data byte) {
func (i2c *I2C) writeByte(data byte) error {
// Write data to register.
avr.TWDR.Set(data)
@@ -107,6 +107,7 @@ func (i2c *I2C) writeByte(data byte) {
// Wait till data is transmitted.
for !avr.TWCR.HasBits(avr.TWCR_TWINT) {
}
return nil
}
// readByte reads a single byte from the I2C bus.
@@ -190,7 +191,7 @@ func (uart *UART) handleInterrupt(intr interrupt.Interrupt) {
}
// 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 UART buffer is not busy.
for !uart.statusRegA.HasBits(avr.UCSR0A_UDRE0) {
}
@@ -198,6 +199,8 @@ func (uart *UART) WriteByte(c byte) error {
return nil
}
func (uart *UART) flush() {}
// SPIConfig is used to store config info for SPI.
type SPIConfig struct {
Frequency uint32