19 #define MCAN_TEST_SEND_ID_STD 0x125 20 #define MCAN_TEST_SEND_ID_EXT 0x100000A5 21 #define MCAN_TEST_RECV_ID_STD 0x126 22 #define MCAN_TEST_RECV_ID_EXT 0x100000A6 66 for (uint32_t i = 0; i < data_length; i++) {
67 tx_element.
data[i] = data[i];
93 *id_value = rx_element_buffer.
R0.
bit.
ID >> 18;
94 for(
int i=0; i<rx_element_buffer.
R1.
bit.
DLC; i++)
95 data[i] = rx_element_buffer.
data[i];
111 *id_value = rx_element_buffer.
R0.
bit.
ID;
112 for(
int i=0; i<rx_element_buffer.
R1.
bit.
DLC; i++)
113 data[i] = rx_element_buffer.
data[i];
115 return rx_element_buffer.
R1.
bit.
DLC;
127 static int standard_filter_count = 0;
128 static int extended_filter_count = 0;
130 if(id_value >= 0x800)
142 return extended_filter_count++;
156 return standard_filter_count++;
167 uint32_t success_count = 0;
168 uint32_t failure_count = 0;
182 len = 2 + rand() % 7;
184 for(
int i=0; i<len; i++)
185 can_tx_message[i] = rand();
194 uint32_t id, timeout = 100;
201 if((uint8_t)(can_tx_message[i] + 1) != can_rx_message[i])
231 for(
int i=0; i<len; i++)
232 can_tx_message[i] = can_rx_message[i] + 1;
MCAN receive element structure for FIFO 0.
#define MCAN_RXF1S_F1FL_Msk
(MCAN_RXF1S) Receive FIFO 1 Fill Level
#define MCAN_TXFQS_TFQPI_Pos
MCAN transfer element structure.
struct MCAN_RX_ELEMENT_R0_Type::@3 bit
int mcan_set_rx_filter(uint32_t id_value)
#define CONF_MCAN1_RX_EXTENDED_ID_FILTER_NUM
MCAN extended message ID filter element structure.
#define MCAN1
(MCAN1 ) Base Address
__IO MCAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type F0
#define MCAN_TX_ELEMENT_T0_EXTENDED_ID(value)
MCAN receive element structure for FIFO 1.
void mcan_test_slave(void)
static void mcan_rx_fifo_acknowledge(struct mcan_module *const module_inst, bool fifo_number, uint32_t index)
Set Rx acknowledge.
struct MCAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type::@9 bit
__IO MCAN_RX_ELEMENT_R1_Type R1
void mcan_stop(struct mcan_module *const module_inst)
stop mcan module when bus off occurs
#define MCAN_TX_ELEMENT_T0_XTD
static struct mcan_module mcan_instance
static void mcan_get_config_defaults(struct mcan_config *const config)
Initializes an MCAN configuration structure to defaults.
void mcan_start(struct mcan_module *const module_inst)
start can module after initialization.
#define CONF_MCAN_ELEMENT_DATA_SIZE
#define MCAN_TEST_SEND_ID_STD
static void mcan_get_extended_message_filter_element_default(struct mcan_extended_message_filter_element *et_filter)
Get the extended message filter default value.
#define CONF_MCAN1_RX_STANDARD_ID_FILTER_NUM
MCAN configuration structure.
#define MCAN_TEST_RECV_ID_EXT
__IO MCAN_TX_ELEMENT_T0_Type T0
#define MCAN_RXF1S_F1GI_Pos
uint8_t data[CONF_MCAN_ELEMENT_DATA_SIZE]
uint8_t data[CONF_MCAN_ELEMENT_DATA_SIZE]
bool mcan_send_message(uint32_t id_value, uint8_t *data, uint32_t data_length)
static void mcan_get_standard_message_filter_element_default(struct mcan_standard_message_filter_element *sd_filter)
Get the standard message filter default value.
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.
#define MCAN_TXFQS_TFQF
(MCAN_TXFQS) Tx FIFO/Queue Full
static uint32_t mcan_tx_get_fifo_queue_status(struct mcan_module *const module_inst)
Get Tx FIFO/Queue status.
#define MCAN_TX_ELEMENT_T0_STANDARD_ID(value)
struct MCAN_RX_ELEMENT_R1_Type::@4 bit
static void mcan_get_tx_buffer_element_defaults(struct mcan_tx_element *tx_element)
Get the default transfer buffer element.
__IO MCAN_TX_ELEMENT_T1_Type T1
static uint32_t mcan_rx_get_fifo_status(struct mcan_module *const module_inst, bool fifo_number)
Get Rx FIFO status.
USBInterfaceDescriptor data
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 .
evb_flash_cfg_t * g_flashCfg
static enum status_code mcan_tx_transfer_request(struct mcan_module *const module_inst, uint32_t trig_mask)
Tx buffer add transfer request.
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 .
void mcan_set_baudrate(Mcan *hw, uint32_t baudrate)
Set MCAN baudrate.
#define MCAN_RXF0S_F0GI_Pos
uint8_t mcan_receive_message(uint32_t *id_value, uint8_t *data)
__IO MCAN_RX_ELEMENT_R1_Type R1
struct MCAN_TX_ELEMENT_T1_Type::@6 bit
void vTaskDelay(const TickType_t xTicksToDelay) PRIVILEGED_FUNCTION
__IO MCAN_RX_ELEMENT_R0_Type R0
MCAN standard message ID filter element structure.
Autogenerated API include file for the Atmel Software Framework (ASF)
__IO MCAN_STANDARD_MESSAGE_FILTER_ELEMENT_S0_Type S0
struct MCAN_EXTENDED_MESSAGE_FILTER_ELEMENT_F0_Type::@10 bit
#define MCAN_RXF0S_F0FL_Msk
(MCAN_RXF0S) Receive FIFO 0 Fill Level
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 .
__IO MCAN_RX_ELEMENT_R0_Type R0
void mcan_init(struct mcan_module *const module_inst, Mcan *hw, struct mcan_config *config)
initialize can module.
uint32_t can_receive_address
#define MCAN_TEST_RECV_ID_STD
#define MCAN_TXFQS_TFQPI_Msk
(MCAN_TXFQS) Tx FIFO/Queue Put Index
MCAN software device instance structure.
#define MCAN_TEST_SEND_ID_EXT
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.
void mcan_test_master(void)
uint8_t data[CONF_MCAN_ELEMENT_DATA_SIZE]