Struct bxcan::Can [−][src]
pub struct Can<I: Instance> { /* fields omitted */ }
Expand description
Interface to a CAN peripheral.
Implementations
impl<I> Can<I> where
I: Instance,
[src]
impl<I> Can<I> where
I: Instance,
[src]pub fn new(instance: I) -> Self
[src]
pub fn new(instance: I) -> Self
[src]Creates a CAN interface, taking ownership of the raw peripheral.
pub fn instance(&mut self) -> &mut I
[src]
pub fn instance(&mut self) -> &mut I
[src]Returns a reference to the peripheral instance.
This allows accessing HAL-specific data stored in the instance type.
pub fn free(self) -> I
[src]
pub fn free(self) -> I
[src]Disables the CAN interface and returns back the raw peripheral it was created from.
The peripheral is disabled by setting RESET
in CAN_MCR
, which causes the peripheral to
enter sleep mode.
pub fn configure<F>(&mut self, f: F) where
F: FnOnce(&mut CanConfig<'_, I>),
[src]
pub fn configure<F>(&mut self, f: F) where
F: FnOnce(&mut CanConfig<'_, I>),
[src]Configure bit timings and silent/loop-back mode.
Acutal configuration happens on the CanConfig
that is passed to the
closure. It must be done this way because those configuration bits can
only be set if the CAN controller is in a special init mode.
Puts the peripheral in sleep mode afterwards. Can::enable()
must be
called to exit sleep mode and start reception and transmission.
pub fn modify_config(&mut self) -> CanConfig<'_, I>
[src]
pub fn modify_config(&mut self) -> CanConfig<'_, I>
[src]Configure bit timings and silent/loop-back mode.
pub fn set_automatic_wakeup(&mut self, enabled: bool)
[src]
pub fn set_automatic_wakeup(&mut self, enabled: bool)
[src]Configures the automatic wake-up feature.
pub fn enable(&mut self) -> Result<(), Infallible>
[src]
pub fn enable(&mut self) -> Result<(), Infallible>
[src]Start reception and transmission.
Waits for 11 consecutive recessive bits to sync to the CAN bus.
pub fn sleep(&mut self)
[src]
pub fn sleep(&mut self)
[src]Puts the peripheral in a sleep mode to save power.
While in sleep mode, an incoming CAN frame will trigger Interrupt::Wakeup
if enabled.
pub fn wakeup(&mut self)
[src]
pub fn wakeup(&mut self)
[src]Wakes up from sleep mode.
Note that this will not trigger Interrupt::Wakeup
, only reception of an incoming CAN
frame will cause that interrupt.
pub fn enable_interrupt(&mut self, interrupt: Interrupt)
[src]
pub fn enable_interrupt(&mut self, interrupt: Interrupt)
[src]Starts listening for a CAN interrupt.
pub fn enable_interrupts(&mut self, interrupts: Interrupts)
[src]
pub fn enable_interrupts(&mut self, interrupts: Interrupts)
[src]Starts listening for a set of CAN interrupts.
pub fn disable_interrupt(&mut self, interrupt: Interrupt)
[src]
pub fn disable_interrupt(&mut self, interrupt: Interrupt)
[src]Stops listening for a CAN interrupt.
pub fn disable_interrupts(&mut self, interrupts: Interrupts)
[src]
pub fn disable_interrupts(&mut self, interrupts: Interrupts)
[src]Stops listening for a set of CAN interrupts.
pub fn clear_sleep_interrupt(&mut self)
[src]
pub fn clear_sleep_interrupt(&mut self)
[src]Clears the pending flag of Interrupt::Sleep
.
pub fn clear_wakeup_interrupt(&mut self)
[src]
pub fn clear_wakeup_interrupt(&mut self)
[src]Clears the pending flag of Interrupt::Wakeup
.
pub fn clear_request_completed_flag(&mut self) -> Option<Mailbox>
[src]
pub fn clear_request_completed_flag(&mut self) -> Option<Mailbox>
[src]Clears the “Request Completed” (RQCP) flag of a transmit mailbox.
Returns the Mailbox
whose flag was cleared. If no mailbox has the flag set, returns
None
.
Once this function returns None
, a pending Interrupt::TransmitMailboxEmpty
is
considered acknowledged.
pub fn clear_tx_interrupt(&mut self)
[src]
pub fn clear_tx_interrupt(&mut self)
[src]Clears a pending TX interrupt (Interrupt::TransmitMailboxEmpty
).
This does not return the mailboxes that have finished tranmission. If you need that
information, call Can::clear_request_completed_flag
instead.
pub fn transmit(&mut self, frame: &Frame) -> Result<Option<Frame>, Infallible>
[src]
pub fn transmit(&mut self, frame: &Frame) -> Result<Option<Frame>, Infallible>
[src]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, a higher priority frame replaces the
lowest priority frame, which is returned as Ok(Some(frame))
.
pub fn transmit_and_get_mailbox(
&mut self,
frame: &Frame
) -> Result<(Option<Frame>, Mailbox), Infallible>
[src]
pub fn transmit_and_get_mailbox(
&mut self,
frame: &Frame
) -> Result<(Option<Frame>, Mailbox), Infallible>
[src]Puts a CAN frame in a free transmit mailbox for transmission on the bus.
This function is equivalent to transmit
except that it returns the
mailbox that was accessed. This can be used to keep track of additional information
about each frame, even when frames are placed into transmit mailboxes and later
removed before being transmitted.
pub fn is_transmitter_idle(&self) -> bool
[src]
pub fn is_transmitter_idle(&self) -> bool
[src]Returns true
if no frame is pending for transmission.
pub fn abort(&mut self, mailbox: Mailbox) -> bool
[src]
pub fn abort(&mut self, mailbox: Mailbox) -> bool
[src]Attempts to abort the sending of a frame that is pending in a mailbox.
If there is no frame in the provided mailbox, this function has no effect and returns false.
If there is a frame in the provided mailbox, this function returns true if the transmission was aborted. This function returns false if the frame was successfully transmitted.
pub fn receive(&mut self) -> Result<Frame, ()>
[src]
pub fn receive(&mut self) -> Result<Frame, ()>
[src]Returns a received frame if available.
Returns Err
when a frame was lost due to buffer overrun.
pub fn split_by_ref(&mut self) -> (&mut Tx<I>, &mut Rx<I>)
[src]
pub fn split_by_ref(&mut self) -> (&mut Tx<I>, &mut Rx<I>)
[src]Splits this Can
instance into transmitting and receiving halves, by reference.
impl<I: FilterOwner> Can<I>
[src]
impl<I: FilterOwner> Can<I>
[src]pub fn modify_filters(&mut self) -> MasterFilters<'_, I>
[src]
pub fn modify_filters(&mut self) -> MasterFilters<'_, I>
[src]Accesses the filter banks owned by this CAN peripheral.
To modify filters of a slave peripheral, modify_filters
has to be called on the master
peripheral instead.
Trait Implementations
impl<I> Can for Can<I> where
I: Instance,
[src]
impl<I> Can for Can<I> where
I: Instance,
[src]type Error = ()
type Error = ()
Associated error type.
fn try_transmit(
&mut self,
frame: &Self::Frame
) -> Result<Option<Self::Frame>, Self::Error>
[src]
fn try_transmit(
&mut self,
frame: &Self::Frame
) -> Result<Option<Self::Frame>, Self::Error>
[src]Puts a frame in the transmit buffer to be sent on the bus. Read more
fn try_receive(&mut self) -> Result<Self::Frame, Self::Error>
[src]
fn try_receive(&mut self) -> Result<Self::Frame, Self::Error>
[src]Returns a received frame if available.
Auto Trait Implementations
impl<I> Send for Can<I> where
I: Send,
I: Send,
impl<I> Sync for Can<I> where
I: Sync,
I: Sync,
impl<I> Unpin for Can<I> where
I: Unpin,
I: Unpin,