mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-24 11:46:34 +00:00
initial WiFiSpi support for STM32F4xx
This commit is contained in:
parent
60b3dd052f
commit
b508503fcd
@ -154,6 +154,11 @@
|
||||
#include "hasp_ethernet.h"
|
||||
#endif
|
||||
|
||||
#if HASP_USE_WIFI > 0 && defined(STM32F4xx)
|
||||
#include "WiFiSpi.h"
|
||||
static WiFiSpiClass WiFi;
|
||||
#endif
|
||||
|
||||
#ifndef FPSTR
|
||||
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
|
||||
#endif
|
||||
|
240
platformio_override_OLD.ini
Normal file
240
platformio_override_OLD.ini
Normal file
@ -0,0 +1,240 @@
|
||||
[override]
|
||||
; -- Hasp config options ----------------------
|
||||
build_flags =
|
||||
; -- Use settings from file user_config_override.h
|
||||
-DUSE_CONFIG_OVERRIDE
|
||||
|
||||
;***************************************************
|
||||
; Generic ESP32 build with ILI9488 SPI 4-WIRE
|
||||
;***************************************************
|
||||
[env:esp32dev-ILI9488]
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
upload_port = COM11 ; Change to the correct port
|
||||
monitor_port = COM11 ; Change to the correct port
|
||||
; upload_protocol = espota ; Use ArduinoOTA after flashing over serial
|
||||
; upload_port = 10.4.0.171 ; IP of the ESP
|
||||
; upload_flags =
|
||||
; --port=3232
|
||||
monitor_speed = 115200
|
||||
debug_tool = esp-prog
|
||||
debug_init_break = tbreak setup
|
||||
|
||||
build_flags =
|
||||
${flags.esp32_flags}
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
-D ILI9488_DRIVER=1
|
||||
-D TFT_BCKL=5 ;None, configurable via web UI (e.g. 2 for D4)
|
||||
-D TFT_WIDTH=320
|
||||
-D TFT_HEIGHT=480
|
||||
-D TFT_ROTATION=0 ; 0=0, 1=90, 2=180 or 3=270 degree
|
||||
-D USER_SETUP_LOADED=1
|
||||
-D TFT_MISO=19 ;// (leave TFT SDO disconnected if other SPI devices share MISO)
|
||||
-D TFT_MOSI=23
|
||||
-D TFT_SCLK=18
|
||||
-D TFT_CS=15 ;// Chip select control pin
|
||||
-D TFT_DC=2 ;// Data Command control pin
|
||||
-D TFT_RST=4 ;// Reset pin (could connect to RST pin)
|
||||
-D SUPPORT_TRANSACTIONS
|
||||
-D TOUCH_CS=22
|
||||
-D TOUCH_DRIVER=0 ; XPT2606 Resistive touch panel driver
|
||||
-D SPI_FREQUENCY=27000000
|
||||
-D SPI_TOUCH_FREQUENCY=2500000
|
||||
-D SPI_READ_FREQUENCY=16000000
|
||||
|
||||
; -- Debugging options -----------------------------
|
||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
|
||||
; -- Library options -------------------------------
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
|
||||
src_filter = +<*> +<../drivers/stm32f429_disco>
|
||||
|
||||
|
||||
[env:esp32dev-mrb3511]
|
||||
; upload_port = COM11 ; Change to the correct port
|
||||
; monitor_port = COM11 ; Change to the correct port
|
||||
upload_protocol = espota ; Use ArduinoOTA after flashing over serial
|
||||
upload_port = 10.4.0.171 ; IP of the ESP
|
||||
upload_flags =
|
||||
--port=3232
|
||||
|
||||
|
||||
[env:nodemcu32s-raspi]
|
||||
; upload_port = COM11 ; Change to the correct port
|
||||
; monitor_port = COM11 ; Change to the correct port
|
||||
upload_protocol = espota ; Use ArduinoOTA after flashing over serial
|
||||
upload_port = 10.4.0.151 ; IP of the ESP
|
||||
upload_flags =
|
||||
--port=3232
|
||||
|
||||
|
||||
|
||||
;***************************************************
|
||||
; ESP32CAM with MHS-4" RPI Display-B
|
||||
;***************************************************
|
||||
[env:esp32cam-raspi]
|
||||
platform = espressif32
|
||||
board = esp32cam
|
||||
; upload_port = COM18 ; To change the port, use platform_override.ini
|
||||
; monitor_port = COM18 ; To change the port, use platform_override.ini
|
||||
upload_protocol = espota ; Use ArduinoOTA after flashing over serial
|
||||
upload_port = 10.4.0.166 ; IP of the ESP
|
||||
upload_flags =
|
||||
--port=3232
|
||||
|
||||
debug_tool = esp-prog
|
||||
debug_init_break = tbreak setup
|
||||
;board_build.partitions = min_spiffs.csv
|
||||
board_build.partitions = default.csv
|
||||
;ESP32 CAM PINS
|
||||
build_flags =
|
||||
${flags.esp32_flags}
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
${lcd.raspberrypi}
|
||||
-D USE_HSPI_PORT
|
||||
${pins.hspi32}
|
||||
-D TFT_CS=15
|
||||
-D TFT_DC=2
|
||||
-D TFT_RST=-1 ; 3.3v
|
||||
-D TOUCH_CS=0 ; 3 ; RX
|
||||
-D TFT_BCKL=-1
|
||||
|
||||
; -- Debugging options -----------------------------
|
||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
|
||||
; -- Library options -------------------------------
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
|
||||
;***************************************************
|
||||
; ESP32 Programmer with MHS-4" RPI Display-B
|
||||
;***************************************************
|
||||
[env:programmer-raspi]
|
||||
platform = espressif32
|
||||
board = esp32dev
|
||||
upload_port = COM11 ; To change the port, use platform_override.ini
|
||||
monitor_port = COM11 ; To change the port, use platform_override.ini
|
||||
debug_tool = esp-prog
|
||||
debug_init_break = tbreak setup
|
||||
|
||||
build_flags =
|
||||
${flags.esp32_flags}
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
; ${lcd.raspberrypi}
|
||||
${lcd.lolin24}
|
||||
${pins.hspi32}
|
||||
-D TFT_CS=15
|
||||
-D TFT_DC=4
|
||||
-D TFT_RST=-1
|
||||
-D TOUCH_CS=5
|
||||
-D USE_HSPI_PORT=1
|
||||
|
||||
; -- Debugging options -----------------------------
|
||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
|
||||
; -- Library options -------------------------------
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
|
||||
;***************************************************
|
||||
; STM32F4 build
|
||||
;***************************************************
|
||||
[env:DevEBox]
|
||||
platform = ststm32
|
||||
board = black_f407zg
|
||||
board_build.mcu = stm32f407vgt6
|
||||
; upload_protocol = dfu
|
||||
upload_protocol = stlink
|
||||
debug_tool = stlink
|
||||
monitor_port = COM19 ; To change the port, use platform_override.ini
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
${flags.stm32_flags}
|
||||
-I include/stm32f4
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
${lcd.lolin24}
|
||||
;-D TFT_MISO=PB4 ;Default
|
||||
;-D TFT_MOSI=PB5 ;Default
|
||||
;-D TFT_SCLK=PB3 ;Default
|
||||
-D TFT_CS=PE13 ;D8
|
||||
-D TFT_DC=PE14 ;D3
|
||||
-D TFT_BCKL=-1 ;None, configurable via web UI (e.g. 2 for D4)
|
||||
-D TOUCH_CS=PA6 ;NC
|
||||
-D TFT_RST=-1 ;D4
|
||||
; -D STM32
|
||||
-D TFT_SPI1
|
||||
-D USE_DMA_TO_TFT
|
||||
-D HASP_USE_TASMOTA_SLAVE=1
|
||||
-D HASP_OUTPUT_PIN=PA1 ; User LED D2 on DevEBox board
|
||||
-D HASP_INPUT_PIN=PA0 ; User Button K1 on DevEBox board
|
||||
-D STM32_SERIAL1 ; Set this option to use Serial1 as default sersial port, leave out if using Serial2
|
||||
-D HASP_USE_ETHERNET=1
|
||||
-D HAL_ETH_MODULE_ENABLED=1
|
||||
-D LAN8742A_PHY_ADDRESS=0x01U
|
||||
; -D DP83848_PHY_ADDRESS=0x00U
|
||||
|
||||
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
Ticker@^3.1.5
|
||||
; STM32duino LwIP@^2.1.2
|
||||
; STM32duino STM32Ethernet@^1.0.5
|
||||
https://github.com/stm32duino/LwIP.git
|
||||
https://github.com/stm32duino/STM32Ethernet.git
|
||||
; https://github.com/andrethomas/TasmotaSlave.git
|
||||
|
||||
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
|
||||
|
||||
|
||||
;***************************************************
|
||||
; STM32F4 build
|
||||
;***************************************************
|
||||
[env:DIYMore_f407vg]
|
||||
platform = ststm32
|
||||
board = diymore_f407vgt
|
||||
board_build.mcu = stm32f407vgt6
|
||||
upload_protocol = dfu
|
||||
monitor_port = COM7 ; To change the port, use platform_override.ini
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
${flags.stm32_flags}
|
||||
-I include/stm32f4
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
${lcd.lolin24}
|
||||
;-D TFT_MISO=PB4 ;Default
|
||||
;-D TFT_MOSI=PB5 ;Default
|
||||
;-D TFT_SCLK=PB3 ;Default
|
||||
-D TFT_CS=PE13 ;D8
|
||||
-D TFT_DC=PE14 ;D3
|
||||
-D TFT_BCKL=PA15 ;None, configurable via web UI (e.g. 2 for D4)
|
||||
-D TOUCH_CS=PA6 ;NC
|
||||
-D TFT_RST=-1 ;D4
|
||||
-D HASP_OUTPUT_PIN=PE0 ; User LED D2 on DevEBox board
|
||||
-D HASP_INPUT_PIN=PD15 ; User Button K1 on DevEBox board
|
||||
-D STM32_SERIAL1 ; Set this option to use Serial1 as default sersial port, leave out if using Serial2
|
||||
-D HASP_USE_ETHERNET=1
|
||||
-D W5500_MOSI=PB15 ;SPI2 MOSI
|
||||
-D W5500_MISO=PB14 ;SPI2 MISO
|
||||
-D W5500_SCLK=PB13 ;SPI2 SCLK
|
||||
-D W5500_CS=PB6 ;SPI2 CS
|
||||
-D W5500_RST=PD1 ;SPI2 CS
|
||||
; -D HAL_ETH_MODULE_ENABLED=1 ; enable ethernet support
|
||||
; -D LAN8742A_PHY_ADDRESS=0x01U ; set LAN8720 PHY address
|
||||
-D HASP_USE_TASMOTA_SLAVE=1
|
||||
-D W5500_LAN
|
||||
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
Ticker@^3.1.5
|
||||
; Ethernet
|
||||
https://github.com/khoih-prog/EthernetWebServer_STM32.git
|
||||
https://github.com/netwizeBE/Ethernet3.git
|
||||
|
||||
lib_ignore =
|
||||
lv_lib_zifont
|
||||
|
||||
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> +<stm32f4/>
|
||||
|
||||
;***************************************************
|
@ -576,7 +576,7 @@ void guiSetup()
|
||||
lv_obj_set_style_local_value_color(bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_COLOR_WHITE);
|
||||
lv_obj_set_style_local_value_align(bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_ALIGN_CENTER);
|
||||
lv_obj_set_style_local_value_ofs_y(bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, 20);
|
||||
lv_obj_set_style_local_value_font(bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, &lv_font_montserrat_12);
|
||||
lv_obj_set_style_local_value_font(bar, LV_BAR_PART_BG, LV_STATE_DEFAULT, LV_FONT_DEFAULT);
|
||||
lv_obj_set_style_local_bg_color(lv_layer_sys(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
|
||||
lv_obj_set_style_local_bg_opa(lv_layer_sys(), LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_0);
|
||||
|
||||
|
@ -50,6 +50,12 @@ char httpPassword[32] = "";
|
||||
EthernetWebServer webServer(80);
|
||||
#endif
|
||||
|
||||
#if defined(STM32F4xx) && HASP_USE_WIFI>0
|
||||
#include <EthernetWebServer_STM32.h>
|
||||
// #include <WiFi.h>
|
||||
EthernetWebServer webServer(80);
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#include <ESP8266WebServer.h>
|
||||
ESP8266WebServer webServer(80);
|
||||
@ -478,7 +484,18 @@ void webHandleInfo()
|
||||
} else {
|
||||
httpMessage += F("Very Bad)");
|
||||
}
|
||||
|
||||
#if defined(STM32F4xx)
|
||||
byte mac[6];
|
||||
WiFi.macAddress(mac);
|
||||
char macAddress[16];
|
||||
sprintf_P(macAddress, PSTR("%02x%02x%02x"), mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||
httpMessage += F("</br><b>IP Address: </b>");
|
||||
httpMessage += String(WiFi.localIP());
|
||||
httpMessage += F("</br><b>Gateway: </b>");
|
||||
httpMessage += String(WiFi.gatewayIP());
|
||||
httpMessage += F("</br><b>MAC Address: </b>");
|
||||
httpMessage += String(macAddress);
|
||||
#else
|
||||
httpMessage += F("</br><b>IP Address: </b>");
|
||||
httpMessage += String(WiFi.localIP().toString());
|
||||
httpMessage += F("</br><b>Gateway: </b>");
|
||||
@ -488,6 +505,7 @@ void webHandleInfo()
|
||||
httpMessage += F("</br><b>MAC Address: </b>");
|
||||
httpMessage += String(WiFi.macAddress());
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Mqtt Stats */
|
||||
#if HASP_USE_MQTT > 0
|
||||
@ -892,7 +910,7 @@ void webHandleConfig()
|
||||
}
|
||||
|
||||
// Reboot after saving wifi config in AP mode
|
||||
#if HASP_USE_WIFI > 0
|
||||
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
|
||||
if(WiFi.getMode() != WIFI_STA) {
|
||||
httpHandleReboot();
|
||||
}
|
||||
@ -1096,7 +1114,7 @@ void webHandleWifiConfig()
|
||||
}
|
||||
httpMessage += F("'><p><button type='submit' name='save' value='wifi'>Save Settings</button></p></form>");
|
||||
|
||||
#if HASP_USE_WIFI > 0
|
||||
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
|
||||
if(WiFi.getMode() == WIFI_STA) {
|
||||
httpMessage +=
|
||||
PSTR("<p><form method='get' action='/config'><button type='submit'>Configuration</button></form></p>");
|
||||
@ -1105,7 +1123,11 @@ void webHandleWifiConfig()
|
||||
|
||||
webSendPage(httpGetNodename(), httpMessage.length(), false);
|
||||
webServer.sendContent(httpMessage);
|
||||
#if defined(STM32F4xx)
|
||||
httpMessage = "";
|
||||
#else
|
||||
httpMessage.clear();
|
||||
#endif
|
||||
webSendFooter();
|
||||
}
|
||||
#endif
|
||||
@ -1559,8 +1581,14 @@ void webStart()
|
||||
webServer.begin();
|
||||
webServerStarted = true;
|
||||
#if HASP_USE_WIFI > 0
|
||||
#if defined(STM32F4xx)
|
||||
IPAddress ip;
|
||||
ip = WiFi.localIP();
|
||||
Log.notice(F("HTTP: Server started @ http://%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||
#else
|
||||
Log.notice(F("HTTP: Server started @ http://%s"),
|
||||
(WiFi.getMode() != WIFI_STA ? WiFi.softAPIP().toString().c_str() : WiFi.localIP().toString().c_str()));
|
||||
#endif
|
||||
#else
|
||||
IPAddress ip;
|
||||
ip = Ethernet.localIP();
|
||||
@ -1581,10 +1609,12 @@ void httpSetup()
|
||||
// httpSetConfig(settings);
|
||||
|
||||
#if HASP_USE_WIFI > 0
|
||||
#if !defined(STM32F4xx)
|
||||
if(WiFi.getMode() != WIFI_STA) {
|
||||
Log.notice(F("HTTP: Wifi access point"));
|
||||
webServer.on(F("/"), webHandleWifiConfig);
|
||||
} else {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
webServer.on(F("/page/"), []() {
|
||||
@ -1656,7 +1686,9 @@ void httpSetup()
|
||||
webServer.on(F("/reboot"), httpHandleReboot);
|
||||
webServer.onNotFound(httpHandleNotFound);
|
||||
#if HASP_USE_WIFI > 0
|
||||
#if !defined(STM32F4xx)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Shared pages
|
||||
@ -1676,7 +1708,7 @@ void httpReconnect()
|
||||
if(webServerStarted) {
|
||||
webStop();
|
||||
} else
|
||||
#if HASP_USE_WIFI > 0
|
||||
#if HASP_USE_WIFI > 0 && !defined(STM32F4xx)
|
||||
if(WiFi.status() == WL_CONNECTED || WiFi.getMode() != WIFI_STA)
|
||||
#endif
|
||||
{
|
||||
|
@ -18,7 +18,10 @@ WiFiClient mqttNetworkClient;
|
||||
#include <ESP.h>
|
||||
WiFiClient mqttNetworkClient;
|
||||
#else
|
||||
|
||||
#if defined(STM32F4xx) && HASP_USE_WIFI>0
|
||||
// #include <WiFi.h>
|
||||
WiFiSpiClient mqttNetworkClient;
|
||||
#else
|
||||
#if defined(W5500_MOSI) && defined(W5500_MISO) && defined(W5500_SCLK)
|
||||
#define W5500_LAN
|
||||
#include <Ethernet.h>
|
||||
@ -28,6 +31,7 @@ WiFiClient mqttNetworkClient;
|
||||
|
||||
EthernetClient mqttNetworkClient;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "hasp_hal.h"
|
||||
#include "hasp_tft.h"
|
||||
@ -191,8 +195,17 @@ void mqtt_send_statusupdate()
|
||||
haspGetVersion().c_str(), long(millis() / 1000));
|
||||
strcat(buffer, data);
|
||||
#if HASP_USE_WIFI>0
|
||||
#if defined(STM32F4xx)
|
||||
IPAddress ip;
|
||||
ip = WiFi.localIP();
|
||||
char espIp[16];
|
||||
memset(espIp, 0 ,sizeof(espIp));
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("\"ssid\":\"%s\",\"rssi\":%i,\"ip\":\"%d.%d.%d.%d\","), WiFi.SSID(),
|
||||
WiFi.RSSI(), ip[0], ip[1], ip[2], ip[3]);
|
||||
#else
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("\"ssid\":\"%s\",\"rssi\":%i,\"ip\":\"%s\","), WiFi.SSID().c_str(),
|
||||
WiFi.RSSI(), WiFi.localIP().toString().c_str());
|
||||
#endif
|
||||
strcat(data, buffer);
|
||||
#endif
|
||||
snprintf_P(buffer, sizeof(buffer), PSTR("\"heapFree\":%u,\"heapFrag\":%u,\"espCore\":\"%s\","),
|
||||
|
@ -19,6 +19,12 @@
|
||||
|
||||
static WiFiEventHandler gotIpEventHandler, disconnectedEventHandler;
|
||||
|
||||
#elif defined(STM32F4xx)
|
||||
// #include <WiFi.h>
|
||||
// #include "WiFiSpi.h"
|
||||
// extern WiFiSpiClass WiFi;
|
||||
SPIClass spi2(ESPSPI_MOSI, ESPSPI_MISO, ESPSPI_SCLK); // SPI port where esp is connected
|
||||
|
||||
#endif
|
||||
//#include "DNSserver.h"
|
||||
|
||||
@ -43,7 +49,13 @@ uint8_t wifiReconnectCounter = 0;
|
||||
|
||||
void wifiConnected(IPAddress ipaddress)
|
||||
{
|
||||
#if defined(STM32F4xx)
|
||||
IPAddress ip;
|
||||
ip = WiFi.localIP();
|
||||
Log.notice(F("WIFI: Received IP address %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||
#else
|
||||
Log.notice(F("WIFI: Received IP address %s"), ipaddress.toString().c_str());
|
||||
#endif
|
||||
Log.verbose(F("WIFI: Connected = %s"), WiFi.status() == WL_CONNECTED ? PSTR("yes") : PSTR("no"));
|
||||
|
||||
// if(isConnected) {
|
||||
@ -122,7 +134,9 @@ bool wifiShowAP(char * ssid, char * pass)
|
||||
WiFi.macAddress(mac);
|
||||
sprintf_P(ssid, PSTR("HASP-%02x%02x%02x"), mac[3], mac[4], mac[5]);
|
||||
sprintf_P(pass, PSTR("haspadmin"));
|
||||
|
||||
#if defined(STM32F4xx)
|
||||
Log.warning(F("WIFI: We should setup Temporary Access Point %s password: %s"), ssid, pass);
|
||||
#else
|
||||
WiFi.softAP(ssid, pass);
|
||||
|
||||
/* Setup the DNS server redirecting all the domains to the apIP */
|
||||
@ -132,12 +146,47 @@ bool wifiShowAP(char * ssid, char * pass)
|
||||
Log.warning(F("WIFI: Temporary Access Point %s password: %s"), ssid, pass);
|
||||
Log.warning(F("WIFI: AP IP address : %s"), WiFi.softAPIP().toString().c_str());
|
||||
// httpReconnect();}
|
||||
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void wifiSetup()
|
||||
{
|
||||
#if defined(STM32F4xx)
|
||||
// Temp ESP reset function
|
||||
pinMode(ESPSPI_RST, OUTPUT);
|
||||
digitalWrite(ESPSPI_RST, 0);
|
||||
delay(150);
|
||||
digitalWrite(ESPSPI_RST, 1);
|
||||
delay(150);
|
||||
//
|
||||
|
||||
// Initialize the WifiSpi library
|
||||
WiFiSpi.init(ESPSPI_CS, 8000000, &spi2);
|
||||
|
||||
// check for the presence of the shield:
|
||||
if (WiFiSpi.status() == WL_NO_SHIELD) {
|
||||
Log.notice(F("WIFI: WiFi shield not present"));
|
||||
// don't continue:
|
||||
while (true);
|
||||
}
|
||||
|
||||
if (!WiFiSpi.checkProtocolVersion()) {
|
||||
Log.notice(F("WIFI: Protocol version mismatch. Please upgrade the firmware"));
|
||||
// don't continue:
|
||||
while (true);
|
||||
}
|
||||
|
||||
// attempt to connect to Wifi network
|
||||
int status = WL_IDLE_STATUS; // the Wifi radio's status
|
||||
|
||||
// while (status != WL_CONNECTED) {
|
||||
Log.notice(F("WIFI: Connecting to : %s"), wifiSsid);
|
||||
// Connect to WPA/WPA2 network
|
||||
status = WiFi.begin(wifiSsid, wifiPassword);
|
||||
// }
|
||||
|
||||
#else
|
||||
if(wifiShowAP()) {
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
} else {
|
||||
@ -156,13 +205,18 @@ void wifiSetup()
|
||||
WiFi.begin(wifiSsid, wifiPassword);
|
||||
Log.notice(F("WIFI: Connecting to : %s"), wifiSsid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool wifiEvery5Seconds()
|
||||
{
|
||||
#if defined(STM32F4xx)
|
||||
if(WiFi.status() == WL_CONNECTED) {
|
||||
#else
|
||||
if(WiFi.getMode() != WIFI_STA) {
|
||||
return false;
|
||||
} else if(WiFi.status() == WL_CONNECTED) {
|
||||
#endif
|
||||
return true;
|
||||
} else {
|
||||
wifiReconnectCounter++;
|
||||
@ -221,14 +275,27 @@ bool wifiTestConnection()
|
||||
{
|
||||
uint8_t attempt = 0;
|
||||
WiFi.begin(wifiSsid, wifiPassword);
|
||||
#if defined(STM32F4xx)
|
||||
IPAddress ip;
|
||||
ip = WiFi.localIP();
|
||||
char espIp[16];
|
||||
memset(espIp, 0 ,sizeof(espIp));
|
||||
snprintf_P(espIp, sizeof(espIp), PSTR("%d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
|
||||
while(attempt < 10 && (WiFi.status() != WL_CONNECTED || String(espIp) == F("0.0.0.0"))) {
|
||||
#else
|
||||
while(attempt < 10 && (WiFi.status() != WL_CONNECTED || WiFi.localIP().toString() == F("0.0.0.0"))) {
|
||||
#endif
|
||||
attempt++;
|
||||
Log.verbose(F("WIFI: Trying to connect to %s... %u"), wifiSsid, attempt);
|
||||
delay(1000);
|
||||
}
|
||||
#if defined(STM32F4xx)
|
||||
Log.verbose(F("WIFI: Received IP addres %s"), espIp);
|
||||
if((WiFi.status() == WL_CONNECTED && String(espIp) != F("0.0.0.0"))) return true;
|
||||
#else
|
||||
Log.verbose(F("WIFI: Received IP addres %s"), WiFi.localIP().toString().c_str());
|
||||
if((WiFi.status() == WL_CONNECTED && WiFi.localIP().toString() != F("0.0.0.0"))) return true;
|
||||
|
||||
#endif
|
||||
WiFi.disconnect();
|
||||
return false;
|
||||
}
|
||||
@ -237,7 +304,9 @@ void wifiStop()
|
||||
{
|
||||
wifiReconnectCounter = 0; // Prevent endless loop in wifiDisconnected
|
||||
WiFi.disconnect();
|
||||
#if !defined(STM32F4xx)
|
||||
WiFi.mode(WIFI_OFF);
|
||||
#endif
|
||||
Log.warning(F("WIFI: Stopped"));
|
||||
}
|
||||
|
||||
|
6
test/espspi/WiFi.h
Normal file
6
test/espspi/WiFi.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef WIFISPI_H
|
||||
#define WIFISPI_H
|
||||
#include "WiFiSpi.h"
|
||||
|
||||
WiFiSpiClass WiFi;
|
||||
#endif
|
60
user_setups/stm32f4xx/stm32f407-black_ili9341_parallel.ini
Normal file
60
user_setups/stm32f4xx/stm32f407-black_ili9341_parallel.ini
Normal file
@ -0,0 +1,60 @@
|
||||
;***************************************************;
|
||||
; Generic ESP32 build with ;
|
||||
; - ESP32dev board ;
|
||||
; - ili9488 TFT ;
|
||||
; - GT911 touch controller ;
|
||||
;***************************************************;
|
||||
|
||||
[env:stm32f4xx-parallel]
|
||||
platform = ststm32
|
||||
board = diymore_f407vgt
|
||||
board_build.mcu = stm32f407vet6
|
||||
upload_protocol = dfu
|
||||
monitor_port = COM7 ; To change the port, use platform_override.ini
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
${flags.stm32_flags}
|
||||
-I include/stm32f4
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
-D ILI9341_DRIVER=1
|
||||
-D TFT_WIDTH=240
|
||||
-D TFT_HEIGHT=320
|
||||
-D TFT_PARALLEL_8_BIT=1
|
||||
-D TFT_BCKL=PB1 ;None, configurable via web UI (e.g. 2 for D4)
|
||||
-D TFT_CS=PB12 ; Chip select control pin
|
||||
-D TFT_DC=PD13 ; =RS; Data Command control pin - must use a pin in the range 0-31
|
||||
-D TFT_RST=-1 ; Reset pin
|
||||
-D TFT_WR=PD5 ; Write strobe control pin - must use a pin in the range 0-31
|
||||
-D TFT_RD=PD4
|
||||
-D TFT_D0=PD14 ; Must use pins in the range 0-31 for the data bus
|
||||
-D TFT_D1=PD15 ; so a single register write sets/clears all bits
|
||||
-D TFT_D2=PD0
|
||||
-D TFT_D3=PD1
|
||||
-D TFT_D4=PE7
|
||||
-D TFT_D5=PE8
|
||||
-D TFT_D6=PE9
|
||||
-D TFT_D7=PE10
|
||||
; -D TFT_SPI2
|
||||
; -D TFT_SCLK=PB13
|
||||
; -D TFT_MISO=PB14
|
||||
; -D TFT_MOSI=PB15
|
||||
; -D TOUCH_CS=PB12
|
||||
; -D TOUCH_IRQ=PC5 ; use 34-39 as these are input only pins
|
||||
; -D TOUCH_RST=-1 ; not used, connected to 3.3V
|
||||
-D HASP_OUTPUT_PIN=PA6 ; User LED D2 on MCUDev Black board
|
||||
-D HASP_INPUT_PIN=PE4 ; User Button K0 on MCUDev Black board
|
||||
-D HASP_USE_HTTP=0
|
||||
-D HASP_USE_MQTT=0
|
||||
|
||||
; -- Debugging options -----------------------------
|
||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
||||
|
||||
; -- Library options -------------------------------
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
Ticker@^3.1.5
|
||||
|
||||
lib_ignore =
|
||||
lv_lib_zifont
|
||||
|
||||
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
|
70
user_setups/stm32f4xx/stm32f407-black_ili9341_wifi.ini
Normal file
70
user_setups/stm32f4xx/stm32f407-black_ili9341_wifi.ini
Normal file
@ -0,0 +1,70 @@
|
||||
;***************************************************;
|
||||
; STM32F4 build with ;
|
||||
; - DIY_more board ;
|
||||
; - ili9341 TFT ;
|
||||
; - xpt2046 touch controller ;
|
||||
;***************************************************;
|
||||
|
||||
[env:black_f407vg_wifi]
|
||||
platform = ststm32
|
||||
board = diymore_f407vgt
|
||||
board_build.mcu = stm32f407vgt6
|
||||
upload_protocol = dfu
|
||||
monitor_port = COM7 ; To change the port, use platform_override.ini
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
${flags.stm32_flags}
|
||||
-I include/stm32f4
|
||||
; -- TFT_eSPI build options ------------------------
|
||||
${lcd.lolin24}
|
||||
;-D TFT_MISO=PB4 ;Default
|
||||
;-D TFT_MOSI=PB5 ;Default
|
||||
;-D TFT_SCLK=PB3 ;Default
|
||||
-D USE_DMA_TO_TFT=1
|
||||
-D TFT_CS=PE13 ;D8
|
||||
-D TFT_DC=PE14 ;D3
|
||||
-D TFT_BCKL=PA15 ;None, configurable via web UI (e.g. 2 for D4)
|
||||
-D TOUCH_CS=PA6 ;NC
|
||||
-D TFT_RST=PD13 ;D4
|
||||
-D HASP_OUTPUT_PIN=PE0 ; User LED D2 on DevEBox board
|
||||
-D HASP_INPUT_PIN=PD15 ; User Button K1 on DevEBox board
|
||||
-D STM32_SERIAL1 ; Set this option to use Serial1 as default sersial port, leave out if using Serial2
|
||||
;-D HAL_ETH_MODULE_ENABLED=1 ; enable ethernet support
|
||||
;-D LAN8742A_PHY_ADDRESS=0x01U ; set LAN8720 PHY address
|
||||
-D HASP_USE_WIFI=1
|
||||
-D HASP_USE_MQTT=1
|
||||
-D HASP_USE_HTTP=1
|
||||
-D HASP_USE_MDNS=0
|
||||
-D HASP_USE_SYSLOG=0
|
||||
-D HASP_USE_TELNET=0
|
||||
-D HASP_USE_SPIFFS=0
|
||||
-D HASP_USE_EEPROM=1
|
||||
-D HASP_USE_GPIO=0
|
||||
-D HASP_USE_TASMOTA_SLAVE=0
|
||||
-D HASP_USE_ETHERNET=0
|
||||
-D ESPSPI_MOSI=PB15 ;SPI2 MOSI
|
||||
-D ESPSPI_MISO=PB14 ;SPI2 MISO
|
||||
-D ESPSPI_SCLK=PB13 ;SPI2 SCLK
|
||||
-D ESPSPI_CS=PB6 ;SPI2 CS
|
||||
-D ESPSPI_RST=PD1 ;SPI2 CS
|
||||
|
||||
lib_deps =
|
||||
${env.lib_deps}
|
||||
Ticker@^3.1.5
|
||||
;Ethernet
|
||||
; STM32duino LwIP@^2.1.2
|
||||
; STM32duino STM32Ethernet@^1.0.5
|
||||
; https://github.com/stm32duino/LwIP.git
|
||||
; https://github.com/netwizeBE/Ethernet3.git
|
||||
; https://github.com/khoih-prog/EthernetWebServer_STM32
|
||||
https://github.com/arovak/EthernetWebServer_STM32.git
|
||||
https://github.com/JiriBilek/WiFiSpi.git
|
||||
|
||||
lib_ignore =
|
||||
GxTFT
|
||||
XPT2046_Touchscreen
|
||||
lv_lib_zifont
|
||||
|
||||
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
|
||||
|
||||
;***************************************************
|
Loading…
x
Reference in New Issue
Block a user