Expand description
Shared wire-protocol types for the Pico de Gallo USB bridge.
This crate defines the postcard-rpc endpoints,
request/response types, and shared constants used by both the firmware
([pico-de-gallo-firmware]) and the host-side library ([pico-de-gallo-lib]).
§Wire Compatibility
All types are serialized with postcard. Postcard
encodes enum variants by index (0, 1, 2, …), not by discriminant value.
Reordering variants in any enum in this crate is a breaking wire change
that will silently corrupt communication between mismatched firmware and host
versions.
§Feature Flags
use-std— EnablesVec<u8>response types for the host side. Without this feature (the default for firmware), responses use borrowed&[u8]slices.
§Crate Organization
- Constants:
MICROSOFT_VID,PICO_DE_GALLO_PID,MAX_TRANSFER_SIZE - Endpoints: Defined via the
postcard_rpc::endpoints!macro — seeENDPOINT_LISTfor the full table. - I2C types:
I2cReadRequest,I2cWriteRequest,I2cWriteReadRequest,I2cScanRequest, and their shared error typeI2cError. - SPI types:
SpiReadRequest,SpiWriteRequest,SpiTransferRequestand their shared error typeSpiError. - GPIO types:
GpioGetRequest,GpioPutRequest,GpioWaitRequest,GpioState,GpioDirection,GpioPull,GpioSetConfigurationRequest, and their shared error typeGpioError. - UART types:
UartReadRequest,UartWriteRequest,UartSetConfigurationRequest,UartConfigurationInfo, and their shared error typeUartError. - PWM types:
PwmSetDutyCycleRequest,PwmGetDutyCycleRequest,PwmEnableRequest,PwmDisableRequest,PwmSetConfigurationRequest,PwmGetConfigurationRequest,PwmDutyCycleInfo,PwmConfigurationInfo, and their shared error typePwmError. - ADC types:
AdcReadRequest,AdcChannel,AdcConfigurationInfo, and their shared error typeAdcError. - 1-Wire types:
OneWireReadRequest,OneWireWriteRequest,OneWireWritePullupRequest, and their shared error typeOneWireError. - Batch types:
I2cBatchRequest,I2cBatchError,I2cBatchOp,SpiBatchRequest,SpiBatchError,SpiBatchOp, encoding helpers [encode_i2c_batch_ops], [encode_spi_batch_ops], and response-length helpersi2c_batch_response_len,spi_batch_response_len. - Configuration:
I2cSetConfigurationRequest,SpiSetConfigurationRequest,GpioSetConfigurationRequest,UartSetConfigurationRequest,PwmSetConfigurationRequest,I2cFrequency,SpiPhase,SpiPolarity,GpioDirection,GpioPull,SpiConfigurationInfo,UartConfigurationInfo. - Version:
VersionInfo. - Device Info:
DeviceInfo,Capabilities.
Structs§
- AdcConfiguration
Info - Current ADC configuration as reported by the firmware.
- AdcGet
Configuration - Macro Generated Marker Type
- AdcRead
- Macro Generated Marker Type
- AdcRead
Request - Request to perform a single-shot ADC read on a specific channel.
- Capabilities
- Hardware capabilities — a bitflag set describing which peripherals are available on the connected device.
- Device
Info - Extended device information including firmware version, schema version, hardware version, and peripheral capabilities.
- GetDevice
Info - Macro Generated Marker Type
- Gpio
Event - A GPIO event notification published by the firmware.
- Gpio
Event Topic - $tp_name - A Topic definition type
- GpioGet
- Macro Generated Marker Type
- Gpio
GetRequest - Request to read the current level of a GPIO pin.
- GpioPut
- Macro Generated Marker Type
- Gpio
PutRequest - Request to set a GPIO pin to a specific level.
- Gpio
SetConfiguration - Macro Generated Marker Type
- Gpio
SetConfiguration Request - Request to configure a GPIO pin’s direction and pull resistor.
- Gpio
Subscribe - Macro Generated Marker Type
- Gpio
Subscribe Request - Request to subscribe a GPIO pin to edge-event monitoring.
- Gpio
Unsubscribe - Macro Generated Marker Type
- Gpio
Unsubscribe Request - Request to unsubscribe a GPIO pin from edge-event monitoring.
- Gpio
Wait ForAny - Macro Generated Marker Type
- Gpio
Wait ForFalling - Macro Generated Marker Type
- Gpio
Wait ForHigh - Macro Generated Marker Type
- Gpio
Wait ForLow - Macro Generated Marker Type
- Gpio
Wait ForRising - Macro Generated Marker Type
- Gpio
Wait Request - Request to wait for a GPIO pin to reach a specific state or edge.
- I2cBatch
- Macro Generated Marker Type
- I2cBatch
Error - Error returned when an I2C batch transaction fails.
- I2cBatch
Request - Request to execute a batch of I2C operations as a single transaction.
- I2cGet
Configuration - Macro Generated Marker Type
- I2cRead
- Macro Generated Marker Type
- I2cRead
Request - Request to read bytes from an I2C device.
- I2cScan
- Macro Generated Marker Type
- I2cScan
Request - Request to scan the I2C bus for responding devices.
- I2cSet
Configuration - Macro Generated Marker Type
- I2cSet
Configuration Request - Request to reconfigure I2C bus parameters.
- I2cWrite
- Macro Generated Marker Type
- I2cWrite
Read - Macro Generated Marker Type
- I2cWrite
Read Request - Request to write bytes to an I2C device, then read back.
- I2cWrite
Request - Request to write bytes to an I2C device.
- OneWire
Read - Macro Generated Marker Type
- OneWire
Read Request - Request to read bytes from the 1-Wire bus.
- OneWire
Reset - Macro Generated Marker Type
- OneWire
Search - Macro Generated Marker Type
- OneWire
Search Next - Macro Generated Marker Type
- OneWire
Write - Macro Generated Marker Type
- OneWire
Write Pullup - Macro Generated Marker Type
- OneWire
Write Pullup Request - Request to write bytes to the 1-Wire bus with strong pullup.
- OneWire
Write Request - Request to write bytes to the 1-Wire bus.
- Ping
Endpoint - Macro Generated Marker Type
- PwmConfiguration
Info - Current PWM slice configuration as reported by the firmware.
- PwmDisable
- Macro Generated Marker Type
- PwmDisable
Request - Request to disable a PWM channel’s slice.
- PwmDuty
Cycle Info - Information about a PWM channel’s current duty cycle.
- PwmEnable
- Macro Generated Marker Type
- PwmEnable
Request - Request to enable a PWM channel’s slice.
- PwmGet
Configuration - Macro Generated Marker Type
- PwmGet
Configuration Request - Request to query the current configuration of a PWM channel’s slice.
- PwmGet
Duty Cycle - Macro Generated Marker Type
- PwmGet
Duty Cycle Request - Request to query the current duty cycle of a PWM channel.
- PwmSet
Configuration - Macro Generated Marker Type
- PwmSet
Configuration Request - Request to reconfigure the PWM slice behind a channel.
- PwmSet
Duty Cycle - Macro Generated Marker Type
- PwmSet
Duty Cycle Request - Request to set the duty cycle of a PWM channel.
- SpiBatch
- Macro Generated Marker Type
- SpiBatch
Error - Error returned when an SPI batch transaction fails.
- SpiBatch
Request - Request to execute a batch of SPI operations as a single transaction.
- SpiConfiguration
Info - Current SPI bus configuration as reported by the firmware.
- SpiFlush
- Macro Generated Marker Type
- SpiGet
Configuration - Macro Generated Marker Type
- SpiRead
- Macro Generated Marker Type
- SpiRead
Request - Request to read bytes from the SPI bus.
- SpiSet
Configuration - Macro Generated Marker Type
- SpiSet
Configuration Request - Request to reconfigure SPI bus parameters.
- SpiTransfer
- Macro Generated Marker Type
- SpiTransfer
Request - Request for a full-duplex SPI transfer.
- SpiWrite
- Macro Generated Marker Type
- SpiWrite
Request - Request to write bytes to the SPI bus.
- Uart
Configuration Info - Current UART bus configuration as reported by the firmware.
- Uart
Flush - Macro Generated Marker Type
- Uart
GetConfiguration - Macro Generated Marker Type
- Uart
Read - Macro Generated Marker Type
- Uart
Read Request - Request to read bytes from the UART bus.
- Uart
SetConfiguration - Macro Generated Marker Type
- Uart
SetConfiguration Request - Request to reconfigure UART bus parameters.
- Uart
Write - Macro Generated Marker Type
- Uart
Write Request - Request to write bytes to the UART bus.
- Version
- Macro Generated Marker Type
- 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.
- 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.
Constants§
- ADC_
NOMINAL_ REFERENCE_ MV - Nominal ADC reference voltage in millivolts.
- ADC_
RESOLUTION_ BITS - ADC resolution in bits.
- ENDPOINT_
LIST - Macro Generated Endpoint Map
- MAX_
BATCH_ OPS - This limits stack usage on the firmware side. Each operation requires a small amount of bookkeeping during execution.
- MAX_
TRANSFER_ SIZE - Maximum number of bytes the firmware can handle in a single I2C or SPI transaction. Requests exceeding this limit will be rejected by the firmware with an error.
- MICROSOFT_
VID - USB Vendor ID (Microsoft Corporation).
- NUM_
ADC_ GPIO_ CHANNELS - Number of external (GPIO-based) ADC channels exposed by the firmware.
- NUM_
PWM_ CHANNELS - Number of PWM output channels exposed by the firmware.
- PICO_
DE_ GALLO_ PID - USB Product ID assigned to Pico de Gallo.
- SCHEMA_
VERSION_ MAJOR - Schema version major — derived from the pico-de-gallo-internal crate version.
- SCHEMA_
VERSION_ MINOR - Schema version minor — derived from the pico-de-gallo-internal crate version.
- SCHEMA_
VERSION_ PATCH - Schema version patch — derived from the pico-de-gallo-internal crate version.
- TOPICS_
IN_ LIST - Macro Generated Topic Map
- TOPICS_
OUT_ LIST - Macro Generated Topic Map
Functions§
- 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.
- 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.
Type Aliases§
- AdcConfig
Error - Error returned when ADC configuration fails.
- AdcGet
Configuration Response - Response type for ADC get-configuration queries.
- AdcRead
Response - Response type for ADC read operations.
- Gpio
GetResponse - Response type for GPIO get operations.
- Gpio
PutResponse - Response type for GPIO put operations.
- Gpio
SetConfiguration Response - Response type for GPIO set-configuration operations.
- Gpio
Subscribe Response - Response type for GPIO subscribe operations.
- Gpio
Unsubscribe Response - Response type for GPIO unsubscribe operations.
- Gpio
Wait Response - Response type for GPIO wait operations.
- I2cBatch
Response - Response type for I2C batch transaction operations.
On the host (
use-std), returnsVec<u8>of concatenated read data; on firmware, returns&[u8]. - I2cConfig
Error - Error returned when I2C configuration fails.
- I2cGet
Configuration Response - Response type for I2C get-configuration queries.
- I2cRead
Response - Response type for I2C read operations.
On the host (
use-std), returnsVec<u8>; on firmware, returns&[u8]. - I2cScan
Response - Response type for I2C bus scan operations.
On the host (
use-std), returnsVec<u8>of responding addresses; on firmware, returns&[u8]. - I2cSet
Configuration Response - Response type for I2C bus configuration operations.
- I2cWrite
Read Response - Response type for I2C write-read operations.
On the host (
use-std), returnsVec<u8>; on firmware, returns&[u8]. - I2cWrite
Response - Response type for I2C write operations.
- OneWire
Read Response - Response type for 1-Wire read operations.
On the host (
use-std), returnsVec<u8>; on firmware, returns&[u8]. - OneWire
Reset Response - Response type for 1-Wire reset operations.
Returns
trueif at least one device is present on the bus. - OneWire
Search Response - Response type for 1-Wire ROM search operations.
Returns
Some(rom_id)for the next device found, orNoneif the search is complete. - OneWire
Write Pullup Response - Response type for 1-Wire write-with-pullup operations.
- OneWire
Write Response - Response type for 1-Wire write operations.
- PwmConfig
Error - Error returned when PWM configuration fails.
- PwmDisable
Response - Response type for PWM disable operations.
- PwmEnable
Response - Response type for PWM enable operations.
- PwmGet
Configuration Response - Response type for PWM get-configuration queries.
- PwmGet
Duty Cycle Response - Response type for PWM get-duty-cycle queries.
- PwmSet
Configuration Response - Response type for PWM set-configuration operations.
- PwmSet
Duty Cycle Response - Response type for PWM set-duty-cycle operations.
- SpiBatch
Response - Response type for SPI batch transaction operations.
On the host (
use-std), returnsVec<u8>of concatenated read/transfer data; on firmware, returns&[u8]. - SpiConfig
Error - Error returned when SPI configuration fails.
- SpiFlush
Response - Response type for SPI flush operations.
- SpiGet
Configuration Response - Response type for SPI get-configuration queries.
- SpiRead
Response - Response type for SPI read operations.
On the host (
use-std), returnsVec<u8>; on firmware, returns&[u8]. - SpiSet
Configuration Response - Response type for SPI bus configuration operations.
- SpiTransfer
Error - Error returned when an SPI transfer operation fails.
- SpiTransfer
Response - Response type for SPI transfer operations.
On the host (
use-std), returnsVec<u8>; on firmware, returns&[u8]. - SpiWrite
Response - Response type for SPI write operations.
- Uart
Config Error - Error returned when UART configuration fails.
- Uart
Flush Response - Response type for UART flush operations.
- Uart
GetConfiguration Response - Response type for UART get-configuration queries.
- Uart
Read Response - Response type for UART read operations.
On the host (
use-std), returnsVec<u8>; on firmware, returns&[u8]. - Uart
SetConfiguration Response - Response type for UART bus configuration operations.
- Uart
Write Response - Response type for UART write operations.