Merge pull request #3823 from flippette/main

Correct ADC channels for RP235XB
This commit is contained in:
Dario Nieuwenhuis 2025-01-29 22:22:18 +00:00 committed by GitHub
commit 6ca31d765a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -58,11 +58,21 @@ impl<'p> Channel<'p> {
}
fn channel(&self) -> u8 {
#[cfg(any(feature = "rp2040", feature = "rp235xa"))]
const CH_OFFSET: u8 = 26;
#[cfg(feature = "rp235xb")]
const CH_OFFSET: u8 = 40;
#[cfg(any(feature = "rp2040", feature = "rp235xa"))]
const TS_CHAN: u8 = 4;
#[cfg(feature = "rp235xb")]
const TS_CHAN: u8 = 8;
match &self.0 {
// this requires adc pins to be sequential and matching the adc channels,
// which is the case for rp2040
Source::Pin(p) => p._pin() - 26,
Source::TempSensor(_) => 4,
// which is the case for rp2040/rp235xy
Source::Pin(p) => p._pin() - CH_OFFSET,
Source::TempSensor(_) => TS_CHAN,
}
}
}