Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
81: Add features for spi and i2c r=eldruin a=zuckschwerdt

Adds the features `i2c` and `spi` for an optional dependency on `i2cdev` and `spidev`.

Discussion in rust-embedded#80.
Closes rust-embedded#80 

Co-authored-by: Christian W. Zuckschwerdt <[email protected]>
  • Loading branch information
bors[bot] and zuckschwerdt authored Apr 6, 2022
2 parents 245b250 + ff5b588 commit 12847c4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Added

- Added feature flag for `spi` and `i2c`

## [v0.4.0-alpha.2] - 2022-02-15

### Added
Expand Down
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ edition = "2018"
gpio_sysfs = ["sysfs_gpio"]
gpio_cdev = ["gpio-cdev"]
async-tokio = ["gpio-cdev/async-tokio"]
i2c = ["i2cdev"]
spi = ["spidev"]

default = [ "gpio_cdev", "gpio_sysfs" ]
default = [ "gpio_cdev", "gpio_sysfs", "i2c", "spi" ]

[dependencies]
embedded-hal = "=1.0.0-alpha.7"
gpio-cdev = { version = "0.5.1", optional = true }
sysfs_gpio = { version = "0.6.1", optional = true }
i2cdev = "0.5.1"
i2cdev = { version = "0.5.1", optional = true }
nb = "1"
serial-core = "0.4.0"
serial-unix = "0.4.0"
spidev = "0.5.1"
spidev = { version = "0.5.1", optional = true }
nix = "0.23.1"

[dev-dependencies]
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ linux-embedded-hal = { version = "0.3", features = ["gpio_cdev"] }

`SysfsPin` can be still used with feature flag `gpio_sysfs`.

With `default-features = false` you can enable the features `gpio_cdev`, `gpio_sysfs`, `i2c`, and `spi` as needed.

## Minimum Supported Rust Version (MSRV)

This crate is guaranteed to compile on stable Rust 1.46.0 and up. It *might*
Expand Down
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@

#![deny(missing_docs)]

#[cfg(feature = "i2c")]
pub use i2cdev;
pub use nb;
pub use serial_core;
pub use serial_unix;
#[cfg(feature = "spi")]
pub use spidev;

#[cfg(feature = "gpio_sysfs")]
Expand All @@ -40,13 +42,17 @@ pub use cdev_pin::CdevPin;
pub use sysfs_pin::SysfsPin;

mod delay;
#[cfg(feature = "i2c")]
mod i2c;
mod serial;
#[cfg(feature = "spi")]
mod spi;
mod timer;

pub use crate::delay::Delay;
#[cfg(feature = "i2c")]
pub use crate::i2c::{I2CError, I2cdev};
pub use crate::serial::{Serial, SerialError};
#[cfg(feature = "spi")]
pub use crate::spi::{SPIError, Spidev};
pub use crate::timer::{CountDown, Periodic, SysTimer};

0 comments on commit 12847c4

Please sign in to comment.