From b732afc718394afa985a87c129e5f643fed08be0 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 18 Oct 2018 10:44:23 -0600 Subject: [PATCH] arch/arm/src/stm32: Costmetic changes from review of last PR. --- arch/arm/src/stm32/Kconfig | 36 ++++++---------------------------- arch/arm/src/stm32/stm32_spi.c | 21 ++++++++++---------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/arch/arm/src/stm32/Kconfig b/arch/arm/src/stm32/Kconfig index 006626d2ae..24c1108b38 100644 --- a/arch/arm/src/stm32/Kconfig +++ b/arch/arm/src/stm32/Kconfig @@ -8465,72 +8465,48 @@ config STM32_SPI_DMA ---help--- Use DMA to improve SPI transfer performance. Cannot be used with STM32_SPI_INTERRUPT. -if STM32_SPI1 - config STM32_SPI1_DMA bool "SPI1 DMA" default n - depends on STM32_SPI_DMA + depends on STM32_SPI1 && STM32_SPI_DMA ---help--- Use DMA to improve SPI1 transfer performance. -endif # STM32_SPI1 - -if STM32_SPI2 - config STM32_SPI2_DMA bool "SPI2 DMA" default n - depends on STM32_SPI_DMA + depends on STM32_SPI2 && STM32_SPI_DMA ---help--- Use DMA to improve SPI2 transfer performance. -endif # STM32_SPI2 - -if STM32_SPI3 - config STM32_SPI3_DMA bool "SPI3 DMA" default n - depends on STM32_SPI_DMA + depends on STM32_SPI3 && STM32_SPI_DMA ---help--- Use DMA to improve SPI3 transfer performance. -endif # STM32_SPI2 - -if STM32_SPI4 - config STM32_SPI4_DMA bool "SPI4 DMA" default n - depends on STM32_SPI_DMA + depends on STM32_SPI4 && STM32_SPI_DMA ---help--- Use DMA to improve SPI4 transfer performance. -endif # STM32_SPI4 - -if STM32_SPI5 - config STM32_SPI5_DMA bool "SPI5 DMA" default n - depends on STM32_SPI_DMA + depends on STM32_SPI5 && STM32_SPI_DMA ---help--- Use DMA to improve SPI5 transfer performance. -endif # STM32_SPI5 - -if STM32_SPI6 - config STM32_SPI6_DMA bool "SPI6 DMA" default n - depends on STM32_SPI_DMA + depends on STM32_SPI6 && STM32_SPI_DMA ---help--- Use DMA to improve SPI6 transfer performance. -endif # STM32_SPI6 - endmenu # SPI Configuration menu "I2S Configuration" diff --git a/arch/arm/src/stm32/stm32_spi.c b/arch/arm/src/stm32/stm32_spi.c index d767a11ee8..c34d806e99 100644 --- a/arch/arm/src/stm32/stm32_spi.c +++ b/arch/arm/src/stm32/stm32_spi.c @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/stm32/stm32_spi.c * - * Copyright (C) 2009-2013, 2016-2017 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2013, 2016-2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -1613,7 +1613,9 @@ static void spi_exchange(FAR struct spi_dev_s *dev, FAR const void *txbuffer, (rxbuffer && !stm32_dmacapable((uint32_t)rxbuffer, nwords, priv->rxccr)) || up_interrupt_context()) { - /* Invalid DMA channels, unsupported memory region, or interrupt context, fall back to non-DMA method. */ + /* Invalid DMA channels, unsupported memory region, or interrupt context, fall + * back to non-DMA method. + */ spi_exchange_nodma(dev, txbuffer, rxbuffer, nwords); } @@ -1781,12 +1783,12 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) nxsem_setprotocol(&priv->rxsem, SEM_PRIO_NONE); nxsem_setprotocol(&priv->txsem, SEM_PRIO_NONE); - /* Get DMA channels. NOTE: stm32_dmachannel() will always assign the DMA channel. - * if the channel is not available, then stm32_dmachannel() will block and wait - * until the channel becomes available. WARNING: If you have another device sharing - * a DMA channel with SPI and the code never releases that channel, then the call - * to stm32_dmachannel() will hang forever in this function! Don't let your - * design do that! + /* Get DMA channels. NOTE: stm32_dmachannel() will always assign the DMA + * channel. If the channel is not available, then stm32_dmachannel() will + * block and wait until the channel becomes available. WARNING: If you have + * another device sharing a DMA channel with SPI and the code never releases + * that channel, then the call to stm32_dmachannel() will hang forever in + * this function! Don't let your design do that! */ priv->rxdma = stm32_dmachannel(priv->rxch); @@ -1794,7 +1796,6 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) DEBUGASSERT(priv->rxdma && priv->txdma); spi_modifycr2(priv, SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN, 0); - } else { @@ -1803,7 +1804,7 @@ static void spi_bus_initialize(FAR struct stm32_spidev_s *priv) } #endif - /* Enable spi */ + /* Enable SPI */ spi_modifycr1(priv, SPI_CR1_SPE, 0); }