@@ -20,7 +20,7 @@ use nb;
20
20
/// impl Channel<Adc1> for Gpio1Pin1<Analog> {
21
21
/// type ID = u8; // ADC channels are identified numerically
22
22
///
23
- /// fn channel() -> u8 { 7_u8 } // GPIO pin 1 is connected to ADC channel 7
23
+ /// const CHANNEL: u8 = 7_u8; // GPIO pin 1 is connected to ADC channel 7
24
24
/// }
25
25
///
26
26
/// struct Adc2; // ADC with two banks of 16 channels
@@ -31,7 +31,7 @@ use nb;
31
31
/// impl Channel<Adc2> for Gpio2PinA<AltFun> {
32
32
/// type ID = (u8, u8); // ADC channels are identified by bank number and channel number
33
33
///
34
- /// fn channel() -> (u8, u8) { (0, 3) } // bank 0 channel 3
34
+ /// const CHANNEL: (u8, u8) = (0, 3); // bank 0 channel 3
35
35
/// }
36
36
/// ```
37
37
pub trait Channel < ADC > {
@@ -44,12 +44,7 @@ pub trait Channel<ADC> {
44
44
45
45
/// Get the specific ID that identifies this channel, for example `0_u8` for the first ADC
46
46
/// channel, if Self::ID is u8.
47
- fn channel ( ) -> Self :: ID ;
48
-
49
- // `channel` is a function due to [this reported
50
- // issue](https://github.com/rust-lang/rust/issues/54973). Something about blanket impls
51
- // combined with `type ID; const CHANNEL: Self::ID;` causes problems.
52
- //const CHANNEL: Self::ID;
47
+ const CHANNEL : Self :: ID ;
53
48
}
54
49
55
50
/// ADCs that sample on single channels per request, and do so at the time of the request.
@@ -75,7 +70,7 @@ pub trait Channel<ADC> {
75
70
/// type Error = ();
76
71
///
77
72
/// fn try_read(&mut self, _pin: &mut PIN) -> nb::Result<WORD, Self::Error> {
78
- /// let chan = 1 << PIN::channel() ;
73
+ /// let chan = 1 << PIN::CHANNEL ;
79
74
/// self.power_up();
80
75
/// let result = self.do_conversion(chan);
81
76
/// self.power_down();
0 commit comments