1515extern crate cast;
1616extern crate core;
1717extern crate embedded_hal as hal;
18- #[ cfg( feature = "gpio_cdev" ) ]
19- pub extern crate gpio_cdev;
2018pub extern crate i2cdev;
21- pub extern crate nb;
22- pub extern crate serial_core;
23- pub extern crate serial_unix;
2419pub 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" ) ]
2626pub extern crate sysfs_gpio;
2727
28+ #[ cfg( feature = "gpio_cdev" ) ]
29+ pub extern crate gpio_cdev;
30+
31+
2832use std:: io:: { self , Write } ;
2933use std:: path:: { Path , PathBuf } ;
3034use std:: time:: Duration ;
@@ -37,19 +41,24 @@ use spidev::SpidevTransfer;
3741
3842mod 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
4548mod 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
4856pub use cdev_pin:: CdevPin ;
49- pub use serial:: Serial ;
5057#[ cfg( feature = "gpio_sysfs" ) ]
58+ /// Sysfs pin re-export
5159pub use sysfs_pin:: SysfsPin ;
5260
61+
5362/// Empty struct that provides delay functionality on top of `thread::sleep`
5463pub struct Delay ;
5564
@@ -107,6 +116,22 @@ impl hal::blocking::delay::DelayMs<u64> for Delay {
107116 }
108117}
109118
119+
120+ #[ cfg( all( feature = "gpio_sysfs" , feature = "gpio_cdev" ) ) ]
121+ /// Re-export of `sysfs_pin::SysfsPin` when both pin types are enabled
122+ /// This exists to maintain backwards compatibility with existing users
123+ pub type Pin = sysfs_pin:: SysfsPin ;
124+
125+ #[ cfg( all( feature = "gpio_sysfs" , not( feature = "gpio_cdev" ) ) ) ]
126+ /// Re-export of `sysfs_pin::SysfsPin` pin type when `gpio_sysfs` feature is selected
127+ pub type Pin = sysfs_pin:: SysfsPin ;
128+
129+ #[ cfg( all( feature = "gpio_cdev" , not( feature = "gpio_sysfs" ) ) ) ]
130+ /// Re-export of `cdev_pin::CdevPin` pin type when `gpio_cdev` feature is selected
131+ pub type Pin = cdev_pin:: CdevPin ;
132+
133+
134+
110135/// Newtype around [`i2cdev::linux::LinuxI2CDevice`] that implements the `embedded-hal` traits
111136///
112137/// [`i2cdev::linux::LinuxI2CDevice`]: https://docs.rs/i2cdev/0.3.1/i2cdev/linux/struct.LinuxI2CDevice.html
0 commit comments