From 27ad46cdfdfd3565b0376a96a3068839a3c63250 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Wed, 14 Nov 2018 09:24:25 +0000 Subject: Minor changes to MFS project. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12421 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c | 15 +++------------ os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c | 12 ++++++++++++ 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'os/hal/ports/STM32') diff --git a/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c b/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c index e3cc607a4..f121e14bb 100644 --- a/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c +++ b/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c @@ -285,9 +285,6 @@ void wspi_lld_stop(WSPIDriver *wspip) { */ void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) { - /* Waiting for the previous operation to complete, if any.*/ - wspi_lld_sync(wspip); - #if 0 //STM32_USE_STM32_D1_WORKAROUND == TRUE /* If it is a command without address and alternate phases then the command is sent as an alternate byte, the command phase is suppressed.*/ @@ -309,6 +306,9 @@ void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) { if ((cmdp->cfg & WSPI_CFG_ADDR_MODE_MASK) != WSPI_CFG_ADDR_MODE_NONE) { wspip->ospi->AR = cmdp->addr; } + + /* Waiting for the previous operation to complete.*/ + wspi_lld_sync(wspip); } /** @@ -338,9 +338,6 @@ void wspi_lld_send(WSPIDriver *wspip, const wspi_command_t *cmdp, dmaStreamSetTransactionSize(wspip->dma, n); dmaStreamSetMode(wspip->dma, wspip->dmamode | STM32_DMA_CR_DIR_M2P); - /* Waiting for the previous operation to complete, if any.*/ - wspi_lld_sync(wspip); - wspip->ospi->CR &= ~OCTOSPI_CR_FMODE; wspip->ospi->DLR = n - 1U; wspip->ospi->TCR = cmdp->dummy; @@ -381,9 +378,6 @@ void wspi_lld_receive(WSPIDriver *wspip, const wspi_command_t *cmdp, dmaStreamSetTransactionSize(wspip->dma, n); dmaStreamSetMode(wspip->dma, wspip->dmamode | STM32_DMA_CR_DIR_P2M); - /* Waiting for the previous operation to complete, if any.*/ - wspi_lld_sync(wspip); - wspip->ospi->CR = (wspip->ospi->CR & ~OCTOSPI_CR_FMODE) | OCTOSPI_CR_FMODE_0; wspip->ospi->DLR = n - 1U; wspip->ospi->TCR = cmdp->dummy; @@ -414,9 +408,6 @@ void wspi_lld_map_flash(WSPIDriver *wspip, const wspi_command_t *cmdp, uint8_t **addrp) { - /* Waiting for the previous operation to complete, if any.*/ - wspi_lld_sync(wspip); - /* Starting memory mapped mode using the passed parameters.*/ wspip->ospi->CR = OCTOSPI_CR_FMODE_1 | OCTOSPI_CR_FMODE_0 | OCTOSPI_CR_EN; wspip->ospi->TCR = cmdp->dummy; diff --git a/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c b/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c index 5ef7b7f62..66b5696d6 100644 --- a/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c +++ b/os/hal/ports/STM32/LLD/QUADSPIv1/hal_wspi_lld.c @@ -51,6 +51,15 @@ WSPIDriver WSPID1; /* Driver local functions. */ /*===========================================================================*/ +/** + * @brief Waits for completion of previous operation. + */ +static inline void wspi_lld_sync(WSPIDriver *wspip) { + + while ((wspip->qspi->SR & QUADSPI_SR_BUSY) != 0U) { + } +} + /** * @brief Shared service routine. * @@ -232,6 +241,9 @@ void wspi_lld_command(WSPIDriver *wspip, const wspi_command_t *cmdp) { if ((cmdp->cfg & WSPI_CFG_ADDR_MODE_MASK) != WSPI_CFG_ADDR_MODE_NONE) { wspip->qspi->AR = cmdp->addr; } + + /* Waiting for the previous operation to complete.*/ + wspi_lld_sync(wspip); } /** -- cgit v1.2.3