19 #include "hal_clocks.h" 21 #include "nrf_peripherals.h" 25 if((NRF_CLOCK->LFCLKSTAT &
26 (CLOCK_LFCLKSTAT_STATE_Running << CLOCK_LFCLKSTAT_STATE_Pos)) &&
28 ((NRF_CLOCK->LFCLKSTAT & CLOCK_LFCLKSTAT_SRC_Msk) == lfclk_src))
34 NRF_CLOCK->LFCLKSRC = (lfclk_src << CLOCK_LFCLKSRC_SRC_Pos);
35 NRF_CLOCK->INTENSET = CLOCK_INTENSET_LFCLKSTARTED_Msk;
36 NVIC_ClearPendingIRQ(POWER_CLOCK_IRQn);
39 SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
41 NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
42 (void)NRF_CLOCK->EVENTS_LFCLKSTARTED;
43 NRF_CLOCK->TASKS_LFCLKSTART = 1;
45 while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
50 NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
51 (void)NRF_CLOCK->EVENTS_LFCLKSTARTED;
52 NVIC_ClearPendingIRQ(POWER_CLOCK_IRQn);
53 NRF_CLOCK->INTENCLR = CLOCK_INTENCLR_LFCLKSTARTED_Msk;
56 SCB->SCR &= (~(SCB_SCR_SEVONPEND_Msk));
59 NRF_RTC0->TASKS_STOP = 0;
60 NRF_RTC1->TASKS_STOP = 0;
62 NRF_RTC2->TASKS_STOP = 0;
68 NRF_CLOCK->TASKS_LFCLKSTOP = 1;
74 if(NRF_CLOCK->HFCLKSTAT !=
75 ((CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos) |
76 (CLOCK_HFCLKSTAT_SRC_Xtal << CLOCK_HFCLKSTAT_SRC_Pos)))
78 NRF_CLOCK->INTENSET = CLOCK_INTENSET_HFCLKSTARTED_Msk;
80 SCB->SCR |= SCB_SCR_SEVONPEND_Msk;
82 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
83 (void) NRF_CLOCK->EVENTS_HFCLKSTARTED;
84 NRF_CLOCK->TASKS_HFCLKSTART = 1;
86 while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
91 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
92 (void) NRF_CLOCK->EVENTS_HFCLKSTARTED;
93 NVIC_ClearPendingIRQ(POWER_CLOCK_IRQn);
94 NRF_CLOCK->INTENCLR = CLOCK_INTENCLR_HFCLKSTARTED_Msk;
97 SCB->SCR &= (~(SCB_SCR_SEVONPEND_Msk));
104 if(NRF_CLOCK->HFCLKSTAT !=
105 ((CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos) |
106 (CLOCK_HFCLKSTAT_SRC_Xtal << CLOCK_HFCLKSTAT_SRC_Pos)))
108 NRF_CLOCK->TASKS_HFCLKSTART = 1;
115 if(NRF_CLOCK->HFCLKSTAT !=
116 ((CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos) |
117 (CLOCK_HFCLKSTAT_SRC_Xtal << CLOCK_HFCLKSTAT_SRC_Pos)))
120 while (NRF_CLOCK->HFCLKSTAT !=
121 ((CLOCK_HFCLKSTAT_STATE_Running << CLOCK_HFCLKSTAT_STATE_Pos) |
122 (CLOCK_HFCLKSTAT_SRC_Xtal << CLOCK_HFCLKSTAT_SRC_Pos)))
127 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
128 (void) NRF_CLOCK->EVENTS_HFCLKSTARTED;
134 NRF_CLOCK->TASKS_HFCLKSTOP = 1;
void hfclk_xtal_deinit(void)
Function to de-initialize the HF clock from using the crystal. RC oscillator will be used to generate...
void lfclk_init(lfclk_src_t lfclk_src)
Function to initialize the LF clock.
void hfclk_xtal_init_nonblocking(void)
Function to initialize the HF clock to use the crystal. This function returns immediately after trigg...
void hfclk_block_till_xtal(void)
Blocks until the HF crystal oscillator is running.
void lfclk_deinit(void)
Function to de-initialize the LF clock. Saves a bit of power as LF clock is not running,...
void hfclk_xtal_init_blocking(void)
Function to start the crystal oscillator to be used for HF clock. This function blocks until the crys...