esp32/machine_hw_spi: Fix hardware SPI DMA channels for S2/S3.

This commit is contained in:
Seon Rozenblum 2021-09-17 19:44:06 +10:00 committed by Damien George
parent da4593f937
commit 13e6e0d7f5
1 changed files with 12 additions and 0 deletions

View File

@ -57,6 +57,7 @@
#define HSPI_HOST SPI2_HOST #define HSPI_HOST SPI2_HOST
#elif CONFIG_IDF_TARGET_ESP32S3 #elif CONFIG_IDF_TARGET_ESP32S3
#define HSPI_HOST SPI3_HOST #define HSPI_HOST SPI3_HOST
#define FSPI_HOST SPI2_HOST
#endif #endif
typedef struct _machine_hw_spi_default_pins_t { typedef struct _machine_hw_spi_default_pins_t {
@ -195,6 +196,9 @@ STATIC void machine_hw_spi_init_internal(
} }
if (self->host != HSPI_HOST if (self->host != HSPI_HOST
#ifdef FSPI_HOST
&& self->host != FSPI_HOST
#endif
#ifdef VSPI_HOST #ifdef VSPI_HOST
&& self->host != VSPI_HOST && self->host != VSPI_HOST
#endif #endif
@ -233,7 +237,15 @@ STATIC void machine_hw_spi_init_internal(
// Select DMA channel based on the hardware SPI host // Select DMA channel based on the hardware SPI host
int dma_chan = 0; int dma_chan = 0;
if (self->host == HSPI_HOST) { if (self->host == HSPI_HOST) {
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
dma_chan = 3;
#else
dma_chan = 1; dma_chan = 1;
#endif
#ifdef FSPI_HOST
} else if (self->host == FSPI_HOST) {
dma_chan = 1;
#endif
#ifdef VSPI_HOST #ifdef VSPI_HOST
} else if (self->host == VSPI_HOST) { } else if (self->host == VSPI_HOST) {
dma_chan = 2; dma_chan = 2;