Page 1 of 1

esp32s2, SPI interfaces (VSPI, HSPI, FSPI...)?

Posted: Wed Jan 13, 2021 9:49 am
by kurtzweber
Hi!

I'm working on a project based on an esp32s2 board and I need to interface with an SD card, using the SPI peripheral.

The datasheet says:
ESP32-S2 family features four SPI interfaces (SPI0, SPI1, SPI2 and SPI3). SPI0 and SPI1 can only be configured
to operate in SPI memory mode; SPI2 can be configured to operate in SPI memory and general-purpose SPI
modes; SPI3 can only be configured to operate in general-purpose SPI mode

With esp32, we had two available interfaces in the Arduino core:
  • HSPI (SPI2)
  • VSPI (SPI3)
In the source code of the esp32s2 branch, I see somewhere a "new" name (FSPI), for example:

Code: Select all

#if CONFIG_IDF_TARGET_ESP32S2
        _sck = (_spi_num == FSPI) ? SCK : -1;
        _miso = (_spi_num == FSPI) ? MISO : -1;
        _mosi = (_spi_num == FSPI) ? MOSI : -1;
        _ss = (_spi_num == FSPI) ? SS : -1;
#else
and:

Code: Select all

#if CONFIG_IDF_TARGET_ESP32S2
#define VSPI FSPI
#endif
So which interfaces are available for this chip?
Thanks!

Re: esp32s2, SPI interfaces (VSPI, HSPI, FSPI...)?

Posted: Wed Jan 13, 2021 11:02 am
by rubby456
(moderator note: deleted spam)

Re: esp32s2, SPI interfaces (VSPI, HSPI, FSPI...)?

Posted: Wed Jan 13, 2021 11:45 am
by chegewara
Admins, please mark it as spam and remove due to links in post ^UP

Re: esp32s2, SPI interfaces (VSPI, HSPI, FSPI...)?

Posted: Wed Jan 13, 2021 3:31 pm
by lbernstone

Re: esp32s2, SPI interfaces (VSPI, HSPI, FSPI...)?

Posted: Tue Jan 31, 2023 4:31 pm
by s-light
for the ESP32S2 and newer there was a rename:
https://github.com/espressif/arduino-es ... ypes.h#L77

Code: Select all

//alias for different chips, deprecated for the chips after esp32s2
#ifdef CONFIG_IDF_TARGET_ESP32
#define SPI_HOST    SPI1_HOST
#define HSPI_HOST   SPI2_HOST
#define VSPI_HOST   SPI3_HOST
#elif CONFIG_IDF_TARGET_ESP32S2
// SPI_HOST (SPI1_HOST) is not supported by the SPI Master and SPI Slave driver on ESP32-S2 and later
#define SPI_HOST    SPI1_HOST
#define FSPI_HOST   SPI2_HOST
#define HSPI_HOST   SPI3_HOST
#endif
https://github.com/espressif/arduino-es ... -spi.h#L28

Code: Select all

#if CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3
	#define FSPI  0
	#define HSPI  1
#else
	#define FSPI  1 //SPI bus attached to the flash (can use the same data lines but different SS)
	#define HSPI  2 //SPI bus normally mapped to pins 12 - 15, but can be matrixed to any pins
	#if CONFIG_IDF_TARGET_ESP32
		#define VSPI  3 //SPI bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins
	#endif
#endif