Expand description
C-compatible FFI bindings for the Pico de Gallo USB bridge.
This crate wraps pico-de-gallo-lib in
a C-compatible API using opaque pointers and integer status codes. It is
compiled as a cdylib (shared library) and generates a C header via
cbindgen.
§Usage from C
#include "pico_de_gallo.h"
const PicoDeGallo *gallo = gallo_init();
uint32_t id = 42;
Status status = gallo_ping(gallo, &id);
// id now contains the round-tripped value
gallo_free(gallo);§Lifecycle
- Call
gallo_init(orgallo_init_with_serial_number) to create a context. - Use
gallo_*functions, passing the context pointer. - Call
gallo_freeto release resources.
§Thread Safety
The context pointer is safe to share across threads — the inner type is
Send + Sync (enforced by a compile-time assertion). Each function call
creates its own async executor via futures::executor::block_on, so
concurrent calls from multiple threads are safe.
§Status Codes
All functions return a Status code. Status::Ok (0) indicates success;
negative values indicate errors. See Status for the full list.
Structs§
- Gallo
Device Info - C-compatible device information struct.
- Pico
DeGallo - Opaque handle to a Pico de Gallo device context.
Enums§
- Status
- Status codes returned by all FFI functions.
Constants§
- GALLO_
CAP_ ADC - ADC input support (bit 5).
- GALLO_
CAP_ GPIO - GPIO support (bit 3).
- GALLO_
CAP_ I2C - I2C bus support (bit 0).
- GALLO_
CAP_ ONEWIRE - 1-Wire bus support (bit 6).
- GALLO_
CAP_ PWM - PWM output support (bit 4).
- GALLO_
CAP_ SPI - SPI bus support (bit 1).
- GALLO_
CAP_ UART - UART support (bit 2).
Functions§
- gallo_
adc_ ⚠get_ config - gallo_adc_get_config - Query the ADC configuration.
- gallo_
adc_ ⚠read - gallo_adc_read - Perform a single-shot ADC read.
- gallo_
free ⚠ - gallo_free - Releases and destroys the library context created by
gallo_init. - gallo_
get_ ⚠device_ info - gallo_get_device_info - Gets extended device information.
- gallo_
gpio_ ⚠get - gallo_gpio_get - Get the state of a given GPIO pin.
- gallo_
gpio_ ⚠put - gallo_gpio_put - Set the state of a given GPIO pin.
- gallo_
gpio_ ⚠set_ config - gallo_gpio_set_config - Configure a GPIO pin’s direction and pull resistor.
- gallo_
gpio_ ⚠subscribe - gallo_gpio_subscribe - Subscribe to GPIO edge events on a pin.
- gallo_
gpio_ ⚠unsubscribe - gallo_gpio_unsubscribe - Unsubscribe from GPIO edge events on a pin.
- gallo_
gpio_ ⚠wait_ for_ any_ edge - gallo_gpio_wait_for_any_edge - Waits for a any edge on a given GPIO pin.
- gallo_
gpio_ ⚠wait_ for_ falling_ edge - gallo_gpio_wait_for_falling_edge - Waits for a falling edge on a given GPIO pin.
- gallo_
gpio_ ⚠wait_ for_ high - gallo_gpio_wait_for_high - Waits for a high level on a given GPIO pin.
- gallo_
gpio_ ⚠wait_ for_ low - gallo_gpio_wait_for_low - Waits for a low level on a given GPIO pin.
- gallo_
gpio_ ⚠wait_ for_ rising_ edge - gallo_gpio_wait_for_rising_edge - Waits for a rising edge on a given GPIO pin.
- gallo_
i2c_ ⚠get_ config - gallo_i2c_get_config - Queries the current I2C bus configuration.
- gallo_
i2c_ ⚠read - gallo_i2c_read - Read
lenbytes from the device ataddressintobuf. - gallo_
i2c_ ⚠scan - gallo_i2c_scan - Scan the I2C bus for responding devices.
- gallo_
i2c_ ⚠set_ config - gallo_i2c_set_config - Sets the I2C bus configuration parameters.
- gallo_
i2c_ ⚠write - gallo_i2c_write - Write
lenbytes frombufto the device ataddress. - gallo_
i2c_ ⚠write_ read - gallo_i2c_write_read - Perform a write followed by a read.
- gallo_
init - gallo_init - Initialize the library context.
- gallo_
init_ ⚠with_ serial_ number - gallo_init_with_serial_number - Initialize the library context for a device with the given serial number.
- gallo_
onewire_ ⚠read - gallo_onewire_read - Read bytes from the 1-Wire bus.
- gallo_
onewire_ ⚠reset - gallo_onewire_reset - Perform a 1-Wire bus reset.
- gallo_
onewire_ ⚠search - gallo_onewire_search - Search for all devices on the 1-Wire bus.
- gallo_
onewire_ ⚠write - gallo_onewire_write - Write raw bytes to the 1-Wire bus.
- gallo_
onewire_ ⚠write_ pullup - gallo_onewire_write_pullup - Write bytes then apply a strong pullup.
- gallo_
ping ⚠ - gallo_ping - Ping the firmware and wait for a response
- gallo_
pwm_ ⚠disable - gallo_pwm_disable - Disable the PWM slice that owns the given channel.
- gallo_
pwm_ ⚠enable - gallo_pwm_enable - Enable the PWM slice that owns the given channel.
- gallo_
pwm_ ⚠get_ config - gallo_pwm_get_config - Query the current PWM configuration.
- gallo_
pwm_ ⚠get_ duty_ cycle - gallo_pwm_get_duty_cycle - Query the current duty cycle of a PWM channel.
- gallo_
pwm_ ⚠set_ config - gallo_pwm_set_config - Configure the PWM slice behind a channel.
- gallo_
pwm_ ⚠set_ duty_ cycle - gallo_pwm_set_duty_cycle - Set the raw duty cycle of a PWM channel.
- gallo_
spi_ ⚠flush - gallo_spi_flush - Flush the SPI interface.
- gallo_
spi_ ⚠get_ config - gallo_spi_get_config - Queries the current SPI bus configuration.
- gallo_
spi_ ⚠read - gallo_spi_read - Read
lenbytes. - gallo_
spi_ ⚠set_ config - gallo_spi_set_config - Sets the SPI bus configuration parameters.
- gallo_
spi_ ⚠write - gallo_spi_write - Write
lenbytes frombuf. - gallo_
uart_ ⚠flush - gallo_uart_flush - Flush the UART transmit buffer.
- gallo_
uart_ ⚠get_ config - gallo_uart_get_config - Query the current UART configuration.
- gallo_
uart_ ⚠read - gallo_uart_read - Read bytes from the UART bus.
- gallo_
uart_ ⚠set_ config - gallo_uart_set_config - Set the UART baud rate.
- gallo_
uart_ ⚠write - gallo_uart_write - Write bytes to the UART bus.
- gallo_
version ⚠ - gallo_version - Gets the firmware version.