Loading...
Searching...
No Matches
clocks.h File Reference
#include "pico.h"
#include "hardware/structs/clocks.h"
#include "pico/util/fixed_bitset.h"

Go to the source code of this file.

Macros

#define KHZ   1000
#define MHZ   1000000
#define PLL_COMMON_REFDIV   1
#define PLL_SYS_REFDIV   PLL_COMMON_REFDIV
#define SYS_CLK_VREG_VOLTAGE_AUTO_ADJUST   0
#define SYS_CLK_VREG_VOLTAGE_AUTO_ADJUST_DELAY_US   1000
#define PLL_USB_REFDIV   PLL_COMMON_REFDIV
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_CLOCKS   0
#define PICO_CLOCK_GPIO_CLKDIV_ROUND_NEAREST   PICO_CLKDIV_ROUND_NEAREST
#define clock_dest_bitset_none()
#define clock_dest_bitset_all()
#define GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040(gpio, default_clk_handle)
#define GPIO_TO_GPOUT_CLOCK_HANDLE_RP2350(gpio, default_clk_handle)
#define GPIO_TO_GPOUT_CLOCK_HANDLE
 Returns the GPOUT clock number associated with a particular GPIO if there is one, or default_clk_handle otherwise.

Typedefs

typedef clock_num_t clock_handle_t
typedef void(* resus_callback_t) (void)
 Resus callback function type.

Functions

bool clock_configure (clock_handle_t clock, uint32_t src, uint32_t auxsrc, uint32_t src_freq, uint32_t freq)
 Configure the specified clock with automatic clock divisor setup.
bool clock_configure_mhz (clock_handle_t clock, uint32_t src, uint32_t auxsrc, uint32_t src_freq_mhz, uint32_t freq_mhz)
 Configure the specified clock with 1MHz accuracy.
void clock_configure_undivided (clock_handle_t clock, uint32_t src, uint32_t auxsrc, uint32_t src_freq)
 Configure the specified clock to use the undivided input source.
void clock_configure_int_divider (clock_handle_t clock, uint32_t src, uint32_t auxsrc, uint32_t src_freq, uint32_t int_divider)
 Configure the specified clock to use the undivided input source.
void clock_stop (clock_handle_t clock)
 Stop the specified clock.
uint32_t clock_get_hz (clock_handle_t clock)
 Get the current frequency of the specified clock.
uint32_t frequency_count_khz (uint src)
 Measure a clock's frequency using the frequency counter.
void clock_set_reported_hz (clock_handle_t clock, uint hz)
 Set the "current frequency" of the clock as reported by clock_get_hz without actually changing the clock.
static float frequency_count_mhz (uint src)
 Measure a clock's frequency using the frequency counter.
void clocks_enable_resus (resus_callback_t resus_callback)
 Enable the resus function. Restarts clk_sys if it is accidentally stopped.
void clock_gpio_init_int_frac16 (uint gpio, uint src, uint32_t div_int, uint16_t div_frac16)
 Output an optionally divided clock to the specified gpio pin.
static void clock_gpio_init_int_frac8 (uint gpio, uint src, uint32_t div_int, uint8_t div_frac8)
 Output an optionally divided clock to the specified gpio pin.
static void clock_gpio_init_int_frac (uint gpio, uint src, uint32_t div_int, uint8_t div_frac8)
static void clock_gpio_init (uint gpio, uint src, float div)
 Output an optionally divided clock to the specified gpio pin.
bool clock_configure_gpin (clock_handle_t clock, uint gpio, uint32_t src_freq, uint32_t freq)
 Configure a clock to come from a gpio input.
void set_sys_clock_48mhz (void)
 Initialise the system clock to 48MHz.
void set_sys_clock_pll (uint32_t vco_freq, uint post_div1, uint post_div2)
 Initialise the system clock.
bool check_sys_clock_hz (uint32_t freq_hz, uint *vco_freq_out, uint *post_div1_out, uint *post_div2_out)
 Check if a given system clock frequency is valid/attainable.
bool check_sys_clock_khz (uint32_t freq_khz, uint *vco_freq_out, uint *post_div1_out, uint *post_div2_out)
 Check if a given system clock frequency is valid/attainable.
static bool set_sys_clock_hz (uint32_t freq_hz, bool required)
 Attempt to set a system clock frequency in hz.
static bool set_sys_clock_khz (uint32_t freq_khz, bool required)
 Attempt to set a system clock frequency in khz.
typedef fixed_bitset_type (NUM_CLOCK_DESTINATIONS) clock_dest_bitset_t
static clock_dest_bitset_t * clock_dest_bitset_clear (clock_dest_bitset_t *dests)
static clock_dest_bitset_t * clock_dest_bitset_add_all (clock_dest_bitset_t *dests)
static clock_dest_bitset_t * clock_dest_bitset_add (clock_dest_bitset_t *dests, clock_dest_num_t dest)
static clock_dest_bitset_t * clock_dest_bitset_remove (clock_dest_bitset_t *dests, clock_dest_num_t dest)
void clock_get_sleep_en_gate (clock_dest_bitset_t *clocks)
void clock_gate_sleep_en (const clock_dest_bitset_t *clocks)
static clock_handle_t gpio_to_gpout_clock_handle (uint gpio, clock_handle_t default_clk_handle)
 return the associated GPOUT clock for a given GPIO if any

Macro Definition Documentation

◆ clock_dest_bitset_all

#define clock_dest_bitset_all ( )
Value:
fixed_bitset_with_fill(clock_dest_bitset_t, NUM_CLOCK_DESTINATIONS, 1)
#define fixed_bitset_with_fill(type, N, fill)
Macro used to create a bitset with all bits set to a value.
Definition fixed_bitset.h:65

◆ clock_dest_bitset_none

#define clock_dest_bitset_none ( )
Value:
fixed_bitset_with_fill(clock_dest_bitset_t, NUM_CLOCK_DESTINATIONS, 0)

◆ GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040

#define GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040 ( gpio,
default_clk_handle )
Value:
((gpio) == 21 ? clk_gpout0 : \
((gpio) == 23 ? clk_gpout1 : \
((gpio) == 24 ? clk_gpout2 : \
((gpio) == 25 ? clk_gpout3 : \
(default_clk_handle)))))
@ clk_gpout0
Select CLK_GPOUT0 as clock source.
Definition clocks.h:30
@ clk_gpout2
Select CLK_GPOUT2 as clock source.
Definition clocks.h:32
@ clk_gpout1
Select CLK_GPOUT1 as clock source.
Definition clocks.h:31
@ clk_gpout3
Select CLK_GPOUT3 as clock source.
Definition clocks.h:33

◆ GPIO_TO_GPOUT_CLOCK_HANDLE_RP2350

#define GPIO_TO_GPOUT_CLOCK_HANDLE_RP2350 ( gpio,
default_clk_handle )
Value:
((gpio) == 13 ? clk_gpout0 : \
((gpio) == 15 ? clk_gpout1 : \
(GPIO_TO_GPOUT_CLOCK_HANDLE_RP2040(gpio, default_clk_handle))))