Skip to content

Commit b386f8c

Browse files
Wio sx1262 support
1 parent cc7f2e4 commit b386f8c

File tree

8 files changed

+22
-7
lines changed

8 files changed

+22
-7
lines changed

examples/lora/lorawan/common/stm32wlx.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ var (
1919
loraRadio *sx126x.Device
2020
)
2121

22-
var spi = machine.SPI3
22+
var (
23+
spi = machine.SPI3
24+
rstPin = machine.NoPin
25+
)
2326

2427
func newRadioControl() sx126x.RadioController {
2528
return sx126x.NewRadioControl()
2629
}
2730

2831
// do sx126x setup here
2932
func SetupLora() (lora.Radio, error) {
30-
loraRadio = sx126x.New(spi)
33+
loraRadio = sx126x.New(spi, rstPin)
3134
loraRadio.SetDeviceType(sx126x.DEVICE_TYPE_SX1262)
3235

3336
// Create radio controller for target

examples/sx126x/lora_continuous/lora_continuous.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ const FREQ = 868100000
1313

1414
var (
1515
loraRadio *sx126x.Device
16+
rstPin = machine.GP10
1617
)
1718

1819
func main() {
1920
println("\n# TinyGo Lora continuous Wave/Preamble test")
2021
println("# -----------------------------------------")
2122

2223
machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput})
24+
rstPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
2325

2426
// Create the driver
25-
loraRadio = sx126x.New(spi)
27+
loraRadio = sx126x.New(spi, rstPin)
2628
loraRadio.SetDeviceType(sx126x.DEVICE_TYPE_SX1262)
2729

2830
// Create radio controller for target

examples/sx126x/lora_continuous/radio.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var (
1212
spi = machine.SPI0
1313
nssPin, busyPin, dio1Pin = machine.GP17, machine.GP10, machine.GP11
1414
rxPin, txLowPin, txHighPin = machine.GP13, machine.GP12, machine.GP12
15+
rstPin = machine.GP10
1516
)
1617

1718
func newRadioControl() sx126x.RadioController {

examples/sx126x/lora_continuous/radio_stm32wl.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88
"tinygo.org/x/drivers/sx126x"
99
)
1010

11-
var spi = machine.SPI3
11+
var (
12+
spi = machine.SPI3
13+
rstPin = machine.NoPin
14+
)
1215

1316
func newRadioControl() sx126x.RadioController {
1417
return sx126x.NewRadioControl()

examples/sx126x/lora_rxtx/lora_rxtx.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ func main() {
2727
println("\n# TinyGo Lora RX/TX test")
2828
println("# ----------------------")
2929
machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput})
30+
rstPin.Configure(machine.PinConfig{Mode: machine.PinOutput})
3031

3132
// Create the driver
32-
loraRadio = sx126x.New(spi)
33+
loraRadio = sx126x.New(spi, rstPin)
3334
loraRadio.SetDeviceType(sx126x.DEVICE_TYPE_SX1262)
3435

3536
// Create radio controller for target

examples/sx126x/lora_rxtx/radio.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var (
1212
spi = machine.SPI1
1313
nssPin, busyPin, dio1Pin = machine.GP13, machine.GP6, machine.GP7
1414
rxPin, txLowPin, txHighPin = machine.GP9, machine.GP8, machine.GP8
15+
rstPin = machine.GP10
1516
)
1617

1718
func newRadioControl() sx126x.RadioController {

examples/sx126x/lora_rxtx/radio_stm32wl.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import (
88
"tinygo.org/x/drivers/sx126x"
99
)
1010

11-
var spi = machine.SPI3
11+
var (
12+
spi = machine.SPI3
13+
rstPin = machine.NoPin
14+
)
1215

1316
func newRadioControl() sx126x.RadioController {
1417
return sx126x.NewRadioControl()

sx126x/sx126x.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ type Device struct {
5454
}
5555

5656
// New creates a new SX126x connection.
57-
func New(spi drivers.SPI) *Device {
57+
func New(spi drivers.SPI, rstPin machine.Pin) *Device {
5858
return &Device{
5959
spi: spi,
60+
rstPin: rstPin,
6061
radioEventChan: make(chan lora.RadioEvent, RADIOEVENTCHAN_SIZE),
6162
spiTxBuf: make([]byte, SPI_BUFFER_SIZE),
6263
spiRxBuf: make([]byte, SPI_BUFFER_SIZE),

0 commit comments

Comments
 (0)