aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2019-01-23 23:40:06 +1100
committerDamien George2019-01-23 23:40:06 +1100
commitd82f344f61811687faee67f4b8d3b4bd333e9f32 (patch)
treecc80fe6359dc50fc9a2c0103cfb5b11d7b8ef09d
parentcd52d2c691be0dd11e3a1104dc6eac3b3173d792 (diff)
esp32/machine_hw_spi: Use separate DMA channels for HSPI and VSPI.
Otherwise only one of HSPI or VSPI can be used at a time. Fixes issue #4068.
-rw-r--r--ports/esp32/machine_hw_spi.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/ports/esp32/machine_hw_spi.c b/ports/esp32/machine_hw_spi.c
index d011ce53e..560d19a5a 100644
--- a/ports/esp32/machine_hw_spi.c
+++ b/ports/esp32/machine_hw_spi.c
@@ -186,9 +186,16 @@ STATIC void machine_hw_spi_init_internal(
};
//Initialize the SPI bus
- // FIXME: Does the DMA matter? There are two
- ret = spi_bus_initialize(self->host, &buscfg, 1);
+ // Select DMA channel based on the hardware SPI host
+ int dma_chan = 0;
+ if (self->host == HSPI_HOST) {
+ dma_chan = 1;
+ } else if (self->host == VSPI_HOST) {
+ dma_chan = 2;
+ }
+
+ ret = spi_bus_initialize(self->host, &buscfg, dma_chan);
switch (ret) {
case ESP_ERR_INVALID_ARG:
mp_raise_msg(&mp_type_OSError, "invalid configuration");