Datasheet

Table Of Contents
379 if (has_glitchless_mux(clk_index)) {
380 // AUX src is always 1
381 src = 1;
382 }
383
384 // Set the GPIO function
385 gpio_set_function(gpio, GPIO_FUNC_GPCK);
386
387 // Now we have the src, auxsrc, and configured the gpio input
388 // call clock configure to run the clock from a gpio
389 return clock_configure(clk_index, src, auxsrc, src_freq, freq);
390 }
2.15.6.5. Enabling resus
SDK: https://github.com/raspberrypi/pico-sdk/tree/master/src/rp2_common/hardware_clocks/clocks.c Lines 293 - 315
293 void clocks_enable_resus(resus_callback_t resus_callback) {
294 // Restart clk_sys if it is stopped by forcing it
295 // to the default source of clk_ref. If clk_ref stops running this will
296 // not work.
297
298 // Store user's resus callback
299 _resus_callback = resus_callback;
300
301 irq_set_exclusive_handler(CLOCKS_IRQ, clocks_irq_handler);
302
303 // Enable the resus interrupt in clocks
304 clocks_hw->inte = CLOCKS_INTE_CLK_SYS_RESUS_BITS;
305
306 // Enable the clocks irq
307 irq_set_enabled(CLOCKS_IRQ, true);
308
309 // 2 * clk_ref freq / clk_sys_min_freq;
310 // assume clk_ref is 3MHz and we want clk_sys to be no lower than 1MHz
311 uint timeout = 2 * 3 * 1;
312
313 // Enable resus with the maximum timeout
314 clocks_hw->resus.ctrl = CLOCKS_CLK_SYS_RESUS_CTRL_ENABLE_BITS | timeout;
315 }
2.15.6.6. Configuring sleep mode
Sleep mode is active when neither processor core or the DMA are requesting clocks. For example, the DMA is not active
and both core0 and core1 are waiting for an interrupt. The SLEEP_EN registers set what clocks are running in sleep mode.
The hello_sleep example (https://github.com/raspberrypi/pico-playground/tree/master/sleep/hello_sleep/
hello_sleep.c) illustrates how to put the chip to sleep until the RTC fires. In this case, only the RTC clock is enabled in the
SLEEP_EN0 register.
RP2040 Datasheet
2.15. Clocks 217