Skip to content

Commit fa7e02d

Browse files
rob-robinson-14cfriedt
authored andcommitted
drivers: clock_control: nordic: Enable calibration from LFRC peripheral
For some nordic devices the LFRC peripheral is used to calibrate the LFCLK clock instead of NRFX_CLOCK peripheral. This commit adds support for the changes already made in nrfx drivers. Signed-off-by: Robert Robinson <[email protected]>
1 parent 8d08da8 commit fa7e02d

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

drivers/clock_control/clock_control_nrf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ static void clock_event_handler(nrfx_clock_evt_type_t event)
751751
}
752752
clkstarted_handle(dev, CLOCK_CONTROL_NRF_TYPE_LFCLK);
753753
break;
754-
#if NRF_CLOCK_HAS_CALIBRATION
754+
#if NRF_CLOCK_HAS_CALIBRATION || NRF_LFRC_HAS_CALIBRATION
755755
case NRFX_CLOCK_EVT_CAL_DONE:
756756
if (IS_ENABLED(CONFIG_CLOCK_CONTROL_NRF_DRIVER_CALIBRATION)) {
757757
z_nrf_clock_calibration_done_handler();
@@ -801,6 +801,10 @@ static int clk_init(const struct device *dev)
801801
.stop = onoff_stop
802802
};
803803

804+
#if NRF_LFRC_HAS_CALIBRATION
805+
IRQ_CONNECT(LFRC_IRQn, DT_INST_IRQ(0, priority), nrfx_isr, nrfx_power_clock_irq_handler, 0);
806+
#endif
807+
804808
IRQ_CONNECT(DT_INST_IRQN(0), DT_INST_IRQ(0, priority),
805809
nrfx_isr, nrfx_power_clock_irq_handler, 0);
806810

modules/hal_nordic/nrfx/Kconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ config NRFX_CLOCK
1919

2020
if NRFX_CLOCK
2121

22+
config NRFX_CLOCK_USE_LFRC_CALIBRATION
23+
bool "Extend NRFX_CLOCK to use LFRC peripheral"
24+
2225
config NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED
2326
bool "Two stage start sequence of the low frequency clock"
2427

modules/hal_nordic/nrfx/nrfx_kconfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#ifdef CONFIG_NRFX_CLOCK_LOG
2828
#define NRFX_CLOCK_CONFIG_LOG_ENABLED 1
2929
#endif
30+
#ifdef CONFIG_NRFX_CLOCK_USE_LFRC_CALIBRATION
31+
#define NRFX_CLOCK_CONFIG_USE_LFRC_CALIBRATION 1
32+
#endif
3033

3134
#ifdef CONFIG_NRFX_CLOCK_LF_SRC_RC
3235
#if defined(CONFIG_SOC_SERIES_NRF91X) || defined(CONFIG_SOC_COMPATIBLE_NRF53X)

0 commit comments

Comments
 (0)