Skip to main content

Crate pico_de_gallo_internal

Crate pico_de_gallo_internal 

Source
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 — Enables Vec<u8> response types for the host side. Without this feature (the default for firmware), responses use borrowed &[u8] slices.

§Crate Organization

Structs§

AdcConfigurationInfo
Current ADC configuration as reported by the firmware.
AdcGetConfiguration
Macro Generated Marker Type
AdcRead
Macro Generated Marker Type
AdcReadRequest
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.
DeviceInfo
Extended device information including firmware version, schema version, hardware version, and peripheral capabilities.
GetDeviceInfo
Macro Generated Marker Type
GpioEvent
A GPIO event notification published by the firmware.
GpioEventTopic
$tp_name - A Topic definition type
GpioGet
Macro Generated Marker Type
GpioGetRequest
Request to read the current level of a GPIO pin.
GpioPut
Macro Generated Marker Type
GpioPutRequest
Request to set a GPIO pin to a specific level.
GpioSetConfiguration
Macro Generated Marker Type
GpioSetConfigurationRequest
Request to configure a GPIO pin’s direction and pull resistor.
GpioSubscribe
Macro Generated Marker Type
GpioSubscribeRequest
Request to subscribe a GPIO pin to edge-event monitoring.
GpioUnsubscribe
Macro Generated Marker Type
GpioUnsubscribeRequest
Request to unsubscribe a GPIO pin from edge-event monitoring.
GpioWaitForAny
Macro Generated Marker Type
GpioWaitForFalling
Macro Generated Marker Type
GpioWaitForHigh
Macro Generated Marker Type
GpioWaitForLow
Macro Generated Marker Type
GpioWaitForRising
Macro Generated Marker Type
GpioWaitRequest
Request to wait for a GPIO pin to reach a specific state or edge.
I2cBatch
Macro Generated Marker Type
I2cBatchError
Error returned when an I2C batch transaction fails.
I2cBatchRequest
Request to execute a batch of I2C operations as a single transaction.
I2cGetConfiguration
Macro Generated Marker Type
I2cRead
Macro Generated Marker Type
I2cReadRequest
Request to read bytes from an I2C device.
I2cScan
Macro Generated Marker Type
I2cScanRequest
Request to scan the I2C bus for responding devices.
I2cSetConfiguration
Macro Generated Marker Type
I2cSetConfigurationRequest
Request to reconfigure I2C bus parameters.
I2cWrite
Macro Generated Marker Type
I2cWriteRead
Macro Generated Marker Type
I2cWriteReadRequest
Request to write bytes to an I2C device, then read back.
I2cWriteRequest
Request to write bytes to an I2C device.
OneWireRead
Macro Generated Marker Type
OneWireReadRequest
Request to read bytes from the 1-Wire bus.
OneWireReset
Macro Generated Marker Type
OneWireSearch
Macro Generated Marker Type
OneWireSearchNext
Macro Generated Marker Type
OneWireWrite
Macro Generated Marker Type
OneWireWritePullup
Macro Generated Marker Type
OneWireWritePullupRequest
Request to write bytes to the 1-Wire bus with strong pullup.
OneWireWriteRequest
Request to write bytes to the 1-Wire bus.
PingEndpoint
Macro Generated Marker Type
PwmConfigurationInfo
Current PWM slice configuration as reported by the firmware.
PwmDisable
Macro Generated Marker Type
PwmDisableRequest
Request to disable a PWM channel’s slice.
PwmDutyCycleInfo
Information about a PWM channel’s current duty cycle.
PwmEnable
Macro Generated Marker Type
PwmEnableRequest
Request to enable a PWM channel’s slice.
PwmGetConfiguration
Macro Generated Marker Type
PwmGetConfigurationRequest
Request to query the current configuration of a PWM channel’s slice.
PwmGetDutyCycle
Macro Generated Marker Type
PwmGetDutyCycleRequest
Request to query the current duty cycle of a PWM channel.
PwmSetConfiguration
Macro Generated Marker Type
PwmSetConfigurationRequest
Request to reconfigure the PWM slice behind a channel.
PwmSetDutyCycle
Macro Generated Marker Type
PwmSetDutyCycleRequest
Request to set the duty cycle of a PWM channel.
SpiBatch
Macro Generated Marker Type
SpiBatchError
Error returned when an SPI batch transaction fails.
SpiBatchRequest
Request to execute a batch of SPI operations as a single transaction.
SpiConfigurationInfo
Current SPI bus configuration as reported by the firmware.
SpiFlush
Macro Generated Marker Type
SpiGetConfiguration
Macro Generated Marker Type
SpiRead
Macro Generated Marker Type
SpiReadRequest
Request to read bytes from the SPI bus.
SpiSetConfiguration
Macro Generated Marker Type
SpiSetConfigurationRequest
Request to reconfigure SPI bus parameters.
SpiTransfer
Macro Generated Marker Type
SpiTransferRequest
Request for a full-duplex SPI transfer.
SpiWrite
Macro Generated Marker Type
SpiWriteRequest
Request to write bytes to the SPI bus.
UartConfigurationInfo
Current UART bus configuration as reported by the firmware.
UartFlush
Macro Generated Marker Type
UartGetConfiguration
Macro Generated Marker Type
UartRead
Macro Generated Marker Type
UartReadRequest
Request to read bytes from the UART bus.
UartSetConfiguration
Macro Generated Marker Type
UartSetConfigurationRequest
Request to reconfigure UART bus parameters.
UartWrite
Macro Generated Marker Type
UartWriteRequest
Request to write bytes to the UART bus.
Version
Macro Generated Marker Type
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.
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.

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§

