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,
impl<I, MODE> FdCan<I, MODE>where
I: Instance,
Sourcepub fn instance(&mut self) -> &mut I
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.
Sourcepub fn get_config(&self) -> FdCanConfig
pub fn get_config(&self) -> FdCanConfig
Returns the current FDCAN config settings
Sourcepub fn enable_interrupt_line(&mut self, line: InterruptLine, enabled: bool)
pub fn enable_interrupt_line(&mut self, line: InterruptLine, enabled: bool)
Enable/Disable the specific Interrupt Line
Sourcepub fn enable_interrupt(&mut self, interrupt: Interrupt)
pub fn enable_interrupt(&mut self, interrupt: Interrupt)
Starts listening for a CAN interrupt.
Sourcepub fn enable_interrupts(&mut self, interrupts: Interrupts)
pub fn enable_interrupts(&mut self, interrupts: Interrupts)
Starts listening for a set of CAN interrupts.
Sourcepub fn disable_interrupt(&mut self, interrupt: Interrupt)
pub fn disable_interrupt(&mut self, interrupt: Interrupt)
Stops listening for a CAN interrupt.
Sourcepub fn disable_interrupts(&mut self, interrupts: Interrupts)
pub fn disable_interrupts(&mut self, interrupts: Interrupts)
Stops listening for a set of CAN interrupts.
Sourcepub fn error_counters(&self) -> ErrorCounters
pub fn error_counters(&self) -> ErrorCounters
Retrieve the CAN error counters
Sourcepub fn set_standard_filter(
&mut self,
slot: StandardFilterSlot,
filter: StandardFilter,
)
pub fn set_standard_filter( &mut self, slot: StandardFilterSlot, filter: StandardFilter, )
Set an Standard Address CAN filter into slot ‘id’
Sourcepub fn set_standard_filters(&mut self, filters: &[StandardFilter; 28])
pub fn set_standard_filters(&mut self, filters: &[StandardFilter; 28])
Set an array of Standard Address CAN filters and overwrite the current set
Sourcepub fn set_extended_filter(
&mut self,
slot: ExtendedFilterSlot,
filter: ExtendedFilter,
)
pub fn set_extended_filter( &mut self, slot: ExtendedFilterSlot, filter: ExtendedFilter, )
Set an Extended Address CAN filter into slot ‘id’
Sourcepub fn set_extended_filters(&mut self, filters: &[ExtendedFilter; 8])
pub fn set_extended_filters(&mut self, filters: &[ExtendedFilter; 8])
Set an array of Extended Address CAN filters and overwrite the current set
Sourcepub fn get_protocol_status(&self) -> ProtocolStatus
pub fn get_protocol_status(&self) -> ProtocolStatus
Retrieve the current protocol status
Sourcepub fn has_interrupt(&mut self, interrupt: Interrupt) -> bool
pub fn has_interrupt(&mut self, interrupt: Interrupt) -> bool
Check if the interrupt is triggered
Sourcepub fn clear_interrupt(&mut self, interrupt: Interrupt)
pub fn clear_interrupt(&mut self, interrupt: Interrupt)
Clear specified interrupt
Sourcepub fn clear_interrupts(&mut self, interrupts: Interrupts)
pub fn clear_interrupts(&mut self, interrupts: Interrupts)
Clear specified interrupts
Source§impl<I> FdCan<I, PoweredDownMode>where
I: Instance,
impl<I> FdCan<I, PoweredDownMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
pub fn into_config_mode(self) -> FdCan<I, ConfigMode>
Moves out of PoweredDownMode and into ConfigMode
Source§impl<I> FdCan<I, ConfigMode>where
I: Instance,
impl<I> FdCan<I, ConfigMode>where
I: Instance,
Sourcepub fn into_internal_loopback(self) -> FdCan<I, InternalLoopbackMode>
pub fn into_internal_loopback(self) -> FdCan<I, InternalLoopbackMode>
Moves out of ConfigMode and into InternalLoopbackMode
Sourcepub fn into_external_loopback(self) -> FdCan<I, ExternalLoopbackMode>
pub fn into_external_loopback(self) -> FdCan<I, ExternalLoopbackMode>
Moves out of ConfigMode and into ExternalLoopbackMode
Sourcepub fn into_restricted(self) -> FdCan<I, RestrictedOperationMode>
pub fn into_restricted(self) -> FdCan<I, RestrictedOperationMode>
Moves out of ConfigMode and into RestrictedOperationMode
Sourcepub fn into_normal(self) -> FdCan<I, NormalOperationMode>
pub fn into_normal(self) -> FdCan<I, NormalOperationMode>
Moves out of ConfigMode and into NormalOperationMode
Sourcepub fn into_bus_monitoring(self) -> FdCan<I, BusMonitoringMode>
pub fn into_bus_monitoring(self) -> FdCan<I, BusMonitoringMode>
Moves out of ConfigMode and into BusMonitoringMode
Sourcepub fn into_test_mode(self) -> FdCan<I, TestMode>
pub fn into_test_mode(self) -> FdCan<I, TestMode>
Moves out of ConfigMode and into Testmode
Sourcepub fn into_powered_down(self) -> FdCan<I, PoweredDownMode>
pub fn into_powered_down(self) -> FdCan<I, PoweredDownMode>
Moves out of ConfigMode and into PoweredDownmode
Sourcepub fn apply_config(&mut self, config: FdCanConfig)
pub fn apply_config(&mut self, config: FdCanConfig)
Applies the settings of a new FdCanConfig See FdCanConfig
Sourcepub fn set_nominal_bit_timing(&mut self, btr: NominalBitTiming)
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.
Sourcepub fn set_data_bit_timing(&mut self, btr: DataBitTiming)
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.
Sourcepub fn set_automatic_retransmit(&mut self, enabled: bool)
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.
Sourcepub fn set_transmit_pause(&mut self, enabled: bool)
pub fn set_transmit_pause(&mut self, enabled: bool)
Configures the transmit pause feature. See
FdCanConfig::set_transmit_pause
Sourcepub fn set_non_iso_mode(&mut self, enabled: bool)
pub fn set_non_iso_mode(&mut self, enabled: bool)
Configures non-iso mode. See FdCanConfig::set_non_iso_mode
Sourcepub fn set_edge_filtering(&mut self, enabled: bool)
pub fn set_edge_filtering(&mut self, enabled: bool)
Configures edge filtering. See FdCanConfig::set_edge_filtering
Sourcepub fn set_frame_transmit(&mut self, fts: FrameTransmissionConfig)
pub fn set_frame_transmit(&mut self, fts: FrameTransmissionConfig)
Configures frame transmission mode. See
FdCanConfig::set_frame_transmit
Sourcepub fn set_interrupt_line_config(&mut self, l0int: Interrupts)
👎Deprecated since 0.1.3: Deprecated in favour of .select_interrupt_line_1(..)
pub fn set_interrupt_line_config(&mut self, l0int: Interrupts)
Configures the interrupt lines. See
FdCanConfig::set_interrupt_line_config
Sourcepub fn select_interrupt_line_1(&mut self, l1int: Interrupts)
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
Sourcepub fn set_protocol_exception_handling(&mut self, enabled: bool)
pub fn set_protocol_exception_handling(&mut self, enabled: bool)
Sets the protocol exception handling on/off
Sourcepub fn set_timestamp_counter_source(&mut self, select: TimestampSource)
pub fn set_timestamp_counter_source(&mut self, select: TimestampSource)
Configures and resets the timestamp counter
Sourcepub fn set_global_filter(&mut self, filter: GlobalFilter)
pub fn set_global_filter(&mut self, filter: GlobalFilter)
Configures the global filter settings
Source§impl<I> FdCan<I, InternalLoopbackMode>where
I: Instance,
impl<I> FdCan<I, InternalLoopbackMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
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,
impl<I> FdCan<I, ExternalLoopbackMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
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,
impl<I> FdCan<I, NormalOperationMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
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,
impl<I> FdCan<I, RestrictedOperationMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
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,
impl<I> FdCan<I, BusMonitoringMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
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,
impl<I> FdCan<I, TestMode>where
I: Instance,
Sourcepub fn into_config_mode(self) -> FdCan<I, ConfigMode>
pub fn into_config_mode(self) -> FdCan<I, ConfigMode>
Returns out of TestMode and back into ConfigMode
Sourcepub fn get_receive_pin(&mut self) -> bool
pub fn get_receive_pin(&mut self) -> bool
Gets the state of the receive pin to either Dominant (false), or Recessive (true)
Sourcepub fn set_transmit_pin(&mut self, state: TestTransmitPinState)
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>
impl<I, M> FdCan<I, M>
Sourcepub fn split_by_ref(
&mut self,
) -> (&mut FdCanControl<I, M>, &mut Tx<I, M>, &mut Rx<I, M, Fifo0>, &mut Rx<I, M, Fifo1>)
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§impl<I, M> FdCan<I, M>
impl<I, M> FdCan<I, M>
Sourcepub fn transmit(
&mut self,
frame: TxFrameHeader,
buffer: &[u8],
) -> Result<Option<()>, Infallible>
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.
Sourcepub fn transmit_preserve<PTX, P>(
&mut self,
frame: TxFrameHeader,
buffer: &[u8],
pending: &mut PTX,
) -> Result<Option<P>, Infallible>
pub fn transmit_preserve<PTX, P>( &mut self, frame: TxFrameHeader, buffer: &[u8], pending: &mut PTX, ) -> Result<Option<P>, 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, pending
is called with the mailbox,
header and data of the to-be-replaced frame.
Sourcepub fn is_transmitter_idle(&self) -> bool
pub fn is_transmitter_idle(&self) -> bool
Returns true
if no frame is pending for transmission.
Sourcepub fn abort(&mut self, mailbox: Mailbox) -> bool
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>
impl<I, M> FdCan<I, M>
Sourcepub fn receive0(
&mut self,
buffer: &mut [u8],
) -> Result<ReceiveOverrun<RxFrameInfo>, Infallible>
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.
Sourcepub fn receive1(
&mut self,
buffer: &mut [u8],
) -> Result<ReceiveOverrun<RxFrameInfo>, Infallible>
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.