Struct FdCan

Source
pub struct FdCan<I: Instance, MODE> { /* private fields */ }
Expand description

Interface to a FdCAN peripheral.

Implementations§

Source§

impl<I, MODE> FdCan<I, MODE>
where I: Instance,

Source

pub fn instance(&mut self) -> &mut I

Returns a reference to the peripheral instance.

This allows accessing HAL-specific data stored in the instance type.

Source

pub fn get_config(&self) -> FdCanConfig

Returns the current FDCAN config settings

Source

pub fn enable_interrupt_line(&mut self, line: InterruptLine, enabled: bool)

Enable/Disable the specific Interrupt Line

Source

pub fn enable_interrupt(&mut self, interrupt: Interrupt)

Starts listening for a CAN interrupt.

Source

pub fn enable_interrupts(&mut self, interrupts: Interrupts)

Starts listening for a set of CAN interrupts.

Source

pub fn disable_interrupt(&mut self, interrupt: Interrupt)

Stops listening for a CAN interrupt.

Source

pub fn disable_interrupts(&mut self, interrupts: Interrupts)

Stops listening for a set of CAN interrupts.

Source

pub fn error_counters(&self) -> ErrorCounters

Retrieve the CAN error counters

Source

pub fn set_standard_filter( &mut self, slot: StandardFilterSlot, filter: StandardFilter, )

Set an Standard Address CAN filter into slot ‘id’

Source

pub fn set_standard_filters(&mut self, filters: &[StandardFilter; 28])

Set an array of Standard Address CAN filters and overwrite the current set

Source

pub fn set_extended_filter( &mut self, slot: ExtendedFilterSlot, filter: ExtendedFilter, )

Set an Extended Address CAN filter into slot ‘id’

Source

pub fn set_extended_filters(&mut self, filters: &[ExtendedFilter; 8])

Set an array of Extended Address CAN filters and overwrite the current set

Source

pub fn get_protocol_status(&self) -> ProtocolStatus

Retrieve the current protocol status

Source

pub fn has_interrupt(&mut self, interrupt: Interrupt) -> bool

Check if the interrupt is triggered

Source

pub fn clear_interrupt(&mut self, interrupt: Interrupt)

Clear specified interrupt

Source

pub fn clear_interrupts(&mut self, interrupts: Interrupts)

Clear specified interrupts

Source

pub fn combine( t: (FdCanControl<I, MODE>, Tx<I, MODE>, Rx<I, MODE, Fifo0>, Rx<I, MODE, Fifo1>), ) -> Self

Combines an FdCanControl, Tx and the two Rx instances back into an FdCan instance

Source§

impl<I> FdCan<I, PoweredDownMode>
where I: Instance,

Source

pub fn new(instance: I) -> Self

Creates a FdCan interface with the default configuration

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Moves out of PoweredDownMode and into ConfigMode

Source

pub fn free(self) -> I

Disables the CAN interface and returns back the raw peripheral it was created from.

Source§

impl<I> FdCan<I, ConfigMode>
where I: Instance,

Source

pub fn into_internal_loopback(self) -> FdCan<I, InternalLoopbackMode>

Moves out of ConfigMode and into InternalLoopbackMode

Source

pub fn into_external_loopback(self) -> FdCan<I, ExternalLoopbackMode>

Moves out of ConfigMode and into ExternalLoopbackMode

Source

pub fn into_restricted(self) -> FdCan<I, RestrictedOperationMode>

Moves out of ConfigMode and into RestrictedOperationMode

Source

pub fn into_normal(self) -> FdCan<I, NormalOperationMode>

Moves out of ConfigMode and into NormalOperationMode

Source

pub fn into_bus_monitoring(self) -> FdCan<I, BusMonitoringMode>

Moves out of ConfigMode and into BusMonitoringMode

Source

pub fn into_test_mode(self) -> FdCan<I, TestMode>

Moves out of ConfigMode and into Testmode

