From 41325641f087f6e01e31d7d5bd741becf0154e77 Mon Sep 17 00:00:00 2001 From: Diego Barrios Romero Date: Wed, 7 Nov 2018 20:20:16 +0100 Subject: Implement ADC channel traits --- src/devices/channels.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/devices/channels.rs (limited to 'src/devices/channels.rs') 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 hal::adc::Channel> 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); -- cgit v1.2.3-54-g00ecf