Skip to content

Commit 3ef8d1b

Browse files
authored
Merge pull request #10934 from evva-sfw/feature/NRF_Cordio_low_frequency_clock
Fix: Low frequency clock will now selected by given "lf_clock_src" setting.
2 parents a84c239 + 3b904d5 commit 3ef8d1b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCIDriver.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
// Nordic Includes
4242
#include "nrf.h"
43+
#include "nrf5x_lf_clk_helper.h"
4344

4445
#include "NRFCordioHCIDriver.h"
4546
#include "NRFCordioHCITransportDriver.h"
@@ -78,6 +79,14 @@ using namespace ble::vendor::cordio;
7879
/*! \brief Typical implementation revision number (LlRtCfg_t::implRev). */
7980
#define LL_IMPL_REV 0x2303
8081

82+
#if MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_SYNTH
83+
#define NRF_LF_CLK_SRC CLOCK_LFCLKSRC_SRC_Synth
84+
#elif MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_XTAL
85+
#define NRF_LF_CLK_SRC CLOCK_LFCLKSRC_SRC_Xtal
86+
#elif MBED_CONF_NORDIC_NRF_LF_CLOCK_SRC == NRF_LF_SRC_RC
87+
#define NRF_LF_CLK_SRC CLOCK_LFCLKSRC_SRC_RC
88+
#endif
89+
8190
// Note to implementer: this should be amended if the Cordio stack is updated
8291

8392
// The Nordic-specific baseband configuration
@@ -283,7 +292,7 @@ void NRFCordioHCIDriver::do_initialize()
283292
}
284293

285294
/* configure low-frequency clock */
286-
NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
295+
NRF_CLOCK->LFCLKSRC = (NRF_LF_CLK_SRC << CLOCK_LFCLKSRC_SRC_Pos);
287296
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
288297
NRF_CLOCK->TASKS_LFCLKSTART = 1;
289298
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)

0 commit comments

Comments
 (0)