Unit tests for CAN driver.
Copyright (c) 2011-2018 Microchip Technology Inc. and its subsidiaries.
#include <stdint.h>
#include <stdbool.h>
#include <board.h>
#include <sysclk.h>
#include <can.h>
#include <sn65hvd234.h>
#include <string.h>
#include <unit_test/suite.h>
#include <stdio_serial.h>
#include <conf_test.h>
#include <conf_board.h>
Macros | |
#define | CAN0_RX_MB_IDX 1 |
#define | CAN0_TX_MB_IDX 0 |
The CAN0 communication mailbox ID. More... | |
#define | CAN1_PRO_MB_IDX 0 |
The CAN1 communication mailbox ID. More... | |
#define | CAN_TRANSFER_DATA_LEN 8 |
The transfer data length. More... | |
#define | CAN_TRANSFER_ID 0x0a |
The transfer identifier. More... | |
#define | TRANSFER_DATA_HIGH 0x87654321 |
#define | TRANSFER_DATA_LOW 0x12345678 |
The data transfer between the CAN0 and CAN1. More... | |
Functions | |
void | CAN0_Handler (void) |
Default interrupt handler for CAN0. More... | |
int | main (void) |
Run RSTC driver unit tests. More... | |
static void | reset_mailbox_conf (can_mb_conf_t *p_mailbox) |
Reset mailbox configure structure. More... | |
static void | run_can_test (const struct test_case *test) |
Test Controller Area Network (CAN) Controller. More... | |
Variables | |
can_mb_conf_t | can0_mailbox |
CAN0 Transfer. More... | |
sn65hvd234_ctrl_t | can0_transceiver |
CAN0 Transceiver. More... | |
can_mb_conf_t | can1_mailbox |
CAN1 Transfer. More... | |
sn65hvd234_ctrl_t | can1_transceiver |
CAN1 Transceiver. More... | |
volatile uint32_t | g_ul_recv_status = 0 |
Receive status. More... | |
#define CAN0_RX_MB_IDX 1 |
Referenced by CAN0_Handler(), and run_can_test().
#define CAN0_TX_MB_IDX 0 |
The CAN0 communication mailbox ID.
Referenced by run_can_test().
#define CAN1_PRO_MB_IDX 0 |
The CAN1 communication mailbox ID.
Referenced by run_can_test().
#define CAN_TRANSFER_DATA_LEN 8 |
The transfer data length.
Referenced by run_can_test().
#define CAN_TRANSFER_ID 0x0a |
The transfer identifier.
Referenced by run_can_test().
#define TRANSFER_DATA_HIGH 0x87654321 |
Referenced by run_can_test().
#define TRANSFER_DATA_LOW 0x12345678 |
The data transfer between the CAN0 and CAN1.
Referenced by run_can_test().
void CAN0_Handler | ( | void | ) |
Default interrupt handler for CAN0.
References CAN0_RX_MB_IDX, can_get_status(), can_mailbox_get_status(), can_mailbox_read(), g_ul_recv_status, GLOBAL_MAILBOX_MASK, can_mb_conf_t::ul_mb_idx, and can_mb_conf_t::ul_status.
int main | ( | void | ) |
Run RSTC driver unit tests.
References uart_rs232_options::baudrate, board_init(), DEFINE_TEST_ARRAY, DEFINE_TEST_CASE, DEFINE_TEST_SUITE, NULL, run_can_test(), stdio_serial_init(), sysclk_enable_peripheral_clock(), sysclk_init(), test_suite_run(), and usart_serial_options.
|
static |
Reset mailbox configure structure.
p_mailbox | Pointer to mailbox configure structure. |
References can_mb_conf_t::uc_id_ver, can_mb_conf_t::uc_length, can_mb_conf_t::uc_obj_type, can_mb_conf_t::uc_tx_prio, can_mb_conf_t::ul_datah, can_mb_conf_t::ul_datal, can_mb_conf_t::ul_fid, can_mb_conf_t::ul_id, can_mb_conf_t::ul_id_msk, can_mb_conf_t::ul_mb_idx, and can_mb_conf_t::ul_status.
Referenced by run_can_test().
|
static |
Test Controller Area Network (CAN) Controller.
This test checks whether the transmitted and received data are consistent.
test | Current test case. |
References CAN0_RX_MB_IDX, CAN0_TX_MB_IDX, CAN1_PRO_MB_IDX, CAN_BPS_1000K, can_disable(), CAN_DISABLE_ALL_INTERRUPT_MASK, can_disable_interrupt(), can_enable_interrupt(), can_global_send_transfer_cmd(), can_init(), can_mailbox_init(), can_mailbox_tx_remote_frame(), can_mailbox_write(), CAN_MB_PRODUCER_MODE, CAN_MB_RX_MODE, CAN_MB_TX_MODE, can_reset_all_mailbox(), CAN_TRANSFER_DATA_LEN, CAN_TRANSFER_ID, g_ul_recv_status, pmc_enable_periph_clk(), reset_mailbox_conf(), sn65hvd234_disable(), sn65hvd234_disable_low_power(), sn65hvd234_enable(), sn65hvd234_enable_low_power(), sn65hvd234_set_en(), sn65hvd234_set_rs(), sysclk_get_cpu_hz(), test_assert_true, TRANSFER_DATA_HIGH, TRANSFER_DATA_LOW, can_mb_conf_t::uc_id_ver, can_mb_conf_t::uc_length, can_mb_conf_t::uc_obj_type, can_mb_conf_t::uc_tx_prio, can_mb_conf_t::ul_datah, can_mb_conf_t::ul_datal, can_mb_conf_t::ul_id, can_mb_conf_t::ul_id_msk, and can_mb_conf_t::ul_mb_idx.
Referenced by main().
can_mb_conf_t can0_mailbox |
CAN0 Transfer.
sn65hvd234_ctrl_t can0_transceiver |
CAN0 Transceiver.
can_mb_conf_t can1_mailbox |
CAN1 Transfer.
sn65hvd234_ctrl_t can1_transceiver |
CAN1 Transceiver.
volatile uint32_t g_ul_recv_status = 0 |
Receive status.