atmega2560: support UART1-3

+ example for uart
This commit is contained in:
Yurii Soldak
2022-06-15 15:55:11 +02:00
committed by Ron Evans
parent 9294141d70
commit c119721e3b
4 changed files with 135 additions and 25 deletions
+25
View File
@@ -0,0 +1,25 @@
// This reads from UART1 and outputs to default serial, usually UART0 or USB.
// Example of how to work with UARTs other than the default.
package main
import (
"machine"
"time"
)
var (
uart = machine.UART1
tx = machine.UART1_TX_PIN
rx = machine.UART1_RX_PIN
)
func main() {
uart.Configure(machine.UARTConfig{TX: tx, RX: rx})
for {
if uart.Buffered() > 0 {
data, _ := uart.ReadByte()
print(string(data))
}
time.Sleep(10 * time.Millisecond)
}
}