pub struct TxRmtDriver<'d> { /* private fields */ }
Expand description

The RMT transmitter driver.

Use TxRmtDriver::start() or TxRmtDriver::start_blocking() to transmit pulses.

See the rmt module for more information.

Implementations§

source§

impl<'d> TxRmtDriver<'d>

source

pub fn new<C: RmtChannel>( _channel: impl Peripheral<P = C> + 'd, pin: impl Peripheral<P = impl OutputPin> + 'd, config: &TransmitConfig ) -> Result<Self, EspError>

Initialise the rmt module with the specified pin, channel and configuration.

To uninstall the driver just drop it.

Internally this calls rmt_config() and rmt_driver_install().

source

pub fn counter_clock(&self) -> Result<Hertz, EspError>

Get speed of the channel’s internal counter clock.

This calls rmt_get_counter_clock() internally. It is used for calculating the number of ticks per second for pulses.

See Pulse::new_with_duration().

source

pub fn start<S>(&mut self, signal: S) -> Result<(), EspError>
where S: Signal,

Start sending the given signal without blocking.

signal is captured for safety so that the user can’t change the data while transmitting.

source

pub fn start_blocking<S>(&mut self, signal: &S) -> Result<(), EspError>
where S: Signal + ?Sized,

Start sending the given signal while blocking.

source

pub fn start_iter<T>(&mut self, iter: T) -> Result<(), EspError>
where T: Iterator<Item = Symbol> + Send + 'static,

Transmit all items in iter without blocking.

Note that this requires iter to be [Box]ed for an allocation free version see Self::start_iter_blocking.

§Warning

Iteration of iter happens inside an interrupt handler so beware of side-effects that don’t work in interrupt handlers. Iteration must also be fast so that there are no time-gaps between successive transmissions where the perhipheral has to wait for items. This can cause weird behavior and can be counteracted with increasing [Config::mem_block_num] or making iteration more efficient.

source

pub fn start_iter_blocking<T>(&mut self, iter: T) -> Result<(), EspError>
where T: Iterator<Item = Symbol> + Send,

Transmit all items in iter, blocking until all items are transmitted.

This method does not require any allocations since the thread is paused until all items are transmitted. The iterator lives on the stack and will be dropped after all items are written and before this method returns.

§Warning

Iteration of iter happens inside an interrupt handler so beware of side-effects that don’t work in interrupt handlers. Iteration must also be fast so that there are no time-gaps between successive transmissions where the perhipheral has to wait for items. This can cause weird behavior and can be counteracted with increasing [Config::mem_block_num] or making iteration more efficient.

source

pub fn stop(&mut self) -> Result<(), EspError>

Stop transmitting.

source

pub fn set_looping(&mut self, looping: Loop) -> Result<(), EspError>

source

pub fn channel(&self) -> rmt_channel_t

Trait Implementations§

source§

impl<'d> Drop for TxRmtDriver<'d>

source§

fn drop(&mut self)

Stop transmitting and release the driver.

source§

impl<'d> Send for TxRmtDriver<'d>

Auto Trait Implementations§

§

impl<'d> RefUnwindSafe for TxRmtDriver<'d>

§

impl<'d> Sync for TxRmtDriver<'d>

§

impl<'d> Unpin for TxRmtDriver<'d>

§

impl<'d> !UnwindSafe for TxRmtDriver<'d>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.