sx127x: lora rx/tx example working, now assumes pybadge+featherwing

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2022-12-26 16:59:38 +01:00
committed by Ron Evans
parent 6d51370512
commit 9b14ee3ec5
2 changed files with 8 additions and 23 deletions
+8 -7
View File
@@ -1,7 +1,7 @@
package main
// This example code demonstrates Lora RX/TX With SX127x driver
// You need to connect SPI, DIO0 and DIO1 to use.
// You need to connect SPI, RST, CS, DIO0 (aka IRQ) and DIO1 to use.
import (
"machine"
@@ -22,11 +22,11 @@ var (
loraRadio *sx127x.Device
txmsg = []byte("Hello TinyGO")
// We assume the module is connected this way:
SX127X_PIN_RST = machine.PB9
SX127X_PIN_CS = machine.PB8
SX127X_PIN_DIO0 = machine.PA0
SX127X_PIN_DIO1 = machine.PA1
// We assume LoRa Featherwing module is connected to PyBadge:
SX127X_PIN_RST = machine.D11
SX127X_PIN_CS = machine.D10
SX127X_PIN_DIO0 = machine.D6
SX127X_PIN_DIO1 = machine.D9
SX127X_SPI = machine.SPI0
)
@@ -35,6 +35,7 @@ func dioIrqHandler(machine.Pin) {
}
func main() {
time.Sleep(5 * time.Second)
println("\n# TinyGo Lora RX/TX test")
println("# ----------------------")
machine.LED.Configure(machine.PinConfig{Mode: machine.PinOutput})
@@ -85,7 +86,7 @@ func main() {
tStart := time.Now()
println("main: Receiving Lora for 10 seconds")
for int(time.Now().Sub(tStart).Seconds()) < 10 {
for time.Since(tStart) < 10*time.Second {
buf, err := loraRadio.LoraRx(LORA_DEFAULT_RXTIMEOUT_MS)
if err != nil {
println("RX Error: ", err)
-16
View File
@@ -31,22 +31,6 @@ const (
RFSWITCH_TX_HP = iota
)
// const (
// RadioEventRxDone = iota
// RadioEventTxDone = iota
// RadioEventTimeout = iota
// RadioEventWatchdog = iota
// RadioEventCrcError = iota
// RadioEventUnhandled = iota
// )
// // RadioEvent are used for communicating in the radio Event Channel
// type RadioEvent struct {
// EventType int
// IRQStatus uint16
// EventData []byte
// }
const (
PERIOD_PER_SEC = (uint32)(1000000 / 15.625) // SX1261 DS 13.1.4
SPI_BUFFER_SIZE = 256