Skip to main content

AdcCalScheme

Trait AdcCalScheme 

Source
pub trait AdcCalScheme<ADCX>: Sized + Sealed {
    // Required method
    fn new_cal(atten: Attenuation) -> Result<Self, Error>;

    // Provided methods
    fn new_cal_with_channel(
        atten: Attenuation,
        _channel: u8,
    ) -> Result<Self, Error> { ... }
    fn adc_val(&self, val: u16) -> u16 { ... }
}
Expand description

A trait abstracting over calibration methods.

The methods in this trait are mostly for internal use. Call enable_pin_with_cal with an implementor of this trait to get calibrated ADC reads.

Required Methods§

Source

fn new_cal(atten: Attenuation) -> Result<Self, Error>

Creates a new calibration scheme for the given attenuation.

§Errors

Returns Error::MissingCalibrationData if the chip carries no calibration data for the scheme, or Error::UnsupportedAttenuation if the attenuation has no calibration data on this chip.

Provided Methods§

Source

fn new_cal_with_channel(atten: Attenuation, _channel: u8) -> Result<Self, Error>

Creates a new calibration scheme for the given attenuation and ADC channel.

The default implementation ignores channel and calls Self::new_cal.

§Errors

Returns Error::MissingCalibrationData if the chip carries no calibration data for the scheme, or Error::UnsupportedAttenuation if the attenuation has no calibration data on this chip.

Source

fn adc_val(&self, val: u16) -> u16

Converts ADC value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<ADCX> AdcCalScheme<ADCX> for ()

Available on crate feature unstable only.
Source§

fn new_cal(_atten: Attenuation) -> Result<Self, Error>

Implementors§

Source§

impl<ADCX> AdcCalScheme<ADCX> for AdcCalBasic<ADCX>
where ADCX: AdcCalEfuse + CalibrationAccess,

Available on crate feature unstable only.
Source§

impl<ADCX> AdcCalScheme<ADCX> for AdcCalLine<ADCX>
where ADCX: AdcCalEfuse + AdcHasLineCal + CalibrationAccess,

Available on crate feature unstable only.