You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2021/01/07 12:30:16 UTC

[GitHub] [mynewt-core] danielkucera commented on a change in pull request #2441: hw/mcu/nordic/nrf52xxx: Using hfxo_request and release. Addresses #2393.

danielkucera commented on a change in pull request #2441:
URL: https://github.com/apache/mynewt-core/pull/2441#discussion_r553298941



##########
File path: hw/mcu/nordic/nrf52xxx/src/nrf52_clock.c
##########
@@ -44,7 +44,16 @@ nrf52_clock_hfxo_request(void)
     __HAL_DISABLE_INTERRUPTS(ctx);
     assert(nrf52_clock_hfxo_refcnt < 0xff);
     if (nrf52_clock_hfxo_refcnt == 0) {
-        NRF_CLOCK->TASKS_HFCLKSTART = 1;
+        /* Check the current STATE and SRC of HFCLK */
+        if ((NRF_CLOCK->HFCLKSTAT &
+             (CLOCK_HFCLKSTAT_SRC_Msk | CLOCK_HFCLKSTAT_STATE_Msk)) !=
+            (CLOCK_HFCLKSTAT_SRC_Xtal << CLOCK_HFCLKSTAT_SRC_Pos |
+             CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos)) {
+            NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
+            NRF_CLOCK->TASKS_HFCLKSTART = 1;
+            while ((NRF_CLOCK->EVENTS_HFCLKSTARTED) != 0) {

Review comment:
       this logic is reversed - `NRF_CLOCK->EVENTS_HFCLKSTARTED` has to be non-zero to escape the loop




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org