rp2040_adc
RP2040’s single 12-bit SAR ADC.
GPIO 26 through 29 are channels 0 through 3. Channel 4 is the internal
temperature sensor. One [Rp2040Adc] owns the shared converter and claims
external GPIOs as they are first used.
Structs
Section titled “Structs”Rp2040Adc
Section titled “Rp2040Adc”struct Rp2040Adc { /* private fields */ }Exclusive owner of the shared RP2040 ADC.
Implements: Drop
AdcError
Section titled “AdcError”enum AdcError { Timeout, Conversion, PinInUse,}A conversion failure distinguishable from ownership errors.
Implements: Clone, Copy, Debug, Eq, From, PartialEq, StructuralPartialEq
Channel
Section titled “Channel”enum Channel { Gpio26, Gpio27, Gpio28, Gpio29, Temperature,}One of the RP2040 ADC inputs.
Implements: Clone, Copy, Debug, Eq, PartialEq, StructuralPartialEq
Functions
Section titled “Functions”raw_to_microvolts
Section titled “raw_to_microvolts”const fn raw_to_microvolts(raw: u16) -> u32Convert a raw count to microvolts using the nominal 3.3 V reference.
This is appropriate for the temperature formula and diagnostics. It is not calibrated voltage metrology: the reference and ADC both vary by device.
temperature_milli_celsius
Section titled “temperature_milli_celsius”const fn temperature_milli_celsius(raw: u16) -> i32Convert the internal sensor’s raw count to nominal milli-degrees Celsius.
Formula and typical constants are from the RP2040 datasheet. The sensor is not factory calibrated, so callers must treat this as an approximate chip temperature rather than an ambient-temperature measurement.