| RTOS_MSPM0 1.1 ECE445M starter code

CAN.h
1 // CAN.h
2 // Runs on MSPM0G3507
3 // Use FDCAN0 to communicate on CAN bus PA12 and PA13
4 //
5
6 // Jonathan Valvano
7 // December 11, 2025
8 // derived from can_to_uart_bridge_LP_MSPM0G3507_nortos_ticlang
9 /*
10 Copyright 2025 by Jonathan W. Valvano, valvano@mail.utexas.edu
11 You may use, edit, run or distribute this file
12 as long as the above copyright notice remains
13 THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
14 OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
15 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
16 VALVANO SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
17 OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
18 For more information about my classes, my research, and my books, see
19 http://users.ece.utexas.edu/~valvano/
20 */
21 // Use TCAN1057AVDRQ1 (not TCAN1057A-Q1, the version with pin 5 nc)
22 // Pin1 TXD ---- CAN_Tx PA12 FD-CAN module 0 transmit
23 // Pin2 Vss ---- ground
24 // Pin3 VCC ---- +5V with 0.1uF cap to ground
25 // Pin4 RXD ---- CAN_Rx PA13 FD-CAN module 0 receive (0 to 3.3V)
26 // Pin5 VIO ---- +3.3V (digital interface supply)
27 // Pin6 CANL ---- to other CANL on network
28 // Pin7 CANH ---- to other CANH on network
29 // Pin8 RS ---- ground, Slope-Control Input (maximum slew rate)
30 // 120 ohm across CANH, CANL on both ends of network
31
32 #ifndef __CAN_H__
33 #define __CAN_H__
34 #include <stdint.h>
35
36 void CAN_Init(void);
37
38 void CAN_EnableInterrupts(uint32_t priority);
39
40 // 0 if failure
41 // 1 if ok
42 int CAN_Send(uint32_t id, uint32_t dlc, uint8_t *data);
43
44 // Returns 1 if receive data is available
45 // 0 if no receive data ready
46 int CAN_CheckMail(void);
47
48 // if receive data is ready, gets the data and returns true
49 // if no receive data is ready, returns false
50 int CAN_GetMailNonBlock(uint32_t *id, uint32_t *dlc, uint8_t *data);
51
52 // if receive data is ready, gets the data
53 // if no receive data is ready, it waits until it is ready
54 void CAN_GetMail(uint32_t *id, uint32_t *dlc, uint8_t *data);
55
56 #endif // __CAN_H__
57