Struct esp_idf_hal::rmt::TxRmtDriver
source · 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>
impl<'d> TxRmtDriver<'d>
sourcepub fn new<C: RmtChannel>(
_channel: impl Peripheral<P = C> + 'd,
pin: impl Peripheral<P = impl OutputPin> + 'd,
config: &TransmitConfig,
) -> Result<Self, EspError>
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()
.
sourcepub fn counter_clock(&self) -> Result<Hertz, EspError>
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.
sourcepub fn start<S>(&mut self, signal: S) -> Result<(), EspError>where
S: Signal,
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.
sourcepub fn start_blocking<S>(&mut self, signal: &S) -> Result<(), EspError>where
S: Signal + ?Sized,
pub fn start_blocking<S>(&mut self, signal: &S) -> Result<(), EspError>where
S: Signal + ?Sized,
Start sending the given signal while blocking.
sourcepub fn start_iter<T>(&mut self, iter: T) -> Result<(), EspError>where
T: Iterator<Item = Symbol> + Send + 'static,
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.
sourcepub fn start_iter_blocking<T>(&mut self, iter: T) -> Result<(), EspError>where
T: Iterator<Item = Symbol> + Send,
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.