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

kurtzweber
Posts: 64
Joined: Tue Jan 10, 2017 1:09 pm

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

Postby kurtzweber » Wed Jan 13, 2021 9:49 am

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!

rubby456
Posts: 1
Joined: Wed Jan 13, 2021 10:55 am

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

Postby rubby456 » Wed Jan 13, 2021 11:02 am

(moderator note: deleted spam)

chegewara
Posts: 2376
Joined: Wed Jun 14, 2017 9:00 pm

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

Postby chegewara » Wed Jan 13, 2021 11:45 am

Admins, please mark it as spam and remove due to links in post ^UP

lbernstone
Posts: 828
Joined: Mon Jul 22, 2019 3:20 pm

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

Postby lbernstone » Wed Jan 13, 2021 3:31 pm


s-light
Posts: 13
Joined: Mon Oct 29, 2018 6:50 pm

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

Postby s-light » Tue Jan 31, 2023 4:31 pm

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

Who is online

Users browsing this forum: Baidu [Spider] and 66 guests