Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cpu/stm32/periph_spi: only perform DMA transfer above threshold #20214

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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