Skip to content

Commit

Permalink
Use FIFO mode in SPI flash DMA for better performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli committed Jan 9, 2024
1 parent fc64479 commit ccb6c4b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions radio/src/targets/common/arm/stm32/diskio_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ static const stm32_spi_t _sd_spi_hw = {
.txDMA_Stream = SD_SPI_DMA_TX_STREAM,
.rxDMA_Stream = SD_SPI_DMA_RX_STREAM,
.DMA_FIFOMode = LL_DMA_FIFOMODE_ENABLE,
.DMA_FIFOThreshold = LL_DMA_FIFOTHRESHOLD_FULL,
.DMA_MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_BYTE,
.DMA_MemBurst = LL_DMA_MBURST_SINGLE,
};

static uint32_t _sdcard_sectors;
Expand Down
3 changes: 3 additions & 0 deletions radio/src/targets/common/arm/stm32/spi_flash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const stm32_spi_t _flash_spi = {
.txDMA_Stream = FLASH_SPI_DMA_TX_STREAM,
.rxDMA_Stream = FLASH_SPI_DMA_RX_STREAM,
.DMA_FIFOMode = LL_DMA_FIFOMODE_DISABLE,
.DMA_FIFOThreshold = LL_DMA_FIFOTHRESHOLD_1_2,
.DMA_MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_HALFWORD,
.DMA_MemBurst = LL_DMA_MBURST_INC4,
};

static SpiFlashDescriptor _flashDescriptor;
Expand Down
4 changes: 3 additions & 1 deletion radio/src/targets/common/arm/stm32/stm32_spi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ static void _config_dma_streams(const stm32_spi_t* spi)
dmaInit.MemoryOrM2MDstIncMode = LL_DMA_MEMORY_INCREMENT;
dmaInit.Priority = LL_DMA_PRIORITY_VERYHIGH;
dmaInit.FIFOMode = spi->DMA_FIFOMode;
dmaInit.FIFOThreshold = LL_DMA_FIFOTHRESHOLD_FULL;
dmaInit.FIFOThreshold = spi->DMA_FIFOThreshold;
dmaInit.MemoryOrM2MDstDataSize = spi->DMA_MemoryOrM2MDstDataSize;
dmaInit.MemBurst = spi->DMA_MemBurst;

dmaInit.Direction = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
LL_DMA_Init(spi->DMA, spi->rxDMA_Stream, &dmaInit);
Expand Down
3 changes: 3 additions & 0 deletions radio/src/targets/common/arm/stm32/stm32_spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ struct stm32_spi_t {
uint32_t txDMA_Stream;
uint32_t rxDMA_Stream;
uint32_t DMA_FIFOMode;
uint32_t DMA_FIFOThreshold;
uint32_t DMA_MemoryOrM2MDstDataSize;
uint32_t DMA_MemBurst;
};

void stm32_spi_enable_clock(SPI_TypeDef *SPIx);
Expand Down

0 comments on commit ccb6c4b

Please sign in to comment.