diff --git a/src/platform/PICO/bus_spi_pico.c b/src/platform/PICO/bus_spi_pico.c index 4ecfd7ef5e..9bdb6dfc0c 100644 --- a/src/platform/PICO/bus_spi_pico.c +++ b/src/platform/PICO/bus_spi_pico.c @@ -302,7 +302,6 @@ void spiInitBusDMA(void) // no more available channels so give up return; } - channel_rx = dma_claim_unused_channel(true); if (channel_rx == -1) { // no more available channels so give up, first releasing the one @@ -311,6 +310,14 @@ void spiInitBusDMA(void) return; } + if (!dmaAllocate(DMA_CHANNEL_TO_IDENTIFIER(channel_tx), OWNER_SPI_SDO, device + 1) || + !dmaAllocate(DMA_CHANNEL_TO_IDENTIFIER(channel_rx), OWNER_SPI_SDI, device + 1)) { + // This should never happen if all allocated channels are claimed + dma_channel_unclaim(channel_tx); + dma_channel_unclaim(channel_rx); + return; + } + bus->dmaTx = &dmaDescriptors[DMA_CHANNEL_TO_INDEX(channel_tx)]; bus->dmaTx->channel = channel_tx; diff --git a/src/platform/PICO/include/platform/platform.h b/src/platform/PICO/include/platform/platform.h index a263a3344a..0110506a0c 100644 --- a/src/platform/PICO/include/platform/platform.h +++ b/src/platform/PICO/include/platform/platform.h @@ -34,7 +34,7 @@ #define PLATFORM_NO_LIBC 0 #define DEFIO_PORT_PINS 64 -#if defined(RP2350A) || defined(RP2350B) +#ifdef RP2350 typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState;