pub struct Qdec<'d> { /* private fields */ }Expand description
Quadrature decoder driver.
Implementations§
Source§impl<'d> Qdec<'d>
impl<'d> Qdec<'d>
Sourcepub fn new<T: Instance>(
qdec: Peri<'d, T>,
a: Peri<'d, impl GpioPin>,
b: Peri<'d, impl GpioPin>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
config: Config,
) -> Self
pub fn new<T: Instance>( qdec: Peri<'d, T>, a: Peri<'d, impl GpioPin>, b: Peri<'d, impl GpioPin>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, config: Config, ) -> Self
Create a new QDEC.
Sourcepub fn new_with_led<T: Instance>(
qdec: Peri<'d, T>,
a: Peri<'d, impl GpioPin>,
b: Peri<'d, impl GpioPin>,
led: Peri<'d, impl GpioPin>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
config: Config,
) -> Self
pub fn new_with_led<T: Instance>( qdec: Peri<'d, T>, a: Peri<'d, impl GpioPin>, b: Peri<'d, impl GpioPin>, led: Peri<'d, impl GpioPin>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, config: Config, ) -> Self
Create a new QDEC, with a pin for LED output.
Sourcepub async fn read(&mut self) -> i16
pub async fn read(&mut self) -> i16
Perform an asynchronous read of the decoder. The returned future can be awaited to obtain the number of steps accumulated since the previous read.
This method is cancel-safe: if the future is dropped before it completes, no counts are lost; they stay in the accumulator and are returned by the next read.
§Example
use embassy_nrf::qdec::{self, Qdec};
use embassy_nrf::{bind_interrupts, peripherals};
bind_interrupts!(struct Irqs {
QDEC => qdec::InterruptHandler<peripherals::QDEC>;
});
let config = qdec::Config::default();
let mut q = Qdec::new(p.QDEC, p.P0_31, p.P0_30, Irqs, config);
let delta = q.read().await;Auto Trait Implementations§
impl<'d> !RefUnwindSafe for Qdec<'d>
impl<'d> !UnwindSafe for Qdec<'d>
impl<'d> Freeze for Qdec<'d>
impl<'d> Send for Qdec<'d>
impl<'d> Sync for Qdec<'d>
impl<'d> Unpin for Qdec<'d>
impl<'d> UnsafeUnpin for Qdec<'d>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more