pub struct RxChannelDriver<'d> { /* private fields */ }Implementations§
Source§impl<'d> RxChannelDriver<'d>
impl<'d> RxChannelDriver<'d>
Sourcepub fn new(
pin: impl InputPin + 'd,
config: &RxChannelConfig,
) -> Result<Self, EspError>
pub fn new( pin: impl InputPin + 'd, config: &RxChannelConfig, ) -> Result<Self, EspError>
Creates a new RMT RX channel.
§Errors
ESP_ERR_INVALID_ARG: Create RMT RX channel failed because of invalid argumentESP_ERR_NO_MEM: Create RMT RX channel failed because out of memoryESP_ERR_NOT_FOUND: Create RMT RX channel failed because all RMT channels are used up and no more free oneESP_ERR_NOT_SUPPORTED: Create RMT RX channel failed because some feature is not supported by hardware, e.g. DMA feature is not supported by hardwareESP_FAIL: Create RMT RX channel failed because of other error
Sourcepub const fn has_finished(&self) -> bool
pub const fn has_finished(&self) -> bool
Returns whether the last receive operation has finished.
If a timeout happend before the receive finished, this will return false
and the data can be obtained on the next call to Self::receive.
For partial receives, this will return false, until all parts have been received.
If this function returns true, the next call to Self::receive
will start a new receive operation.
Sourcepub fn receive(
&mut self,
buffer: &mut [Symbol],
config: &ReceiveConfig,
) -> Result<usize, EspError>
pub fn receive( &mut self, buffer: &mut [Symbol], config: &ReceiveConfig, ) -> Result<usize, EspError>
Receives RMT symbols into the provided buffer, returning the number of received symbols.
This function will wait until the ISR signals that it has received data. After that, it copies the data from the internal buffer to the user-provided buffer and returns the number of received symbols.
§Timeouts
A timeout can be specified in the ReceiveConfig::timeout field. If a timeout happens,
it will return an error with the EspError::code ESP_ERR_TIMEOUT.
If the data arrives after the timeout, it can be obtained on the next call to this function.
§Partial Receives
If partial receives are enabled (see ReceiveConfig::enable_partial_rx), subsequent
calls to this function will only start a new receive after all parts have been received.
The driver will continue to write data into the internal buffer after this function returns. It is important that this function is called without much delay, to not miss any data.
One can check whether a partial receive has finished with Self::has_finished.
Sourcepub async fn receive_async(
&mut self,
buffer: &mut [Symbol],
config: &ReceiveConfig,
) -> Result<usize, EspError>
pub async fn receive_async( &mut self, buffer: &mut [Symbol], config: &ReceiveConfig, ) -> Result<usize, EspError>
Receives RMT symbols into the provided buffer, returning the number of received symbols.
For more details, see RxChannelDriver::receive.
§Cancel Safety
If the future is cancelled before completion, the received data can be obtained on the next call to this function. Make sure that the buffer provided on the next call is large enough to hold the data.
Sourcepub unsafe fn subscribe(
&mut self,
on_recv_done: impl FnMut(RxDoneEventData) + Send + 'static,
)
pub unsafe fn subscribe( &mut self, on_recv_done: impl FnMut(RxDoneEventData) + Send + 'static, )
Subscribe to the ISR handler to get notified when a receive operation is done.
There is only one callback possible, you can not subscribe multiple callbacks.
§Panics
This function will panic if called from an ISR context or while the channel is enabled.
§Safety
Care should be taken not to call std, libc or FreeRTOS APIs (except for a few allowed ones) in the callback passed to this function, as it is executed in an ISR context.
You are not allowed to block, but you are allowed to call FreeRTOS APIs with the FromISR suffix.
Sourcepub fn unsubscribe(&mut self)
pub fn unsubscribe(&mut self)
Remove the ISR handler for when a transmission is done.
Trait Implementations§
Source§impl<'d> Debug for RxChannelDriver<'d>
impl<'d> Debug for RxChannelDriver<'d>
Source§impl<'d> Drop for RxChannelDriver<'d>
impl<'d> Drop for RxChannelDriver<'d>
Source§impl<'d> RmtChannel for RxChannelDriver<'d>
impl<'d> RmtChannel for RxChannelDriver<'d>
Source§fn handle(&self) -> rmt_channel_handle_t
fn handle(&self) -> rmt_channel_handle_t
rmt_channel_handle_t.