MSPM0_ValvanoWare  1.0
ECE445L starter code
Functions
CAN

Controller Area Network. More...

Functions

void CAN_Init (void)
 Initialize CAN. More...
 
void CAN_EnableInterrupts (uint32_t priority)
 Enable CAN interrupts. More...
 
int CAN_Send (uint32_t id, uint32_t dlc, uint8_t *data)
 Send CAN message. More...
 
int CAN_CheckMail (void)
 Check for received CAN message. More...
 
int CAN_GetMailNonBlock (uint32_t *id, uint32_t *dlc, uint8_t *data)
 Received a CAN message. More...
 
void CAN_GetMail (uint32_t *id, uint32_t *dlc, uint8_t *data)
 Receive a CAN message. More...
 

Detailed Description

Controller Area Network.

CAN pins
TCAN1057AVDRQ1MSPM0G3507
Pin1 TXD CAN_Tx PA12 FD-CAN module 0 transmit
Pin2 Vss ground
Pin3 VCC +5V with 0.1uF cap to ground
Pin4 RXD CAN_Rx PA13 FD-CAN module 0 receive (0 to 3.3V)
Pin5 VIO +3.3V (digital interface supply)
Pin6 CANL to other CANL on network
Pin7 CANH to other CANH on network
Pin8 RS ground, Slope-Control Input (maximum slew rate)

Function Documentation

◆ CAN_CheckMail()

int CAN_CheckMail ( void  )

Check for received CAN message.

Check to see if a receive message has been received on the Controller Area Network

Parameters
none
Returns
0 if no receive data ready, 1 if receive data is available

◆ CAN_EnableInterrupts()

void CAN_EnableInterrupts ( uint32_t  priority)

Enable CAN interrupts.

enable interrupts on the Controller Area Network

Parameters
priority0(highest) to 3(lowest)
Returns
none

◆ CAN_GetMail()

void CAN_GetMail ( uint32_t *  id,
uint32_t *  dlc,
uint8_t *  data 
)

Receive a CAN message.

Receive message on the Controller Area Network, blocking. If receive data is ready, gets the data and returns. If no receive data is ready, it will spin waiting for message

Parameters
idpointer to 11-bit id
dlcpointer to data length
dataarray of data received (0 to 8 bytes)
Returns
none

◆ CAN_GetMailNonBlock()

int CAN_GetMailNonBlock ( uint32_t *  id,
uint32_t *  dlc,
uint8_t *  data 
)

Received a CAN message.

Receive message on the Controller Area Network, nonblocking. If receive data is ready, gets the data and returns true. If no receive data is ready, returns false

Parameters
idpointer to 11-bit id, valid if function returns true
dlcpointer to data length, valid if function returns true
dataarray of data received (0 to 8 bytes), valid if function returns true
Returns
0 if no receive data ready, 1 if message received

◆ CAN_Init()

void CAN_Init ( void  )

Initialize CAN.

initialize Controller Area Network
bit rate 1Mbps

Parameters
none
Returns
none

◆ CAN_Send()

int CAN_Send ( uint32_t  id,
uint32_t  dlc,
uint8_t *  data 
)

Send CAN message.

Send a message on the Controller Area Network

Parameters
id11-bit identifier
dlc0 to 8, data length
dataarray of data to send (0 to 8 bytes)
Returns
0 if failure, 1 if ok