Library guide · API index and notation
This page is generated from the bundled library in this checkout. Signatures and adjacent source comments are reproduced below; the linked guide explains usage, storage, failures, and platform support.
import "std/embedded/board/pico"
Names used in signatures
Unqualified names denote this package’s types (including other source files in the same package), language built-ins, or generic parameters such as T. Qualified names use the import aliases below. These aliases belong to the library source; import a dependency yourself to use its alias in your program.
| Alias | Package | Source file |
|---|---|---|
hal |
std/embedded/hal |
pico.dodo |
rp2040 |
std/embedded/chip/rp2040 |
pico.dodo |
rp_dma |
std/embedded/chip/rp_dma |
pico.dodo |
rp_flash |
std/embedded/chip/rp_flash |
pico.dodo |
rp_multicore |
std/embedded/chip/rp_multicore |
pico.dodo |
rp_rng |
std/embedded/chip/rp_rng |
pico.dodo |
rp_usb |
std/embedded/chip/rp_usb |
pico.dodo |
rp_watchdog |
std/embedded/chip/rp_watchdog |
pico.dodo |
NAME
Constant · Source
pub const NAME: &str = "Raspberry Pi Pico"
LED_PIN
Constant · Source
pub const LED_PIN: u32 = 25
CRYSTAL_HZ
Constant · Source
pub const CRYSTAL_HZ: u32 = 12_000_000
I2C_SDA_PIN
Constant · Source
The usual bus pins, as in the Pico SDK and Raspberry Pi’s pinout diagrams: I2C0 on GP4 (SDA) and GP5 (SCL), SPI0 on GP16 (RX), GP18 (clock), and GP19 (TX), with GP17 free for a chip select, and UART0 on GP0 (TX) and GP1 (RX), where the Raspberry Pi Debug Probe’s UART connects:
i2c := b.pins.i2c(I2C_SDA_PIN, I2C_SCL_PIN, hal.I2C_FAST_HZ)! serial := b.pins.uart(UART_TX_PIN, some(UART_RX_PIN), 115_200)!
pub const I2C_SDA_PIN: u32 = 4
I2C_SCL_PIN
Constant · Source
pub const I2C_SCL_PIN: u32 = 5
SPI_RX_PIN
Constant · Source
pub const SPI_RX_PIN: u32 = 16
SPI_SELECT_PIN
Constant · Source
pub const SPI_SELECT_PIN: u32 = 17
SPI_CLOCK_PIN
Constant · Source
pub const SPI_CLOCK_PIN: u32 = 18
SPI_TX_PIN
Constant · Source
pub const SPI_TX_PIN: u32 = 19
UART_TX_PIN
Constant · Source
pub const UART_TX_PIN: u32 = 0
UART_RX_PIN
Constant · Source
pub const UART_RX_PIN: u32 = 1
Board
Struct · Source
pub struct Board {
// The user LED, an output pin that is on when high.
pub led: rp2040.Pin
// The remaining GPIOs, and the I2C, SPI, and UART ports on them; GP25 is
// already taken by `led`.
pub pins: rp2040.Pins
// The 1 MHz system timer: delay_us, delay_ms, and now_us.
pub timer: rp2040.Timer
// The real-time clock, with the hal Rtc and RtcAlarm protocols: the
// time of day in seconds.
pub rtc: rp2040.Rtc
// The watchdog, stopped until `start(timeout_ms)`: it then resets the
// board unless `feed()` is called in time; see
// std/embedded/chip/rp_watchdog.
pub watchdog: rp_watchdog.Watchdog
// The USB port: `serial()` makes the board a USB serial port, for
// printing over the USB cable.
pub usb: Usb
// The DMA channels: `channel()` claims one, for transfers that run
// while the program does other work.
pub dma: rp_dma.Dma
// The random number generator, from the RP2040's ring oscillator: for
// seeds and games, not for cryptographic keys; std/embedded/chip/rp_rng
// documents it.
pub rng: rp_rng.Rosc
// The second core, `start`ed with a task of its own, and the FIFOs and
// spinlocks the two cores share; see std/embedded/chip/rp_multicore.
pub core1: rp_multicore.Core1
pub fifos: rp_multicore.Fifos
pub spinlocks: rp_multicore.Spinlocks
// The program flash: the free flash above `flash.program_end()` keeps
// data across restarts and reflashing, for example a
// std/embedded/storage key-value store; see std/embedded/chip/rp_flash.
pub flash: rp_flash.Flash
// Sleep modes, clock gating, and the dormant state, with the
// std/embedded/power protocol; see rp2040.Power.
pub power: rp2040.Power
}
take
Function · Source
Start the chip with the Pico’s crystal and claim the LED. A second call returns hal.Error.Busy.
pub fn take() -> Board!hal.Error
Usb
Struct · Source
The USB port, as
b.usb.
pub struct Usb {
// Private implementation fields omitted.
}
Usb.serial
Function · Source
Make the board a USB serial port named after it, with rp_usb’s default identity, for printing and reading over the USB cable; rp_usb documents the port. After a restart into the bootloader through the port, as
dodo rundoes, the LED lights while the bootloader’s drive is accessed. Busy if a port is open.
pub fn serial(&mut self) -> rp_usb.Serial!hal.Error
Usb.serial_with
Function · Source
serial, with theidentitythe host sees in place of the default: the vendor and product IDs and strings of a product of your own.dodo runfinds only the default IDs, so a board with others needs BOOTSEL held to flash it.
pub fn serial_with(&mut self, identity: rp_usb.Identity) -> rp_usb.Serial!hal.Error
Usb.release_serial
Function · Source
Give back the port: the board disconnects from the host.
pub fn release_serial(&mut self, serial: rp_usb.Serial)
report_panic
Function · Source
Write a failed check’s message to every serial port claimed from
b.pins.uartand to the USB serial port, as the default panic hook does before it halts. For a panic hook of your own, for example one that restarts into the bootloader sododo runworks again without pressing BOOTSEL:extern “C” fn dodo_board_panic(check: *const u8, file: *const u8, line: u32, column: u32) { unsafe { board.report_panic(check, file, line, column) } board.reboot_to_bootloader() }
SAFETY:
checkandfilemust be the hook’s NUL-terminated strings, and the caller must halt or reset afterwards, as this takes over the ports.
pub unsafe fn report_panic(check: *const u8, file: *const u8, line: u32, column: u32)
Requires an unsafe context. Follow the source safety preconditions and the linked guide before calling this API.
reboot_to_bootloader
Function · Source
Restart into the USB bootloader, as if BOOTSEL were held at power-up: the Pico reappears as the RPI-RP2 drive, ready for
dodo run. The LED shows drive activity. Does not return.
pub fn reboot_to_bootloader()