diff options
| -rw-r--r-- | embassy-rp/src/adc.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/embassy-rp/src/adc.rs b/embassy-rp/src/adc.rs index 19441f194..8defb5231 100644 --- a/embassy-rp/src/adc.rs +++ b/embassy-rp/src/adc.rs | |||
| @@ -58,11 +58,21 @@ impl<'p> Channel<'p> { | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | fn channel(&self) -> u8 { | 60 | fn channel(&self) -> u8 { |
| 61 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] | ||
| 62 | const CH_OFFSET: u8 = 26; | ||
| 63 | #[cfg(feature = "rp235xb")] | ||
| 64 | const CH_OFFSET: u8 = 40; | ||
| 65 | |||
| 66 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] | ||
| 67 | const TS_CHAN: u8 = 4; | ||
| 68 | #[cfg(feature = "rp235xb")] | ||
| 69 | const TS_CHAN: u8 = 8; | ||
| 70 | |||
| 61 | match &self.0 { | 71 | match &self.0 { |
| 62 | // this requires adc pins to be sequential and matching the adc channels, | 72 | // this requires adc pins to be sequential and matching the adc channels, |
| 63 | // which is the case for rp2040 | 73 | // which is the case for rp2040/rp235xy |
| 64 | Source::Pin(p) => p._pin() - 26, | 74 | Source::Pin(p) => p._pin() - CH_OFFSET, |
| 65 | Source::TempSensor(_) => 4, | 75 | Source::TempSensor(_) => TS_CHAN, |
| 66 | } | 76 | } |
| 67 | } | 77 | } |
| 68 | } | 78 | } |
