summaryrefslogtreecommitdiffstats
path: root/src/devices/channels.rs
blob: 35ad6432edd8e9f6a89ae4f54779adae9d9782ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);