Struct esp32c3_hal::twai::Twai
source · pub struct Twai<'d, T> { /* private fields */ }
Expand description
An active TWAI peripheral in Normal Mode.
In this mode, the TWAI controller can transmit and receive messages including error signals (such as error and overload frames).
Implementations§
source§impl<'d, T> Twai<'d, T>where
T: Instance,
impl<'d, T> Twai<'d, T>where T: Instance,
sourcepub fn stop(self) -> TwaiConfiguration<'d, T>
pub fn stop(self) -> TwaiConfiguration<'d, T>
Stop the peripheral, putting it into reset mode and enabling reconfiguration.
pub fn receive_error_count(&self) -> u8
pub fn transmit_error_count(&self) -> u8
sourcepub fn is_bus_off(&self) -> bool
pub fn is_bus_off(&self) -> bool
Check if the controller is in a bus off state.
sourcepub fn num_available_messages(&self) -> u8
pub fn num_available_messages(&self) -> u8
Get the number of messages that the peripheral has available in the receive FIFO.
Note that this may not be the number of valid messages in the receive FIFO due to fifo overflow/overrun.
sourcepub fn clear_receive_fifo(&self)
pub fn clear_receive_fifo(&self)
Clear the receive FIFO, discarding any valid, partial, or invalid packets.
This is typically used to clear an overrun receive FIFO.
TODO: Not sure if this needs to be guarded against Bus Off or other error states.
Trait Implementations§
source§impl<T> Can for Twai<'_, T>where
T: Instance,
impl<T> Can for Twai<'_, T>where T: Instance,
source§fn transmit(
&mut self,
frame: &<Twai<'_, T> as Can>::Frame
) -> Result<Option<<Twai<'_, T> as Can>::Frame>, Error<<Twai<'_, T> as Can>::Error>>
fn transmit( &mut self, frame: &<Twai<'_, T> as Can>::Frame ) -> Result<Option<<Twai<'_, T> as Can>::Frame>, Error<<Twai<'_, T> as Can>::Error>>
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.
source§fn receive(
&mut self
) -> Result<<Twai<'_, T> as Can>::Frame, Error<<Twai<'_, T> as Can>::Error>>
fn receive( &mut self ) -> Result<<Twai<'_, T> as Can>::Frame, Error<<Twai<'_, T> as Can>::Error>>
Return a received frame if there are any available.