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