From d09ee42742b84d16eab87d8ca7fe3469dfbedd3f Mon Sep 17 00:00:00 2001 From: deadprogram Date: Sun, 15 Jan 2023 14:47:29 +0100 Subject: [PATCH] examples: set pin mappings for sx126x external board Signed-off-by: deadprogram --- examples/sx126x/lora_rxtx/lora_rxtx.go | 2 ++ examples/sx126x/lora_rxtx/radio.go | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/examples/sx126x/lora_rxtx/lora_rxtx.go b/examples/sx126x/lora_rxtx/lora_rxtx.go index 524d6c6..f382dd3 100644 --- a/examples/sx126x/lora_rxtx/lora_rxtx.go +++ b/examples/sx126x/lora_rxtx/lora_rxtx.go @@ -24,6 +24,8 @@ var ( ) func main() { + time.Sleep(3 * time.Second) + println("\n# TinyGo Lora RX/TX test") println("# ----------------------") machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput}) diff --git a/examples/sx126x/lora_rxtx/radio.go b/examples/sx126x/lora_rxtx/radio.go index 8657026..02a1f24 100644 --- a/examples/sx126x/lora_rxtx/radio.go +++ b/examples/sx126x/lora_rxtx/radio.go @@ -9,11 +9,21 @@ import ( ) var ( - spi = machine.SPI0 - nssPin, busyPin, dio1Pin = machine.GP17, machine.GP10, machine.GP11 - rxPin, txLowPin, txHighPin = machine.GP13, machine.GP12, machine.GP12 + spi = machine.SPI1 + nssPin, busyPin, dio1Pin = machine.GP13, machine.GP6, machine.GP7 + rxPin, txLowPin, txHighPin = machine.GP9, machine.GP8, machine.GP8 ) func newRadioControl() sx126x.RadioController { return sx126x.NewRadioControl(nssPin, busyPin, dio1Pin, rxPin, txLowPin, txHighPin) } + +func init() { + spi.Configure(machine.SPIConfig{ + Mode: 0, + Frequency: 8 * 1e6, + SDO: machine.SPI1_SDO_PIN, + SDI: machine.SPI1_SDI_PIN, + SCK: machine.SPI1_SCK_PIN, + }) +}