pub struct CanBus<I>where
Can<I>: Instance,{ /* private fields */ }Expand description
Wrapper around a bxcan CAN instance built from a HAL CAN peripheral.
Implementations§
Source§impl<I> CanBus<I>where
Can<I>: Instance,
impl<I> CanBus<I>where
Can<I>: Instance,
Sourcepub fn new(hal_can: Can<I>, btr: u32, loopback: bool, silent: bool) -> Self
pub fn new(hal_can: Can<I>, btr: u32, loopback: bool, silent: bool) -> Self
Create and enable a bxcan instance from a HAL CAN peripheral.
hal_can– the HAL CAN wrapperbtr– value for the CAN_BTR register (bit timing). Get this from the reference manual or the bxcan timing tables.loopback– enable internal loopbacksilent– enable silent mode
Sourcepub fn inner(&mut self) -> &mut Can<Can<I>>
pub fn inner(&mut self) -> &mut Can<Can<I>>
Access the underlying bxcan instance for advanced configuration.
Sourcepub fn transmit_frame(
&mut self,
frame: &Frame,
) -> Result<TransmitStatus, Infallible>
pub fn transmit_frame( &mut self, frame: &Frame, ) -> Result<TransmitStatus, Infallible>
Transmit a pre-built CAN frame.
Returns the bxcan TransmitStatus. The error type is Infallible.
Sourcepub fn transmit_data(
&mut self,
id: StandardId,
data: &[u8],
) -> Option<Result<TransmitStatus, Infallible>>
pub fn transmit_data( &mut self, id: StandardId, data: &[u8], ) -> Option<Result<TransmitStatus, Infallible>>
Transmit a data frame with a standard 11-bit ID.
data must be at most 8 bytes, otherwise this returns None.
Sourcepub fn receive(&mut self) -> Result<Frame, OverrunError>
pub fn receive(&mut self) -> Result<Frame, OverrunError>
Blocking receive of a frame.
This will block inside bxcan until a frame is available or an overrun is detected.
Source§impl<I> CanBus<I>where
Can<I>: Instance + FilterOwner,
Extra helpers for CAN instances that own filters (e.g., CAN1 on STM32F7).
impl<I> CanBus<I>where
Can<I>: Instance + FilterOwner,
Extra helpers for CAN instances that own filters (e.g., CAN1 on STM32F7).
Sourcepub fn configure_accept_all_filters_for_dual_can<I2>(
&mut self,
_can2: &mut Can<I2>,
)where
Can<I2>: Instance,
pub fn configure_accept_all_filters_for_dual_can<I2>(
&mut self,
_can2: &mut Can<I2>,
)where
Can<I2>: Instance,
Configure CAN1 and CAN2 filters so that both accept all frames on FIFO0.
This must be called on CAN1 (the filter owner).
Auto Trait Implementations§
impl<I> Freeze for CanBus<I>where
I: Freeze,
impl<I> RefUnwindSafe for CanBus<I>where
I: RefUnwindSafe,
impl<I> Send for CanBus<I>where
I: Send,
impl<I> Sync for CanBus<I>where
I: Sync,
impl<I> Unpin for CanBus<I>where
I: Unpin,
impl<I> UnwindSafe for CanBus<I>where
I: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more