Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Endpoint Catalog

This is the canonical list of postcard-rpc endpoints and topics exposed by the Pico de Gallo firmware. The source of truth is the endpoints! and topics! invocations in crates/pico-de-gallo-internal/src/lib.rs.

Important

Variant order in shared enums is part of the wire ABI. postcard encodes enum variants by their index (0, 1, 2…), not by the discriminant value. Reordering or removing a variant is a breaking schema change. New variants must be appended at the end. See AGENTS.md §6 for the full rule.

Each schema break bumps SCHEMA_VERSION_MINOR (pre-1.0). The host library refuses to talk to a firmware whose major/minor version doesn’‘t match — that’’s where Status::SchemaMismatch (−63) comes from.

Endpoints

PathDescription
pingEcho a u32. Useful for liveness checks.
versionFirmware version triple (major / minor / patch).
device/infoFirmware version + schema version + capability bitfield + runtime GPIO count + firmware build identity.
i2c/readRead N bytes from a target address.
i2c/writeWrite bytes to a target address.
i2c/write-readWrite then read on the same target (repeated start).
i2c/scanProbe every address on the bus.
i2c/batchOne I²C transaction: gather same-direction ops, repeated START on direction changes, one final STOP. See the contract below.
i2c/set-configSet I²C frequency (I2cFrequency enum).
i2c/get-configQuery current I²C frequency.
spi/readClock in N bytes (MISO).
spi/writeClock out bytes (MOSI).
spi/transferFull-duplex transfer of equal-length TX and RX.
spi/flushWait for any in-flight DMA SPI ops to complete.
spi/batchSequence of SPI ops under chip-select in one round-trip. See the chip-select contract below.
spi/set-configSet frequency, CPHA, and CPOL.
spi/get-configQuery current SPI configuration.
uart/readRead with timeout.
uart/writeWrite bytes.
uart/flushDrain the TX FIFO.
uart/set-configSet baud rate and framing (data bits, parity, stop bits).
uart/get-configQuery current UART baud rate and framing.
gpio/getRead a pin.
gpio/putWrite a pin.
gpio/wait-highBlock until pin is high.
gpio/wait-lowBlock until pin is low.
gpio/wait-risingBlock until rising edge.
gpio/wait-fallingBlock until falling edge.
gpio/wait-anyBlock until any edge.
gpio/set-configSet direction and pull resistor.
gpio/subscribeBegin push-based edge events on a pin.
gpio/unsubscribeStop push-based events on a pin.
pwm/set-duty-cycleSet raw compare value.
pwm/get-duty-cycleQuery current compare value and max.
pwm/enableEnable the PWM slice owning a channel.
pwm/disableDisable the PWM slice owning a channel.
pwm/set-configSet frequency and phase-correct mode.
pwm/get-configQuery PWM configuration.
adc/readSingle-shot ADC read.
adc/get-configQuery ADC capabilities (channel count, resolution).
onewire/reset1-Wire reset + presence detection.
onewire/readRead N bytes from the 1-Wire bus.
onewire/writeWrite bytes on the 1-Wire bus.
onewire/write-pullupWrite bytes then assert strong pullup (parasitic power).
onewire/searchStart a ROM search (returns first ROM).
onewire/search-nextContinue a ROM search.
system/reset-subscriptionsTear down any GPIO subscriptions left over from a prior host.

i2c/batch transaction contract

Firmware schema 0.7 and newer executes the entire batch as one I²C transaction. A START and address precede the first operation. Adjacent operations in the same direction run back to back without a STOP or repeated START, so two adjacent writes form one gather write. A direction change emits a repeated START and re-addresses the target. Only the final operation is followed by a STOP. Zero-length writes are rejected.

spi/batch chip-select contract

A valid cs_pin is inside 0..DeviceInfo::num_gpios, is not being monitored for GPIO events, and is not explicitly configured as an input. Refusals return InvalidCsPin, CsPinMonitored, and CsPinUnavailable respectively, and leave the pin unchanged. An accepted pin is driven as an output and left deasserted high.

Topics (server → client push)

PathMessageDescription
gpio/eventGpioEventPush stream of edge events for subscribed GPIO pins.

The gpio/event topic is a single multiplexed stream carrying events for every subscribed pin (each GpioEvent carries a pin: u8 field so the host can demultiplex). gpio/subscribe(pin, edge) enables firmware-side monitoring of one pin; gpio/unsubscribe(pin) tears it down. Events for any subscribed pin arrive on the shared stream — there is no per-pin sub-channel and no implicit per-pin stream-open/close.

Subscriptions are server-side state that outlives the USB transport, so a host whose process crashed or was killed without unsubscribing will leave the pin owned by a firmware monitor task. Hosts should call system/reset-subscriptions once on connect (after device/info) to reclaim any such pins. The endpoint is idempotent and returns the number of subscriptions that were torn down.

Stale events: after gpio/unsubscribe(pin) returns Ok, a GpioEvent for that pin may still arrive (the firmware best-effort publishes events that were in-flight at unsubscribe time). Consumers should filter against their current subscription set and drop unknown-pin events without erroring.

Adding Endpoints

If you’‘re contributing a new endpoint, the recipe touches six crates plus tests and documentation. Don’’t forget the schema-version bump and the lockstep release of internal + firmware + every host crate.