Skip to content

Commit

Permalink
Merge pull request #20214 from benpicco/CONFIG_SPI_DMA_THRESHOLD_BYTES
Browse files Browse the repository at this point in the history
cpu/stm32/periph_spi: only perform DMA transfer above threshold
  • Loading branch information
MrKevinWeiss authored Jan 4, 2024
2 parents 616b48d + 753fae6 commit 7fef2e4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 0 additions & 8 deletions cpu/sam0_common/periph/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,6 @@
#define ENABLE_DEBUG 0
#include "debug.h"

/**
* @brief Threshold under which polling transfers are used instead of DMA
* TODO: determine at run-time based on SPI clock
*/
#ifndef CONFIG_SPI_DMA_THRESHOLD_BYTES
#define CONFIG_SPI_DMA_THRESHOLD_BYTES 16
#endif

/**
* @brief Array holding one pre-initialized mutex for each SPI device
*/
Expand Down
2 changes: 1 addition & 1 deletion cpu/stm32/periph/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont,
}

#ifdef MODULE_PERIPH_DMA
if (_use_dma(&spi_config[bus])) {
if (_use_dma(&spi_config[bus]) && len > CONFIG_SPI_DMA_THRESHOLD_BYTES) {
_transfer_dma(bus, out, in, len);
}
else {
Expand Down
8 changes: 8 additions & 0 deletions drivers/include/periph/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@
extern "C" {
#endif

/**
* @brief Threshold under which polling transfers are used instead of DMA
* TODO: determine at run-time based on SPI clock
*/
#ifndef CONFIG_SPI_DMA_THRESHOLD_BYTES
#define CONFIG_SPI_DMA_THRESHOLD_BYTES 16
#endif

/**
* @brief Default SPI device access macro
*/
Expand Down

0 comments on commit 7fef2e4

Please # to comment.