embassy-stm32

Crates

git

Versions

stm32u545ne

Flavors

Comp

Struct Comp 

Source
pub struct Comp<'d, T: Instance> { /* private fields */ }
Expand description

Comparator driver.

Implementations§

Source§

impl<'d, T: Instance> Comp<'d, T>

Source

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.

Source

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.

Source

pub fn enable(&mut self)

Enable the comparator.

Source

pub fn disable(&mut self)

Disable the comparator.

Source

pub fn is_enabled(&self) -> bool

Check if the comparator is enabled.

Source

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

Source

pub fn set_blanking_source(&mut self, source: BlankingSource)

Set the blanking source.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'d, T: Instance> Drop for Comp<'d, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'d, T> Freeze for Comp<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for Comp<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for Comp<'d, T>
where T: Send,

§

impl<'d, T> Sync for Comp<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for Comp<'d, T>
where T: Unpin,

§

impl<'d, T> !UnwindSafe for Comp<'d, T>

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.