r/arduino • u/rattushackus • 1d ago
If TFT_eSPI doesn't compile with the ESP32 v4 board definitions ...
If you upgrade to the ESP32 v4 board definitions you'll get an error when you compile a sketch using the TFT_eSPI library:
In file included from d:\Dev\Arduino\ESP32\libraries\TFT_eSPI\TFT_eSPI.cpp:24:
d:\Dev\Arduino\ESP32\libraries\TFT_eSPI\Processors/TFT_eSPI_ESP32.c:36:36: error: 'HSPI_HOST' was not declared in this scope; did you mean 'SPI3_HOST'?
36 | spi_host_device_t spi_host = HSPI_HOST;
| ^~~~~~~~~
| SPI3_HOST
exit status 1
Compilation error: exit status 1
This because TFT_eSPI still uses the deprecated definitions HSPI_HOST and VSPI_HOST for the two SPI buses and v4 of the board defs removes those definitions.
To fix this simply edit your User_Setup.h file and add:
#ifndef HSPI_HOST
#define HSPI_HOST SPI2_HOST
#endif
#ifndef VSPI_HOST
#define VSPI_HOST SPI3_HOST
#endif
The library maintainer will presumably eventually fix this, but they don't seem to be responding to issues at the moment.

