Expand description
embedded-hal and
embedded-hal-async implementations
backed by a Pico de Gallo USB bridge.
This crate lets you run embedded Rust drivers on a host machine by forwarding I2C, SPI, GPIO, PWM, ADC, 1-Wire, and delay operations to a Pico de Gallo device over USB.
§Quick Start
use pico_de_gallo_hal::Hal;
use embedded_hal::i2c::I2c;
let hal = Hal::new();
let mut i2c = hal.i2c();
// Read 2 bytes from a TMP102 temperature sensor
let mut buf = [0u8; 2];
i2c.write_read(0x48, &[0x00], &mut buf).unwrap();§Blocking vs. Async
Both embedded-hal (blocking) and embedded-hal-async traits are
implemented. The HAL automatically detects whether it is running inside a
tokio runtime and adjusts its execution strategy:
- Inside tokio: Uses
tokio::task::block_in_placeto avoid blocking the async executor while waiting for USB responses. - Outside tokio: Blocks directly on the tokio handle.
This means the same Hal instance works in both synchronous test code
and async application code.
§Implemented Traits
Structs§
- Delay
- Delay provider using host-side timers.
- Gpio
- GPIO pin handle implementing [
embedded-hal] digital traits. - Gpio
Event - A GPIO event notification published by the firmware.
- Hal
- Top-level HAL context for a Pico de Gallo device.
- I2c
- I2C bus handle implementing [
embedded-hal] I2C traits. - OneWire
- 1-Wire bus handle backed by PIO hardware on the firmware.
- PwmChannel
- A single PWM channel on the Pico de Gallo board.
- Spi
- SPI bus handle implementing [
embedded-hal] SPI traits. - SpiConfiguration
Info - Current SPI bus configuration as reported by the firmware.
- SpiDev
- SPI device handle implementing [
embedded-hal]SpiDevicetraits. - Uart
- UART handle implementing [
embedded-io] traits. - Uart
Configuration Info - Current UART bus configuration as reported by the firmware.
Enums§
- AdcHal
Error - Error type for ADC HAL operations.
- Gpio
HalError - Error type for GPIO HAL operations.
- I2cFrequency
- I2C bus clock frequency.
- I2cHal
Error - Error type for I2C HAL operations.
- OneWire
HalError - Error type for 1-Wire HAL operations.
- PwmHal
Error - Error type for PWM HAL operations.
- SpiHal
Error - Error type for SPI HAL operations.
- SpiPhase
- SPI clock phase setting.
- SpiPolarity
- SPI clock polarity setting.
- Uart
HalError - Error type for UART HAL operations.