A Rust library that provides access to the Raspberry Pi's GPIO, I2C, PWM, SPI and UART peripherals.
hal-unproven
feature flag (disabled by default), which enables unproven
embedded-hal
trait implementations. Note that embedded-hal
's unproven
traits don't follow semver rules. Patch releases may introduce breaking changes.Sync
trait for IoPin
and OutputPin
.unproven
embedded-hal
trait digital::InputPin
for Pin
, InputPin
, OutputPin
and IoPin
.unproven
embedded-hal
traits digital::{StatefulOutputPin, ToggleableOutputPin}
and Pwm
for OutputPin
and IoPin
.MSG_WAITING
flag from software PWM implementation to resolve an issue found in the wild causing delays in message processing (contributed by @aehmlo).hal
module, containing embedded-hal
trait implementations that aren't tied to a specific peripheral.embedded-hal
traits blocking::delay::{DelayMs, DelayUs}
for Delay
.embedded-hal
trait timer::CountDown
for Timer
(contributed by @jacobrosenthal).Display
trait for Channel
and Polarity
.unproven
embedded-hal
trait Pwm
for Pwm
.Display
trait for BitOrder
, Bus
, Mode
, Polarity
and SlaveSelect
.From<Error>
implementation due to a conflict with nb
v0.1.2 (contributed by @gferon).embedded-hal
traits serial::{Read, Write}
and blocking::serial::Write
for Uart
.timespec
fields.hal
feature (disabled by default), which includes embedded-hal
trait implementations for all supported peripherals.Gpio
example demonstrating software-based PWM.Model::__Nonexhaustive
and SoC::__Nonexhaustive
variants, indicating Model
and SoC
shouldn't be exhaustively matched. After this change, adding new variants to these enums when a new Raspberry Pi model is released won't be considered a breaking change anymore. This is a hack that can still be circumvented, but anyone that does so should be aware of the repercussions. This will be replaced once #[non_exhaustive]
stabilizes.OutputPin
and IoPin
through set_pwm()
, set_pwm_frequency()
and clear_pwm()
.is_set_low()
and is_set_high()
to OutputPin
to check the pin's output state.embedded-hal
traits OutputPin
and PwmPin
for OutputPin
and IoPin
.embedded-hal
traits Read
, Write
and WriteRead
for I2c
.reset_on_drop()
and set_reset_on_drop()
to Pwm
to optionally keep the PWM channel enabled on drop (contributed by @benkard).embedded-hal
trait PwmPin
for Pwm
.embedded-hal
traits FullDuplex
, Transfer
and Write
for Spi
.README.md
, indicating the required minimum rustc version.Gpio
, I2c
, Pwm
and Spi
examples to the examples subdirectory.Display
formatting for Error
s in all modules to include more details when available.DeviceInfo::peripheral_base()
and DeviceInfo::gpio_offset()
from the public API.Gpio
to the new InputPin
/OutputPin
structs. Access pins through Gpio::get()
(contributed by @reitermarkus).IoPin
struct which allows mode switching between input, output or an alternate function.Gpio::get()
returns an owned unconfigured Pin
, which can be used to read the pin's mode and logic level. Convert a Pin
to an InputPin
, OutputPin
or IoPin
through the various Pin::into_
methods to access additional functionality.InputPin
, OutputPin
and IoPin
for common tasks.Error::NotInitialized
, Error::UnknownMode
and Error::InvalidPin
(contributed by @reitermarkus).Error::InstanceExists
. Multiple (thread-safe) Gpio
instances can now exist simultaneously.Error::UnknownSoC
to Error::UnknownModel
for consistency.Error::PermissionDenied
to make it easier to solve file permission issues.Error::PinNotAvailable
, returned by Gpio::get()
to indicate a pin is already in use, or isn't available on the current Raspberry Pi model.clear_on_drop()
/set_clear_on_drop()
to reset_on_drop()
/set_reset_on_drop()
for clarity.Gpio::poll_interrupts()
pins
input parameter and return type from u8
to &InputPin
(contributed by @reitermarkus).reset_on_drop
is set to true.Clone
for Gpio
.Error::UnknownSoC
to Error::UnknownModel
for consistency.duty_cycle()
to pulse_width()
and set_duty_cycle()
to set_pulse_width()
to better reflect the specified value type.enabled()
to is_enabled()
for more idiomatic predicates.duty_cycle()
, set_duty_cycle()
and frequency()
convenience methods that convert between frequency/duty cycle and period/pulse width.period()
, duty_cycle()
, polarity()
and enabled()
caused by whitespace.TransferSegment
to Segment
.Segment::new()
parameters are no longer wrapped in Option
. Use Segment::with_read()
or Segment::with_write()
instead when a full-duplex transfer isn't needed.Segment::with_read()
and Segment::with_write()
convenience methods for read operations without any outgoing data, or write operations where any incoming data should be discarded.