aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/OCTOSPIv1
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-11-09 09:57:16 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-11-09 09:57:16 +0000
commit9472504bb695fef7f68849847ffe40dff9b0a591 (patch)
treef26590d3c6f97ef1264631726aeccdf7344819a4 /os/hal/ports/STM32/LLD/OCTOSPIv1
parent8e0e4b064425c9c54e109191bba8bcf0775ba9ee (diff)
downloadChibiOS-9472504bb695fef7f68849847ffe40dff9b0a591.tar.gz
ChibiOS-9472504bb695fef7f68849847ffe40dff9b0a591.tar.bz2
ChibiOS-9472504bb695fef7f68849847ffe40dff9b0a591.zip
WSPI and flash support improvements.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12411 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/ports/STM32/LLD/OCTOSPIv1')
-rw-r--r--os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c25
1 files changed, 23 insertions, 2 deletions
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 1b5088dc8..c7fad45f3 100644
--- a/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c
+++ b/os/hal/ports/STM32/LLD/OCTOSPIv1/hal_wspi_lld.c
@@ -58,6 +58,15 @@ WSPIDriver WSPID2;
/*===========================================================================*/
/**
+ * @brief Waits for completion of previous operation.
+ */
+static inline void wspi_lld_sync(WSPIDriver *wspip) {
+
+ while ((wspip->ospi->SR & OCTOSPI_SR_BUSY) != 0U) {
+ }
+}
+
+/**
* @brief Shared service routine.
*
* @param[in] wspip pointer to the @p WSPIDriver object
@@ -244,6 +253,9 @@ void wspi_lld_start(WSPIDriver *wspip) {
*/
void wspi_lld_stop(WSPIDriver *wspip) {
+ /* Waiting for the previous operation to complete, if any.*/
+ wspi_lld_sync(wspip);
+
/* If in ready state then disables the OCTOSPI clock.*/
if (wspip->state == WSPI_READY) {
@@ -273,6 +285,9 @@ 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.*/
@@ -323,6 +338,9 @@ 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;
@@ -363,6 +381,9 @@ 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;
@@ -393,8 +414,8 @@ void wspi_lld_map_flash(WSPIDriver *wspip,
const wspi_command_t *cmdp,
uint8_t **addrp) {
- /* Disabling the DMA request while in memory mapped mode.*/
- wspip->ospi->CR &= ~OCTOSPI_CR_DMAEN;
+ /* Waiting for the previous operation to complete, if any.*/
+ wspi_lld_sync(wspip);
/* Starting memory mapped mode using the passed parameters.*/
wspip->ospi->CR = (wspip->ospi->CR & ~OCTOSPI_CR_FMODE) |