Add W5500 support

This commit is contained in:
fvanroie 2020-05-06 22:44:59 +02:00
parent 34cfd1cb94
commit 313d938968
9 changed files with 41 additions and 24 deletions

View File

@ -35,7 +35,7 @@
#endif
#ifndef HASP_USE_SYSLOG
#define HASP_USE_SYSLOG (HASP_HAS_NETWORK)
#define HASP_USE_SYSLOG 0
#endif
#ifndef HASP_USE_TELNET
@ -94,7 +94,7 @@
#include "hasp_spiffs.h"
#if defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
#include "lv_zifont.h"
//#include "lv_zifont.h"
#endif
#endif // SPIFFS
@ -107,6 +107,19 @@
#endif
#if HASP_USE_ETHERNET>0
#if USE_BUILTIN_ETHERNET>0
#include <LwIP.h>
#include <STM32Ethernet.h>
#warning Use built-in STM32 Ethernet
#elif USE_UIP_ETHERNET
#include <UIPEthernet.h>
#include <utility/logging.h>
#warning Use ENC28J60 Ethernet shield
#else
#include "Ethernet.h"
#include "EthernetClient.h"
#warning Use W5x00 Ethernet shield
#endif
#include "hasp_ethernet.h"
#endif

View File

@ -1,6 +1,7 @@
/* Include the normal default core configuration */
#include "stm32f4xx_hal_conf_default.h"
#if USE_BUILTIN_ETHERNET
/* Remove the default PHY address */
#ifdef LAN8742A_PHY_ADDRESS
#undef LAN8742A_PHY_ADDRESS
@ -10,4 +11,6 @@
/* Redefine LAN8742A PHY Address*/
#ifndef LAN8742A_PHY_ADDRESS
#define LAN8742A_PHY_ADDRESS 0x01U //HASP_PHY_ADDRESS
#endif
#endif

View File

@ -5,15 +5,7 @@
#if HASP_USE_ETHERNET > 0
#if defined(W5500_MOSI) && defined(W5500_MISO) && defined(W5500_SCLK)
#define W5500_LAN
#include <SPI.h>
#include <Ethernet3.h>
#else
#include <LwIP.h>
#include <STM32Ethernet.h>
#include <EthernetUdp.h>
#endif
EthernetClient EthClient;
IPAddress ip;

View File

@ -1,8 +1,5 @@
#if defined(STM32F4xx)
#include <Stm32Ethernet.h>
#endif
#include "hasp_hal.h"
#include "hasp_conf.h"
#if defined(ESP8266)
#include <ESP.h>
@ -250,7 +247,7 @@ String halGetMacAddress(int start, const char * seperator)
#if defined(STM32F4xx)
uint8_t * mac_p;
mac_p = Ethernet.MACAddress();
//mac_p = Ethernet.MACAddress();
for(uint8_t i = 0; i < 6; i++) mac[i] = *(mac_p + i);
#else
WiFi.macAddress(mac);

View File

@ -18,7 +18,14 @@ WiFiClient mqttNetworkClient;
#include <ESP.h>
WiFiClient mqttNetworkClient;
#else
#if defined(W5500_MOSI) && defined(W5500_MISO) && defined(W5500_SCLK)
#define W5500_LAN
#include <Ethernet.h>
#else
#include <STM32Ethernet.h>
#endif
EthernetClient mqttNetworkClient;
#endif

View File

@ -9,6 +9,7 @@
#include "hasp_config.h"
#include "hasp_dispatch.h"
#include "hasp_telnet.h"
#include "hasp_conf.h"
#if defined(ARDUINO_ARCH_ESP32)
#include <Wifi.h>
@ -19,7 +20,7 @@ static WiFiServer * telnetServer;
WiFiClient telnetClient;
static WiFiServer * telnetServer;
#else
#include <STM32Ethernet.h>
//#include <STM32Ethernet.h>
EthernetClient telnetClient;
static EthernetServer telnetServer(23);
#endif

View File

@ -9,10 +9,6 @@
#include "hasp_oobe.h"
#include "hasp_gpio.h"
#if HASP_USE_ETHERNET > 0
#include <STM32Ethernet.h>
#endif
bool isConnected;
uint8_t mainLoopCounter = 0;
unsigned long mainLastLoopTime = 0;

View File

@ -28,17 +28,24 @@ build_flags =
-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 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_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
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/stm32duino/STM32Ethernet.git
;https://github.com/netwizeBE/Ethernet3.git
https://github.com/khoih-prog/EthernetWebServer_STM32
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>

View File

@ -47,5 +47,6 @@ lib_deps =
; STM32duino STM32Ethernet@^1.0.5
https://github.com/stm32duino/LwIP.git
https://github.com/stm32duino/STM32Ethernet.git
https://github.com/khoih-prog/EthernetWebServer_STM32
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>