pub struct Adc { /* private fields */ }Expand description
A calibrated ADC, ready to convert.
Implementations§
Source§impl Adc
impl Adc
Sourcepub fn release(self, rcu: &mut Rcu) -> Adc
pub fn release(self, rcu: &mut Rcu) -> Adc
Returns the peripheral, powered down, with its interrupt off and its clock stopped. A conversion still running is abandoned.
Sourcepub fn result(&mut self) -> u16
pub fn result(&mut self) -> u16
Reads the conversion result out of RDATA, clearing EOC.
Does not check EOC itself — call this once notified of it (an Eoc
handler after listen), not on a guess.
Sourcepub fn listen(&mut self, event: Event)
pub fn listen(&mut self, event: Event)
Lets event raise an interrupt. Unmasking the line in the NVIC is the
caller’s.
Sourcepub fn read<PIN: Channel>(&mut self, _pin: &PIN, time: SampTime) -> u16
pub fn read<PIN: Channel>(&mut self, _pin: &PIN, time: SampTime) -> u16
Converts one channel and returns the raw 12-bit code (0..=4095).
The pin is borrowed only to identify the channel — nothing is read from the value itself. Blocks until the conversion finishes.
Sourcepub fn read_temperature(&mut self) -> Option<i32>
pub fn read_temperature(&mut self) -> Option<i32>
Reads the internal temperature sensor, in tenths of a degree Celsius.
Scaled against the real supply from read_vref.
Returns None when CK_ADC runs too fast for the sensor’s minimum
sampling time: SampTime is counted in cycles, so above roughly 14
MHz even the longest no longer spans the required 17.1 µs.
Sourcepub fn read_vref(&mut self) -> i32
pub fn read_vref(&mut self) -> i32
Measures the actual analog supply voltage VDDA, in millivolts.
The internal reference is fixed, so its raw code moves only because VDDA
— the ADC’s own reference — moved; comparing it against the factory
calibration in flash gives the real supply.
If that calibration is blank (0xFFFF, seen on some parts), falls back to
the typical VREFINT of ~1.2 V: less accurate, but not wildly wrong.