Skip to main content

Capture

Struct Capture 

Source
pub struct Capture<TIMERX> { /* private fields */ }
Expand description

A free running timer whose channels timestamp edges on their pins.

The counter is only a time base: it runs to u16::MAX and wraps, while each channel latches the count when its edge arrives. Intervals are differences between latched values, so this role carries no period of its own.

Implementations§

Source§

impl<TIMERX: Instance> Capture<TIMERX>

Source

pub fn channel<PIN, const C: u8>( &mut self, pin: PIN, edge: Edge, ) -> CaptureChannel<TIMERX, PIN, C>
where PIN: ChannelPin<TIMERX, C>, TIMERX: CaptureOps<C>,

Points one channel of this timer at the given pin and hands it out.

Which channel it is follows from the pin, as in Pwm::channel. The channel comes out configured but not enabled, latches nothing until it is, and holds the pin until release_channel takes it back. The edge is set here; select_edge changes it later.

Source

pub fn release_channel<PIN, const C: u8>( &mut self, channel: CaptureChannel<TIMERX, PIN, C>, ) -> PIN
where PIN: ChannelPin<TIMERX, C>, TIMERX: CaptureOps<C>,

Takes a channel back, disabled and no longer listening, and returns its pin.

Source

pub fn listen(&mut self, event: Event)

Lets event raise an interrupt.

The time base’s own event, shared by every channel. Update is what extends the range here: the counter is only 16 bits wide, so an interval longer than one cycle needs the rollovers counted alongside the timestamps — interval sees the latched values alone and cannot know how many cycles passed between them. Captures raise their own event, through CaptureChannel::listen. Unmasking the line in the NVIC is the caller’s.

Source

pub fn unlisten(&mut self, event: Event)

Stops event from raising an interrupt. Leaves the NVIC alone.

Source

pub fn is_listening(&self, event: Event) -> bool

Whether event reaches the NVIC.

Source

pub fn is_pending(&self, event: Event) -> bool

Whether the flag event raises is standing.

Source

pub fn clear_interrupt(&mut self, event: Event)

Clears the flag event raised, which hardware never does on its own.

Source

pub fn into_timer(self) -> Timer<TIMERX>

Halts the counter, stops listening and takes the timer back out of capture duty.

§Panics

If a channel is still out — hand each one back through release_channel first.

Source

pub fn release(self, rcu: &mut Rcu) -> TIMERX

Halts the counter and returns the peripheral with its clock stopped, skipping the stopped form.

§Panics

As for into_timer.

Source

pub fn try_release(self, rcu: &mut Rcu) -> Result<TIMERX, Self>

Same as release, but hands self back instead of panicking.

§Errors

Returns self untouched while a channel is still out.

Auto Trait Implementations§

§

impl<TIMERX> Freeze for Capture<TIMERX>
where TIMERX: Freeze,

§

impl<TIMERX> RefUnwindSafe for Capture<TIMERX>
where TIMERX: RefUnwindSafe,

§

impl<TIMERX> Send for Capture<TIMERX>
where TIMERX: Send,

§

impl<TIMERX> Sync for Capture<TIMERX>
where TIMERX: Sync,

§

impl<TIMERX> Unpin for Capture<TIMERX>
where TIMERX: Unpin,

§

impl<TIMERX> UnsafeUnpin for Capture<TIMERX>
where TIMERX: UnsafeUnpin,

§

impl<TIMERX> UnwindSafe for Capture<TIMERX>
where TIMERX: UnwindSafe,

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.