From 47e12e5a67ff7af82dd97170f92e345fa1abb8be Mon Sep 17 00:00:00 2001 From: Linar Yusupov Date: Fri, 15 Mar 2024 10:18:01 +0300 Subject: [PATCH] nRF52: build with WiFiNINA (or WiFiNINA_Generic) library --- software/firmware/source/SoftRF/src/driver/WiFi.h | 2 +- software/firmware/source/SoftRF/src/platform/nRF52.cpp | 9 +++++++++ software/firmware/source/SoftRF/src/platform/nRF52.h | 9 +++++++++ software/firmware/source/SoftRF/src/ui/Web.cpp | 2 +- software/firmware/source/SoftRF/src/ui/Web.h | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/software/firmware/source/SoftRF/src/driver/WiFi.h b/software/firmware/source/SoftRF/src/driver/WiFi.h index a1d410a28..c2b26739f 100644 --- a/software/firmware/source/SoftRF/src/driver/WiFi.h +++ b/software/firmware/source/SoftRF/src/driver/WiFi.h @@ -21,7 +21,7 @@ #include "../system/SoC.h" -#if defined(ARDUINO) && !defined(EXCLUDE_WIFI) +#if defined(ARDUINO) && !defined(EXCLUDE_WIFI) && !defined(USING_WIFI101_GENERIC) #include #endif diff --git a/software/firmware/source/SoftRF/src/platform/nRF52.cpp b/software/firmware/source/SoftRF/src/platform/nRF52.cpp index 66563e568..dc1189cf1 100644 --- a/software/firmware/source/SoftRF/src/platform/nRF52.cpp +++ b/software/firmware/source/SoftRF/src/platform/nRF52.cpp @@ -88,6 +88,11 @@ Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIX_NUM, SOC_GPIO_PIN_LED, #if defined(EXCLUDE_WIFI) char UDPpacketBuffer[4]; // Dummy definition to satisfy build sequence +#else +#if defined(USING_WIFI101_GENERIC) || defined(WiFiNINA_h) +#include +SoftSPI WiFiSPI(_PINNUM(1, 7), _PINNUM(1, 6), _PINNUM(0, 8)); +#endif /* USING_WIFI101_GENERIC || WiFiNINA_h */ #endif /* EXCLUDE_WIFI */ static uint32_t prev_tx_packets_counter = 0; @@ -821,6 +826,10 @@ static void nRF52_setup() Serial1.begin(115200); WiFi.init(&Serial1); #endif /* _WIFI_ESP_AT_H_ */ + +#if defined(WiFiNINA_h) + WiFi.setPins(SPIWIFI_SS, SPIWIFI_ACK, ESP32_RESETN, ESP32_GPIO0, &SPIWIFI); +#endif /* WiFiNINA_h */ #endif /* EXCLUDE_WIFI */ } diff --git a/software/firmware/source/SoftRF/src/platform/nRF52.h b/software/firmware/source/SoftRF/src/platform/nRF52.h index 9fdadc0c6..691bbbe2a 100644 --- a/software/firmware/source/SoftRF/src/platform/nRF52.h +++ b/software/firmware/source/SoftRF/src/platform/nRF52.h @@ -248,7 +248,16 @@ struct rst_info { //#define USE_ARDUINO_WIFI //#define USE_WIFI_NINA false //#define USE_WIFI_CUSTOM true + //#include + +//#define SPIWIFI WiFiSPI +//#define SPIWIFI_SS _PINNUM(0, 6) +//#define ESP32_RESETN _PINNUM(1, 3) +//#define SPIWIFI_ACK _PINNUM(0,15) +//#define ESP32_GPIO0 -1 +//#include +//#include //#define Serial_setDebugOutput(x) ({}) //#define WIFI_STA_TIMEOUT 20000 diff --git a/software/firmware/source/SoftRF/src/ui/Web.cpp b/software/firmware/source/SoftRF/src/ui/Web.cpp index 7d51f7d1e..26a89cfda 100644 --- a/software/firmware/source/SoftRF/src/ui/Web.cpp +++ b/software/firmware/source/SoftRF/src/ui/Web.cpp @@ -678,7 +678,7 @@ void handleSettings() { server.sendHeader(String(F("Cache-Control")), String(F("no-cache, no-store, must-revalidate"))); server.sendHeader(String(F("Pragma")), String(F("no-cache"))); server.sendHeader(String(F("Expires")), String(F("-1"))); -#if !defined(USE_ARDUINO_WIFI) +#if !defined(USE_ARDUINO_WIFI) || defined(USING_WIFI101_GENERIC) server.send ( 200, "text/html", Settings_temp ); #else char *content = Settings_temp; diff --git a/software/firmware/source/SoftRF/src/ui/Web.h b/software/firmware/source/SoftRF/src/ui/Web.h index 1822f67f2..98dc0f6a1 100644 --- a/software/firmware/source/SoftRF/src/ui/Web.h +++ b/software/firmware/source/SoftRF/src/ui/Web.h @@ -21,7 +21,7 @@ #include "../system/SoC.h" -#if defined(ARDUINO) && !defined(EXCLUDE_WIFI) +#if defined(ARDUINO) && !defined(EXCLUDE_WIFI) && !defined(USING_WIFI101_GENERIC) #include #endif /* ARDUINO */