Skip to content

Commit 71e5903

Browse files
authored
Try #34:
2 parents c921d3f + ca7b29f commit 71e5903

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Set default features to build both sysfs and cdev pin types
13+
- Removed `Pin` export, use `CdevPin` or `SysfsPin`
14+
1015
## [v0.3.0] - 2019-11-25
1116

1217
### Added

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ repository = "https://github.com/japaric/linux-embedded-hal"
99
version = "0.3.0"
1010

1111
[features]
12-
default = []
1312
gpio_sysfs = ["sysfs_gpio"]
1413
gpio_cdev = ["gpio-cdev"]
1514

15+
default = [ "gpio_cdev", "gpio_sysfs" ]
16+
1617
[dependencies]
1718
embedded-hal = { version = "0.2.3", features = ["unproven"] }
1819
gpio-cdev = { version = "0.2", optional = true }

src/cdev_pin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use core::ops;
1+
//! Linux CDev pin type
22
33
/// Newtype around [`gpio_cdev::LineHandle`] that implements the `embedded-hal` traits
44
///
@@ -43,15 +43,15 @@ impl hal::digital::v2::InputPin for CdevPin {
4343
}
4444
}
4545

46-
impl ops::Deref for CdevPin {
46+
impl core::ops::Deref for CdevPin {
4747
type Target = gpio_cdev::LineHandle;
4848

4949
fn deref(&self) -> &Self::Target {
5050
&self.0
5151
}
5252
}
5353

54-
impl ops::DerefMut for CdevPin {
54+
impl core::ops::DerefMut for CdevPin {
5555
fn deref_mut(&mut self) -> &mut Self::Target {
5656
&mut self.0
5757
}

src/lib.rs

+19-9
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
extern crate cast;
1616
extern crate core;
1717
extern crate embedded_hal as hal;
18-
#[cfg(feature = "gpio_cdev")]
19-
pub extern crate gpio_cdev;
2018
pub extern crate i2cdev;
21-
pub extern crate nb;
22-
pub extern crate serial_core;
23-
pub extern crate serial_unix;
2419
pub extern crate spidev;
20+
pub extern crate serial_unix;
21+
pub extern crate serial_core;
22+
pub extern crate nb;
23+
24+
2525
#[cfg(feature = "gpio_sysfs")]
2626
pub extern crate sysfs_gpio;
2727

28+
#[cfg(feature = "gpio_cdev")]
29+
pub extern crate gpio_cdev;
30+
31+
2832
use std::io::{self, Write};
2933
use std::path::{Path, PathBuf};
3034
use std::time::Duration;
@@ -37,19 +41,24 @@ use spidev::SpidevTransfer;
3741

3842
mod serial;
3943

40-
#[cfg(feature = "gpio_cdev")]
41-
/// Cdev Pin wrapper module
42-
mod cdev_pin;
44+
pub use serial::Serial;
45+
4346
#[cfg(feature = "gpio_sysfs")]
4447
/// Sysfs Pin wrapper module
4548
mod sysfs_pin;
4649

4750
#[cfg(feature = "gpio_cdev")]
51+
/// Cdev Pin wrapper module
52+
mod cdev_pin;
53+
54+
#[cfg(feature = "gpio_cdev")]
55+
/// Cdev pin re-export
4856
pub use cdev_pin::CdevPin;
49-
pub use serial::Serial;
5057
#[cfg(feature = "gpio_sysfs")]
58+
/// Sysfs pin re-export
5159
pub use sysfs_pin::SysfsPin;
5260

61+
5362
/// Empty struct that provides delay functionality on top of `thread::sleep`
5463
pub struct Delay;
5564

@@ -107,6 +116,7 @@ impl hal::blocking::delay::DelayMs<u64> for Delay {
107116
}
108117
}
109118

119+
110120
/// Newtype around [`i2cdev::linux::LinuxI2CDevice`] that implements the `embedded-hal` traits
111121
///
112122
/// [`i2cdev::linux::LinuxI2CDevice`]: https://docs.rs/i2cdev/0.3.1/i2cdev/linux/struct.LinuxI2CDevice.html

src/sysfs_pin.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
use std::ops;
1+
//! Linux Sysfs pin type
2+
23
use std::path::Path;
34

45
/// Newtype around [`sysfs_gpio::Pin`] that implements the `embedded-hal` traits
@@ -53,15 +54,15 @@ impl hal::digital::v2::InputPin for SysfsPin {
5354
}
5455
}
5556

56-
impl ops::Deref for SysfsPin {
57+
impl core::ops::Deref for SysfsPin {
5758
type Target = sysfs_gpio::Pin;
5859

5960
fn deref(&self) -> &Self::Target {
6061
&self.0
6162
}
6263
}
6364

64-
impl ops::DerefMut for SysfsPin {
65+
impl core::ops::DerefMut for SysfsPin {
6566
fn deref_mut(&mut self) -> &mut Self::Target {
6667
&mut self.0
6768
}

0 commit comments

Comments
 (0)