diff --git a/CHANGELOG.md b/CHANGELOG.md index be0fee6..10d342e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed + +- Set default features to build both sysfs and cdev pin types +- Removed `Pin` export, use `CdevPin` or `SysfsPin` + ## [v0.3.0] - 2019-11-25 ### Added diff --git a/Cargo.toml b/Cargo.toml index 080a254..e04376e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,10 +9,11 @@ repository = "https://github.com/japaric/linux-embedded-hal" version = "0.3.0" [features] -default = [] gpio_sysfs = ["sysfs_gpio"] gpio_cdev = ["gpio-cdev"] +default = [ "gpio_cdev", "gpio_sysfs" ] + [dependencies] embedded-hal = { version = "0.2.3", features = ["unproven"] } gpio-cdev = { version = "0.2", optional = true } diff --git a/src/cdev_pin.rs b/src/cdev_pin.rs index 69e27bb..22a4cd1 100644 --- a/src/cdev_pin.rs +++ b/src/cdev_pin.rs @@ -1,4 +1,4 @@ -use core::ops; +//! Linux CDev pin type /// Newtype around [`gpio_cdev::LineHandle`] that implements the `embedded-hal` traits /// @@ -43,7 +43,7 @@ impl hal::digital::v2::InputPin for CdevPin { } } -impl ops::Deref for CdevPin { +impl core::ops::Deref for CdevPin { type Target = gpio_cdev::LineHandle; fn deref(&self) -> &Self::Target { @@ -51,7 +51,7 @@ impl ops::Deref for CdevPin { } } -impl ops::DerefMut for CdevPin { +impl core::ops::DerefMut for CdevPin { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } diff --git a/src/lib.rs b/src/lib.rs index f5e55a9..0d9cffa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,16 +15,20 @@ extern crate cast; extern crate core; extern crate embedded_hal as hal; -#[cfg(feature = "gpio_cdev")] -pub extern crate gpio_cdev; pub extern crate i2cdev; -pub extern crate nb; -pub extern crate serial_core; -pub extern crate serial_unix; pub extern crate spidev; +pub extern crate serial_unix; +pub extern crate serial_core; +pub extern crate nb; + + #[cfg(feature = "gpio_sysfs")] pub extern crate sysfs_gpio; +#[cfg(feature = "gpio_cdev")] +pub extern crate gpio_cdev; + + use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::time::Duration; @@ -37,19 +41,24 @@ use spidev::SpidevTransfer; mod serial; -#[cfg(feature = "gpio_cdev")] -/// Cdev Pin wrapper module -mod cdev_pin; +pub use serial::Serial; + #[cfg(feature = "gpio_sysfs")] /// Sysfs Pin wrapper module mod sysfs_pin; #[cfg(feature = "gpio_cdev")] +/// Cdev Pin wrapper module +mod cdev_pin; + +#[cfg(feature = "gpio_cdev")] +/// Cdev pin re-export pub use cdev_pin::CdevPin; -pub use serial::Serial; #[cfg(feature = "gpio_sysfs")] +/// Sysfs pin re-export pub use sysfs_pin::SysfsPin; + /// Empty struct that provides delay functionality on top of `thread::sleep` pub struct Delay; @@ -107,6 +116,7 @@ impl hal::blocking::delay::DelayMs for Delay { } } + /// Newtype around [`i2cdev::linux::LinuxI2CDevice`] that implements the `embedded-hal` traits /// /// [`i2cdev::linux::LinuxI2CDevice`]: https://docs.rs/i2cdev/0.3.1/i2cdev/linux/struct.LinuxI2CDevice.html diff --git a/src/sysfs_pin.rs b/src/sysfs_pin.rs index cfb4638..8e0597d 100644 --- a/src/sysfs_pin.rs +++ b/src/sysfs_pin.rs @@ -1,4 +1,5 @@ -use std::ops; +//! Linux Sysfs pin type + use std::path::Path; /// Newtype around [`sysfs_gpio::Pin`] that implements the `embedded-hal` traits @@ -53,7 +54,7 @@ impl hal::digital::v2::InputPin for SysfsPin { } } -impl ops::Deref for SysfsPin { +impl core::ops::Deref for SysfsPin { type Target = sysfs_gpio::Pin; fn deref(&self) -> &Self::Target { @@ -61,7 +62,7 @@ impl ops::Deref for SysfsPin { } } -impl ops::DerefMut for SysfsPin { +impl core::ops::DerefMut for SysfsPin { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }