From 8ffd0ae23c9a84c680cd56edc3965c3570a9c5bf Mon Sep 17 00:00:00 2001 From: fvanroie Date: Mon, 21 Dec 2020 22:25:08 +0100 Subject: [PATCH] Fix STM32F4 environments --- lib/ArduinoLog/ArduinoLog.h | 2 +- lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp | 2 ++ src/hasp_ethernet_stm32.cpp | 30 ++++++++++++++----- src/hasp_ethernet_stm32.h | 4 +++ .../stm32f4xx/STM32F407VET6_black_fsmc.ini | 12 ++++---- .../stm32f4xx/stm32f407-devebox_ili9341.ini | 6 ++-- 6 files changed, 38 insertions(+), 18 deletions(-) diff --git a/lib/ArduinoLog/ArduinoLog.h b/lib/ArduinoLog/ArduinoLog.h index e2b670c5..d3b72c4d 100644 --- a/lib/ArduinoLog/ArduinoLog.h +++ b/lib/ArduinoLog/ArduinoLog.h @@ -44,7 +44,7 @@ typedef void (*printfunction)(uint8_t tag, int level, Print *); #define LOG_LEVEL_VERBOSE 7 #define LOG_LEVEL_DEBUG 7 -#define CR "\n" +//#define CR "\n" #define LOGGING_VERSION 1_0_3 /** diff --git a/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp b/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp index f525acd2..3101218a 100644 --- a/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp +++ b/lib/lv_drv_fsmc_ili9341/fsmc_ili9341.cpp @@ -7,6 +7,8 @@ * INCLUDES *********************/ +#include "lv_drv_conf.h" + #if USE_FSMC_ILI9341 > 0 #include "fsmc_ili9341.h" diff --git a/src/hasp_ethernet_stm32.cpp b/src/hasp_ethernet_stm32.cpp index fe2de37d..65fed22c 100644 --- a/src/hasp_ethernet_stm32.cpp +++ b/src/hasp_ethernet_stm32.cpp @@ -6,26 +6,28 @@ #include "hasp_debug.h" #include "hasp_hal.h" -#if HASP_USE_ETHERNET > 0 && !defined(ARDUINO_ARCH_ESP32) +#if HASP_USE_ETHERNET > 0 && defined(STM32F4xx) EthernetClient EthClient; IPAddress ip; void ethernetSetup() { -#if USE_BUILTIN_ETHERNET > 0 + #if USE_BUILTIN_ETHERNET > 0 // start Ethernet and UDP Log.notice(TAG_ETH, F("Begin Ethernet LAN8720")); if(Ethernet.begin() == 0) { Log.notice(TAG_ETH, F("Failed to configure Ethernet using DHCP")); + eth_connected = false; } else { ip = Ethernet.localIP(); Log.notice(TAG_ETH, F("DHCP Success got IP %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); + eth_connected = true; } Log.notice(TAG_ETH, F("MAC Address %s"), halGetMacAddress(0, ":")); -#else + #else byte mac[6]; uint32_t baseUID = (uint32_t)UID_BASE; mac[0] = 0x00; @@ -49,7 +51,7 @@ void ethernetSetup() ip = Ethernet.localIP(); Log.notice(TAG_ETH, F("DHCP Success got IP %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); } -#endif + #endif } void ethernetLoop(void) @@ -86,13 +88,25 @@ void ethernetLoop(void) bool ethernetEvery5Seconds() { bool state; -#if USE_BUILTIN_ETHERNET > 0 + #if USE_BUILTIN_ETHERNET > 0 state = Ethernet.linkStatus() == LinkON; -#else - state = Ethernet.link() == 1; -#endif + #else + state = Ethernet.link() == 1; + #endif Log.warning(TAG_ETH, state ? F("ONLINE") : F("OFFLINE")); return state; } +void ethernet_get_statusupdate(char * buffer, size_t len) +{ + #if USE_BUILTIN_ETHERNET > 0 + bool state = Ethernet.linkStatus() == LinkON; + #else + bool state = Ethernet.link() == 1; + #endif + + IPAddress ip = Ethernet.localIP(); + snprintf_P(buffer, len, PSTR("\"eth\":\"%s\",\"link\":%d,\"ip\":\"%d.%d.%d.%d\","), state ? F("ON") : F("OFF"), 10, + ip[0], ip[1], ip[2], ip[3]); +} #endif \ No newline at end of file diff --git a/src/hasp_ethernet_stm32.h b/src/hasp_ethernet_stm32.h index bfa1b432..04ddec72 100644 --- a/src/hasp_ethernet_stm32.h +++ b/src/hasp_ethernet_stm32.h @@ -4,8 +4,12 @@ #ifndef HASP_ETHERNET_STM32_H #define HASP_ETHERNET_STM32_H +static bool eth_connected = false; + void ethernetSetup(); void ethernetLoop(void); bool ethernetEvery5Seconds(); +void ethernet_get_statusupdate(char * buffer, size_t len); + #endif \ No newline at end of file diff --git a/user_setups/stm32f4xx/STM32F407VET6_black_fsmc.ini b/user_setups/stm32f4xx/STM32F407VET6_black_fsmc.ini index 7715f629..5b5ede6e 100644 --- a/user_setups/stm32f4xx/STM32F407VET6_black_fsmc.ini +++ b/user_setups/stm32f4xx/STM32F407VET6_black_fsmc.ini @@ -38,8 +38,8 @@ build_flags = -D ILI9341_DRIVER=1 -D TFT_WIDTH=240 -D TFT_HEIGHT=320 - -D USE_FSMC ; Use the onboard FSMC TFT header - ;-D USER_SETUP_LOADED=1 + -D USE_FSMC= ; Use the onboard FSMC TFT header + ;-D USER_SETUP_LOADED=1 ; TFT_eSPI is not used here ;-D TOUCH_CS=PA6 ;NC ;-D TFT_RST=-1 ;D4 ;-D STM32 @@ -76,11 +76,11 @@ build_flags = lib_deps = ${env.lib_deps} ${stm32f4.lib_deps} - ; STM32duino STM32Ethernet@^1.0.5 - https://github.com/stm32duino/STM32Ethernet.git - https://github.com/khoih-prog/EthernetWebServer_STM32 + stm32duino/STM32Ethernet @ ^1.2.0 + ;https://github.com/stm32duino/STM32Ethernet.git + khoih-prog/EthernetWebServer_STM32 @ ^1.1.0 adafruit/Adafruit GFX Library @ ^1.10.3 - ;adafruit/Adafruit BusIO @ ^1.6.0 + adafruit/Adafruit BusIO @ ^1.6.0 ;https://github.com/ZinggJM/GxTFT.git XPT2046_Touchscreen diff --git a/user_setups/stm32f4xx/stm32f407-devebox_ili9341.ini b/user_setups/stm32f4xx/stm32f407-devebox_ili9341.ini index 1adeaf29..96667a6a 100644 --- a/user_setups/stm32f4xx/stm32f407-devebox_ili9341.ini +++ b/user_setups/stm32f4xx/stm32f407-devebox_ili9341.ini @@ -71,9 +71,9 @@ build_flags = lib_deps = ${env.lib_deps} ${stm32f4.lib_deps} - ; STM32duino STM32Ethernet@^1.0.5 - https://github.com/stm32duino/STM32Ethernet.git - https://github.com/khoih-prog/EthernetWebServer_STM32 + stm32duino/STM32Ethernet @ ^1.2.0 + ; https://github.com/stm32duino/STM32Ethernet.git + khoih-prog/EthernetWebServer_STM32 @ ^1.1.0 lib_ignore = GxTFT