-
Notifications
You must be signed in to change notification settings - Fork 10
CAN
This package allows communication over the CAN bus on DUBSAT1. People on subsystems should use the CAN Wrapper package instead.
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)
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 |
void canInit()
This method initializes the MCP25625, finishes operations in configuration mode, and sets the operation mode to normal mode.
uint8_t canSend(uint8_t bufNum, uint8_t* tech, uint8_t* msg)
Initializes the one of the transmit buffers to transmit over the CAN bus.
Returns: 0 if success CAN_FAIL if given incorrect bufNum
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.
uint8_t setRegister(uint8_t address, uint8_t value)
This method writes a register to the MCP25625.
Returns: 0
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.
uint8_t readRegister(uint8_t address, uint8_t* value)
This method reads a register from the MCP25625.
Returns: 0
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.
void setReceiveCallback0((void (*ReceiveCallbackArg)(uint8_t, uint8_t*))
This method sets the method to run when a the receive 0 buffer is filled with data.
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.
void setReceiveCallback1((void (*ReceiveCallbackArg)(uint8_t, uint8_t*))
This method sets the method to run when a the receive 1 buffer is filled with data.
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.
void setFilter(uint8_t address, uint32_t value);
This method sets a receive mask or filter.
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.
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 |
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?