Skip to main content

TwaiTx

Struct TwaiTx 

Source
pub struct TwaiTx<'d, Dm: DriverMode> { /* private fields */ }
Expand description

Interface to the TWAI transmitter part.

Implementations§

Source§

impl TwaiTx<'_, Async>

Source

pub async fn transmit_async( &mut self, frame: &EspTwaiFrame, ) -> Result<(), EspTwaiError>

Transmits an EspTwaiFrame asynchronously over the TWAI bus.

The transmission is aborted if the future is dropped. The technical reference manual does not specifiy if aborting the transmission also stops it, in case it is actively transmitting. Therefor it could be the case that even though the future is dropped, the frame was sent anyways.

If the bus cannot carry the frame (e.g. no other node acknowledges it), the transmission is aborted once the peripheral enters the error-passive or bus-off state and the future resolves to EspTwaiError::TransmissionAborted or EspTwaiError::BusOff, respectively.

Source§

impl<Dm> TwaiTx<'_, Dm>
where Dm: DriverMode,

Source

pub fn transmit(&mut self, frame: &EspTwaiFrame) -> Result<(), EspTwaiError>

Transmit a frame.

Because of how the TWAI registers are set up, we have to do some assembly of bytes. Note that these registers serve a filter configuration role when the device is in configuration mode so patching the svd files to improve this may be non-trivial.

ESP32C3 Reference Manual

NOTE: TODO: This may not work if using the self reception/self test functionality. See notes 1 and 2 in the “Frame Identifier” section of the reference manual.

If a previous frame is still pending and the peripheral has entered the error-passive state because of it (the bus cannot carry the frame, e.g. no other node acknowledges it), the pending transmission is aborted and EspTwaiError::TransmissionAborted is returned. An unacknowledged transmitter’s error counter does not increase past the error-passive threshold, so without giving up the transmission would be retried forever.

Auto Trait Implementations§

§

impl<'d, Dm> Freeze for TwaiTx<'d, Dm>

§

impl<'d, Dm> RefUnwindSafe for TwaiTx<'d, Dm>
where Dm: RefUnwindSafe,

§

impl<'d, Dm> Send for TwaiTx<'d, Dm>
where Dm: Send,

§

impl<'d, Dm> Sync for TwaiTx<'d, Dm>
where Dm: Sync,

§

impl<'d, Dm> Unpin for TwaiTx<'d, Dm>
where Dm: Unpin,

§

impl<'d, Dm> UnsafeUnpin for TwaiTx<'d, Dm>

§

impl<'d, Dm> !UnwindSafe for TwaiTx<'d, Dm>

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.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

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.