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§
- AdcConfiguration
Info - Current ADC configuration as reported by the firmware.
- Capabilities
- Hardware capabilities — a bitflag set describing which peripherals are available on the connected device.
- Device
Description - Description of a connected Pico de Gallo device.
- Device
Info - Extended device information including firmware version, schema version, hardware version, and peripheral capabilities.
- Gpio
Event - A GPIO event notification published by the firmware.
- I2cBatch
Error - Error returned when an I2C batch transaction fails.
- IoClosed
- The I/O worker has closed.
- Multi
Subscription - A structure that represents a subscription to the given topic
- Pico
DeGallo - Async client for a Pico de Gallo USB bridge device.
- PwmConfiguration
Info - Current PWM slice configuration as reported by the firmware.
- PwmDuty
Cycle Info - Information about a PWM channel’s current duty cycle.
- SpiBatch
Error - Error returned when an SPI batch transaction fails.
- SpiConfiguration
Info - Current SPI bus configuration as reported by the firmware.
- Uart
Configuration Info - Current UART bus configuration as reported by the firmware.
- Version
Info - Firmware version information.
Enums§
- AdcChannel
- ADC channel selector.
- AdcError
- Error from ADC operations, propagated from firmware.
- Gpio
Direction - GPIO pin direction.
- Gpio
Edge - Edge type for GPIO event monitoring.
- Gpio
Error - Error from GPIO operations, propagated from firmware.
- Gpio
Pull - GPIO internal pull resistor configuration.
- Gpio
State - Logic level of a GPIO pin.
- I2cBatch
Op - A single I2C operation for building a batch request.
- I2cError
- Error from I2C operations, propagated from firmware.
- I2cFrequency
- I2C bus clock frequency.
- OneWire
Error - Error from 1-Wire operations, propagated from firmware.
- Pico
DeGallo Error - Error type for Pico de Gallo operations.
- PwmError
- Error from PWM operations, propagated from firmware.
- SpiBatch
Op - 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.
- Uart
Error - Error from UART operations, propagated from firmware.
- Validate
Error - 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.