Skip to main content

Adc

Struct Adc 

Source
pub struct Adc { /* private fields */ }
Expand description

A calibrated ADC, ready to convert.

Implementations§

Source§

impl Adc

Source

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.

Source

pub fn start<PIN: Channel>(&mut self, _pin: &PIN, time: SampTime)

Triggers a conversion, blocking only until the trigger is acknowledged — not until it finishes. Pairs with listen and result for the interrupt-driven path.

Source

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.

Source

pub fn listen(&mut self, event: Event)

Lets event raise an interrupt. Unmasking the line in the NVIC is the caller’s.

Source

pub fn unlisten(&mut self, event: Event)

Stops event from raising an interrupt.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl DmaPeriph<0> for Adc

Source§

type Word = u16

The word type this peripheral transfers, fixing PWIDTH/MWIDTH.
Source§

fn addr(&self) -> u32

Address of the peripheral’s data register.
Source§

fn enable_dma(&mut self)

Lets the peripheral raise DMA requests on its channel. Read more
Source§

fn disable_dma(&mut self)

Stops the peripheral raising DMA requests. Read more
Source§

impl DmaSrc<0> for Adc

Auto Trait Implementations§

§

impl !Sync for Adc

§

impl Freeze for Adc

§

impl RefUnwindSafe for Adc

§

impl Send for Adc

§

impl Unpin for Adc

§

impl UnsafeUnpin for Adc

§

impl UnwindSafe for Adc

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.