Skip to content

Commit 9ee947e

Browse files
committed
Hotfix to not use DMA on SPI3 of ESP32-S2
See issue tbnobody#2343.
1 parent b7f830f commit 9ee947e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/SpiManager/src/SpiBus.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,19 @@ SpiBus::SpiBus(const std::string& _id, spi_host_device_t _host_device)
1818
.data5_io_num = -1,
1919
.data6_io_num = -1,
2020
.data7_io_num = -1,
21-
.max_transfer_sz = SPI_MAX_DMA_LEN,
21+
.max_transfer_sz = 0, // defaults to SPI_MAX_DMA_LEN (=4092) or SOC_SPI_MAXIMUM_BUFFER_SIZE (=64)
2222
.flags = 0,
2323
.intr_flags = 0
2424
};
25-
ESP_ERROR_CHECK(spi_bus_initialize(host_device, &bus_config, SPI_DMA_CH_AUTO));
25+
26+
#if !CONFIG_IDF_TARGET_ESP32S2
27+
spi_dma_chan_t dma_channel = SPI_DMA_CH_AUTO;
28+
#else
29+
// DMA for SPI3 on ESP32-S2 is shared with ADC/DAC, so we cannot use it here
30+
spi_dma_chan_t dma_channel = (host_device != SPI3_HOST ? SPI_DMA_CH_AUTO : SPI_DMA_DISABLED);
31+
#endif
32+
33+
ESP_ERROR_CHECK(spi_bus_initialize(host_device, &bus_config, dma_channel));
2634
}
2735

2836
SpiBus::~SpiBus()

0 commit comments

Comments
 (0)