This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 99e709d  hw/mcu/da1469x: hal_flash manual mode enhanced
99e709d is described below

commit 99e709d7df4dfa1b72f802654812dd222bbe8fb5
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri Sep 6 14:37:07 2019 +0200

    hw/mcu/da1469x: hal_flash manual mode enhanced
    
    - returning to automode is done by restoring original value of
      QSPIC_CTRLMODE_REG. This will take care of correct bus width
      and D2 D3 lines state. There is no automatic switch to quad mode
      any more.
    - switching to manual mode sequence of call was made:
      da1469x_qspi_mode_manual()
      da1469x_qspi_mode_single()
      now da1469x_qspi_mode_manual() will automatically switch to single mode
      and additionally it will send break sequence that should end any
      continues read mode.
      previous code sent only one byte in single mode that is not enough
      to leave dual continuous read.
    - da1469x_qspi_mode_dual() and da1469x_qspi_mode_single() now setup
      controller in requested state without sending break sequence that
      was sent when manual mode was entered.
---
 hw/mcu/dialog/da1469x/src/hal_flash.c | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/hal_flash.c 
b/hw/mcu/dialog/da1469x/src/hal_flash.c
index 2ae59bd..65df0c0 100644
--- a/hw/mcu/dialog/da1469x/src/hal_flash.c
+++ b/hw/mcu/dialog/da1469x/src/hal_flash.c
@@ -92,10 +92,6 @@ da1469x_qspi_mode_single(const struct hal_flash *dev)
                                  QSPIC_QSPIC_CTRLMODE_REG_QSPIC_IO2_DAT_Msk |
                                  QSPIC_QSPIC_CTRLMODE_REG_QSPIC_IO3_OEN_Msk |
                                  QSPIC_QSPIC_CTRLMODE_REG_QSPIC_IO3_DAT_Msk;
-
-    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_EN_CS_Msk;
-    da1469x_qspi_write8(dev, 0xff);
-    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_DIS_CS_Msk;
 }
 
 CODE_QSPI_INLINE static void
@@ -114,16 +110,17 @@ da1469x_qspi_mode_dual(const struct hal_flash *dev)
                                  QSPIC_QSPIC_CTRLMODE_REG_QSPIC_IO2_DAT_Msk |
                                  QSPIC_QSPIC_CTRLMODE_REG_QSPIC_IO3_OEN_Msk |
                                  QSPIC_QSPIC_CTRLMODE_REG_QSPIC_IO3_DAT_Msk;
-
-    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_EN_CS_Msk;
-    da1469x_qspi_write8(dev, 0xff);
-    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_DIS_CS_Msk;
 }
 
 CODE_QSPI_INLINE static void
 da1469x_qspi_mode_manual(const struct hal_flash *dev)
 {
     QSPIC->QSPIC_CTRLMODE_REG &= ~QSPIC_QSPIC_CTRLMODE_REG_QSPIC_AUTO_MD_Msk;
+    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_SET_SINGLE_Msk;
+    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_EN_CS_Msk;
+    da1469x_qspi_write8(dev, 0xff);
+    da1469x_qspi_write8(dev, 0xff);
+    QSPIC->QSPIC_CTRLBUS_REG = QSPIC_QSPIC_CTRLBUS_REG_QSPIC_DIS_CS_Msk;
 }
 
 CODE_QSPI_INLINE static void
@@ -251,11 +248,13 @@ da1469x_qspi_write(const struct hal_flash *dev, uint32_t 
address,
 {
     uint32_t primask;
     uint32_t written;
+    uint32_t ctrlmode;
 
     __HAL_DISABLE_INTERRUPTS(primask);
 
+    ctrlmode = QSPIC->QSPIC_CTRLMODE_REG;
+
     da1469x_qspi_mode_manual(dev);
-    da1469x_qspi_mode_single(dev);
 
     da1469x_qspi_wait_busy(dev);
 
@@ -270,8 +269,8 @@ da1469x_qspi_write(const struct hal_flash *dev, uint32_t 
address,
         da1469x_qspi_wait_busy(dev);
     }
 
-    da1469x_qspi_mode_quad(dev);
-    da1469x_qspi_mode_auto(dev);
+    /* Restore automode and bus mode */
+    QSPIC->QSPIC_CTRLMODE_REG = ctrlmode;
 
     /* XXX Should check if region was cached before flushing cache */
     CACHE->CACHE_CTRL1_REG |= CACHE_CACHE_CTRL1_REG_CACHE_FLUSH_Msk;
@@ -285,19 +284,21 @@ static sec_text_ram_core int
 da1469x_qspi_erase_sector(const struct hal_flash *dev, uint32_t sector_address)
 {
     uint32_t primask;
+    uint32_t ctrlmode;
 
     __HAL_DISABLE_INTERRUPTS(primask);
 
+    ctrlmode = QSPIC->QSPIC_CTRLMODE_REG;
+
     da1469x_qspi_mode_manual(dev);
-    da1469x_qspi_mode_single(dev);
 
     da1469x_qspi_wait_busy(dev);
     da1469x_qspi_cmd_enable_write(dev);
     da1469x_qspi_cmd_erase_sector(dev, sector_address);
     da1469x_qspi_wait_busy(dev);
 
-    da1469x_qspi_mode_quad(dev);
-    da1469x_qspi_mode_auto(dev);
+    /* Restore automode and bus mode */
+    QSPIC->QSPIC_CTRLMODE_REG = ctrlmode;
 
     /* XXX Should check if region was cached before flushing cache */
     CACHE->CACHE_CTRL1_REG |= CACHE_CACHE_CTRL1_REG_CACHE_FLUSH_Msk;

Reply via email to