pub struct Can<'a> { /* private fields */ }
Implementations§
source§impl<'a> Can<'a>
impl<'a> Can<'a>
pub fn new( clocks: &'a dyn Stm32f4Clocks, registers: StaticRef<Registers>, ) -> Can<'a>
sourcepub fn enable(&self) -> Result<(), ErrorCode>
pub fn enable(&self) -> Result<(), ErrorCode>
Enable the peripheral with the stored communication parameters: bit timing settings and communication mode
sourcepub fn config_filter(&self, filter_info: FilterParameters, enable: bool)
pub fn config_filter(&self, filter_info: FilterParameters, enable: bool)
Configure a filter to receive messages
pub fn enable_filter_config(&self)
pub fn enter_normal_mode(&self) -> Result<(), ErrorCode>
pub fn enter_sleep_mode(&self)
sourcepub fn send_8byte_message(
&self,
id: Id,
dlc: usize,
rtr: u8,
) -> Result<(), ErrorCode>
pub fn send_8byte_message( &self, id: Id, dlc: usize, rtr: u8, ) -> Result<(), ErrorCode>
This function sends an 8-byte message
pub fn find_empty_mailbox(&self) -> Option<usize>
pub fn is_enabled_clock(&self) -> bool
pub fn enable_clock(&self)
pub fn disable_clock(&self)
sourcepub fn handle_transmit_interrupt(&self)
pub fn handle_transmit_interrupt(&self)
Handle the transmit interrupt. Check the status register for each transmit mailbox to find out the mailbox that the message was sent from.
pub fn process_received_message( &self, rx_mailbox: usize, ) -> (Id, usize, [u8; 8])
pub fn handle_fifo0_interrupt(&self)
pub fn handle_fifo1_interrupt(&self)
pub fn handle_error_status_interrupt(&self)
pub fn enable_irq(&self, interrupt: CanInterruptMode)
pub fn disable_irq(&self, interrupt: CanInterruptMode)
pub fn enable_irqs(&self)
pub fn disable_irqs(&self)
Trait Implementations§
source§impl Configure for Can<'_>
impl Configure for Can<'_>
source§const MIN_BIT_TIMINGS: BitTiming = _
const MIN_BIT_TIMINGS: BitTiming = _
Constants that define the minimum and maximum values that the timing
parameters can take. They are used when calculating the optimum timing
parameters for a given bitrate.
const MAX_BIT_TIMINGS: BitTiming = _
source§const SYNC_SEG: u8 = 1u8
const SYNC_SEG: u8 = 1u8
This constant represents the synchronization segment.
Most CAN devices seems to have define this in hardware to 1 quantum long.
1 quantum long. It is used for the synchronization of the clocks.
source§fn set_bitrate(&self, bitrate: u32) -> Result<(), ErrorCode>
fn set_bitrate(&self, bitrate: u32) -> Result<(), ErrorCode>
Configures the CAN peripheral at the given bitrate. This function is
supposed to be called before the
enable
function. This function is
synchronous as the driver should only calculate the timing parameters
based on the bitrate and the frequency of the board and store them.
This function does not configure the hardware. Read moresource§fn set_bit_timing(&self, bit_timing: BitTiming) -> Result<(), ErrorCode>
fn set_bit_timing(&self, bit_timing: BitTiming) -> Result<(), ErrorCode>
Configures the CAN peripheral with the given arguments. This function is
supposed to be called before the
enable
function. This function is
synchronous as the driver should only store the arguments, and should not
configure the hardware. Read moresource§fn set_operation_mode(&self, mode: OperationMode) -> Result<(), ErrorCode>
fn set_operation_mode(&self, mode: OperationMode) -> Result<(), ErrorCode>
Configures the CAN peripheral with the given arguments. This function is
supposed to be called before the
enable
function. This function is
synchronous as the driver should only store the arguments, and should not
configure the hardware. Read moresource§fn get_bit_timing(&self) -> Result<BitTiming, ErrorCode>
fn get_bit_timing(&self) -> Result<BitTiming, ErrorCode>
Returns the current timing parameters for the CAN peripheral. Read more
source§fn get_operation_mode(&self) -> Result<OperationMode, ErrorCode>
fn get_operation_mode(&self) -> Result<OperationMode, ErrorCode>
Returns the current operating mode for the CAN peripheral. Read more
source§fn set_automatic_retransmission(&self, automatic: bool) -> Result<(), ErrorCode>
fn set_automatic_retransmission(&self, automatic: bool) -> Result<(), ErrorCode>
Configures the CAN peripheral with the automatic retransmission setting.
This function is optional, but if used, must be called before the
enable
function. This function is synchronous as the driver should
only store the arguments, and should not configure the hardware. Read moresource§fn set_wake_up(&self, wake_up: bool) -> Result<(), ErrorCode>
fn set_wake_up(&self, wake_up: bool) -> Result<(), ErrorCode>
Configures the CAN peripheral with the automatic wake up setting.
This function is optional, but if used, must be called before the
enable
function. This function is synchronous as the driver should
only store the arguments, and should not configure the hardware. Read moresource§fn get_automatic_retransmission(&self) -> Result<bool, ErrorCode>
fn get_automatic_retransmission(&self) -> Result<bool, ErrorCode>
Returns the current automatic retransmission setting of the peripheral. Read more
source§fn get_wake_up(&self) -> Result<bool, ErrorCode>
fn get_wake_up(&self) -> Result<bool, ErrorCode>
Returns the current automatic wake up setting of the peripheral. Read more
source§fn receive_fifo_count(&self) -> usize
fn receive_fifo_count(&self) -> usize
Returns the number of receive FIFOs the peripheral provides
source§impl Controller for Can<'_>
impl Controller for Can<'_>
source§fn set_client(&self, client: Option<&'static dyn ControllerClient>)
fn set_client(&self, client: Option<&'static dyn ControllerClient>)
Set the client to be used for callbacks of the
Controller
implementation.source§fn enable(&self) -> Result<(), ErrorCode>
fn enable(&self) -> Result<(), ErrorCode>
This function enables the CAN peripheral with the Timing, Operation and Mode
arguments that are provided to the driver before calling the
enable
function. Read moresource§impl DeferredCallClient for Can<'_>
impl DeferredCallClient for Can<'_>
source§impl Receive<{ can::STANDARD_CAN_PACKET_SIZE }> for Can<'_>
impl Receive<{ can::STANDARD_CAN_PACKET_SIZE }> for Can<'_>
source§fn set_client(
&self,
client: Option<&'static dyn ReceiveClient<{ can::STANDARD_CAN_PACKET_SIZE }>>,
)
fn set_client( &self, client: Option<&'static dyn ReceiveClient<{ can::STANDARD_CAN_PACKET_SIZE }>>, )
Set the client to be used for callbacks of the
Receive
implementation.source§fn start_receive_process(
&self,
buffer: &'static mut [u8; 8],
) -> Result<(), (ErrorCode, &'static mut [u8; 8])>
fn start_receive_process( &self, buffer: &'static mut [u8; 8], ) -> Result<(), (ErrorCode, &'static mut [u8; 8])>
Start receiving messaged on the CAN bus. Read more
source§fn stop_receive(&self) -> Result<(), ErrorCode>
fn stop_receive(&self) -> Result<(), ErrorCode>
Asks the driver to stop receiving messages. This function should
be called only after a call to the
start_receive_process
function. Read moreconst PACKET_SIZE: usize = PACKET_SIZE
source§impl Transmit<{ can::STANDARD_CAN_PACKET_SIZE }> for Can<'_>
impl Transmit<{ can::STANDARD_CAN_PACKET_SIZE }> for Can<'_>
source§fn set_client(
&self,
client: Option<&'static dyn TransmitClient<{ can::STANDARD_CAN_PACKET_SIZE }>>,
)
fn set_client( &self, client: Option<&'static dyn TransmitClient<{ can::STANDARD_CAN_PACKET_SIZE }>>, )
Set the client to be used for callbacks of the
Transmit
implementation.source§fn send(
&self,
id: Id,
buffer: &'static mut [u8; 8],
len: usize,
) -> Result<(), (ErrorCode, &'static mut [u8; 8])>
fn send( &self, id: Id, buffer: &'static mut [u8; 8], len: usize, ) -> Result<(), (ErrorCode, &'static mut [u8; 8])>
Sends a buffer using the CAN bus. Read more
const PACKET_SIZE: usize = PACKET_SIZE
Auto Trait Implementations§
impl<'a> !Freeze for Can<'a>
impl<'a> !RefUnwindSafe for Can<'a>
impl<'a> !Send for Can<'a>
impl<'a> !Sync for Can<'a>
impl<'a> Unpin for Can<'a>
impl<'a> !UnwindSafe for Can<'a>
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