diff options
author | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-07 20:20:16 +0100 |
---|---|---|
committer | Diego Barrios Romero <eldruin@gmail.com> | 2018-11-07 20:20:16 +0100 |
commit | 41325641f087f6e01e31d7d5bd741becf0154e77 (patch) | |
tree | f659bdece14efa0a8d501b9ddc970944dd50ebdd /src | |
parent | 28b16cc364cc4f4112aca2195df389ea6f007048 (diff) | |
download | ads1x1x-async-41325641f087f6e01e31d7d5bd741becf0154e77.tar.gz ads1x1x-async-41325641f087f6e01e31d7d5bd741becf0154e77.tar.xz ads1x1x-async-41325641f087f6e01e31d7d5bd741becf0154e77.zip |
Implement ADC channel traits
Diffstat (limited to 'src')
-rw-r--r-- | src/devices/channels.rs | 32 | ||||
-rw-r--r-- | src/devices/mod.rs | 2 |
2 files changed, 34 insertions, 0 deletions
diff --git a/src/devices/channels.rs b/src/devices/channels.rs new file mode 100644 index 0000000..35ad643 --- /dev/null +++ b/src/devices/channels.rs @@ -0,0 +1,32 @@ +//! ADC input channels +use { Ads1x1x, ic, hal }; + +/// ADC input channels +#[allow(dead_code)] +pub mod channel { + /// ADC input channel 0 + pub struct A0; + /// ADC input channel 1 + pub struct A1; + /// ADC input channel 2 + pub struct A2; + /// ADC input channel 3 + pub struct A3; +} + +macro_rules! impl_channel { + ( $IC:ident, $CH:ident, $ID:expr ) => { + impl<DI, MODE> hal::adc::Channel<Ads1x1x<DI, ic::$IC, MODE>> for channel::$CH { + type ID = u8; + + fn channel() -> Self::ID { + $ID + } + } + } +} + +impl_channel!(Ads1013, A0, 0); +impl_channel!(Ads1013, A1, 1); +impl_channel!(Ads1113, A0, 0); +impl_channel!(Ads1113, A1, 1); diff --git a/src/devices/mod.rs b/src/devices/mod.rs index e35196c..3bcc3fa 100644 --- a/src/devices/mod.rs +++ b/src/devices/mod.rs @@ -4,3 +4,5 @@ use super::private; pub mod ic; mod ads1x1x; mod construction; +mod channels; +pub use self::channels::channel; |