You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/10 17:18:43 UTC

[incubator-nuttx] branch master updated: stm32l4 dfumode: enable for STM32L4+ chips

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

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 201c67a  stm32l4 dfumode: enable for STM32L4+ chips
201c67a is described below

commit 201c67acbdfbedee57d2ad06e9d691eb801734dd
Author: Juha Niskanen <ju...@haltian.com>
AuthorDate: Wed Nov 10 12:47:38 2021 +0200

    stm32l4 dfumode: enable for STM32L4+ chips
---
 arch/arm/src/stm32l4/stm32l4_dfumode.c | 10 ++++++----
 arch/arm/src/stm32l4/stm32l4_dfumode.h |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm/src/stm32l4/stm32l4_dfumode.c b/arch/arm/src/stm32l4/stm32l4_dfumode.c
index f81d4a2..b68dd06 100644
--- a/arch/arm/src/stm32l4/stm32l4_dfumode.c
+++ b/arch/arm/src/stm32l4/stm32l4_dfumode.c
@@ -46,6 +46,8 @@ static inline void rcc_reset(void)
 {
   uint32_t regval;
 
+  /* Enable the MSI clock */
+
   regval = getreg32(STM32L4_RCC_CR);
   regval |= RCC_CR_MSION;
   putreg32(regval, STM32L4_RCC_CR);
@@ -63,11 +65,11 @@ static inline void rcc_reset(void)
 
   putreg32(0x00000000, STM32L4_RCC_CFGR);
 
-  /* Reset HSION, HSEON, CSSON and PLLON bits */
+  /* Reset enable bits for other clocks than MSI */
 
   regval  = getreg32(STM32L4_RCC_CR);
   regval &= ~(RCC_CR_HSION | RCC_CR_HSIKERON | RCC_CR_HSEON |
-              RCC_CR_HSIASFS | RCC_CR_CSSON | RCC_CR_PLLON | RCC_CR_PLLON |
+              RCC_CR_HSIASFS | RCC_CR_CSSON | RCC_CR_PLLON |
               RCC_CR_PLLSAI1ON | RCC_CR_PLLSAI2ON);
   putreg32(regval, STM32L4_RCC_CR);
 
@@ -121,7 +123,7 @@ static inline void apb_reset(void)
  *
  ****************************************************************************/
 
-#if defined(CONFIG_STM32L4_STM32L4X6)
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4XR)
 void stm32l4_dfumode(void)
 {
   uint32_t regval;
@@ -131,7 +133,7 @@ void stm32l4_dfumode(void)
   _warn("Entering DFU mode...\n");
 #endif
 
-  /* disable all peripherals, interrupts and switch to HSI */
+  /* disable all peripherals, interrupts and switch to MSI */
 
   rcc_reset();
   apb_reset();
diff --git a/arch/arm/src/stm32l4/stm32l4_dfumode.h b/arch/arm/src/stm32l4/stm32l4_dfumode.h
index 460bbb7..bad5968 100644
--- a/arch/arm/src/stm32l4/stm32l4_dfumode.h
+++ b/arch/arm/src/stm32l4/stm32l4_dfumode.h
@@ -39,7 +39,7 @@
  *
  ****************************************************************************/
 
-#if defined(CONFIG_STM32L4_STM32L4X6)
+#if defined(CONFIG_STM32L4_STM32L4X6) || defined(CONFIG_STM32L4_STM32L4XR)
 void stm32l4_dfumode(void) noreturn_function;
 #endif