From 6b817faed37bde4660baafa6c9f9d6cb322629d1 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Fri, 6 Jan 2023 14:15:38 +0100 Subject: [PATCH] sx126x: add Reset() and needed pin Signed-off-by: deadprogram --- sx126x/sx126x.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sx126x/sx126x.go b/sx126x/sx126x.go index 8debed2..c045c6f 100644 --- a/sx126x/sx126x.go +++ b/sx126x/sx126x.go @@ -7,6 +7,8 @@ import ( "errors" "time" + "machine" + "tinygo.org/x/drivers" "tinygo.org/x/drivers/lora" ) @@ -39,6 +41,7 @@ const ( // Device wraps an SPI connection to a SX127x device. type Device struct { 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 loraConf lora.Config // Current Lora configuration rfswitch RFSwitch // RF Switch, if any @@ -86,6 +89,13 @@ func (d *Device) SetRfSwitch(rfswitch RFSwitch) { // 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 func (d *Device) DetectDevice() bool { bak := d.GetSyncWord()