Last active
August 8, 2019 16:11
-
-
Save deadprogram/1494daf7e9db5b26128be8b1c77a0ab8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"machine" | |
"time" | |
) | |
var ( | |
nina = machine.UART1 | |
tx = machine.PA22 | |
rx = machine.PA23 | |
usb = machine.UART0 | |
reset = machine.NINA_RESETN | |
gpio0 = machine.NINA_GPIO0 | |
) | |
func main() { | |
led := machine.LED | |
led.Configure(machine.PinConfig{Mode: machine.PinOutput}) | |
led.Low() | |
nina.Configure(machine.UARTConfig{TX: tx, RX: rx}) | |
// switch to load bootloader | |
gpio0.Configure(machine.PinConfig{Mode: machine.PinOutput}) | |
reset.Configure(machine.PinConfig{Mode: machine.PinOutput}) | |
gpio0.Low() | |
reset.Low() | |
time.Sleep(100 * time.Millisecond) | |
reset.High() | |
time.Sleep(100 * time.Millisecond) | |
for { | |
for usb.Buffered() > 0 { | |
data, _ := usb.ReadByte() | |
nina.WriteByte(data) | |
} | |
for nina.Buffered() > 0 { | |
data, _ := nina.ReadByte() | |
usb.WriteByte(data) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment