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>
impl<T: Instance, M: Mode> AnalogWatchdog<T, M>
Sourcepub fn is_triggered(&mut self) -> bool
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>
impl<T: Instance> AnalogWatchdog<T, Async>
Sourcepub async fn wait(&mut self)
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.
Sourcepub async fn monitor<'a>(
&mut self,
_adc: &mut Adc<'_, T, Async>,
channel: impl BorrowedChannel<'a, T>,
sample_time: SampleTimeOf<T>,
) -> u16
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.