Skip to main content

Crate pico_de_gallo_lib

Crate pico_de_gallo_lib 

Source
Expand description

Host-side library for communicating with a Pico de Gallo USB bridge.

This crate provides PicoDeGallo, an async client for interacting with the Pico de Gallo firmware over USB. It supports I2C reads/writes, SPI operations (including full-duplex transfers), UART reads/writes, GPIO control, PWM output, ADC sampling, 1-Wire bus operations, and device configuration — all via postcard-rpc endpoints.

§Quick Start

use pico_de_gallo_lib::PicoDeGallo;

#[tokio::main]
async fn main() {
    let gallo = PicoDeGallo::new();
    let version = gallo.version().await.unwrap();
    println!("Firmware v{}.{}.{}", version.major, version.minor, version.patch);
}

§Multiple Devices

When multiple Pico de Gallo boards are connected, use list_devices to enumerate them and PicoDeGallo::new_with_serial_number to connect to a specific board:

use pico_de_gallo_lib::{PicoDeGallo, list_devices};

#[tokio::main]
async fn main() {
    for dev in list_devices() {
        println!("Found: {:?}", dev.serial_number);
    }
    let gallo = PicoDeGallo::new_with_serial_number("ABCD1234");
}

§Error Handling

All methods return Result<T, PicoDeGalloError<E>> where E is the endpoint-specific error type. Errors are either communication failures (PicoDeGalloError::Comms) or endpoint-level errors (PicoDeGalloError::Endpoint).

Modules§

decode
Host-side protocol decoders for raw capture data.

Structs§

AdcConfigurationInfo
Current ADC configuration as reported by the firmware.
Capabilities
Hardware capabilities — a bitflag set describing which peripherals are available on the connected device.
DeviceDescription
Description of a connected Pico de Gallo device.
DeviceInfo
Extended device information including firmware version, schema version, hardware version, and peripheral capabilities.
GpioEvent
A GPIO event notification published by the firmware.
I2cBatchError
Error returned when an I2C batch transaction fails.
IoClosed
The I/O worker has closed.
MultiSubscription
A structure that represents a subscription to the given topic
PicoDeGallo
Async client for a Pico de Gallo USB bridge device.
PwmConfigurationInfo
Current PWM slice configuration as reported by the firmware.
PwmDutyCycleInfo
Information about a PWM channel’s current duty cycle.
SpiBatchError
Error returned when an SPI batch transaction fails.
SpiConfigurationInfo
Current SPI bus configuration as reported by the firmware.
UartConfigurationInfo
Current UART bus configuration as reported by the firmware.
VersionInfo
Firmware version information.

Enums§

AdcChannel
ADC channel selector.
AdcError
Error from ADC operations, propagated from firmware.
GpioDirection
GPIO pin direction.
GpioEdge
Edge type for GPIO event monitoring.
GpioError
Error from GPIO operations, propagated from firmware.
GpioPull
GPIO internal pull resistor configuration.
GpioState
Logic level of a GPIO pin.
I2cBatchOp
A single I2C operation for building a batch request.
I2cError
Error from I2C operations, propagated from firmware.
I2cFrequency
I2C bus clock frequency.
OneWireError
Error from 1-Wire operations, propagated from firmware.
PicoDeGalloError
Error type for Pico de Gallo operations.
PwmError
Error from PWM operations, propagated from firmware.
SpiBatchOp
A single SPI operation for building a batch request.
SpiError
Error from SPI operations, propagated from firmware.
SpiPhase
SPI clock phase setting.
SpiPolarity
SPI clock polarity setting.
UartError
Error from UART operations, propagated from firmware.
ValidateError
Error returned by PicoDeGallo::validate() when the connected firmware is incompatible with this host library.

Functions§

encode_i2c_batch_ops
Encode a sequence of I2C batch operations into the postcard wire format.
encode_spi_batch_ops
Encode a sequence of SPI batch operations into the postcard wire format.
i2c_batch_response_len
Compute the total number of bytes that will appear in the response for an I2C batch — the sum of all Read lengths.
list_devices
List all connected Pico de Gallo devices.
spi_batch_response_len
Compute the total number of bytes that will appear in the response for an SPI batch — the sum of Read and Transfer lengths.