11
11
#include <device.h>
12
12
#include <clock_control.h>
13
13
#include <misc/__assert.h>
14
- #include " nrf_clock.h"
14
+ #include < nrf_clock.h>
15
15
#if defined(CONFIG_USB ) && defined(CONFIG_SOC_NRF52840 )
16
16
#include <nrf_power.h>
17
17
#include <drivers/clock_control/nrf_clock_control.h>
@@ -95,7 +95,7 @@ static int _m16src_start(struct device *dev, clock_control_subsys_t sub_system)
95
95
*/
96
96
__ASSERT_NO_MSG (m16src_ref );
97
97
98
- stat = CLOCK_HFCLKSTAT_SRC_Xtal | CLOCK_HFCLKSTAT_STATE_Msk ;
98
+ stat = NRF_CLOCK_HFCLK_HIGH_ACCURACY | CLOCK_HFCLKSTAT_STATE_Msk ;
99
99
if ((NRF_CLOCK -> HFCLKSTAT & stat ) == stat ) {
100
100
return 0 ;
101
101
} else {
@@ -216,6 +216,7 @@ static int _k32src_start(struct device *dev, clock_control_subsys_t sub_system)
216
216
nrf_clock_task_trigger (NRF_CLOCK_TASK_LFCLKSTART );
217
217
#endif /* !CONFIG_CLOCK_CONTROL_NRF_K32SRC_BLOCKING */
218
218
219
+ #if NRF_CLOCK_HAS_CALIBRATION
219
220
/* If RC selected, calibrate and start timer for consecutive
220
221
* calibrations.
221
222
*/
@@ -254,6 +255,7 @@ static int _k32src_start(struct device *dev, clock_control_subsys_t sub_system)
254
255
__ASSERT_NO_MSG (err == - EINPROGRESS );
255
256
}
256
257
}
258
+ #endif /* NRF_CLOCK_HAS_CALIBRATION */
257
259
258
260
lf_already_started :
259
261
stat = (NRF_CLOCK -> LFCLKSRCCOPY & CLOCK_LFCLKSRCCOPY_SRC_Msk ) |
@@ -276,11 +278,14 @@ static inline void power_event_cb(nrf_power_event_t event)
276
278
277
279
static void _power_clock_isr (void * arg )
278
280
{
279
- u8_t pof , hf_intenset , hf , lf_intenset , lf , done , ctto ;
281
+ u8_t pof , hf_intenset , hf , lf_intenset , lf ;
282
+ #if NRF_CLOCK_HAS_CALIBRATION
283
+ u8_t ctto , done ;
284
+ struct device * dev = arg ;
285
+ #endif
280
286
#if defined(CONFIG_USB ) && defined(CONFIG_SOC_NRF52840 )
281
287
bool usb_detected , usb_pwr_rdy , usb_removed ;
282
288
#endif
283
- struct device * dev = arg ;
284
289
285
290
pof = (NRF_POWER -> EVENTS_POFWARN != 0 );
286
291
@@ -292,19 +297,24 @@ static void _power_clock_isr(void *arg)
292
297
CLOCK_INTENSET_LFCLKSTARTED_Msk ) != 0 );
293
298
lf = (NRF_CLOCK -> EVENTS_LFCLKSTARTED != 0 );
294
299
300
+ #if NRF_CLOCK_HAS_CALIBRATION
295
301
done = (NRF_CLOCK -> EVENTS_DONE != 0 );
296
302
ctto = (NRF_CLOCK -> EVENTS_CTTO != 0 );
297
-
303
+ #endif
298
304
#if defined(CONFIG_USB ) && defined(CONFIG_SOC_NRF52840 )
299
305
usb_detected = nrf_power_event_check (NRF_POWER_EVENT_USBDETECTED );
300
306
usb_pwr_rdy = nrf_power_event_check (NRF_POWER_EVENT_USBPWRRDY );
301
307
usb_removed = nrf_power_event_check (NRF_POWER_EVENT_USBREMOVED );
308
+ #endif
302
309
303
- __ASSERT_NO_MSG (pof || hf || hf_intenset || lf || done || ctto ||
304
- usb_detected || usb_pwr_rdy || usb_removed );
305
- #else
306
- __ASSERT_NO_MSG (pof || hf || hf_intenset || lf || done || ctto );
310
+ __ASSERT_NO_MSG (pof || hf || hf_intenset || lf
311
+ #if NRF_CLOCK_HAS_CALIBRATION
312
+ || done || ctto
313
+ #endif
314
+ #if defined(CONFIG_USB ) && defined (CONFIG_SOC_NRF52840 )
315
+ || usb_detected || usb_pwr_rdy || usb_removed
307
316
#endif
317
+ );
308
318
309
319
if (pof ) {
310
320
NRF_POWER -> EVENTS_POFWARN = 0 ;
@@ -332,8 +342,10 @@ static void _power_clock_isr(void *arg)
332
342
* (volatile u32_t * )0x40000C34 = 0x00000002 ;
333
343
#endif /* CONFIG_SOC_SERIES_NRF52X */
334
344
345
+ #if NRF_CLOCK_HAS_CALIBRATION
335
346
/* Start Calibration */
336
347
NRF_CLOCK -> TASKS_CAL = 1 ;
348
+ #endif
337
349
}
338
350
339
351
if (lf ) {
@@ -345,14 +357,17 @@ static void _power_clock_isr(void *arg)
345
357
*/
346
358
NRF_CLOCK -> INTENCLR = CLOCK_INTENCLR_LFCLKSTARTED_Msk ;
347
359
360
+ #if NRF_CLOCK_HAS_CALIBRATION
348
361
/* Start HF Clock if LF RC is used. */
349
362
if ((NRF_CLOCK -> LFCLKSRCCOPY & CLOCK_LFCLKSRCCOPY_SRC_Msk ) ==
350
363
CLOCK_LFCLKSRCCOPY_SRC_RC ) {
351
364
ctto = 1U ;
352
365
}
366
+ #endif
353
367
}
354
368
}
355
369
370
+ #if NRF_CLOCK_HAS_CALIBRATION
356
371
if (done ) {
357
372
int err ;
358
373
@@ -392,6 +407,7 @@ static void _power_clock_isr(void *arg)
392
407
__ASSERT_NO_MSG (err == - EINPROGRESS );
393
408
}
394
409
}
410
+ #endif /* NRF_CLOCK_HAS_CALIBRATION */
395
411
396
412
#if defined(CONFIG_USB ) && defined(CONFIG_SOC_NRF52840 )
397
413
if (usb_detected ) {
0 commit comments