pub struct TwaiTx<'d, Dm: DriverMode> { /* private fields */ }Expand description
Interface to the TWAI transmitter part.
Implementations§
Source§impl TwaiTx<'_, Async>
impl TwaiTx<'_, Async>
Sourcepub async fn transmit_async(
&mut self,
frame: &EspTwaiFrame,
) -> Result<(), EspTwaiError>
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,
impl<Dm> TwaiTx<'_, Dm>where
Dm: DriverMode,
Sourcepub fn transmit(&mut self, frame: &EspTwaiFrame) -> Result<(), EspTwaiError>
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.
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.