![]() |
EVE 1.0
|
Driver for CAN MCP2562x in EVE. More...
#include <dev/spi.h>
Go to the source code of this file.
Data Structures | |
struct | can_t |
CAN driver descriptor: static structure for configuration of driver instance. More... | |
struct | can_state_t |
holds current CAN instance state variables. More... | |
struct | can_frame_t |
holds CAN frame and is used in driver's API to transfer frames between the driver and an application More... | |
struct | can_bittime_t |
CAN timing initialisation structure definition. More... | |
Macros | |
MCP2562x "Read Status" command result bit masks | |
#define | STAT_RX0IF (1 << 0) |
Rx0 buffer interrupt flag (Rx0 is ready to be read) | |
#define | STAT_RX1IF (1 << 1) |
Rx1 buffer interrupt flag (Rx1 is ready to be read) | |
#define | STAT_TX0REQ (1 << 2) |
Tx0 RTS flag (Tx0 is pending) | |
#define | STAT_TX0IF (1 << 3) |
Tx0 buffer interrupt flag (Tx0 being sent) | |
#define | STAT_TX1REQ (1 << 4) |
Tx1 RTS flag (Tx1 is pending) | |
#define | STAT_TX1IF (1 << 5) |
Tx1 buffer interrupt flag (Tx1 being sent) | |
#define | STAT_TX2REQ (1 << 6) |
Tx2 RTS flag (Tx2 is pending) | |
#define | STAT_TX2IF (1 << 7) |
Tx2 buffer interrupt flag (Tx2 being sent) | |
MCP2562x TXBnCTRL register (Transmit Buffer [n] Control) bit masks | |
#define | TXB_TXP_MASK (3 << 0) |
Transmit Buffer Priority mask. | |
#define | TXB_TXP0 (1 << 0) |
Transmit Buffer Priority low bit. | |
#define | TXB_TXP1 (1 << 1) |
Transmit Buffer Priority high bit. | |
#define | TXB_TXREQ (1 << 3) |
Message Transmit Request. | |
#define | TXB_TXERR (1 << 4) |
Transmission Error Detected. | |
#define | TXB_MLOA (1 << 5) |
Message Lost Arbitration. | |
#define | TXB_ABTF (1 << 6) |
Message Aborted Flag. | |
MCP2562x interrupt bit masks | |
#define | INT_RX0IF (1 << 0) |
Rx0 Full Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
#define | INT_RX1IF (1 << 1) |
Rx1 Full Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
#define | INT_TX0IF (1 << 2) |
Tx0 Empty Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
#define | INT_TX1IF (1 << 3) |
Tx1 Empty Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
#define | INT_TX2IF (1 << 4) |
Tx2 Empty Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
#define | INT_ERRIF (1 << 5) |
Error Interrupt Flag bit (multiple sources in the EFLG register) - must be cleared by MCU to reset interrupt condition. | |
#define | INT_WAKIF (1 << 6) |
Wake-up Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
#define | INT_MERRF (1 << 7) |
Message Error Interrupt Flag bit - must be cleared by MCU to reset interrupt condition. | |
Typedefs | |
typedef void(* | can_rx_callback_t) (const struct can_t *Can, enum can_xbuffer_t BufNum) |
The callback is called on CAN frame reception. More... | |
typedef void(* | can_tx_callback_t) (const struct can_t *Can, enum can_xbuffer_t BufNum, uint8_t TXBnCTRL) |
The callback is called at CAN transmission ready and transmission error. More... | |
typedef void(* | can_wake_callback_t) (const struct can_t *Can) |
The callback is called at CAN chip wakeup. More... | |
typedef void(* | can_err_callback_t) (const struct can_t *Can, uint8_t EREG) |
The callback is called at CAN chip error. More... | |
Enumerations |
Functions | |
void | CanInterruptCb (const struct can_t *Can) |
Driver's HW interrupt callback to be exposed to EVE config. More... | |
bool | CanInit (const struct can_t *Can) |
Initialises CAN instance structure, connects it to SPI. Powers up MCP2562x if supported. More... | |
bool | CanDisable (const struct can_t *Can) |
Disables interrupts from MCP2562x and releases SPI. Powers down MCP2562x if supported by product HW. More... | |
void | CanReset (const struct can_t *Can) |
Performs MCP2562x HW reset. MCP2562x switches to configuration mode after reset. NB! It should be verified that MCP2562x is in configuration mode with CanGetMode() function after reset before any subsequent operation. More... | |
bool | CanSetup (const struct can_t *Can) |
Sets up MCP2562x registers according to preconfigured parameters. NB! MCP2562x should be in configuration mode. More... | |
bool | CanSetBitTime (const struct can_t *Can, struct can_bittime_t *BitTime) |
Sets up MCP2562x CAN timing parameters. NB! MCP2562x should be in configuration mode. More... | |
bool | CanSetFilter (const struct can_t *Can, uint32_t Id, enum can_filter_t Filter) |
Sets up MCP2562x acceptance filters. NB! MCP2562x should be in configuration mode. More... | |
enum can_mode_t | CanGetMode (const struct can_t *Can) |
Reads current MCP2562x mode of operation. More... | |
bool | CanSetMode (const struct can_t *Can, enum can_mode_t Mode) |
Sets current MCP2562x mode of operation. NB! After setting new mode it should be verified that MCP2562x is in desired mode (in configuration mode after SW reset) with CanGetMode() function before any subsequent operation. More... | |
enum can_xbuffer_t | CanUploadFrame (const struct can_t *Can, struct can_frame_t *Frame, enum can_xbuffer_t Buffer) |
Loads 1 full CAN frame to MCP2562x TX register. More... | |
bool | CanSendFrame (const struct can_t *Can, enum can_xbuffer_t Buffer, enum can_priority_t Priority, can_tx_callback_t TransmitReadyCb) |
Sets priority and RTS flag to one of MCP2562x TX registers initiating transfer. More... | |
enum can_xbuffer_t | CanDownloadFrame (const struct can_t *Can, struct can_frame_t *Frame, enum can_xbuffer_t Buffer) |
Receives 1 full CAN frame from MCP2562x after Rx1/Rx2 is ready. More... | |
bool | CanReadStatus (const struct can_t *Can, uint8_t *Status) |
Gets MCP2562x TX/RX buffers status (IF/RTS). More... | |
bool | CanClearIF (const struct can_t *Can, uint8_t Mask) |
Clear MCP2562x interrupt flag(s) by mask. More... | |
bool | CanInterrupts (const struct can_t *Can, bool Enable) |
Sets/resets all the preconfigured interrupts. More... | |
Driver for CAN MCP2562x in EVE.
Definition in file can.h.