Skip to content

Commit ee56d1e

Browse files
committed
Make ADC Channel::channel() a constant and update MSRV to 1.35
1 parent 5bc0f0c commit ee56d1e

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
- All traits have been marked as proven (`unproven` feature has been removed).
1515
- All trait methods have been made fallible.
1616
- All trait methods have been renamed `try_*` (i.e. `try_send`) for consistency.
17+
- The minimum supported Rust version is 1.35 due to [this issue](https://github.com/rust-lang/rust/issues/54973).
1718

1819
## [v0.2.3] - 2019-05-09
1920

src/adc.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/// ```
3737
pub 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

Comments
 (0)