SAM CAN basic Quick Start.
Copyright (c) 2015-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include <string.h>
#include <conf_can.h>
Macros | |
#define | CAN_RX_EXTENDED_FILTER_ID_0 0x100000A5 |
#define | CAN_RX_EXTENDED_FILTER_ID_0_BUFFER_INDEX 1 |
#define | CAN_RX_EXTENDED_FILTER_ID_1 0x10000096 |
#define | CAN_RX_EXTENDED_FILTER_INDEX_0 0 |
#define | CAN_RX_EXTENDED_FILTER_INDEX_1 1 |
#define | CAN_RX_STANDARD_FILTER_ID_0 0x45A |
#define | CAN_RX_STANDARD_FILTER_ID_0_BUFFER_INDEX 2 |
#define | CAN_RX_STANDARD_FILTER_ID_1 0x469 |
#define | CAN_RX_STANDARD_FILTER_INDEX_0 0 |
[module_inst] More... | |
#define | CAN_RX_STANDARD_FILTER_INDEX_1 1 |
#define | CAN_TX_BUFFER_INDEX 0 |
[can_filter_setting] More... | |
Functions | |
void | CAN0_Handler (void) |
[can_transfer_message_setup] More... | |
static void | can_send_extended_message (uint32_t id_value, uint8_t *data, uint32_t data_length) |
static void | can_send_standard_message (uint32_t id_value, uint8_t *data, uint32_t data_length) |
[can_receive_filter_setup] More... | |
static void | can_set_extended_filter_0 (void) |
static void | can_set_extended_filter_1 (void) |
static void | can_set_standard_filter_0 (void) |
[can_init_setup] More... | |
static void | can_set_standard_filter_1 (void) |
static void | configure_can (void) |
[cdc_setup] More... | |
static void | configure_usart_cdc (void) |
[can_receive_message_setting] More... | |
static void | display_menu (void) |
[can_interrupt_handler] More... | |
int | main (void) |
[user_menu] More... | |
Variables | |
static struct can_module | can_instance |
static struct usart_module | cdc_instance |
[module_var] More... | |
static volatile uint32_t | extended_receive_index = 0 |
static struct can_rx_element_buffer | rx_element_buffer |
static struct can_rx_element_fifo_0 | rx_element_fifo_0 |
static struct can_rx_element_fifo_1 | rx_element_fifo_1 |
static volatile uint32_t | standard_receive_index = 0 |
[can_transfer_message_setting] More... | |
static uint8_t | tx_message_0 [CONF_CAN_ELEMENT_DATA_SIZE] |
static uint8_t | tx_message_1 [CONF_CAN_ELEMENT_DATA_SIZE] |
#define CAN_RX_EXTENDED_FILTER_ID_0 0x100000A5 |
Referenced by can_set_extended_filter_0(), and main().
#define CAN_RX_EXTENDED_FILTER_ID_0_BUFFER_INDEX 1 |
Referenced by can_set_extended_filter_0().
#define CAN_RX_EXTENDED_FILTER_ID_1 0x10000096 |
Referenced by can_set_extended_filter_1(), and main().
#define CAN_RX_EXTENDED_FILTER_INDEX_0 0 |
Referenced by can_set_extended_filter_0().
#define CAN_RX_EXTENDED_FILTER_INDEX_1 1 |
Referenced by can_set_extended_filter_1().
#define CAN_RX_STANDARD_FILTER_ID_0 0x45A |
Referenced by can_set_standard_filter_0(), and main().
#define CAN_RX_STANDARD_FILTER_ID_0_BUFFER_INDEX 2 |
Referenced by can_set_standard_filter_0().
#define CAN_RX_STANDARD_FILTER_ID_1 0x469 |
Referenced by can_set_standard_filter_1(), and main().
#define CAN_RX_STANDARD_FILTER_INDEX_0 0 |
#define CAN_RX_STANDARD_FILTER_INDEX_1 1 |
Referenced by can_set_standard_filter_1().
#define CAN_TX_BUFFER_INDEX 0 |
[can_filter_setting]
[can_transfer_message_setting]
Referenced by can_send_extended_message(), and can_send_standard_message().
void CAN0_Handler | ( | void | ) |
[can_transfer_message_setup]
[can_interrupt_handler]
References CAN_RX_ELEMENT_R0_Type::bit, CAN_RX_ELEMENT_R1_Type::bit, can_clear_interrupt_status(), can_get_rx_buffer_element(), can_get_rx_fifo_0_element(), can_get_rx_fifo_1_element(), can_instance, CAN_PROTOCOL_ERROR_ARBITRATION, CAN_PROTOCOL_ERROR_DATA, can_read_interrupt_status(), CAN_RX_BUFFER_NEW_MESSAGE, can_rx_clear_buffer_status(), CAN_RX_FIFO_0_NEW_MESSAGE, CAN_RX_FIFO_1_NEW_MESSAGE, can_rx_fifo_acknowledge(), can_rx_get_buffer_status(), can_rx_element_buffer::data, can_rx_element_fifo_0::data, can_rx_element_fifo_1::data, CAN_RX_ELEMENT_R1_Type::DLC, extended_receive_index, i, can_rx_element_buffer::R0, can_rx_element_buffer::R1, can_rx_element_fifo_0::R1, can_rx_element_fifo_1::R1, rx_element_buffer, rx_element_fifo_0, rx_element_fifo_1, standard_receive_index, and CAN_RX_ELEMENT_R0_Type::XTD.
|
static |
References CAN_TX_ELEMENT_T1_Type::bit, can_get_tx_buffer_element_defaults(), can_instance, can_set_tx_buffer_element(), CAN_TX_BUFFER_INDEX, CAN_TX_ELEMENT_T0_EXTENDED_ID, CAN_TX_ELEMENT_T0_XTD, can_tx_transfer_request(), data, can_tx_element::data, CAN_TX_ELEMENT_T1_Type::DLC, i, CAN_TX_ELEMENT_T0_Type::reg, can_tx_element::T0, and can_tx_element::T1.
Referenced by main().
|
static |
[can_receive_filter_setup]
[can_transfer_message_setup]
References CAN_TX_ELEMENT_T1_Type::bit, can_get_tx_buffer_element_defaults(), can_instance, can_set_tx_buffer_element(), CAN_TX_BUFFER_INDEX, CAN_TX_ELEMENT_T0_STANDARD_ID, can_tx_transfer_request(), data, can_tx_element::data, CAN_TX_ELEMENT_T1_Type::DLC, i, CAN_TX_ELEMENT_T0_Type::reg, can_tx_element::T0, and can_tx_element::T1.
Referenced by main().
|
static |
References CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type::bit, CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F1_Type::bit, can_enable_interrupt(), CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_EFEC_STRXBUF_Val, can_get_extended_message_filter_element_default(), can_instance, CAN_RX_BUFFER_NEW_MESSAGE, CAN_RX_EXTENDED_FILTER_ID_0, CAN_RX_EXTENDED_FILTER_ID_0_BUFFER_INDEX, CAN_RX_EXTENDED_FILTER_INDEX_0, can_set_rx_extended_filter(), CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type::EFEC, CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type::EFID1, CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F1_Type::EFID2, can_extended_message_filter_element::F0, and can_extended_message_filter_element::F1.
Referenced by main().
|
static |
References CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type::bit, can_enable_interrupt(), can_get_extended_message_filter_element_default(), can_instance, CAN_RX_EXTENDED_FILTER_ID_1, CAN_RX_EXTENDED_FILTER_INDEX_1, CAN_RX_FIFO_1_NEW_MESSAGE, can_set_rx_extended_filter(), CAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type::EFID1, and can_extended_message_filter_element::F0.
Referenced by main().
|
static |
[can_init_setup]
[can_receive_filter_setup]
References CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::bit, can_enable_interrupt(), can_get_standard_message_filter_element_default(), can_instance, CAN_RX_BUFFER_NEW_MESSAGE, CAN_RX_STANDARD_FILTER_ID_0, CAN_RX_STANDARD_FILTER_ID_0_BUFFER_INDEX, CAN_RX_STANDARD_FILTER_INDEX_0, can_set_rx_standard_filter(), CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_SFEC_STRXBUF_Val, can_standard_message_filter_element::S0, CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::SFEC, CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::SFID1, and CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::SFID2.
Referenced by main().
|
static |
References CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::bit, can_enable_interrupt(), can_get_standard_message_filter_element_default(), can_instance, CAN_RX_FIFO_0_NEW_MESSAGE, CAN_RX_STANDARD_FILTER_ID_1, CAN_RX_STANDARD_FILTER_INDEX_1, can_set_rx_standard_filter(), can_standard_message_filter_element::S0, and CAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::SFID1.
Referenced by main().
|
static |
[cdc_setup]
[can_init_setup]
References can_enable_interrupt(), can_get_config_defaults(), can_init(), can_instance, CAN_PROTOCOL_ERROR_ARBITRATION, CAN_PROTOCOL_ERROR_DATA, can_start(), i, system_pinmux_config::mux_position, system_interrupt_enable(), system_pinmux_get_config_defaults(), system_pinmux_pin_set_config(), tx_message_0, and tx_message_1.
Referenced by main().
|
static |
[can_receive_message_setting]
[module_var] [setup] [cdc_setup]
References usart_config::baudrate, cdc_instance, usart_config::mux_setting, usart_config::pinmux_pad0, usart_config::pinmux_pad1, usart_config::pinmux_pad2, usart_config::pinmux_pad3, usart_enable(), and usart_get_config_defaults().
Referenced by main().
|
static |
int main | ( | void | ) |
[user_menu]
[setup]
[setup_init]
[setup_init]
[main_setup]
[configure_can]
[configure_can]
[display_user_menu]
[display_user_menu]
[main_loop]
[main_loop]
[main_setup]
References CAN_RX_EXTENDED_FILTER_ID_0, CAN_RX_EXTENDED_FILTER_ID_1, CAN_RX_STANDARD_FILTER_ID_0, CAN_RX_STANDARD_FILTER_ID_1, can_send_extended_message(), can_send_standard_message(), can_set_extended_filter_0(), can_set_extended_filter_1(), can_set_standard_filter_0(), can_set_standard_filter_1(), configure_can(), configure_usart_cdc(), display_menu(), system_init(), tx_message_0, and tx_message_1.
|
static |
|
static |
|
static |
Referenced by CAN0_Handler().
|
static |
Referenced by CAN0_Handler().
|
static |
Referenced by CAN0_Handler().
|
static |
Referenced by CAN0_Handler().
|
static |
|
static |
Referenced by configure_can(), and main().
|
static |
Referenced by configure_can(), and main().