mirror of
https://github.com/soypat/lora.git
synced 2026-07-26 07:28:38 +00:00
add latest barebone additions
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
local
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
@@ -9,13 +9,11 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
pinCS0 = machine.GPIO27
|
||||
pinCS1 = machine.GPIO28
|
||||
pinRST0 = machine.GPIO29
|
||||
pinRST1 = machine.GPIO29
|
||||
pinMOSI = machine.GPIO3
|
||||
pinMISO = machine.GPIO4
|
||||
pinSCK = machine.GPIO6
|
||||
pinSCK = machine.GPIO18
|
||||
pinMOSI = machine.GPIO19
|
||||
pinMISO = machine.GPIO16
|
||||
pinCS0 = machine.GPIO8
|
||||
pinRST0 = machine.GPIO9
|
||||
pinDIO0 = machine.GPIO7
|
||||
)
|
||||
|
||||
@@ -69,11 +67,11 @@ func setup() {
|
||||
panic(err.Error())
|
||||
}
|
||||
pinCS0.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
pinCS1.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
pinRST0.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
pinRST1.Configure(machine.PinConfig{Mode: machine.PinOutput})
|
||||
dev0 = &sx127x.DeviceLoRaBare{DL: *sx127x.NewLoRa(bus, pinCS0.Set, pinRST0.Set)}
|
||||
pinDIO0.Configure(machine.PinConfig{Mode: machine.PinInputPulldown})
|
||||
|
||||
dev0 = &sx127x.DeviceLoRaBare{DL: *sx127x.NewLoRa(bus, pinCS0.Set, pinRST0.Set)}
|
||||
|
||||
// dev1 = sx127x.NewLoRa(bus, pinCS1.Set, pinRST1.Set)
|
||||
|
||||
cfg = sx127x.DefaultConfig(lora.Freq433_0M)
|
||||
|
||||
@@ -12,6 +12,9 @@ type DeviceLoRaBare struct {
|
||||
}
|
||||
|
||||
func (d *DeviceLoRaBare) Configure(c lora.Config) (err error) {
|
||||
// Taken from both:
|
||||
// pico-lorawan/src/lorawan.c
|
||||
// pico-lorawan/lib/LoRaMac-node/src/radio/sx1276/sx1276.c
|
||||
d.DL.Reset()
|
||||
// Seems to take just under ~6ms. Wait 20ms.
|
||||
err = d.DL.rxFSKChainCalibration(20 * time.Millisecond)
|
||||
|
||||
+2
-1
@@ -245,6 +245,7 @@ func (d *DeviceLoRa) Reset() {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
d.rst(true)
|
||||
time.Sleep(6 * time.Millisecond)
|
||||
d.csEnable(false)
|
||||
}
|
||||
|
||||
// IsConnected reads the version register and checks if it matches the expected value.
|
||||
@@ -947,7 +948,7 @@ func (d *DeviceLoRa) setHopPeriod(val uint8) error { return d.Write8(regHOP_PERI
|
||||
|
||||
func (d *DeviceLoRa) writeMasked8(addr uint8, mask, value byte) error {
|
||||
if value != 0 && value&^mask != 0 {
|
||||
println("value", value, "mask", mask)
|
||||
println("addr", addr, "value", value, "mask", mask)
|
||||
panic("misuse of writeMasked8") // Bug in this package if hit.
|
||||
}
|
||||
existing, err := d.read8(addr)
|
||||
|
||||
Reference in New Issue
Block a user