You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2023/01/10 10:41:41 UTC

[mynewt-core] branch master updated: hw/mcu/nrf53: Request hfxo for lfsynth via api

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

andk 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 b0c6d2c9d hw/mcu/nrf53: Request hfxo for lfsynth via api
b0c6d2c9d is described below

commit b0c6d2c9d014b82fabfe8d8efd1933d29dc85d7a
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Tue Jan 10 00:57:45 2023 +0100

    hw/mcu/nrf53: Request hfxo for lfsynth via api
    
    We need to request hfxo via API to make sure ref is held all the time,
    otherwise any other request/release will stop hfxo and thus break
    lfsynth.
---
 hw/mcu/nordic/nrf5340/src/hal_system.c     | 5 ++++-
 hw/mcu/nordic/nrf5340_net/src/hal_system.c | 5 ++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/hw/mcu/nordic/nrf5340/src/hal_system.c b/hw/mcu/nordic/nrf5340/src/hal_system.c
index d30743ce9..376aabf0b 100644
--- a/hw/mcu/nordic/nrf5340/src/hal_system.c
+++ b/hw/mcu/nordic/nrf5340/src/hal_system.c
@@ -19,6 +19,7 @@
 
 #include <syscfg/syscfg.h>
 #include <mcu/cortex_m33.h>
+#include <mcu/nrf5340_clock.h>
 #include <hal/hal_system.h>
 #include <hal/hal_debug.h>
 #include <nrf.h>
@@ -120,12 +121,14 @@ hal_system_clock_start(void)
     if ((NRF_CLOCK->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk) !=
         (CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos)) {
         NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
-        NRF_CLOCK->TASKS_HFCLKSTART = 1;
+        nrf5340_clock_hfxo_request();
         while (1) {
             if ((NRF_CLOCK->EVENTS_HFCLKSTARTED) != 0) {
                 break;
             }
         }
+    } else {
+        nrf5340_clock_hfxo_request();
     }
 #endif
 
diff --git a/hw/mcu/nordic/nrf5340_net/src/hal_system.c b/hw/mcu/nordic/nrf5340_net/src/hal_system.c
index df61efa3c..d7d1f3cb5 100644
--- a/hw/mcu/nordic/nrf5340_net/src/hal_system.c
+++ b/hw/mcu/nordic/nrf5340_net/src/hal_system.c
@@ -19,6 +19,7 @@
 
 #include <syscfg/syscfg.h>
 #include <mcu/cortex_m33.h>
+#include <mcu/nrf5340_net_clock.h>
 #include <hal/hal_system.h>
 #include <hal/hal_debug.h>
 #include <nrf.h>
@@ -94,12 +95,14 @@ hal_system_clock_start(void)
     if ((NRF_CLOCK_NS->HFCLKSTAT & CLOCK_HFCLKSTAT_STATE_Msk) !=
         (CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos)) {
         NRF_CLOCK_NS->EVENTS_HFCLKSTARTED = 0;
-        NRF_CLOCK_NS->TASKS_HFCLKSTART = 1;
+        nrf5340_net_clock_hfxo_request();
         while (1) {
             if ((NRF_CLOCK_NS->EVENTS_HFCLKSTARTED) != 0) {
                 break;
             }
         }
+    } else {
+        nrf5340_net_clock_hfxo_request();
     }
 #endif