From 82f7e2012efb31e5fd35c4f5401d6f73c79b6c2a Mon Sep 17 00:00:00 2001 From: Linar Yusupov Date: Thu, 14 Mar 2024 13:38:59 +0300 Subject: [PATCH] nRF52: bringup of Wi-Fi 'co-processor' with 'Esp-AT' firmware --- software/firmware/source/SoftRF/src/driver/WiFi.cpp | 9 ++++++++- .../firmware/source/SoftRF/src/platform/nRF52.cpp | 11 ++++++++++- software/firmware/source/SoftRF/src/platform/nRF52.h | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/software/firmware/source/SoftRF/src/driver/WiFi.cpp b/software/firmware/source/SoftRF/src/driver/WiFi.cpp index 0c7284080..2d65c3f87 100644 --- a/software/firmware/source/SoftRF/src/driver/WiFi.cpp +++ b/software/firmware/source/SoftRF/src/driver/WiFi.cpp @@ -116,13 +116,16 @@ void WiFi_setup() if (WiFi.status() == WL_NO_MODULE) { Serial.println("Communication with WiFi module failed!"); // don't continue - while (true); + // while (true); + return; } +#if !defined(_WIFI_ESP_AT_H_) String fv = WiFi.firmwareVersion(); if (fv < WIFI_FIRMWARE_LATEST_VERSION) { Serial.println("Please upgrade the firmware"); } +#endif /* _WIFI_ESP_AT_H_ */ WiFi.setHostname(host_name.c_str()); @@ -340,7 +343,11 @@ void WiFi_fini() Uni_Udp.stop(); #if defined(USE_ARDUINO_WIFI) +#if !defined(_WIFI_ESP_AT_H_) WiFi.end(); +#else + WiFi.endAP(); +#endif /* _WIFI_ESP_AT_H_ */ #else WiFi.mode(WIFI_OFF); #endif /* USE_ARDUINO_WIFI */ diff --git a/software/firmware/source/SoftRF/src/platform/nRF52.cpp b/software/firmware/source/SoftRF/src/platform/nRF52.cpp index b247934dc..66563e568 100644 --- a/software/firmware/source/SoftRF/src/platform/nRF52.cpp +++ b/software/firmware/source/SoftRF/src/platform/nRF52.cpp @@ -610,8 +610,10 @@ static void nRF52_setup() #if defined(USE_TINYUSB) Serial1.setPins(SOC_GPIO_PIN_CONS_RX, SOC_GPIO_PIN_CONS_TX); +#if defined(EXCLUDE_WIFI) Serial1.begin(SERIAL_OUT_BR, SERIAL_OUT_BITS); -#endif +#endif /* EXCLUDE_WIFI */ +#endif /* USE_TINYUSB */ digitalWrite(SOC_GPIO_PIN_IO_PWR, HIGH); pinMode(SOC_GPIO_PIN_IO_PWR, OUTPUT); /* VDD_POWR is ON */ @@ -813,6 +815,13 @@ static void nRF52_setup() #if defined(USE_TINYUSB) && defined(USBCON) for (int i=0; i < 20; i++) {if (Serial) break; else delay(100);} #endif + +#if !defined(EXCLUDE_WIFI) +#if defined(_WIFI_ESP_AT_H_) + Serial1.begin(115200); + WiFi.init(&Serial1); +#endif /* _WIFI_ESP_AT_H_ */ +#endif /* EXCLUDE_WIFI */ } static void nRF52_post_init() diff --git a/software/firmware/source/SoftRF/src/platform/nRF52.h b/software/firmware/source/SoftRF/src/platform/nRF52.h index 42d0b57d6..9fdadc0c6 100644 --- a/software/firmware/source/SoftRF/src/platform/nRF52.h +++ b/software/firmware/source/SoftRF/src/platform/nRF52.h @@ -248,7 +248,7 @@ struct rst_info { //#define USE_ARDUINO_WIFI //#define USE_WIFI_NINA false //#define USE_WIFI_CUSTOM true -//#include +//#include //#define Serial_setDebugOutput(x) ({}) //#define WIFI_STA_TIMEOUT 20000