mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43: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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user