SAM Control Area Network (MCAN) Low Level Driver.
Copyright (c) 2015-2019 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | BIT_2_TO_15_MASK 0x0000fffc |
#define | PMC_PCK_5 5 |
Functions | |
static void | _mcan_enable_peripheral_clock (struct mcan_module *const module_inst) |
enable can module clock. More... | |
static void | _mcan_message_memory_init (Mcan *hw) |
initialize MCAN memory . More... | |
static void | _mcan_set_configuration (Mcan *hw, struct mcan_config *config) |
set default configuration when initialization. More... | |
void | mcan_disable_bus_monitor_mode (struct mcan_module *const module_inst) |
disable bus monitor mode of mcan module. More... | |
void | mcan_disable_fd_mode (struct mcan_module *const module_inst) |
disable fd mode of mcan module. More... | |
void | mcan_disable_restricted_operation_mode (struct mcan_module *const module_inst) |
disable restricted mode of mcan module. More... | |
void | mcan_disable_sleep_mode (struct mcan_module *const module_inst) |
disable sleep mode of mcan module. More... | |
void | mcan_disable_test_mode (struct mcan_module *const module_inst) |
disable test mode of mcan module. More... | |
void | mcan_enable_bus_monitor_mode (struct mcan_module *const module_inst) |
enable bus monitor mode of mcan module. More... | |
void | mcan_enable_fd_mode (struct mcan_module *const module_inst) |
switch mcan module into fd mode. More... | |
void | mcan_enable_restricted_operation_mode (struct mcan_module *const module_inst) |
enable restricted mode of mcan module. More... | |
void | mcan_enable_sleep_mode (struct mcan_module *const module_inst) |
enable sleep mode of mcan module. More... | |
void | mcan_enable_test_mode (struct mcan_module *const module_inst) |
enable test mode of mcan module. More... | |
void | mcan_fd_set_baudrate (Mcan *hw, uint32_t baudrate) |
Set MCAN_FD baudrate. More... | |
enum status_code | mcan_get_rx_buffer_element (struct mcan_module *const module_inst, struct mcan_rx_element_buffer *rx_element, uint32_t index) |
get dedicated rx buffer element . More... | |
enum status_code | mcan_get_rx_fifo_0_element (struct mcan_module *const module_inst, struct mcan_rx_element_fifo_0 *rx_element, uint32_t index) |
get FIFO rx buffer element . More... | |
enum status_code | mcan_get_rx_fifo_1_element (struct mcan_module *const module_inst, struct mcan_rx_element_fifo_1 *rx_element, uint32_t index) |
get FIFO rx buffer element . More... | |
enum status_code | mcan_get_tx_event_fifo_element (struct mcan_module *const module_inst, struct mcan_tx_event_element *tx_event_element, uint32_t index) |
set FIFO transmit buffer element . More... | |
void | mcan_init (struct mcan_module *const module_inst, Mcan *hw, struct mcan_config *config) |
initialize can module. More... | |
void | mcan_set_baudrate (Mcan *hw, uint32_t baudrate) |
Set MCAN baudrate. More... | |
enum status_code | mcan_set_rx_extended_filter (struct mcan_module *const module_inst, struct mcan_extended_message_filter_element *et_filter, uint32_t index) |
set extended receive CAN ID. More... | |
enum status_code | mcan_set_rx_standard_filter (struct mcan_module *const module_inst, struct mcan_standard_message_filter_element *sd_filter, uint32_t index) |
set standard receive CAN ID. More... | |
enum status_code | mcan_set_tx_buffer_element (struct mcan_module *const module_inst, struct mcan_tx_element *tx_element, uint32_t index) |
set dedicated transmit buffer element . More... | |
void | mcan_start (struct mcan_module *const module_inst) |
start can module after initialization. More... | |
void | mcan_stop (struct mcan_module *const module_inst) |
stop mcan module when bus off occurs More... | |
Variables | |
static struct mcan_rx_element_buffer | mcan0_rx_buffer [CONF_MCAN0_RX_BUFFER_NUM] |
static struct mcan_extended_message_filter_element | mcan0_rx_extended_filter [CONF_MCAN0_RX_EXTENDED_ID_FILTER_NUM] |
static struct mcan_rx_element_fifo_0 | mcan0_rx_fifo_0 [CONF_MCAN0_RX_FIFO_0_NUM] |
static struct mcan_rx_element_fifo_1 | mcan0_rx_fifo_1 [CONF_MCAN0_RX_FIFO_1_NUM] |
static struct mcan_standard_message_filter_element | mcan0_rx_standard_filter [CONF_MCAN0_RX_STANDARD_ID_FILTER_NUM] |
static struct mcan_tx_element | mcan0_tx_buffer [CONF_MCAN0_TX_BUFFER_NUM+CONF_MCAN0_TX_FIFO_QUEUE_NUM] |
static struct mcan_tx_event_element | mcan0_tx_event_fifo [CONF_MCAN0_TX_EVENT_FIFO] |
static struct mcan_rx_element_buffer | mcan1_rx_buffer [CONF_MCAN1_RX_BUFFER_NUM] |
static struct mcan_extended_message_filter_element | mcan1_rx_extended_filter [CONF_MCAN1_RX_EXTENDED_ID_FILTER_NUM] |
static struct mcan_rx_element_fifo_0 | mcan1_rx_fifo_0 [CONF_MCAN1_RX_FIFO_0_NUM] |
static struct mcan_rx_element_fifo_1 | mcan1_rx_fifo_1 [CONF_MCAN1_RX_FIFO_1_NUM] |
static struct mcan_standard_message_filter_element | mcan1_rx_standard_filter [CONF_MCAN1_RX_STANDARD_ID_FILTER_NUM] |
static struct mcan_tx_element | mcan1_tx_buffer [CONF_MCAN1_TX_BUFFER_NUM+CONF_MCAN1_TX_FIFO_QUEUE_NUM] |
static struct mcan_tx_event_element | mcan1_tx_event_fifo [CONF_MCAN1_TX_EVENT_FIFO] |
#define BIT_2_TO_15_MASK 0x0000fffc |
Referenced by _mcan_message_memory_init().
#define PMC_PCK_5 5 |
Referenced by mcan_fd_set_baudrate(), mcan_init(), and mcan_set_baudrate().
|
static |
enable can module clock.
module_inst | MCAN instance |
References pmc_enable_periph_clk().
Referenced by mcan_disable_sleep_mode(), and mcan_init().
|
static |
initialize MCAN memory .
hw | Base address of the MCAN |
The data size in conf_mcan.h should be 8/12/16/20/24/32/48/64, The corresponding setting value in register is 0/1//2/3/4/5/6/7. To simplify the calculation, seperate to two group 8/12/16/20/24 which increased with 4 and 32/48/64 which increased with 16.
References BIT_2_TO_15_MASK, mcan0_rx_buffer, mcan0_rx_extended_filter, mcan0_rx_fifo_0, mcan0_rx_fifo_1, mcan0_rx_standard_filter, mcan0_tx_buffer, mcan0_tx_event_fifo, mcan1_rx_buffer, mcan1_rx_extended_filter, mcan1_rx_fifo_0, mcan1_rx_fifo_1, mcan1_rx_standard_filter, mcan1_tx_buffer, and mcan1_tx_event_fifo.
Referenced by mcan_init().
|
static |
set default configuration when initialization.
hw | Base address of the MCAN |
config | default configuration parameters. |
References mcan_config::automatic_retransmission, mcan_config::clock_stop_request, mcan_config::delay_compensation_offset, mcan_config::extended_id_mask, mcan_config::nonmatching_frames_action_extended, mcan_config::nonmatching_frames_action_standard, mcan_config::remote_frames_extended_reject, mcan_config::remote_frames_standard_reject, mcan_config::rx_fifo_0_overwrite, mcan_config::rx_fifo_0_watermark, mcan_config::rx_fifo_1_overwrite, mcan_config::rx_fifo_1_watermark, mcan_config::tdc_enable, mcan_config::timeout_enable, mcan_config::timeout_mode, mcan_config::timeout_period, mcan_config::timestamp_prescaler, mcan_config::transmit_pause, mcan_config::tx_event_fifo_watermark, mcan_config::tx_queue_mode, and mcan_config::watchdog_configuration.
Referenced by mcan_init().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_rx_buffer_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_set_rx_extended_filter().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_rx_fifo_0_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_rx_fifo_1_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_set_rx_standard_filter().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_set_tx_buffer_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_tx_event_fifo_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_rx_buffer_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_set_rx_extended_filter().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_rx_fifo_0_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_rx_fifo_1_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_set_rx_standard_filter().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_set_tx_buffer_element().
|
static |
Referenced by _mcan_message_memory_init(), and mcan_get_tx_event_fifo_element().