You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2023/04/03 06:45:14 UTC

[mynewt-core] 01/03: mcu/stm32l0: Update system clock settings

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

commit 456914c7d56d41c807dd33e356f6e2391d2188a0
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Mar 31 19:50:37 2023 +0200

    mcu/stm32l0: Update system clock settings
    
    Added option to have HSI16 divided by 4 (needed to
    run USB (48MHz) and sysclk at 32MHz).
    AHB/APB divider descriptions incorrectly suggested that
    clock can be 64MHz while 32MHz iz max
---
 hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c |  2 +-
 hw/mcu/stm/stm32l0xx/syscfg.yml            | 12 ++++++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c b/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c
index 39c1843b5..f5d1f3e67 100644
--- a/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c
+++ b/hw/mcu/stm/stm32l0xx/src/clock_stm32l0xx.c
@@ -143,7 +143,7 @@ SystemClock_Config(void)
      */
 #if MYNEWT_VAL(STM32_CLOCK_HSI)
     osc_init.OscillatorType |= RCC_OSCILLATORTYPE_HSI;
-    osc_init.HSIState = RCC_HSI_ON;
+    osc_init.HSIState = MYNEWT_VAL(STM32_CLOCK_HSI_DIV4) ? RCC_HSI_DIV4 : RCC_HSI_ON;
     /* HSI calibration is not optional when HSI is enabled */
     osc_init.HSICalibrationValue = MYNEWT_VAL(STM32_CLOCK_HSI_CALIBRATION);
 
diff --git a/hw/mcu/stm/stm32l0xx/syscfg.yml b/hw/mcu/stm/stm32l0xx/syscfg.yml
index 72005ba26..5aa7544c7 100644
--- a/hw/mcu/stm/stm32l0xx/syscfg.yml
+++ b/hw/mcu/stm/stm32l0xx/syscfg.yml
@@ -64,9 +64,13 @@ syscfg.defs:
         value: 0
 
     STM32_CLOCK_HSI:
-        description: Enable high-speed internal clock source
+        description: Enable high-speed internal clock source (16MHz)
         value: 1
 
+    STM32_CLOCK_HSI_DIV4:
+        description: Enable divider 4 for HSI, resulting in HSI being 4MHz
+        value: 0
+
     STM32_CLOCK_HSI_CALIBRATION:
         description: HSI calibration value
         value: 'RCC_HSICALIBRATION_DEFAULT'
@@ -84,15 +88,15 @@ syscfg.defs:
         value: 0
 
     STM32_CLOCK_AHB_DIVIDER:
-        description: AHB CLK1 prescaler (64MHz max)
+        description: AHB CLK1 prescaler (32MHz max)
         value: 0
 
     STM32_CLOCK_APB1_DIVIDER:
-        description: APB low-speed prescaler (64MHz max)
+        description: APB low-speed prescaler (32MHz max)
         value: 0
 
     STM32_CLOCK_APB2_DIVIDER:
-        description: APB high-speed prescaler (64MHz max)
+        description: APB high-speed prescaler (32MHz max)
         value: 0
 
     STM32_FLASH_LATENCY: