pub struct Comp<'d, T: Instance> { /* private fields */ }Expand description
Comparator driver.
Implementations§
Source§impl<'d, T: Instance> Comp<'d, T>
impl<'d, T: Instance> Comp<'d, T>
Sourcepub fn new(
peri: Peri<'d, T>,
inp: Peri<'_, impl InputPlusPin<T> + Pin>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>>,
config: Config,
) -> Self
pub fn new( peri: Peri<'d, T>, inp: Peri<'_, impl InputPlusPin<T> + Pin>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>>, config: Config, ) -> Self
Create a new comparator driver.
The comparator is configured but not enabled. Use enable to enable it.
The non-inverting input is connected to the provided pin. The inverting input
is configured via the config.inverting_input parameter.
Sourcepub fn new_with_input_minus_pin(
peri: Peri<'d, T>,
inp: Peri<'_, impl InputPlusPin<T> + Pin>,
inm: Peri<'_, impl InputMinusPin<T> + Pin>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>>,
config: Config,
) -> Self
pub fn new_with_input_minus_pin( peri: Peri<'d, T>, inp: Peri<'_, impl InputPlusPin<T> + Pin>, inm: Peri<'_, impl InputMinusPin<T> + Pin>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>>, config: Config, ) -> Self
Create a new comparator driver with an external inverting input pin.
The comparator is configured but not enabled. Use enable to enable it.
Both non-inverting and inverting inputs are connected to the provided pins.
The config.inverting_input parameter is ignored; the pin determines the input.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the comparator is enabled.
Sourcepub fn output_level(&self) -> bool
pub fn output_level(&self) -> bool
Get the current output level.
Returns true if the non-inverting input is higher than the inverting input
(or the opposite if polarity is inverted).
Sourcepub fn set_blanking_source(&mut self, source: BlankingSource)
pub fn set_blanking_source(&mut self, source: BlankingSource)
Set the blanking source.
Sourcepub async fn wait_for_high(&mut self)
pub async fn wait_for_high(&mut self)
Wait for the comparator output to go high.
This method enables the comparator if it’s not already enabled, then waits asynchronously for the output to transition high. If the output is already high, it returns immediately.
Sourcepub async fn wait_for_low(&mut self)
pub async fn wait_for_low(&mut self)
Wait for the comparator output to go low.
This method enables the comparator if it’s not already enabled, then waits asynchronously for the output to transition low. If the output is already low, it returns immediately.
Sourcepub async fn wait_for_rising_edge(&mut self)
pub async fn wait_for_rising_edge(&mut self)
Wait for a rising edge on the comparator output.
This method waits asynchronously for the output to transition from low to high.
Sourcepub async fn wait_for_falling_edge(&mut self)
pub async fn wait_for_falling_edge(&mut self)
Wait for a falling edge on the comparator output.
This method waits asynchronously for the output to transition from high to low.
Sourcepub async fn wait_for_any_edge(&mut self)
pub async fn wait_for_any_edge(&mut self)
Wait for any edge (rising or falling) on the comparator output.
This method waits asynchronously for any output transition.