From d495a2ce4ef84fccdebe1e24b9552c10ee2cde93 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Fri, 25 Aug 2017 08:48:13 +0000 Subject: Fixed bug #879. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10486 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c | 5 +++-- os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'os/hal/ports') diff --git a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c index 0cee5729b..067651691 100644 --- a/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c +++ b/os/hal/ports/STM32/LLD/SPIv1/hal_spi_lld.c @@ -443,8 +443,9 @@ void spi_lld_stop(SPIDriver *spip) { if (spip->state == SPI_READY) { /* SPI disable.*/ - spip->spi->CR1 = 0; - spip->spi->CR2 = 0; + spip->spi->CR1 &= ~SPI_CR1_SPE; + spip->spi->CR1 = 0; + spip->spi->CR2 = 0; dmaStreamRelease(spip->dmarx); dmaStreamRelease(spip->dmatx); diff --git a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c index b3aafff07..01f894970 100644 --- a/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c +++ b/os/hal/ports/STM32/LLD/SPIv2/hal_spi_lld.c @@ -440,13 +440,15 @@ void spi_lld_start(SPIDriver *spip) { * @notapi */ void spi_lld_stop(SPIDriver *spip) { + uint32_t cr1; /* If in ready state then disables the SPI clock.*/ if (spip->state == SPI_READY) { /* SPI disable.*/ - spip->spi->CR1 = 0; - spip->spi->CR2 = 0; + spip->spi->CR1 &= ~SPI_CR1_SPE; + spip->spi->CR1 = 0; + spip->spi->CR2 = 0; dmaStreamRelease(spip->dmarx); dmaStreamRelease(spip->dmatx); -- cgit v1.2.3