mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 21:43:40 +00:00
Add core support for multiple UARTs (#152)
* machine/uart: add core support for multiple UARTs by allowing for multiple RingBuffers * machine/uart: complete core support for multiple UARTs * machine/uart: no need to store pointer to UART, better to treat like I2C and SPI * machine/uart: increase ring buffer size to 128 bytes * machine/uart: improve godocs comments and use comma-ok idiom for buffer Put/Get methods
This commit is contained in:
@@ -211,6 +211,11 @@ func (i2c I2C) readByte() byte {
|
||||
return byte(*avr.TWDR)
|
||||
}
|
||||
|
||||
// UART on the AVR.
|
||||
type UART struct {
|
||||
Buffer *RingBuffer
|
||||
}
|
||||
|
||||
// Configure the UART on the AVR. Defaults to 9600 baud on Arduino.
|
||||
func (uart UART) Configure(config UARTConfig) {
|
||||
if config.BaudRate == 0 {
|
||||
@@ -248,6 +253,6 @@ func handleUSART_RX() {
|
||||
// Ensure no error.
|
||||
if (*avr.UCSR0A & (avr.UCSR0A_FE0 | avr.UCSR0A_DOR0 | avr.UCSR0A_UPE0)) == 0 {
|
||||
// Put data from UDR register into buffer.
|
||||
bufferPut(byte(data))
|
||||
UART0.Receive(byte(data))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user