mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-16 21:03:23 +00:00
sx126x: add Reset() and needed pin
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"machine"
|
||||||
|
|
||||||
"tinygo.org/x/drivers"
|
"tinygo.org/x/drivers"
|
||||||
"tinygo.org/x/drivers/lora"
|
"tinygo.org/x/drivers/lora"
|
||||||
)
|
)
|
||||||
@@ -39,6 +41,7 @@ const (
|
|||||||
// Device wraps an SPI connection to a SX127x device.
|
// Device wraps an SPI connection to a SX127x device.
|
||||||
type Device struct {
|
type Device struct {
|
||||||
spi drivers.SPI // SPI bus for module communication
|
spi drivers.SPI // SPI bus for module communication
|
||||||
|
rstPin, csPin machine.Pin // GPIOs for reset and chip select
|
||||||
radioEventChan chan lora.RadioEvent // Channel for Receiving events
|
radioEventChan chan lora.RadioEvent // Channel for Receiving events
|
||||||
loraConf lora.Config // Current Lora configuration
|
loraConf lora.Config // Current Lora configuration
|
||||||
rfswitch RFSwitch // RF Switch, if any
|
rfswitch RFSwitch // RF Switch, if any
|
||||||
@@ -86,6 +89,13 @@ func (d *Device) SetRfSwitch(rfswitch RFSwitch) {
|
|||||||
// Operational modes functions
|
// Operational modes functions
|
||||||
// --------------------------------------------------
|
// --------------------------------------------------
|
||||||
|
|
||||||
|
func (d *Device) Reset() {
|
||||||
|
d.rstPin.Low()
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
d.rstPin.High()
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
}
|
||||||
|
|
||||||
// DetectDevice() tries to detect the radio module by changing SyncWord value
|
// DetectDevice() tries to detect the radio module by changing SyncWord value
|
||||||
func (d *Device) DetectDevice() bool {
|
func (d *Device) DetectDevice() bool {
|
||||||
bak := d.GetSyncWord()
|
bak := d.GetSyncWord()
|
||||||
|
|||||||
Reference in New Issue
Block a user