clocks.h File Reference
#include "pico.h"
#include "hardware/structs/clocks.h"
Include dependency graph for clocks.h:

Go to the source code of this file.

Macros

#define KHZ   1000
 
#define MHZ   1000000
 
#define PARAM_ASSERTIONS_ENABLED_CLOCKS   0
 

Typedefs

typedef void(* resus_callback_t) (void)
 Resus callback function type.User provided callback for a resus event (when clk_sys is stopped by the programmer and is restarted for them).
 

Functions

void clocks_init (void)
 Initialise the clock hardwareMust be called before any other clock function.
 
bool clock_configure (enum clock_index clk_index, uint32_t src, uint32_t auxsrc, uint32_t src_freq, uint32_t freq)
 Configure the specified clockSee the tables in the description for details on the possible values for clock sources. More...
 
void clock_stop (enum clock_index clk_index)
 Stop the specified clock. More...
 
uint32_t clock_get_hz (enum clock_index clk_index)
 Get the current frequency of the specified clock. More...
 
uint32_t frequency_count_khz (uint src)
 Measure a clocks frequency using the Frequency counter.Uses the inbuilt frequency counter to measure the specified clocks frequency. Currently, this function is accurate to +-1KHz. See the datasheet for more details.
 
void clock_set_reported_hz (enum clock_index clk_index, uint hz)
 Set the "current frequency" of the clock as reported by clock_get_hz without actually changing the clock. More...
 
static float frequency_count_mhz (uint src)
 
void clocks_enable_resus (resus_callback_t resus_callback)
 Enable the resus function. Restarts clk_sys if it is accidentally stopped.The resuscitate function will restart the system clock if it falls below a certain speed (or stops). This could happen if the clock source the system clock is running from stops. For example if a PLL is stopped. More...
 
void clock_gpio_init_int_frac (uint gpio, uint src, uint32_t div_int, uint8_t div_frac)
 Output an optionally divided clock to the specified gpio pin. More...
 
static void clock_gpio_init (uint gpio, uint src, float div)
 Output an optionally divided clock to the specified gpio pin. More...
 
bool clock_configure_gpin (enum clock_index clk_index, uint gpio, uint32_t src_freq, uint32_t freq)
 Configure a clock to come from a gpio input. More...