arm/stm32f7 add STM32F7_SPI_DMATHRESHOLD
This commit is contained in:
parent
afb2248b7a
commit
608b59792e
@ -2287,6 +2287,15 @@ config STM32F7_SPI_DMA
|
||||
---help---
|
||||
Use DMA to improve SPI transfer performance. Cannot be used with STM32F7_SPI_INTERRUPT.
|
||||
|
||||
config STM32F7_SPI_DMATHRESHOLD
|
||||
int "SPI DMA threshold"
|
||||
default 4
|
||||
depends on STM32F7_SPI_DMA
|
||||
---help---
|
||||
When SPI DMA is enabled, small DMA transfers will still be performed
|
||||
by polling logic. But we need a threshold value to determine what
|
||||
is small.
|
||||
|
||||
config STM32F7_SPI1_DMA
|
||||
bool "SPI1 DMA"
|
||||
default n
|
||||
|
@ -1646,13 +1646,36 @@ static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer,
|
||||
|
||||
DEBUGASSERT(priv != NULL);
|
||||
|
||||
#ifdef CONFIG_STM32F7_DMACAPABLE
|
||||
if ((priv->rxdma == NULL) || (priv->txdma == NULL) ||
|
||||
(txbuffer && !stm32_dmacapable((uint32_t)txbuffer, nwords, priv->txccr)) ||
|
||||
(rxbuffer && !stm32_dmacapable((uint32_t)rxbuffer, nwords, priv->rxccr)) ||
|
||||
up_interrupt_context() || nwords < CONFIG_STM32F7_SPI_DMA_THRESHOLD)
|
||||
#ifdef CONFIG_STM32F7_SPI_DMATHRESHOLD
|
||||
/* Convert the number of word to a number of bytes */
|
||||
|
||||
size_t nbytes = (priv->nbits > 8) ? nwords << 1 : nwords;
|
||||
|
||||
/* If this is a small SPI transfer, then let spi_exchange_nodma() do the work. */
|
||||
|
||||
if (nbytes <= CONFIG_STM32F7_SPI_DMATHRESHOLD)
|
||||
{
|
||||
/* Invalid DMA channels, unsupported memory region, or interrupt context, fall back to non-DMA method. */
|
||||
spi_exchange_nodma(dev, txbuffer, rxbuffer, nwords);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((priv->rxdma == NULL) || (priv->txdma == NULL) ||
|
||||
up_interrupt_context())
|
||||
{
|
||||
/* Invalid DMA channels, or interrupt context, fall
|
||||
* back to non-DMA method.
|
||||
*/
|
||||
|
||||
spi_exchange_nodma(dev, txbuffer, rxbuffer, nwords);
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_STM32F7_DMACAPABLE
|
||||
if ((txbuffer && !stm32_dmacapable((uint32_t)txbuffer, nwords, priv->txccr)) ||
|
||||
(rxbuffer && !stm32_dmacapable((uint32_t)rxbuffer, nwords, priv->rxccr)))
|
||||
{
|
||||
/* Unsupported memory region fall back to non-DMA method. */
|
||||
|
||||
spi_exchange_nodma(dev, txbuffer, rxbuffer, nwords);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user