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 1def077cf mcu/fe310: Export SystemCoreClock variable
1def077cf is described below

commit 1def077cfba35fdabe85ff295c5ecd7502501adb
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Jan 25 14:48:57 2023 +0100

    mcu/fe310: Export SystemCoreClock variable
    
    This does not change anything special it just exports
    SystemCoreClock that matches name commonly used in ARM
    builds.
    Old cpu_freq value was local declaration so there is no
    risk of breaking anything.
    
    Since there is no common way defined by mynewt for
    application to get system clock frequency fe310 adopts
    convention used by ARM code.
---
 hw/mcu/sifive/fe310/src/sys_clock.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/mcu/sifive/fe310/src/sys_clock.c 
b/hw/mcu/sifive/fe310/src/sys_clock.c
index 2f408b346..dec04e19c 100644
--- a/hw/mcu/sifive/fe310/src/sys_clock.c
+++ b/hw/mcu/sifive/fe310/src/sys_clock.c
@@ -82,7 +82,7 @@ HFXOSC_2_MHZ       = {  2000000, 1, 0,  0, 0, 0, 0, 0, 3}; /* 
2 MHz */
 const clock_config_t
 HFXOSC_1_MHZ       = {  1000000, 1, 0,  0, 0, 0, 0, 0, 7}; /* 1 MHz */
 
-static uint32_t cpu_freq;
+uint32_t SystemCoreClock;
 
 static unsigned long __attribute__((noinline))
 measure_cpu_freq(size_t n)
@@ -111,14 +111,14 @@ uint32_t
 get_cpu_freq(void)
 {
 
-    if (!cpu_freq) {
+    if (!SystemCoreClock) {
         // warm up I$
         measure_cpu_freq(1);
         // measure for real
-        cpu_freq = measure_cpu_freq(10);
+        SystemCoreClock = measure_cpu_freq(10);
     }
 
-    return cpu_freq;
+    return SystemCoreClock;
 }
 
 void
@@ -136,7 +136,7 @@ select_clock(const clock_config_t *cfg)
         while ((PRCI_REG(PRCI_HFROSCCFG) & ROSC_RDY(1)) == 0) {
         }
         /* Compute CPU frequency on demand */
-        cpu_freq = 0;
+        SystemCoreClock = 0;
     }
 
     if (cfg->xosc) {
@@ -146,7 +146,7 @@ select_clock(const clock_config_t *cfg)
             while ((PRCI_REG(PRCI_HFXOSCCFG) & XOSC_RDY(1)) == 0) {
             }
         }
-        cpu_freq = cfg->frq;
+        SystemCoreClock = cfg->frq;
     }
 
     /*

Reply via email to