diff --git a/adapter_ninafw.go b/adapter_ninafw.go index 59115fb5..2a095ac2 100644 --- a/adapter_ninafw.go +++ b/adapter_ninafw.go @@ -19,7 +19,6 @@ type Adapter struct { isDefault bool scanning bool - reset func() connectHandler func(device Address, connected bool) connectedDevices []*Device @@ -31,7 +30,6 @@ type Adapter struct { // Make sure to call Enable() before using it to initialize the adapter. var DefaultAdapter = &Adapter{ isDefault: true, - reset: resetNINAInverted, connectHandler: func(device Address, connected bool) { return }, @@ -45,14 +43,14 @@ func (a *Adapter) Enable() error { machine.NINA_CS.Configure(machine.PinConfig{Mode: machine.PinOutput}) machine.NINA_RESETN.Configure(machine.PinConfig{Mode: machine.PinOutput}) machine.NINA_CS.Low() - a.reset() + resetNINA() // serial port for nina chip - uart := machine.UART1 + uart := machine.UART_NINA uart.Configure(machine.UARTConfig{ TX: machine.NINA_TX, RX: machine.NINA_RX, - BaudRate: 115200, + BaudRate: ninaBaudrate, CTS: machine.NINA_CTS, RTS: machine.NINA_RTS, }) @@ -118,20 +116,6 @@ func makeNINAAddress(mac MAC) [6]uint8 { } } -func resetNINA() { - machine.NINA_RESETN.High() - time.Sleep(100 * time.Millisecond) - machine.NINA_RESETN.Low() - time.Sleep(1000 * time.Millisecond) -} - -func resetNINAInverted() { - machine.NINA_RESETN.Low() - time.Sleep(100 * time.Millisecond) - machine.NINA_RESETN.High() - time.Sleep(1000 * time.Millisecond) -} - func (a *Adapter) startNotifications() { if a.notificationsStarted { return diff --git a/ninafw_reset.go b/ninafw_reset.go new file mode 100644 index 00000000..1a658295 --- /dev/null +++ b/ninafw_reset.go @@ -0,0 +1,15 @@ +//go:build ninafw && !ninafw_reset_inverse + +package bluetooth + +import ( + "machine" + "time" +) + +func resetNINA() { + machine.NINA_RESETN.High() + time.Sleep(100 * time.Millisecond) + machine.NINA_RESETN.Low() + time.Sleep(1000 * time.Millisecond) +} diff --git a/ninafw_reset_inverse.go b/ninafw_reset_inverse.go new file mode 100644 index 00000000..3d6e8b5f --- /dev/null +++ b/ninafw_reset_inverse.go @@ -0,0 +1,15 @@ +//go:build ninafw && ninafw_reset_inverse + +package bluetooth + +import ( + "machine" + "time" +) + +func resetNINA() { + machine.NINA_RESETN.Low() + time.Sleep(100 * time.Millisecond) + machine.NINA_RESETN.High() + time.Sleep(1000 * time.Millisecond) +} diff --git a/ninafw_uart.go b/ninafw_uart.go new file mode 100644 index 00000000..69e086d1 --- /dev/null +++ b/ninafw_uart.go @@ -0,0 +1,5 @@ +//go:build ninafw && !ninafw_uart_slow + +package bluetooth + +const ninaBaudrate = 912600 diff --git a/ninafw_uart_slow.go b/ninafw_uart_slow.go new file mode 100644 index 00000000..467d1779 --- /dev/null +++ b/ninafw_uart_slow.go @@ -0,0 +1,5 @@ +//go:build ninafw && ninafw_uart_slow + +package bluetooth + +const ninaBaudrate = 115200