Skip to content
Emory Eng edited this page May 26, 2018 · 25 revisions

DubSat1 CAN Package

This package allows communication over the CAN bus on DUBSAT1. People on subsystems should use the CAN Wrapper package instead.

Description

A C library for the MSP430FR5994 that communicates with the MCP26525 CAN controller to send messages through a CAN bus. (Now abstracted by the canWrap API)

API

methods:

Type Method and Description
void canInit: Initializes the CAN controller and transceiver
uint8_t canSend: Sets up the required registers and requests to send
uint8_t readRxReg: Reads the Recieve Register
uint8_t loadTxBuf: Loads the Transmit Buffer
uint8_t setRegister: Sets a Register
uint8_t readRegister: Reads a Register
uint8_t bitmodify: Modifies a bit
uint8_t requestToSend: Requests to Send
uint8_t readStatus: Read a Status
uint8_t readRXStatus: Read a Receive Status
void setReceiveCallback: Sets the behavior for when a message is received

canInit

void canInit()

Description:

This method initializes the MCP25625, finishes operations in configuration mode, and sets the operation mode to normal mode.

canSend

uint8_t canSend(uint8_t bufNum, uint8_t* tech, uint8_t* msg)

Description:

Initializes the one of the transmit buffers to transmit over the CAN bus.

Returns: 0 if success CAN_FAIL if given incorrect bufNum

Parameters:

uint8_t bufNum: The transmit buffer to write to (0-2).

uint8_t* tech: Pointer to an array of length 5 specifying which values to set for TXBnSIDH, TXBnSIDL, TXBnEID8, TXBnEID0, TXBnDLC

uint8_t* msg: Pointer to an array of length 8 specifying the 8 bytes of data to send over CAN.

setRegister

uint8_t setRegister(uint8_t address, uint8_t value)

Description:

This method writes a register to the MCP25625.

Returns: 0

Parameters:

uint8_t address: the address of the register on the MCP25625 you want to write to.

uint8_t value: the value to set the register on the MCP25625.

readRegister

uint8_t readRegister(uint8_t address, uint8_t* value)

Description:

This method reads a register from the MCP25625.

Returns: 0

Parameters:

uint8_t address: the address of the register on the MCP25625 you want to read from.

uint8_t* value: the pointer to store the value read from the register.

setReceiveCallback0

void setReceiveCallback0((void (*ReceiveCallbackArg)(uint8_t, uint8_t*))

Description:

This method sets the method to run when a the receive 0 buffer is filled with data.

Parameters:

void *ReceiveCallbackArg(uint8_t, uint8_t*): A function pointer to a method that takes in the length of the array and the pointer to the array.

setReceiveCallback1

void setReceiveCallback1((void (*ReceiveCallbackArg)(uint8_t, uint8_t*))

Description:

This method sets the method to run when a the receive 1 buffer is filled with data.

Parameters:

void *ReceiveCallbackArg(uint8_t, uint8_t*): A function pointer to a method that takes in the length of the array and the pointer to the array.

setTheFilter

void setFilter(uint8_t address, uint32_t value);

Description:

This method sets a receive mask or filter.

Parameters:

uint8_t address: The address of the mask or filter to set. Can be CAN_MASK_0, CAN_MASK_1, CAN_FILTER_0, CAN_FILTER_1, CAN_FILTER_2, CAN_FILTER_3, CAN_FILTER_4, or CAN_FILTER_5

uint32_t value: The value of the filter, each bit in the 29 LSBs corresponding to the ID bits in the CAN Packet.

Wiring:

MSP430FR5994 MCP25625 Name
5V 5V n/a
P5.6 SCK CLK
3V3 3V3 n/a
GND GND (left) n/a
P5.4 SDI SIMO
P5.5 SDO SOMI
P2.4 CS_1
P5.7 INT Interrupt Pin

Transmit and Receieve Interrupts

MCP25625 Datasheet pg 26 CANINTE (Interrupt Enable pg 49) CANINTF (Interrupt Flag pg 50)

  • When transmit interrupt is enabled (TXnIE in CANINTE reg) an interrupt will be generated on the INT pin once the associated transmit buffer becomes empty.

Questions: It says it sets the PIN, which means is that physically detected or detected in software?