Source

pub fn into_powered_down(self) -> FdCan<I, PoweredDownMode>

Moves out of ConfigMode and into PoweredDownmode

Source

pub fn apply_config(&mut self, config: FdCanConfig)

Applies the settings of a new FdCanConfig See FdCanConfig

Source

pub fn set_nominal_bit_timing(&mut self, btr: NominalBitTiming)

Configures the bit timings.

You can use http://www.bittiming.can-wiki.info/ to calculate the btr parameter. Enter parameters as follows:

  • Clock Rate: The input clock speed to the CAN peripheral (not the CPU clock speed). This is the clock rate of the peripheral bus the CAN peripheral is attached to (eg. APB1).
  • Sample Point: Should normally be left at the default value of 87.5%.
  • SJW: Should normally be left at the default value of 1.

Then copy the CAN_BUS_TIME register value from the table and pass it as the btr parameter to this method.

Source

pub fn set_data_bit_timing(&mut self, btr: DataBitTiming)

Configures the data bit timings for the FdCan Variable Bitrates. This is not used when frame_transmit is set to anything other than AllowFdCanAndBRS.

Source

pub fn set_automatic_retransmit(&mut self, enabled: bool)

Enables or disables automatic retransmission of messages

If this is enabled, the CAN peripheral will automatically try to retransmit each frame util it can be sent. Otherwise, it will try only once to send each frame.

Automatic retransmission is enabled by default.

Source

pub fn set_transmit_pause(&mut self, enabled: bool)

Configures the transmit pause feature. See FdCanConfig::set_transmit_pause

Source

pub fn set_non_iso_mode(&mut self, enabled: bool)

Configures non-iso mode. See FdCanConfig::set_non_iso_mode

Source

pub fn set_edge_filtering(&mut self, enabled: bool)

Configures edge filtering. See FdCanConfig::set_edge_filtering

Source

pub fn set_frame_transmit(&mut self, fts: FrameTransmissionConfig)

Configures frame transmission mode. See FdCanConfig::set_frame_transmit

Source

pub fn set_interrupt_line_config(&mut self, l0int: Interrupts)

👎Deprecated since 0.1.3: Deprecated in favour of .select_interrupt_line_1(..)

Configures the interrupt lines. See FdCanConfig::set_interrupt_line_config

Source

pub fn select_interrupt_line_1(&mut self, l1int: Interrupts)

Selects Interrupt Line 1 for the given interrupts. Interrupt Line 0 is selected for all other interrupts. See FdCanConfig::select_interrupt_line_1

Source

pub fn set_protocol_exception_handling(&mut self, enabled: bool)

Sets the protocol exception handling on/off

Source

pub fn set_timestamp_counter_source(&mut self, select: TimestampSource)

Configures and resets the timestamp counter

Source

pub fn set_global_filter(&mut self, filter: GlobalFilter)

Configures the global filter settings

Source

pub fn timestamp(&self) -> u16

Returns the current FdCan timestamp counter

Source§

impl<I> FdCan<I, InternalLoopbackMode>
where I: Instance,

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Returns out of InternalLoopbackMode and back into ConfigMode

Source§

impl<I> FdCan<I, ExternalLoopbackMode>
where I: Instance,

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Returns out of ExternalLoopbackMode and back into ConfigMode

Source§

impl<I> FdCan<I, NormalOperationMode>
where I: Instance,

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Returns out of NormalOperationMode and back into ConfigMode

Source§

impl<I> FdCan<I, RestrictedOperationMode>
where I: Instance,

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Returns out of RestrictedOperationMode and back into ConfigMode

Source§

impl<I> FdCan<I, BusMonitoringMode>
where I: Instance,

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Returns out of BusMonitoringMode and back into ConfigMode

Source§

impl<I> FdCan<I, TestMode>
where I: Instance,

Source

pub fn into_config_mode(self) -> FdCan<I, ConfigMode>

