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 2021/01/08 12:25:56 UTC
[mynewt-core] 02/03: hw/mcu/nordic: Waiting for HFCLK to settle
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 e7742ececb8c0ff35d684d484519686588a6d179
Author: Niklas Casaril <ni...@casaril.com>
AuthorDate: Fri Dec 18 07:45:30 2020 +1000
hw/mcu/nordic: Waiting for HFCLK to settle
Checking both STATE and SRC of HFCLK if refcount is 0
---
hw/mcu/nordic/nrf52xxx/src/nrf52_clock.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/hw/mcu/nordic/nrf52xxx/src/nrf52_clock.c b/hw/mcu/nordic/nrf52xxx/src/nrf52_clock.c
index 210c583..3151db6 100644
--- a/hw/mcu/nordic/nrf52xxx/src/nrf52_clock.c
+++ b/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) {
+ }
+ }
started = 1;
}
++nrf52_clock_hfxo_refcnt;