Skip to main content

RxChannelDriver

Struct RxChannelDriver 

Source
pub struct RxChannelDriver<'d> { /* private fields */ }

Implementations§

Source§

impl<'d> RxChannelDriver<'d>

Source

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 argument
  • ESP_ERR_NO_MEM: Create RMT RX channel failed because out of memory
  • ESP_ERR_NOT_FOUND: Create RMT RX channel failed because all RMT channels are used up and no more free one
  • ESP_ERR_NOT_SUPPORTED: Create RMT RX channel failed because some feature is not supported by hardware, e.g. DMA feature is not supported by hardware
  • ESP_FAIL: Create RMT RX channel failed because of other error
Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn unsubscribe(&mut self)

Remove the ISR handler for when a transmission is done.

Trait Implementations§

Source§

impl<'d> Debug for RxChannelDriver<'d>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'d> Drop for RxChannelDriver<'d>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'d> RmtChannel for RxChannelDriver<'d>

Source§

fn handle(&self) -> rmt_channel_handle_t

Returns the underlying rmt_channel_handle_t.
Source§

fn is_enabled(&self) -> bool

Returns whether the channel is currently enabled.
Source§

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

Must be called in advance before transmitting or receiving RMT symbols. For TX channels, enabling a channel enables a specific interrupt and prepares the hardware to dispatch transactions. Read more
Source§

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

Disables the interrupt and clearing any pending interrupts. The transmitter and receiver are disabled as well. Read more
Source§

fn apply_carrier( &mut self, carrier_config: Option<&CarrierConfig>, ) -> Result<(), EspError>

Apply (de)modulation feature for the channel. Read more

Auto Trait Implementations§

§

impl<'d> Freeze for RxChannelDriver<'d>

§

impl<'d> !RefUnwindSafe for RxChannelDriver<'d>

§

impl<'d> !Send for RxChannelDriver<'d>

§

impl<'d> !Sync for RxChannelDriver<'d>

§

impl<'d> Unpin for RxChannelDriver<'d>

§

impl<'d> UnsafeUnpin for RxChannelDriver<'d>

§

impl<'d> !UnwindSafe for RxChannelDriver<'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.