|
3 | 3 | #[cfg(feature = "unproven")]
|
4 | 4 | use nb;
|
5 | 5 |
|
6 |
| -// TODO Channel should be made generic over ADCs, but cannot due to [this reported |
7 |
| -// issue](https://github.com/rust-lang/rust/issues/54973). Something about blanket impls combined |
8 |
| -// with `type ID; const CHANNEL: Self::ID;` causes problems. So, for now, Channel can only be |
9 |
| -// impl'd once for a given pin. |
10 |
| - |
11 | 6 | /// A marker trait to identify MCU pins that can be used as inputs to an ADC channel.
|
12 | 7 | ///
|
13 | 8 | /// This marker trait denotes an object, i.e. a GPIO pin, that is ready for use as an input to the
|
@@ -41,16 +36,22 @@ use nb;
|
41 | 36 | /// }
|
42 | 37 | /// ```
|
43 | 38 | #[cfg(feature = "unproven")]
|
44 |
| -pub trait Channel { |
| 39 | +pub trait Channel<ADC> { |
45 | 40 | /// Channel ID type
|
46 | 41 | ///
|
47 | 42 | /// A type used to identify this ADC channel. For example, if the ADC has eight channels, this
|
48 | 43 | /// might be a `u8`. If the ADC has multiple banks of channels, it could be a tuple, like
|
49 | 44 | /// `(u8: bank_id, u8: channel_id)`.
|
50 | 45 | type ID;
|
51 | 46 |
|
52 |
| - /// The specific ID that identifies this channel, for example `0` for the first ADC channel. |
53 |
| - const CHANNEL: Self::ID; |
| 47 | + /// Get the specific ID that identifies this channel, for example `0_u8` for the first ADC |
| 48 | + /// channel, if Self::ID is u8. |
| 49 | + fn channel() -> Self::ID; |
| 50 | + |
| 51 | + // `channel` is a function due to [this reported |
| 52 | + // issue](https://github.com/rust-lang/rust/issues/54973). Something about blanket impls |
| 53 | + // combined with `type ID; const CHANNEL: Self::ID;` causes problems. |
| 54 | + //const CHANNEL: Self::ID; |
54 | 55 | }
|
55 | 56 |
|
56 | 57 | /// ADCs that sample on single channels per request, and do so at the time of the request.
|
@@ -85,7 +86,7 @@ pub trait Channel {
|
85 | 86 | /// }
|
86 | 87 | /// ```
|
87 | 88 | #[cfg(feature = "unproven")]
|
88 |
| -pub trait OneShot<ADC, Word, Pin: Channel> { |
| 89 | +pub trait OneShot<ADC, Word, Pin: Channel<ADC>> { |
89 | 90 | /// Error type returned by ADC methods
|
90 | 91 | type Error;
|
91 | 92 |
|
|
0 commit comments