API reference Dodo 0.1.5

std/embedded/chip/rp2350

Public declarations, types, methods, and source contracts for std/embedded/chip/rp2350.

On this page

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/chip/rp2350"

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
designware_i2c std/embedded/peripheral/designware_i2c rp2350.dodo
hal std/embedded/hal rp2350.dodo
pl022 std/embedded/peripheral/pl022 rp2350.dodo
rp_pins std/embedded/chip/rp_pins rp2350.dodo

SYS_HZ

Constant · Source

clk_sys, the processor and peripheral clock, after take().

pub const SYS_HZ: u32 = 150_000_000

PIN_COUNT

Constant · Source

User GPIOs 0 to 29.

pub const PIN_COUNT: u32 = 30

reboot_to_bootloader

Function · Source

Restart into the boot ROM’s USB bootloader, as if BOOTSEL were held at power-up: the board reappears as the RP2350 drive and accepts new firmware, for example from dodo run. Pin activity_led, if below PIN_COUNT, lights while the drive is accessed, except on chip revision A2, whose boot ROM mishandles it on the Arm cores (erratum in the Pico SDK’s rom_reset_usb_boot). Does not return.

pub fn reboot_to_bootloader(activity_led: u32)

Config

Struct · Source

What the circuit board decides. Board packages pass theirs to take.

pub struct Config {
    // The crystal on XIN/XOUT, in hertz: 1 to 15 MHz, a whole number of
    // megahertz (for the 1 MHz ticks) that divides 1.5 GHz (for the PLL).
    // 12 MHz, as on the Raspberry Pi Pico 2, is the usual choice.
    pub crystal_hz: u32
}

Peripherals

Struct · Source

The chip’s peripherals, handed out once by take.

pub struct Peripherals {
    pub pins: Pins
    pub timer: Timer
}

take

Function · Source

Configure clocks, take GPIO and the timer out of reset, and return the peripherals. A second call returns Error.Busy, so no two owners exist; an unusable crystal frequency returns Error.InvalidInput, and a crystal or PLL that does not start returns Error.Timeout.

pub fn take(config: Config) -> Peripherals!hal.Error

Pins

Struct · Source

The 30 user GPIOs, and the I2C and SPI controllers that use them. Each pin and each controller can be taken once, and given back.

pub struct Pins {
    // Private implementation fields omitted.
}

Pins.output

Function · Source

Claim pin number as a push-pull output, initially low.

pub fn output(&mut self, number: u32) -> Pin!hal.Error

Pins.input

Function · Source

Claim pin number as an input.

pub fn input(&mut self, number: u32) -> Pin!hal.Error

Pins.release

Function · Source

Give back a pin from output or input. It stops driving and is disconnected until claimed again, for example as part of a bus.

pub fn release(&mut self, pin: Pin)

Pins.i2c

Function · Source

Claim pins sda and scl as an I2C bus with an SCL frequency of frequency_hz, at most hal.I2C_FAST_PLUS_HZ. Even pins carry SDA and odd pins SCL. GPIO 0 and 1, 4 and 5, and so on in steps of four belong to I2C0; GPIO 2 and 3, 6 and 7, and so on to I2C1. InvalidInput if the two pins cannot form a bus or the frequency is out of range, Busy if a pin or the controller is taken. The pads’ own pull-ups (about 50 kOhm) keep an idle bus high but are too weak for fast mode: most sensor boards add 4.7 kOhm pull-ups, and a bare bus needs them. The designware_i2c driver documents the bus’s errors.

pub fn i2c(&mut self, sda: u32, scl: u32, frequency_hz: u32) -> designware_i2c.Bus!hal.Error

Pins.spi

Function · Source

Claim pins as an SPI bus in mode, clocked at the fastest rate up to frequency_hz (at most SYS_HZ / 2, 75 MHz): clock (SCK), tx (data out to the devices, MOSI), and rx (data in from them, MISO), or none when they only listen. GPIO n carries RX when n % 4 is 0, the clock when it is 2, and TX when it is 3. GPIO 0 to 7 and 16 to 23 belong to SPI0, GPIO 8 to 15 and 24 to 29 to SPI1. Give each device an output pin as its chip select, through hal.SpiDevice. Errors as for i2c.

pub fn spi(&mut self, clock: u32, tx: u32, rx: Option<u32>, mode: hal.SpiMode, frequency_hz: u32) -> pl022.Bus!hal.Error

Pins.release_i2c

Function · Source

Give back an I2C bus. Its controller is held in reset and its pins are disconnected but still pulled up, so the bus stays idle. A device that holds SDA low after an interrupted transfer, which makes the bus Timeout, can then be freed by claiming SCL as an output and clocking it by hand before claiming the bus again.

pub fn release_i2c(&mut self, bus: designware_i2c.Bus)

Pins.release_spi

Function · Source

Give back an SPI bus: its controller is held in reset and its pins are disconnected.

pub fn release_spi(&mut self, bus: pl022.Bus)

Pin

Struct · Source

One GPIO driven by the single-cycle I/O block. Implements the std/embedded/hal output and input pin protocols.

pub struct Pin {
    // Private implementation fields omitted.
}

Pin.set_high

Function · Source

pub fn set_high(&mut self)

Pin.set_low

Function · Source

pub fn set_low(&mut self)

Pin.toggle

Function · Source

pub fn toggle(&mut self)

Pin.is_high

Function · Source

pub fn is_high(&self) -> bool

Pin.set_as_output

Function · Source

Drive the pin at its output level, for a line that changes direction such as a half-duplex data line. Pins claimed as inputs start released.

pub fn set_as_output(&mut self)

Pin.set_as_input

Function · Source

Release the pin so another device can drive it; is_high reads it.

pub fn set_as_input(&mut self)

Timer

Struct · Source

The free-running 64-bit microsecond counter of TIMER0. Implements the std/embedded/hal delay protocol.

pub struct Timer {
    // Private implementation fields omitted.
}

Timer.now_us

Function · Source

Microseconds since take().

pub fn now_us(&self) -> u64

Timer.delay_us

Function · Source

pub fn delay_us(&mut self, microseconds: u32)

Timer.delay_ms

Function · Source

pub fn delay_ms(&mut self, milliseconds: u32)

Type to search all documentation.

Keyboard shortcuts

Search documentation
Ctrl K or /
Move through results
↑ ↓
Open selected result
Enter
Close a dialog
Esc
Show these shortcuts
?