;***************************************************;
;          STM32F4xx build with                     ;
;               - DevEBox board                     ;
;               - ili9341 TFT                       ;
;               - xpt2046 touch controller          ;
;***************************************************;

; Purchase Link: https://www.aliexpress.com/item/32985219862.html
;                https://www.aliexpress.com/item/4000094075769.html
;                https://www.aliexpress.com/item/4000602517153.html
; Documentation: https://github.com/mcauser/MCUDEV_DEVEBOX_F407VGT6

; Versions:
; - STM32F407VET6 has 512 KB flash
; - STM32F407VGT6 has 1 MB flash

;[env:DevEBox_STM32F4xx]
[env:stm32f407-devebox_ili9341]
extends = stm32f4
board = black_f407vg
board_upload.maximum_size = 1048576 ; Flash size is wrong in variant
; 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}
    ${stm32f4.build_flags}

;region -- 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
;#define TFT_SPI_PORT 1 // SPI port 1 maximum clock rate is 55MHz
    -D TFT_SPI3
    -D USE_DMA_TO_TFT
;endregion

;region -- Hasp build options ----------------------------
    -D HASP_USE_WIFI=0
    -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=1
    -D HASP_USE_TASMOTA_CLIENT=0
    -D HASP_USE_OTA=0
    -D HASP_OUTPUT_PIN=PA1          ; User LED D2 on DevEBox board 
    -D HASP_INPUT_PIN=PA0           ; User Button K1 on DevEBox board
;endregion

    -D STM32_SERIAL1                ; Set this option to use Serial1 as default sersial port, leave out if using Serial2

;region -- Network build options -------------------------
    -D HASP_USE_ETHERNET=1
    -D USE_BUILTIN_ETHERNET=1
    -D HAL_ETH_MODULE_ENABLED=1
    ; -D LAN8742A_PHY_ADDRESS=0x01U ; moved to include\stm32f4\hal_conf_custom.h
    ; -D DP83848_PHY_ADDRESS=0x01U
;endregion

;region -- Library options -------------------------------
lib_deps =
    ${env.lib_deps}
    ${stm32f4.lib_deps}
    stm32duino/STM32Ethernet @ ^1.2.0
    ; https://github.com/stm32duino/STM32Ethernet.git
    khoih-prog/EthernetWebServer_STM32 @ ^1.1.0

lib_ignore =
    GxTFT
    XPT2046_Touchscreen
    lv_lib_zifont
    
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<lv_lib_zifont/> +<stm32f4/>
;endregion
