7#ifndef _HARDWARE_CLOCKS_H
8#define _HARDWARE_CLOCKS_H
11#include "hardware/structs/clocks.h"
114#ifndef PLL_COMMON_REFDIV
115#define PLL_COMMON_REFDIV 1
118#if (SYS_CLK_KHZ == 125000) && (XOSC_KHZ == 12000) && (PLL_COMMON_REFDIV == 1)
121#ifndef PLL_SYS_VCO_FREQ_KHZ
122#define PLL_SYS_VCO_FREQ_KHZ (1500 * KHZ)
125#ifndef PLL_SYS_POSTDIV1
126#define PLL_SYS_POSTDIV1 6
129#ifndef PLL_SYS_POSTDIV2
130#define PLL_SYS_POSTDIV2 2
133#if !defined(PLL_SYS_VCO_FREQ_KHZ) || !defined(PLL_SYS_POSTDIV1) || !defined(PLL_SYS_POSTDIV2)
134#error PLL_SYS_VCO_FREQ_KHZ, PLL_SYS_POSTDIV1 and PLL_SYS_POSTDIV2 must all be specified when using custom clock setup
137#if (USB_CLK_KHZ == 48000) && (XOSC_KHZ == 12000) && (PLL_COMMON_REFDIV == 1)
140#ifndef PLL_USB_VCO_FREQ_KHZ
141#define PLL_USB_VCO_FREQ_KHZ (1200 * KHZ)
144#ifndef PLL_USB_POSTDIV1
145#define PLL_USB_POSTDIV1 5
148#ifndef PLL_USB_POSTDIV2
149#define PLL_USB_POSTDIV2 5
152#if !defined(PLL_USB_VCO_FREQ_KHZ) || !defined(PLL_USB_POSTDIV1) || !defined(PLL_USB_POSTDIV2)
153#error PLL_USB_VCO_FREQ_KHZ, PLL_USB_POSTDIV1 and PLL_USB_POSTDIV2 must all be specified when using custom clock setup.
157#ifndef PARAM_ASSERTIONS_ENABLED_CLOCKS
158#define PARAM_ASSERTIONS_ENABLED_CLOCKS 0
212static inline float frequency_count_mhz(uint src) {
253 uint div_int = (uint)div;
254 uint8_t frac = (uint8_t)((div - (
float)div_int) * (1u << CLOCKS_CLK_GPOUT0_DIV_INT_LSB));
void clock_stop(enum clock_index clk_index)
Stop the specified clock.
Definition clocks.c:41
void(* resus_callback_t)(void)
Resus callback function type.
Definition clocks.h:222
void clocks_enable_resus(resus_callback_t resus_callback)
Enable the resus function. Restarts clk_sys if it is accidentally stopped.
Definition clocks.c:286
static void clock_gpio_init(uint gpio, uint src, float div)
Output an optionally divided clock to the specified gpio pin.
Definition clocks.h:251
clock_index
Enumeration identifying a hardware clock.
Definition clocks.h:27
bool clock_configure(enum clock_index clk_index, uint32_t src, uint32_t auxsrc, uint32_t src_freq, uint32_t freq)
Configure the specified clock.
Definition clocks.c:48
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.
Definition clocks.c:357
void clocks_init(void)
Initialise the clock hardware.
Definition clocks.c:121
uint32_t clock_get_hz(enum clock_index clk_index)
Get the current frequency of the specified clock.
Definition clocks.c:201
uint32_t frequency_count_khz(uint src)
Measure a clocks frequency using the Frequency counter.
Definition clocks.c:211
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.
Definition clocks.c:310
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 cl...
Definition clocks.c:206