Skip to content

Commit

Permalink
Hotfix to not use DMA on SPI3 of ESP32-S2
Browse files Browse the repository at this point in the history
See issue tbnobody#2343.
  • Loading branch information
LennartF22 committed Oct 10, 2024
1 parent b7f830f commit 9ee947e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/SpiManager/src/SpiBus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ SpiBus::SpiBus(const std::string& _id, spi_host_device_t _host_device)
.data5_io_num = -1,
.data6_io_num = -1,
.data7_io_num = -1,
.max_transfer_sz = SPI_MAX_DMA_LEN,
.max_transfer_sz = 0, // defaults to SPI_MAX_DMA_LEN (=4092) or SOC_SPI_MAXIMUM_BUFFER_SIZE (=64)
.flags = 0,
.intr_flags = 0
};
ESP_ERROR_CHECK(spi_bus_initialize(host_device, &bus_config, SPI_DMA_CH_AUTO));

#if !CONFIG_IDF_TARGET_ESP32S2
spi_dma_chan_t dma_channel = SPI_DMA_CH_AUTO;
#else
// DMA for SPI3 on ESP32-S2 is shared with ADC/DAC, so we cannot use it here
spi_dma_chan_t dma_channel = (host_device != SPI3_HOST ? SPI_DMA_CH_AUTO : SPI_DMA_DISABLED);
#endif

ESP_ERROR_CHECK(spi_bus_initialize(host_device, &bus_config, dma_channel));
}

SpiBus::~SpiBus()
Expand Down

0 comments on commit 9ee947e

Please sign in to comment.