@@ -20,7 +20,7 @@ use nb;
2020/// impl Channel<Adc1> for Gpio1Pin1<Analog> {
2121/// type ID = u8; // ADC channels are identified numerically
2222///
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
2424/// }
2525///
2626/// struct Adc2; // ADC with two banks of 16 channels
@@ -31,7 +31,7 @@ use nb;
3131/// impl Channel<Adc2> for Gpio2PinA<AltFun> {
3232/// type ID = (u8, u8); // ADC channels are identified by bank number and channel number
3333///
34- /// fn channel() -> (u8, u8) { (0, 3) } // bank 0 channel 3
34+ /// const CHANNEL: (u8, u8) = (0, 3); // bank 0 channel 3
3535/// }
3636/// ```
3737pub trait Channel < ADC > {
@@ -44,12 +44,7 @@ pub trait Channel<ADC> {
4444
4545 /// Get the specific ID that identifies this channel, for example `0_u8` for the first ADC
4646 /// 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 ;
5348}
5449
5550/// 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> {
7570/// type Error = ();
7671///
7772/// 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 ;
7974/// self.power_up();
8075/// let result = self.do_conversion(chan);
8176/// self.power_down();
0 commit comments