![]() |
EVE 1.0
|
![]() |
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... | |
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... | |
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. | |
This CAN driver supports MCP2562x CAN chip connected with EVE SPI driver.
Public functionality included:
typedef void(* can_rx_callback_t) (const struct can_t *Can, enum can_xbuffer_t BufNum) |
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.
Can | CAN driver descriptor |
BufNum | Buffer transmitted (Tx0/Tx1/Tx2) |
TXBnCTRL | MCP2562x Transmit buffer control register Masks: TXB_TXP0 - Transmit Buffer Priority low bit TXB_TXP1 - Transmit Buffer Priority high bit TXB_TXREQ - Message Transmit Request TXB_TXERR - Transmission Error Detected TXB_MLOA - Message Lost Arbitration TXB_ABTF - Message Aborted Flag |
typedef void(* can_wake_callback_t) (const struct can_t *Can) |
typedef void(* can_err_callback_t) (const struct can_t *Can, uint8_t EREG) |
enum can_mode_t |
defines possible MCP2562x modes of operation for CanSetMode() function.
NB: values correspond to REQOP bits in CANCTRL register (except CAN_MODE_RESET and CAN_MODE_SPI_BUSY)
enum can_xbuffer_t |
defines MCP2562x TX/RX buffers for data transmission/reception.
enum can_filter_t |
defines MCP2562x Rx filter Ids and Masks.
void CanInterruptCb | ( | const struct can_t * | Can | ) |
Driver's HW interrupt callback to be exposed to EVE config.
Can | Pointer to CAN instance structure |
bool CanInit | ( | const struct can_t * | Can | ) |
Initialises CAN instance structure, connects it to SPI.
Powers up MCP2562x if supported.
Can | CAN driver descriptor |
bool CanDisable | ( | const struct can_t * | Can | ) |
Disables interrupts from MCP2562x and releases SPI.
Powers down MCP2562x if supported by product HW.
Can | CAN driver descriptor |
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.
Can | CAN driver descriptor |
bool CanSetup | ( | const struct can_t * | Can | ) |
Sets up MCP2562x registers according to preconfigured parameters.
NB! MCP2562x should be in configuration mode.
Can | CAN driver descriptor |
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.
Can | CAN driver descriptor |
BitTime | Pointer to can_bittime_t structure containing the configuration information. |
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.
Can | CAN driver descriptor |
Id | Filter identification number / mask number (11 or 29 bit) |
Filter | RX filter Id or Mask |
enum can_mode_t CanGetMode | ( | const struct can_t * | Can | ) |
Reads current MCP2562x mode of operation.
Can | CAN driver descriptor |
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.
Can | CAN driver descriptor |
Mode | Mode of operation to set. |
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.
Can | CAN driver descriptor |
Frame | Structure holding the data to send. |
Buffer | MCP2562x TX buffer to use. |
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.
Can | CAN driver descriptor |
Buffer | MCP2562x TX buffer to use |
Priority | Message priority |
TransmitReadyCb | Callback to call when transmission is done |
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.
Can | CAN driver descriptor |
Frame | Structure to copy received data to |
Buffer | MCP2562x RX buffer to read from |
bool CanReadStatus | ( | const struct can_t * | Can, |
uint8_t * | Status | ||
) |
Gets MCP2562x TX/RX buffers status (IF/RTS).
Can | CAN driver descriptor |
Status | Pointer to result: TX/RX buffers status as returned by MCP2562x "READ STATUS" command. Masks: STAT_TX2IF - Tx2 buffer interrupt flag (Tx2 was sent) STAT_TX2REQ - Tx2 RTS flag (Tx2 is pending) STAT_TX1IF - Tx1 buffer interrupt flag (Tx1 was sent) STAT_TX1REQ - Tx1 RTS flag (Tx1 is pending) STAT_TX0IF - Tx0 buffer interrupt flag (Tx0 was sent) STAT_TX0REQ - Tx0 RTS flag (Tx0 is pending) STAT_RX1IF - Rx1 buffer interrupt flag (Rx1 is ready to be read) STAT_RX0IF - Rx0 buffer interrupt flag (Rx0 is ready to be read) |
bool CanClearIF | ( | const struct can_t * | Can, |
uint8_t | Mask | ||
) |
Clear MCP2562x interrupt flag(s) by mask.
Can | CAN driver descriptor |
Mask | MCP2562x interrupt register mask Masks: INT_RX0IF - Rx0 Full Interrupt Flag bit - must be cleared by MCU to reset interrupt condition INT_RX1IF - Rx1 Full Interrupt Flag bit - must be cleared by MCU to reset interrupt condition INT_TX0IF - Tx0 Empty Interrupt Flag bit - must be cleared by MCU to reset interrupt condition INT_TX1IF - Tx1 Empty Interrupt Flag bit - must be cleared by MCU to reset interrupt condition INT_TX2IF - Tx2 Empty Interrupt Flag bit - must be cleared by MCU to reset interrupt condition INT_ERRIF - Error Interrupt Flag bit (multiple sources in the EFLG register) - must be cleared by MCU to reset interrupt condition INT_WAKIF - Wake-up Interrupt Flag bit - must be cleared by MCU to reset interrupt condition INT_MERRF - Message Error Interrupt Flag bit - must be cleared by MCU to reset interrupt condition |
bool CanInterrupts | ( | const struct can_t * | Can, |
bool | Enable | ||
) |
Sets/resets all the preconfigured interrupts.
Can | CAN driver descriptor |
Enable | true - enable some (preconfigured) interrupts, false - disable all interrupts |