pico_stdlib

Aggregation of a core subset of Raspberry Pi Pico SDK libraries used by most executables along with some additional utility methods. Including pico_stdlib gives you everything you need to get a basic program running which prints to stdout or flashes a LED. More...

Functions

void setup_default_uart (void)
 Set up the default UART and assign it to the default GPIO's. More...
 
void set_sys_clock_48mhz (void)
 Initialise the system clock to 48MHz. More...
 
void set_sys_clock_pll (uint32_t vco_freq, uint post_div1, uint post_div2)
 Initialise the system clock. More...
 
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. More...
 
static bool set_sys_clock_khz (uint32_t freq_khz, bool required)
 Attempt to set a system clock frequency in khz. More...
 

Detailed Description

Aggregation of a core subset of Raspberry Pi Pico SDK libraries used by most executables along with some additional utility methods. Including pico_stdlib gives you everything you need to get a basic program running which prints to stdout or flashes a LED.

This library aggregates:

There are some basic default values used by these functions that will default to usable values, however, they can be customised in a board definition header via config.h or similar

Function Documentation

◆ check_sys_clock_khz()

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.

Parameters
freq_khzRequested frequency
vco_freq_outOn success, the voltage controller oscillator frequeucny to be used by the SYS PLL
post_div1_outOn success, The first post divider for the SYS PLL
post_div2_outOn success, The second post divider for the SYS PLL.
Returns
true if the frequency is possible and the output parameters have been written.

◆ set_sys_clock_48mhz()

void set_sys_clock_48mhz ( void  )

Initialise the system clock to 48MHz.

Set the system clock to 48MHz, and set the peripheral clock to match.

◆ set_sys_clock_khz()

static bool set_sys_clock_khz ( uint32_t  freq_khz,
bool  required 
)
inlinestatic

Attempt to set a system clock frequency in khz.

Note that not all clock frequencies are possible; it is preferred that you use src/rp2_common/hardware_clocks/scripts/vcocalc.py to calculate the parameters for use with set_sys_clock_pll

Parameters
freq_khzRequested frequency
requiredif true then this function will assert if the frequency is not attainable.
Returns
true if the clock was configured

◆ set_sys_clock_pll()

void set_sys_clock_pll ( uint32_t  vco_freq,
uint  post_div1,
uint  post_div2 
)

Initialise the system clock.

Parameters
vco_freqThe voltage controller oscillator frequency to be used by the SYS PLL
post_div1The first post divider for the SYS PLL
post_div2The second post divider for the SYS PLL.

See the PLL documentation in the datasheet for details of driving the PLLs.

◆ setup_default_uart()

void setup_default_uart ( void  )

Set up the default UART and assign it to the default GPIO's.

By default this will use UART 0, with TX to pin GPIO 0, RX to pin GPIO 1, and the baudrate to 115200

Calling this method also initializes stdin/stdout over UART if the pico_stdio_uart library is linked.

Defaults can be changed using configuration defines, PICO_DEFAULT_UART_INSTANCE, PICO_DEFAULT_UART_BAUD_RATE PICO_DEFAULT_UART_TX_PIN PICO_DEFAULT_UART_RX_PIN