mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-28 13:46:36 +00:00
create user setup files/W5500 inital support
This commit is contained in:
parent
66d663683d
commit
41fa7547b5
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,6 +7,7 @@
|
|||||||
data/*
|
data/*
|
||||||
src/user_config_override.h
|
src/user_config_override.h
|
||||||
platformio_override.ini
|
platformio_override.ini
|
||||||
|
user_setups/active/*
|
||||||
|
|
||||||
## Visual Studio Code specific ######
|
## Visual Studio Code specific ######
|
||||||
.vscode
|
.vscode
|
||||||
|
294
platformio.ini
294
platformio.ini
@ -18,6 +18,8 @@ extra_configs =
|
|||||||
pin_config.ini
|
pin_config.ini
|
||||||
; -- Add customizations to this file only:
|
; -- Add customizations to this file only:
|
||||||
platformio_override.ini
|
platformio_override.ini
|
||||||
|
; -- Put active [env] files in this dir to be included in the build menu
|
||||||
|
user_setups/active/*.ini
|
||||||
|
|
||||||
default_envs =
|
default_envs =
|
||||||
; Uncomment the needed environments in platformio_override.ini
|
; Uncomment the needed environments in platformio_override.ini
|
||||||
@ -125,262 +127,6 @@ hspi32 =
|
|||||||
; 7 - mirror content, and rotate 90 deg anti-clockwise
|
; 7 - mirror content, and rotate 90 deg anti-clockwise
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
; STM32F4 build
|
|
||||||
;***************************************************
|
|
||||||
[env:black_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=PB11 ;D8
|
|
||||||
-D TFT_DC=PC5 ;D3
|
|
||||||
-D TFT_BCKL=-1 ;None, configurable via web UI (e.g. 2 for D4)
|
|
||||||
-D TOUCH_CS=PC4 ;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 HAL_ETH_MODULE_ENABLED=1 ; enable ethernet support
|
|
||||||
-D LAN8742A_PHY_ADDRESS=0x01U ; set LAN8720 PHY address
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
|
|
||||||
[env:DevEBox_STM32F4xx]
|
|
||||||
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_SPI3
|
|
||||||
-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=0x01U
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
|
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
; Generic ESP32 build
|
|
||||||
;***************************************************
|
|
||||||
[env:esp32dev-mrb3511]
|
|
||||||
platform = espressif32
|
|
||||||
board = esp32dev
|
|
||||||
upload_port = COM1 ; To change the port, use platform_override.ini
|
|
||||||
monitor_port = COM1 ; 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.mrb3511}
|
|
||||||
-D TFT_BCKL=5 ;None, configurable via web UI (e.g. 2 for D4)
|
|
||||||
-D TFT_CS=33 ; Chip select control pin
|
|
||||||
-D TFT_DC=15 ; =RS; Data Command control pin - must use a pin in the range 0-31
|
|
||||||
-D TFT_RST=32 ; Reset pin
|
|
||||||
-D TFT_WR=4 ; Write strobe control pin - must use a pin in the range 0-31
|
|
||||||
-D TFT_RD=2
|
|
||||||
-D TFT_D0=12 ; Must use pins in the range 0-31 for the data bus
|
|
||||||
-D TFT_D1=13 ; so a single register write sets/clears all bits
|
|
||||||
-D TFT_D2=26
|
|
||||||
-D TFT_D3=25
|
|
||||||
-D TFT_D4=17
|
|
||||||
-D TFT_D5=16
|
|
||||||
-D TFT_D6=27
|
|
||||||
-D TFT_D7=14
|
|
||||||
-D TOUCH_SDA=21
|
|
||||||
-D TOUCH_SCL=22
|
|
||||||
-D TOUCH_IRQ=34 ; use 34-39 as these are input only pins
|
|
||||||
-D TOUCH_RST=-1 ; not used, connected to 3.3V
|
|
||||||
; -- Debugging options -----------------------------
|
|
||||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
|
||||||
|
|
||||||
; -- Library options -------------------------------
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
https://github.com/netwizeBE/arduino-goodix.git ; GT911 touch screen driver
|
|
||||||
|
|
||||||
src_filter = +<*> +<../drivers/stm32f429_disco>
|
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
; Generic ESP32 build with ILI9488 SPI 4-WIRE
|
|
||||||
;***************************************************
|
|
||||||
[env:esp32dev-ili9488]
|
|
||||||
platform = espressif32
|
|
||||||
board = esp32dev
|
|
||||||
upload_port = COM2 ; To change the port, use platform_override.ini
|
|
||||||
monitor_port = COM2 ; To change the port, use platform_override.ini
|
|
||||||
; upload_protocol = espota ; Use ArduinoOTA after flashing over serial
|
|
||||||
; upload_port = 10.4.0.171 ; IP of the ESP
|
|
||||||
; upload_flags =
|
|
||||||
; --port=3232
|
|
||||||
debug_tool = esp-prog
|
|
||||||
debug_init_break = tbreak setup
|
|
||||||
|
|
||||||
build_flags =
|
|
||||||
${flags.esp32_flags}
|
|
||||||
; -- TFT_eSPI build options ------------------------
|
|
||||||
-D USER_SETUP_LOADED=1
|
|
||||||
-D ILI9488_DRIVER=1
|
|
||||||
-D TFT_ROTATION=0 ; 0=0, 1=90, 2=180 or 3=270 degree
|
|
||||||
-D TFT_WIDTH=320
|
|
||||||
-D TFT_HEIGHT=480
|
|
||||||
-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 TFT_BCKL=5 ;None, configurable via web UI (e.g. 2 for D4)
|
|
||||||
-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>
|
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
; NodeMCU32S with MHS-4" RPI Display-B
|
|
||||||
;***************************************************
|
|
||||||
[env:nodemcu32s-raspi]
|
|
||||||
platform = espressif32
|
|
||||||
board = nodemcu-32s
|
|
||||||
upload_port = COM3 ; To change the port, use platform_override.ini
|
|
||||||
monitor_port = COM3 ; 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}
|
|
||||||
${pins.vspi32}
|
|
||||||
-D TFT_CS=15
|
|
||||||
-D TFT_DC=4
|
|
||||||
-D TFT_RST=32
|
|
||||||
-D TOUCH_CS=22
|
|
||||||
|
|
||||||
; -- Debugging options -----------------------------
|
|
||||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
|
||||||
|
|
||||||
; -- Library options -------------------------------
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
; ESP32 build
|
|
||||||
;***************************************************
|
|
||||||
[env:d132-unoshield]
|
|
||||||
platform = espressif32
|
|
||||||
board = esp32dev
|
|
||||||
upload_port = COM4 ; To change the port, use platform_override.ini
|
|
||||||
monitor_port = COM4 ; To change the port, use platform_override.ini
|
|
||||||
|
|
||||||
build_flags =
|
|
||||||
${flags.esp32_flags}
|
|
||||||
; -- TFT_eSPI build options ------------------------
|
|
||||||
-D USER_SETUP_LOADED=1
|
|
||||||
;-D ST7796_DRIVER=1 ;3.95inch Arduino Display-UNO
|
|
||||||
-D ILI9486_DRIVER=1 ;3.5inch Arduino Display-UNO
|
|
||||||
-D ESP32_PARALLEL=1
|
|
||||||
-D TFT_ROTATION=${lcd.TFT_ROTATION}
|
|
||||||
-D TFT_WIDTH=320
|
|
||||||
-D TFT_HEIGHT=480
|
|
||||||
${pins.vspi32}
|
|
||||||
-D TFT_BCKL=-1 ;None, configurable via web UI (e.g. 2 for D4)
|
|
||||||
-D TFT_CS=33 ; Chip select control pin
|
|
||||||
-D TFT_DC=15 ; Data Command control pin - must use a pin in the range 0-31
|
|
||||||
-D TFT_RST=32 ; Reset pin
|
|
||||||
-D TFT_WR=4 ; Write strobe control pin - must use a pin in the range 0-31
|
|
||||||
-D TFT_RD=2
|
|
||||||
-D TFT_D0=12 ; Must use pins in the range 0-31 for the data bus
|
|
||||||
-D TFT_D1=13 ; so a single register write sets/clears all bits
|
|
||||||
-D TFT_D2=26
|
|
||||||
-D TFT_D3=25
|
|
||||||
-D TFT_D4=17
|
|
||||||
-D TFT_D5=16
|
|
||||||
-D TFT_D6=27
|
|
||||||
-D TFT_D7=14
|
|
||||||
-D SD_CS=5
|
|
||||||
-D SPI_FREQUENCY=40000000
|
|
||||||
;-D SPI_TOUCH_FREQUENCY=2500000 ; Uses ADC instead
|
|
||||||
-D SPI_READ_FREQUENCY=20000000
|
|
||||||
; -- Debugging options -----------------------------
|
|
||||||
; -D CORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
|
|
||||||
|
|
||||||
; -- Library options -------------------------------
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
|
|
||||||
src_filter = +<*> +<../drivers/stm32f429_disco>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
;***************************************************
|
||||||
; D1 Mini ESP32 with Lolin TFT 2.4"
|
; D1 Mini ESP32 with Lolin TFT 2.4"
|
||||||
;***************************************************
|
;***************************************************
|
||||||
@ -450,42 +196,6 @@ build_flags =
|
|||||||
-D TFT_RST=-1 ;RST
|
-D TFT_RST=-1 ;RST
|
||||||
|
|
||||||
|
|
||||||
;***************************************************
|
|
||||||
; ESP-12 build
|
|
||||||
;***************************************************
|
|
||||||
[env:esp12e-st7735]
|
|
||||||
platform = espressif8266@^2.4.0 ;@2.3.2
|
|
||||||
board = esp12e
|
|
||||||
upload_port = COM8 ; To change the port, use platform_override.ini
|
|
||||||
monitor_port = COM8 ; To change the port, use platform_override.ini
|
|
||||||
board_build.f_flash = 40000000L
|
|
||||||
board_build.flash_mode = dout
|
|
||||||
board_build.ldscript = eagle.flash.4m2m.ld ; 2Mb Spiffs
|
|
||||||
board_build.f_cpu = 160000000L ; set frequency to 160MHz
|
|
||||||
build_flags =
|
|
||||||
${flags.esp8266_flags}
|
|
||||||
; -- TFT_eSPI build options ------------------------
|
|
||||||
-D USER_SETUP_LOADED=1
|
|
||||||
-D ST7735_DRIVER=1
|
|
||||||
-D ST7735_BLACKTAB=1
|
|
||||||
-D TFT_ROTATION=${lcd.TFT_ROTATION}
|
|
||||||
-D TFT_WIDTH=128
|
|
||||||
-D TFT_HEIGHT=160
|
|
||||||
-D TFT_MISO=-1 ;NC
|
|
||||||
-D TFT_MOSI=13 ;D7
|
|
||||||
-D TFT_SCLK=14 ;D5
|
|
||||||
-D TFT_CS=15 ;D8
|
|
||||||
-D TFT_DC=0 ;D3
|
|
||||||
-D TFT_BCKL=-1 ;None, configurable via web UI (e.g. 2 for D4)
|
|
||||||
-D TOUCH_CS=-1 ;NC
|
|
||||||
-D TFT_RST=2 ;D4
|
|
||||||
-D SPI_FREQUENCY=27000000
|
|
||||||
|
|
||||||
; -- Library options -------------------------------
|
|
||||||
lib_deps =
|
|
||||||
${env.lib_deps}
|
|
||||||
;Ethernet@<2.0.0
|
|
||||||
|
|
||||||
;***************************************************
|
;***************************************************
|
||||||
; Native build
|
; Native build
|
||||||
;***************************************************
|
;***************************************************
|
||||||
|
@ -5,28 +5,83 @@
|
|||||||
|
|
||||||
#if HASP_USE_ETHERNET>0
|
#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 <LwIP.h>
|
||||||
#include <STM32Ethernet.h>
|
#include <STM32Ethernet.h>
|
||||||
#include <EthernetUdp.h>
|
#include <EthernetUdp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
EthernetClient EthClient;
|
EthernetClient EthClient;
|
||||||
|
IPAddress ip;
|
||||||
|
|
||||||
void ethernetSetup()
|
void ethernetSetup()
|
||||||
{
|
{
|
||||||
// start Ethernet and UDP
|
#ifdef W5500_LAN
|
||||||
Log.notice(F("ETH: Begin Ethernet"));
|
byte mac[6];
|
||||||
|
uint32_t baseUID = (uint32_t )UID_BASE;
|
||||||
|
mac[0] = 0x00;
|
||||||
|
mac[1] = 0x80;
|
||||||
|
mac[2] = 0xE1;
|
||||||
|
mac[3] = (baseUID & 0x00FF0000) >> 16;
|
||||||
|
mac[4] = (baseUID & 0x0000FF00) >> 8;
|
||||||
|
mac[5] = (baseUID & 0x000000FF);
|
||||||
|
|
||||||
|
Ethernet.setCsPin(W5500_CS);
|
||||||
|
Ethernet.setRstPin(W5500_RST);
|
||||||
|
Ethernet.setHostname("HASP");
|
||||||
|
Log.notice(F("ETH: Begin Ethernet W5500"));
|
||||||
|
if (Ethernet.begin(mac) == 0) {
|
||||||
|
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
||||||
|
} else {
|
||||||
|
ip = Ethernet.localIP();
|
||||||
|
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
// start Ethernet and UDP
|
||||||
|
Log.notice(F("ETH: Begin Ethernet LAN8720"));
|
||||||
if (Ethernet.begin() == 0) {
|
if (Ethernet.begin() == 0) {
|
||||||
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
Log.notice(F("ETH: Failed to configure Ethernet using DHCP"));
|
||||||
} else {
|
} else {
|
||||||
IPAddress ip = Ethernet.localIP();
|
ip = Ethernet.localIP();
|
||||||
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
Log.notice(F("ETH: DHCP Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ethernetLoop(void)
|
void ethernetLoop(void)
|
||||||
{
|
{
|
||||||
Ethernet.maintain();
|
switch (Ethernet.maintain()) {
|
||||||
|
case 1:
|
||||||
|
//renewed fail
|
||||||
|
Log.notice(F("ETH: Error: renewed fail"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
//renewed success
|
||||||
|
ip = Ethernet.localIP();
|
||||||
|
Log.notice(F("ETH: DHCP Renew Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
//rebind fail
|
||||||
|
Log.notice(F("Error: rebind fail"));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 4:
|
||||||
|
//rebind success
|
||||||
|
ip = Ethernet.localIP();
|
||||||
|
Log.notice(F("ETH: DHCP Rebind Success got IP=%d.%d.%d.%d"),ip[0], ip[1], ip[2], ip[3]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
//nothing happened
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user