Skip to content

Commit

Permalink
Correct ADC channels for RP2350XB
Browse files Browse the repository at this point in the history
  • Loading branch information
flippette committed Jan 29, 2025
1 parent f6532e8 commit c58f631
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions embassy-rp/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,23 @@ 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,
Source::Pin(p) => p._pin() - CH_OFFSET,
Source::TempSensor(_) => TS_CHAN,
}
}
}
Expand Down

0 comments on commit c58f631

Please sign in to comment.