Select the clock source dynamically on SoftDevice initialisation

Instead of relying on build macros to know which oscillator we're
supposedly using, check the value of LFCLKSRC register. This way, we can
trust mbed's init code to fallback on the internal clock if the user
specified a wrong target.
This change, along with the mbed patch that selects clock source
dynamically, will allow lots of application to still run and provide
FOTA, when the wrong Nordic platform is specified.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
This commit is contained in:
Jean-Philippe Brucker 2015-08-03 18:32:41 +01:00
parent 723c701b95
commit b22c2e826f

View file

@ -52,11 +52,10 @@ static void sys_evt_dispatch(uint32_t sys_evt)
error_t btle_init(void)
{
#if defined(TARGET_DELTA_DFCM_NNN40) || defined(TARGET_HRM1017)
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL);
#else
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);
#endif
if (NRF_CLOCK->LFCLKSRC & (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos))
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL);
else
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, NULL);
// Enable BLE stack
/**