ESP32-C3 SPI3_HOST not recognized
Posted: Fri Aug 13, 2021 8:56 am
Hi,
Environment:
board ESP32-C3-DevKitC-02
ESP-IDF V4.3
chip revision 3
Issue
I have an issue with SPI master.
ret = spi_bus_initialize(SPI2_HOST, &buscfg, DMA_CHAN); this is OK
but
ret = spi_bus_initialize(SPI3_HOST, &buscfg, DMA_CHAN); this is not OK
During execution, it fails with the error message:
spi_bus_initialize(627): invalid host_id
But SPI3_HOST should be recognized as illustrated hereunder.
in spi_types.h
SPI_EV_BUF_TXtypedef enum {
//SPI1 can be used as GPSPI only on ESP32
SPI1_HOST=0, ///< SPI1
SPI2_HOST=1, ///< SPI2
SPI3_HOST=2, ///< SPI3
} spi_host_device_t;
I did some search and found that in spi_common.c line 102
static inline bool is_valid_host(spi_host_device_t host)
{
#if (SOC_SPI_PERIPH_NUM == 2)
return host >= SPI1_HOST && host <= SPI2_HOST;
#elif (SOC_SPI_PERIPH_NUM == 3)
return host >= SPI1_HOST && host <= SPI3_HOST;
#endif
}
looking at socs_caps.h line 175
#define SOC_SPI_PERIPH_NUM 2
So why it is 2 instead or 3, ESP32-C3 has 3 SPI interface and SPI3_HOST is for general purpose ???
Environment:
board ESP32-C3-DevKitC-02
ESP-IDF V4.3
chip revision 3
Issue
I have an issue with SPI master.
ret = spi_bus_initialize(SPI2_HOST, &buscfg, DMA_CHAN); this is OK
but
ret = spi_bus_initialize(SPI3_HOST, &buscfg, DMA_CHAN); this is not OK
During execution, it fails with the error message:
spi_bus_initialize(627): invalid host_id
But SPI3_HOST should be recognized as illustrated hereunder.
in spi_types.h
SPI_EV_BUF_TXtypedef enum {
//SPI1 can be used as GPSPI only on ESP32
SPI1_HOST=0, ///< SPI1
SPI2_HOST=1, ///< SPI2
SPI3_HOST=2, ///< SPI3
} spi_host_device_t;
I did some search and found that in spi_common.c line 102
static inline bool is_valid_host(spi_host_device_t host)
{
#if (SOC_SPI_PERIPH_NUM == 2)
return host >= SPI1_HOST && host <= SPI2_HOST;
#elif (SOC_SPI_PERIPH_NUM == 3)
return host >= SPI1_HOST && host <= SPI3_HOST;
#endif
}
looking at socs_caps.h line 175
#define SOC_SPI_PERIPH_NUM 2
So why it is 2 instead or 3, ESP32-C3 has 3 SPI interface and SPI3_HOST is for general purpose ???