embassy-stm32

Crates

git

Versions

stm32u599ni

Flavors

AnalogWatchdog

Struct AnalogWatchdog 

Source
pub struct AnalogWatchdog<T: Instance<Regs = Adc4>> { /* private fields */ }
Expand description

A driver for an ADC analog watchdog.

Created by Adc::enable_watchdog. Does not borrow the Adc — you may hold this guard while performing DMA or other ADC operations concurrently and call Self::wait to detect when a monitored channel leaves the threshold window.

For self-contained single-pin monitoring that drives its own continuous conversion, use Self::monitor, which temporarily borrows the Adc.

Dropping the guard disables the watchdog and its interrupt.

Implementations§

Source§

impl<T: Instance<Regs = Adc4>> AnalogWatchdog<T>

Source

pub async fn wait(&mut self)

Wait for the watchdog to trigger.

The watchdog is configured in Adc::enable_watchdog.

This method assumes conversions are already being performed externally (for example by DMA or another task running concurrently). For typical single-pin monitoring driven entirely by the watchdog driver, prefer Self::monitor.

Source

pub async fn monitor( &mut self, _adc: &mut Adc<'_, T>, channel: &mut impl AdcChannel<T>, sample_time: SampleTime, ) -> u16

Continuously convert channel and return the first result that trips the analog watchdog.

Thresholds and watchdog channel selection are configured in Adc::enable_watchdog. When using WatchdogChannels::Single, pass the same physical channel here.

For AWD2/AWD3 with a WatchdogChannels::Channels bitmask, pass any one of the monitored channels here; the watchdog will fire when any of them leaves the threshold window.

This method takes exclusive access to the Adc for the duration of the operation because it stops any in-progress conversion and starts its own. For concurrent use with DMA, use Self::wait instead.

§Cancel safety

If this future is dropped before it resolves, the ongoing continuous conversion is stopped and continuous mode is cleared when the AnalogWatchdog guard is dropped.

Trait Implementations§

Source§

impl<T: Instance<Regs = Adc4>> Drop for AnalogWatchdog<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for AnalogWatchdog<T>

§

impl<T> RefUnwindSafe for AnalogWatchdog<T>
where T: RefUnwindSafe,

§

impl<T> Send for AnalogWatchdog<T>
where T: Send,

§

impl<T> Sync for AnalogWatchdog<T>
where T: Sync,

§

impl<T> Unpin for AnalogWatchdog<T>
where T: Unpin,

§

impl<T> UnwindSafe for AnalogWatchdog<T>
where T: UnwindSafe,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.