embassy-stm32

Crates

git

Versions

stm32c011d6

Flavors

Skip to main content

AnalogWatchdog

Struct AnalogWatchdog 

Source
pub struct AnalogWatchdog<T: Instance, M: Mode> { /* 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, M: Mode> AnalogWatchdog<T, M>

Source

pub fn is_triggered(&mut self) -> bool

Whether the watchdog has fired since the last call (or since it was enabled). Clears the flag.

Source§

impl<T: Instance> AnalogWatchdog<T, Async>

Source

pub async fn wait(&mut self)

Wait for the watchdog to trigger.

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<'a>( &mut self, _adc: &mut Adc<'_, T, Async>, channel: impl BorrowedChannel<'a, T>, sample_time: SampleTimeOf<T>, ) -> 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.

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 when the AnalogWatchdog guard is dropped.

Trait Implementations§

Source§

impl<T: Instance, M: Mode> Drop for AnalogWatchdog<T, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl<T, M> Freeze for AnalogWatchdog<T, M>

§

impl<T, M> RefUnwindSafe for AnalogWatchdog<T, M>

§

impl<T, M> Send for AnalogWatchdog<T, M>

§

impl<T, M> Sync for AnalogWatchdog<T, M>

§

impl<T, M> Unpin for AnalogWatchdog<T, M>

§

impl<T, M> UnsafeUnpin for AnalogWatchdog<T, M>

§

impl<T, M> UnwindSafe for AnalogWatchdog<T, M>

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, <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.