From 422051d822f08a1cce16c4d182bb280da05cc58a Mon Sep 17 00:00:00 2001 From: deadprogram Date: Tue, 2 May 2023 22:54:25 +0200 Subject: [PATCH] wifinina: add ResetIsHigh to control the behavior of the RESET pin for boards like the Arduino MKR 1010 Signed-off-by: deadprogram --- wifinina/wifinina.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wifinina/wifinina.go b/wifinina/wifinina.go index f6d0b07..9e2d6c8 100644 --- a/wifinina/wifinina.go +++ b/wifinina/wifinina.go @@ -126,6 +126,12 @@ type Device struct { ip uint32 port uint16 mu sync.Mutex + + // ResetIsHigh controls if the RESET signal to the processor + // should be High or Low (the default). Set this to true + // before calling Configure() for boards such as the Arduino MKR 1010, + // where the reset signal needs to go high instead of low. + ResetIsHigh bool } // New returns a new Wifinina device. @@ -139,6 +145,8 @@ func New(bus drivers.SPI, csPin, ackPin, gpio0Pin, resetPin machine.Pin) *Device } } +// Configure sets the needed pin settings and performs a reset +// of the WiFi device. func (d *Device) Configure() { net.UseDriver(d) pinUseDevice(d) @@ -150,14 +158,15 @@ func (d *Device) Configure() { d.GPIO0.High() d.CS.High() - d.RESET.Low() + + d.RESET.Set(d.ResetIsHigh) time.Sleep(10 * time.Millisecond) - d.RESET.High() + + d.RESET.Set(!d.ResetIsHigh) time.Sleep(750 * time.Millisecond) d.GPIO0.Low() d.GPIO0.Configure(machine.PinConfig{Mode: machine.PinInputPullup}) - } // ----------- client methods (should this be a separate struct?) ------------