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:57 UTC
[mynewt-core] 03/03: hw/mcu/nordic: Using hfxo_request and release
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 1cb38082081a813c9f3eed55b148161828b0ed89
Author: Niklas Casaril <ni...@casaril.com>
AuthorDate: Fri Dec 18 07:55:37 2020 +1000
hw/mcu/nordic: Using hfxo_request and release
In hal_system_clock_start we're not taking care of the LFSYNT + HFINT
combination because this is restricted in syscfg for MCU_HFCLK_SOURCE.
---
hw/mcu/nordic/nrf52xxx/src/hal_system.c | 12 ++----------
hw/mcu/nordic/nrf52xxx/src/hal_timer.c | 19 ++++++++-----------
2 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_system.c b/hw/mcu/nordic/nrf52xxx/src/hal_system.c
index 7176cd2..ba98306 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_system.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_system.c
@@ -22,6 +22,7 @@
#include "hal/hal_system.h"
#include "hal/hal_debug.h"
#include "nrf.h"
+#include "mcu/nrf52_clock.h"
/**
* Function called at startup. Called after BSS and .data initialized but
@@ -92,16 +93,7 @@ hal_system_clock_start(void)
#if MYNEWT_VAL_CHOICE(MCU_LFCLK_SOURCE, LFSYNTH)
/* Must turn on HFLCK for synthesized 32768 crystal */
- 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;
- while (1) {
- if ((NRF_CLOCK->EVENTS_HFCLKSTARTED) != 0) {
- break;
- }
- }
- }
+ nrf52_clock_hfxo_request();
#else
/* Make sure HFCLK is stopped */
NRF_CLOCK->TASKS_HFCLKSTOP = 1;
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_timer.c b/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
index b3730f0..fc6fe83 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_timer.c
@@ -26,6 +26,7 @@
#include "hal/hal_timer.h"
#include "nrf.h"
#include "mcu/nrf52_hal.h"
+#include "mcu/nrf52_clock.h"
/* IRQ prototype */
typedef void (*hal_timer_irq_handler_t)(void);
@@ -652,17 +653,7 @@ hal_timer_config(int timer_num, uint32_t freq_hz)
#if MYNEWT_VAL_CHOICE(MCU_HFCLK_SOURCE, HFXO)
/* Make sure HFXO is started */
- if ((NRF_CLOCK->HFCLKSTAT &
- (CLOCK_HFCLKSTAT_SRC_Msk | CLOCK_HFCLKSTAT_STATE_Msk)) !=
- (CLOCK_HFCLKSTAT_SRC_Msk | CLOCK_HFCLKSTAT_STATE_Msk)) {
- NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
- NRF_CLOCK->TASKS_HFCLKSTART = 1;
- while (1) {
- if ((NRF_CLOCK->EVENTS_HFCLKSTARTED) != 0) {
- break;
- }
- }
- }
+ nrf52_clock_hfxo_request();
#endif
hwtimer = bsptimer->tmr_reg;
@@ -723,6 +714,12 @@ hal_timer_deinit(int timer_num)
}
bsptimer->tmr_enabled = 0;
bsptimer->tmr_reg = NULL;
+
+#if MYNEWT_VAL_CHOICE(MCU_HFCLK_SOURCE, HFXO)
+ if (timer_num != 5) {
+ nrf52_clock_hfxo_release();
+ }
+#endif
__HAL_ENABLE_INTERRUPTS(ctx);
err: