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/pico2_w"
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 |
|---|---|---|
cyw43 |
std/embedded/wireless/cyw43 |
pico2_w.dodo |
hal |
std/embedded/hal |
pico2_w.dodo |
rp2350 |
std/embedded/chip/rp2350 |
pico2_w.dodo |
rp_dma |
std/embedded/chip/rp_dma |
pico2_w.dodo |
rp_flash |
std/embedded/chip/rp_flash |
pico2_w.dodo |
rp_multicore |
std/embedded/chip/rp_multicore |
pico2_w.dodo |
rp_rng |
std/embedded/chip/rp_rng |
pico2_w.dodo |
rp_usb |
std/embedded/chip/rp_usb |
pico2_w.dodo |
rp_watchdog |
std/embedded/chip/rp_watchdog |
pico2_w.dodo |
NAME
Constant · Source
pub const NAME: &str = "Raspberry Pi Pico 2 W"
CRYSTAL_HZ
Constant · Source
pub const CRYSTAL_HZ: u32 = 12_000_000
LED_GPIO
Constant · Source
The wireless chip’s GPIO that drives the LED.
pub const LED_GPIO: u32 = 0
VBUS_GPIO
Constant · Source
The wireless chip’s GPIO that reads high while USB power (VBUS) is present.
pub const VBUS_GPIO: u32 = 2
WL_POWER_PIN
Constant · Source
RP2350 pins wired to the wireless chip.
pub const WL_POWER_PIN: u32 = 23
WL_DATA_PIN
Constant · Source
pub const WL_DATA_PIN: u32 = 24
WL_SELECT_PIN
Constant · Source
pub const WL_SELECT_PIN: u32 = 25
WL_CLOCK_PIN
Constant · Source
pub const WL_CLOCK_PIN: u32 = 29
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, on when high. Changing it is one gSPI write to the
// wireless chip, about 20 us with -O2.
pub led: Led
// The remaining GPIOs, and the I2C, SPI, and UART ports on them; GP23 to
// GP25 and GP29 are taken by the wireless chip.
pub pins: rp2350.Pins
// The 1 MHz system timer: delay_us, delay_ms, and now_us.
pub timer: rp2350.Timer
// The real-time clock, with the hal Rtc and RtcAlarm protocols: the
// time of day in milliseconds, which keeps counting through resets.
pub rtc: rp2350.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, the RP2350's TRNG, fit for
// cryptographic keys; std/embedded/chip/rp_rng documents it.
pub rng: rp_rng.Trng
// The second core, `start`ed with a task of its own, and the FIFOs,
// spinlocks, and doorbells 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
pub doorbells: rp_multicore.Doorbells
// 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 rp2350.Power.
pub power: rp2350.Power
}
take
Function · Source
Start the chip with the Pico 2 W’s crystal, power up the wireless chip, and turn the LED off. Takes about 270 ms, most of it the wireless chip’s power-up. A second call returns hal.Error.Busy; a wireless chip that does not answer returns hal.Error.Timeout.
pub fn take() -> Board!hal.Error
Led
Struct · Source
The LED on the wireless chip’s GPIO 0. Implements the std/embedded/hal output pin protocol, plus toggle and is_high like an RP2350 pin.
pub struct Led {
// Private implementation fields omitted.
}
Led.set_high
Function · Source
pub fn set_high(&mut self)
Led.set_low
Function · Source
pub fn set_low(&mut self)
Led.toggle
Function · Source
pub fn toggle(&mut self)
Led.is_high
Function · Source
The level last written.
pub fn is_high(&self) -> bool
Led.read_back
Function · Source
The level on the LED’s pin, read back from the wireless chip.
pub fn read_back(&mut self) -> bool
Led.usb_powered
Function · Source
True while the board has USB power, from the wireless chip’s VBUS sense input.
pub fn usb_powered(&mut self) -> bool
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 is on the wireless chip, so no pin shows the bootloader’s drive activity. 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 2 W reappears as the RP2350 drive, ready for
dodo run. There is no activity LED, since GP25 is the wireless chip’s select line. Does not return.
pub fn reboot_to_bootloader()