AdcConfigError
Error returned when ADC configuration fails.
AdcGetConfigurationResponse
Response type for ADC get-configuration queries.
AdcReadResponse
Response type for ADC read operations.
GpioGetResponse
Response type for GPIO get operations.
GpioPutResponse
Response type for GPIO put operations.
GpioSetConfigurationResponse
Response type for GPIO set-configuration operations.
GpioSubscribeResponse
Response type for GPIO subscribe operations.
GpioUnsubscribeResponse
Response type for GPIO unsubscribe operations.
GpioWaitResponse
Response type for GPIO wait operations.
I2cBatchResponse
Response type for I2C batch transaction operations. On the host (use-std), returns Vec<u8> of concatenated read data; on firmware, returns &[u8].
I2cConfigError
Error returned when I2C configuration fails.
I2cGetConfigurationResponse
Response type for I2C get-configuration queries.
I2cReadResponse
Response type for I2C read operations. On the host (use-std), returns Vec<u8>; on firmware, returns &[u8].
I2cScanResponse
Response type for I2C bus scan operations. On the host (use-std), returns Vec<u8> of responding addresses; on firmware, returns &[u8].
I2cSetConfigurationResponse
Response type for I2C bus configuration operations.
I2cWriteReadResponse
Response type for I2C write-read operations. On the host (use-std), returns Vec<u8>; on firmware, returns &[u8].
I2cWriteResponse
Response type for I2C write operations.
OneWireReadResponse
Response type for 1-Wire read operations. On the host (use-std), returns Vec<u8>; on firmware, returns &[u8].
OneWireResetResponse
Response type for 1-Wire reset operations. Returns true if at least one device is present on the bus.
OneWireSearchResponse
Response type for 1-Wire ROM search operations. Returns Some(rom_id) for the next device found, or None if the search is complete.
OneWireWritePullupResponse
Response type for 1-Wire write-with-pullup operations.
OneWireWriteResponse
Response type for 1-Wire write operations.
PwmConfigError
Error returned when PWM configuration fails.
PwmDisableResponse
Response type for PWM disable operations.
PwmEnableResponse
Response type for PWM enable operations.
PwmGetConfigurationResponse
Response type for PWM get-configuration queries.
PwmGetDutyCycleResponse
Response type for PWM get-duty-cycle queries.
PwmSetConfigurationResponse
Response type for PWM set-configuration operations.
PwmSetDutyCycleResponse
Response type for PWM set-duty-cycle operations.
SpiBatchResponse
Response type for SPI batch transaction operations. On the host (use-std), returns Vec<u8> of concatenated read/transfer data; on firmware, returns &[u8].
SpiConfigError
Error returned when SPI configuration fails.
SpiFlushResponse
Response type for SPI flush operations.
SpiGetConfigurationResponse
Response type for SPI get-configuration queries.
SpiReadResponse
Response type for SPI read operations. On the host (use-std), returns Vec<u8>; on firmware, returns &[u8].
SpiSetConfigurationResponse
Response type for SPI bus configuration operations.
SpiTransferError
Error returned when an SPI transfer operation fails.
SpiTransferResponse
Response type for SPI transfer operations. On the host (use-std), returns Vec<u8>; on firmware, returns &[u8].
SpiWriteResponse
Response type for SPI write operations.
UartConfigError
Error returned when UART configuration fails.
UartFlushResponse
Response type for UART flush operations.
UartGetConfigurationResponse
Response type for UART get-configuration queries.
UartReadResponse
Response type for UART read operations. On the host (use-std), returns Vec<u8>; on firmware, returns &[u8].
UartSetConfigurationResponse
Response type for UART bus configuration operations.
UartWriteResponse
Response type for UART write operations.