Returns out of TestMode and back into ConfigMode

Source

pub fn get_receive_pin(&mut self) -> bool

Gets the state of the receive pin to either Dominant (false), or Recessive (true)

Source

pub fn set_transmit_pin(&mut self, state: TestTransmitPinState)

Sets the state of the transmit pin according to TestTransmitPinState

Source§

impl<I, M> FdCan<I, M>
where I: Instance, M: Transmit + Receive,

Source

pub fn split_by_ref( &mut self, ) -> (&mut FdCanControl<I, M>, &mut Tx<I, M>, &mut Rx<I, M, Fifo0>, &mut Rx<I, M, Fifo1>)

Splits this FdCan instance into transmitting and receiving halves, by reference.

Source

pub fn split( self, ) -> (FdCanControl<I, M>, Tx<I, M>, Rx<I, M, Fifo0>, Rx<I, M, Fifo1>)

Consumes this FdCan instance and splits it into transmitting and receiving halves.

Source§

impl<I, M> FdCan<I, M>
where I: Instance, M: Transmit,

Source

pub fn transmit( &mut self, frame: TxFrameHeader, buffer: &[u8], ) -> Result<Option<()>, Infallible>

Puts a CAN frame in a free transmit mailbox for transmission on the bus.

Frames are transmitted to the bus based on their priority (identifier). Transmit order is preserved for frames with identical identifiers. If all transmit mailboxes are full, this overwrites the mailbox with the lowest priority.

Source

pub fn transmit_preserve<PTX, P>( &mut self, frame: TxFrameHeader, buffer: &[u8], pending: &mut PTX, ) -> Result<Option<P>, Infallible>
where PTX: FnMut(Mailbox, TxFrameHeader, &[u32]) -> P,

Puts a CAN frame in a free transmit mailbox for transmission on the bus.

Frames are transmitted to the bus based on their priority (identifier). Transmit order is preserved for frames with identical identifiers. If all transmit mailboxes are full, pending is called with the mailbox, header and data of the to-be-replaced frame.

Source

pub fn is_transmitter_idle(&self) -> bool

Returns true if no frame is pending for transmission.

Source

pub fn abort(&mut self, mailbox: Mailbox) -> bool

Attempts to abort the sending of a frame that is pending in a mailbox.

If there is no frame in the provided mailbox, or its transmission succeeds before it can be aborted, this function has no effect and returns false.

If there is a frame in the provided mailbox, and it is canceled successfully, this function returns true.

Source§

impl<I, M> FdCan<I, M>
where I: Instance, M: Receive,

Source

pub fn receive0( &mut self, buffer: &mut [u8], ) -> Result<ReceiveOverrun<RxFrameInfo>, Infallible>

Returns a received frame from FIFO_0 if available.

§Panics

Panics if buffer is smaller than the header length. It is recommended to provide a buffer with maximum frame size.

Source

pub fn receive1( &mut self, buffer: &mut [u8], ) -> Result<ReceiveOverrun<RxFrameInfo>, Infallible>

Returns a received frame from FIFO_1 if available.

§Panics

Panics if buffer is smaller than the header length. It is recommended to provide a buffer with maximum frame size.

Auto Trait Implementations§

§

impl<I, MODE> Freeze for FdCan<I, MODE>
where I: Freeze,

§

impl<I, MODE> RefUnwindSafe for FdCan<I, MODE>
where I: RefUnwindSafe, MODE: RefUnwindSafe,

§

impl<I, MODE> Send for FdCan<I, MODE>
where I: Send, MODE: Send,

§

impl<I, MODE> Sync for FdCan<I, MODE>
where I: Sync, MODE: Sync,

§

impl<I, MODE> Unpin for FdCan<I, MODE>
where I: Unpin, MODE: Unpin,

§

impl<I, MODE> UnwindSafe for FdCan<I, MODE>
where I: UnwindSafe, MODE: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.