1 | /**
|
2 | * \brief Test ID mask and Family ID (Filter) from CAN0 Mailbox 0 to CAN1 Mailbox 0.
|
3 | Use rotary encoder for different message ID
|
4 | */
|
5 | void test_7(uint16_t MIDToSend)
|
6 | { uint16_t dataToSend;
|
7 | static uint8_t uc_suppress = 0;
|
8 | if (!uc_suppress) {
|
9 | puts("\n\rTest Message Acceptance Mask + FID, SID selected with rotary encoder, CAN0 Mailbox 0 -> CAN1 Mailbox 0" STRING_EOL);
|
10 | uc_suppress = 1;
|
11 | }
|
12 | can_reset_all_mailbox(CAN0);
|
13 | can_reset_all_mailbox(CAN1);
|
14 |
|
15 | /* Init CAN1 Mailbox 0 to Reception Mailbox. */
|
16 | // CAN_MIDx = 000100 x 11 xx = 0x08C
|
17 | // CAN_MAMx = 111111 0 11 00 = 0x7EC
|
18 | // CAN_MFIDx = 000000 0 01 10 = 0x006
|
19 | reset_mailbox_conf(&can1_mailbox);
|
20 | can1_mailbox.ul_mb_idx = TEST7_CAN_COMM_MB_IDX; //Mailbox 0...7
|
21 | can1_mailbox.uc_obj_type = CAN_MB_RX_MODE;
|
22 | can1_mailbox.ul_id_msk = 0x7EC; //CAN_MAM_MIDvA_Msk | CAN_MAM_MIDvB_Msk;
|
23 | can1_mailbox.ul_id = CAN_MID_MIDvA(0x08C);// CAN_MID_MIDvA(TEST7_CAN_TRANSFER_ID);
|
24 | can1_mailbox.ul_fid = 0x006; //Filter ID
|
25 | can_mailbox_init(CAN1, &can1_mailbox);
|
26 |
|
27 |
|
28 |
|
29 | /* Init CAN0 Mailbox 0 to Transmit Mailbox. */
|
30 | reset_mailbox_conf(&can0_mailbox);
|
31 | can0_mailbox.ul_mb_idx = TEST6_CAN_COMM_MB_IDX;
|
32 | can0_mailbox.uc_obj_type = CAN_MB_TX_MODE;
|
33 | can0_mailbox.uc_tx_prio = TEST6_CAN0_TX_PRIO;
|
34 | can0_mailbox.uc_id_ver = 0;
|
35 | can0_mailbox.ul_id_msk = 0;
|
36 | can_mailbox_init(CAN0, &can0_mailbox);
|
37 |
|
38 | /* Write transmit information into mailbox. */
|
39 | can0_mailbox.ul_id = CAN_MID_MIDvA(MIDToSend); // TEST6_CAN_TRANSFER_ID);
|
40 | can0_mailbox.ul_datal = (MIDToSend + 0x0100); //Nachricht...
|
41 | can0_mailbox.ul_datah = CAN_MSG_DUMMY_DATA;
|
42 | can0_mailbox.uc_length = MAX_CAN_FRAME_DATA_LEN;
|
43 | can_mailbox_write(CAN0, &can0_mailbox);
|
44 |
|
45 | /* Enable CAN1 mailbox 0 interrupt. */
|
46 | can_enable_interrupt(CAN1, CAN_IER_MB0);
|
47 |
|
48 | /* Send out the information in the mailbox. */
|
49 | can_global_send_transfer_cmd(CAN0, CAN_TCR_MB0);
|
50 |
|
51 | while (!g_ul_recv_status); //kommt von CAN-ISR
|
52 | // Ab hier nur noch Anzeige
|
53 | uint32_t ul_val, ul_val2 = 0;
|
54 |
|
55 | puts("Test7 passed" STRING_EOL);
|
56 | printf("CAN1 RX Mailbox 0:\r");
|
57 |
|
58 | ul_val = (uint32_t *)(CAN1->CAN_MB[0].CAN_MDH);
|
59 | ul_val2 = (uint32_t *)(CAN1->CAN_MB[0].CAN_MDL);
|
60 | printf("Dat Hi: MDH\t%08X\t\t\tDat Lo: MDL\t%08X\r", ul_val, ul_val2);
|
61 |
|
62 | ul_val = (uint32_t *)(CAN1->CAN_MB[0].CAN_MFID);
|
63 | ul_val2 = (uint32_t *)(CAN1->CAN_MB[0].CAN_MID);
|
64 | printf("FAM ID: MFID\t%08X\t\t\tID: MID\t%08X\r\r", ul_val, ul_val2);
|
65 | }
|