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>
impl<T: Instance<Regs = Adc4>> AnalogWatchdog<T>
Sourcepub async fn wait(&mut self)
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.
Sourcepub async fn monitor(
&mut self,
_adc: &mut Adc<'_, T>,
channel: &mut impl AdcChannel<T>,
sample_time: SampleTime,
) -> u16
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.