Altera HWLIB  16.0
The Altera HW Manager API Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
CAN Controller API

Description

This module defines an API for configuring and managing the HPS CAN controllers.

The hardware processor system (HPS) provides two controller area network (CAN) controllers for serial communication with the Cortex™-A9 microprocessor unit (MPU) subsystem host processor and the direct memory access (DMA) controller using the CAN protocol. The CAN controllers are instances of the Bosch D_CAN controller and compliant with ISO 11898-1.

The CAN controllers perform communication according to the CAN protocol version 2.0 parts A and B. All communication on the CAN bus is through message objects. The CAN controller stores message objects in its internal message RAM. The host processor cannot access the message RAM directly, instead the IF1and IF2message interface register sets provide the host processor access to the messages. Messages are passed between the message RAM and the CAN core by the message handler. The message handler is also responsible for message level responsibilities such as acceptance filtering, interrupt generation, and transmission request generation.

Features of the CAN Controller:

For a complete details on the configuration and operation of CAN controller, consult the following references:

Data Structures

struct  ALT_CAN_MAILBOX_PARAM_s
 
struct  ALT_CAN_STATUS_s
 
struct  ALT_CAN_BITTIME_s
 
struct  ALT_CAN_MSG_PARAM_s
 
struct  ALT_CAN_MSG_MSK_s
 
struct  ALT_CAN_MSG_ARB_s
 
struct  ALT_CAN_MSG_IFMCTR_s
 
struct  ALT_CAN_ERROR_COUNTER_s
 

Macros

#define ALT_CAN_MAILBOXES_COUNT   (128)
 
#define ALT_CAN_DEFAULT_BAUDRATE   (100000)
 

Typedefs

typedef enum ALT_CAN_TMOD_e ALT_CAN_TMOD_t
 
typedef enum ALT_CAN_FIFO_MODE_e ALT_CAN_FIFO_MODE_t
 
typedef struct
ALT_CAN_MAILBOX_PARAM_s 
ALT_CAN_MAILBOX_PARAM_t
 
typedef enum ALT_CAN_CTLR_e ALT_CAN_CTLR_t
 
typedef enum ALT_CAN_INTERFACE_e ALT_CAN_INTERFACE_t
 
typedef enum ALT_CAN_TEST_TYPE_e ALT_CAN_TEST_TYPE_t
 
typedef enum ALT_CAN_LAST_ERROR_e ALT_CAN_LAST_ERROR_t
 
typedef struct ALT_CAN_STATUS_s ALT_CAN_STATUS_t
 
typedef struct ALT_CAN_BITTIME_s ALT_CAN_BITTIME_t
 
typedef struct ALT_CAN_MSG_PARAM_s ALT_CAN_MSG_PARAM_t
 
typedef struct ALT_CAN_MSG_MSK_s ALT_CAN_MSG_MSK_t
 
typedef struct ALT_CAN_MSG_ARB_s ALT_CAN_MSG_ARB_t
 
typedef struct ALT_CAN_MSG_IFMCTR_s ALT_CAN_MSG_IFMCTR_t
 
typedef enum ALT_CAN_INT_GROUP_e ALT_CAN_INT_GROUP_t
 
typedef struct
ALT_CAN_ERROR_COUNTER_s 
ALT_CAN_ERROR_COUNTER_t
 

ENUMS

enum  ALT_CAN_TMOD_e { ALT_CAN_TMOD_TX = 0, ALT_CAN_TMOD_RX = 1 }
 
enum  ALT_CAN_FIFO_MODE_e { ALT_CAN_FIFO_MODE_SINGLE_MSG, ALT_CAN_FIFO_MODE_BUFFER_NOT_LAST, ALT_CAN_FIFO_MODE_BUFFER_LAST }
 
enum  ALT_CAN_CTLR_e { ALT_CAN_CAN0 = (int)ALT_CAN0_OFST, ALT_CAN_CAN1 = (int)ALT_CAN1_OFST }
 
enum  ALT_CAN_INTERFACE_e { ALT_CAN_INTERFACE_READ = (int)ALT_CAN_MSGIF_IF1CMR_OFST, ALT_CAN_INTERFACE_WRITE = (int)ALT_CAN_MSGIF_IF2CMR_OFST }
 
enum  ALT_CAN_TEST_TYPE_e
 
enum  ALT_CAN_LAST_ERROR_e {
  ALT_CAN_STAT_ERROR_NOERROR, ALT_CAN_STAT_ERROR_STUFF, ALT_CAN_STAT_ERROR_FORM, ALT_CAN_STAT_ERROR_ACK,
  ALT_CAN_STAT_ERROR_BIT1, ALT_CAN_STAT_ERROR_BIT0, ALT_CAN_STAT_ERROR_CRC, ALT_CAN_STAT_ERROR_NOCNG
}
 
enum  ALT_CAN_INT_GROUP_e {
  ALT_CAN_INT_GROUP_MOD_LINE = 1UL << 0, ALT_CAN_INT_GROUP_STATUS = 1UL << 1, ALT_CAN_INT_GROUP_ERROR = 1UL << 2, ALT_CAN_INT_GROUP_MSG_LINE = 1UL << 3,
  ALT_CAN_INT_GROUP_ALL = 0xF
}
 

Functions

ALT_STATUS_CODE alt_can_init (const ALT_CAN_CTLR_t can, ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_reset (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_disable (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_enable (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_is_enabled (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_baudrate_set (ALT_CAN_DEV_t *can_dev, const uint32_t bitrate)
 
ALT_STATUS_CODE alt_can_uninit (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_int_disable (ALT_CAN_DEV_t *can_dev, const uint8_t mask)
 
ALT_STATUS_CODE alt_can_int_enable (ALT_CAN_DEV_t *can_dev, const uint8_t mask)
 
ALT_STATUS_CODE alt_can_int_ident_get (ALT_CAN_DEV_t *can_dev, uint32_t *interrupt)
 
ALT_STATUS_CODE alt_can_int_status_get (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_bit_timing_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_BITTIME_t *params)
 
ALT_STATUS_CODE alt_can_bit_timing_set (ALT_CAN_DEV_t *can_dev, ALT_CAN_BITTIME_t *bittime)
 
ALT_STATUS_CODE alt_can_rate_to_bittime (ALT_CAN_DEV_t *can_dev, uint32_t bitrate, ALT_CAN_BITTIME_t *bittime)
 
ALT_STATUS_CODE alt_can_test_mode_disable (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_test_mode_enable (ALT_CAN_DEV_t *can_dev, ALT_CAN_TEST_TYPE_t type)
 
ALT_STATUS_CODE alt_can_test_mode_is_enabled (ALT_CAN_DEV_t *can_dev, ALT_CAN_TEST_TYPE_t *type)
 
ALT_STATUS_CODE alt_can_error_counter_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_ERROR_COUNTER_t *counter)
 
ALT_STATUS_CODE alt_can_status_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_STATUS_t *status)
 
ALT_STATUS_CODE alt_can_if_cmd_set (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, uint32_t msg_obj_num, ALT_CAN_MSG_PARAM_t *cmd_params)
 
ALT_STATUS_CODE alt_can_if_mask_set (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, ALT_CAN_MSG_MSK_t *mask_param)
 
ALT_STATUS_CODE alt_can_if_mask_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, ALT_CAN_MSG_MSK_t *mask_param)
 
ALT_STATUS_CODE alt_can_if_arb_set (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, ALT_CAN_MSG_ARB_t *arb_param)
 
ALT_STATUS_CODE alt_can_if_arb_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, ALT_CAN_MSG_ARB_t *arb_param)
 
ALT_STATUS_CODE alt_can_if_msg_ctrl_set (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, ALT_CAN_MSG_IFMCTR_t *ctrl)
 
ALT_STATUS_CODE alt_can_if_msg_ctrl_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, ALT_CAN_MSG_IFMCTR_t *ctrl)
 
ALT_STATUS_CODE alt_can_if_data_set (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, uint32_t dataA, uint32_t dataB)
 
ALT_STATUS_CODE alt_can_if_data_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, uint32_t *dataA, uint32_t *dataB)
 
ALT_STATUS_CODE alt_can_mailbox_reset (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, uint32_t msg_obj_num)
 
ALT_STATUS_CODE alt_can_message_is_busy (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index)
 
ALT_STATUS_CODE alt_can_message_put (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, uint32_t msg_obj_num, ALT_CAN_MSG_PARAM_t *cmd_params)
 
ALT_STATUS_CODE alt_can_message_get (ALT_CAN_DEV_t *can_dev, ALT_CAN_INTERFACE_t if_index, uint32_t msg_obj_num, ALT_CAN_MSG_PARAM_t *cmd_params)
 
ALT_STATUS_CODE alt_can_mailbox_init (ALT_CAN_DEV_t *can_dev, uint32_t msg_obj_num, uint32_t id, uint32_t id_mask, ALT_CAN_TMOD_t transfer_mode, ALT_CAN_FIFO_MODE_t fifo_mode)
 
ALT_STATUS_CODE alt_can_mailbox_uninit (ALT_CAN_DEV_t *can_dev, uint32_t msg_obj_num)
 
ALT_STATUS_CODE alt_can_mailboxes_reset (ALT_CAN_DEV_t *can_dev)
 
ALT_STATUS_CODE alt_can_frame_read (ALT_CAN_DEV_t *can_dev, uint32_t msg_obj_num, void *buffer, uint32_t *frame_size)
 
ALT_STATUS_CODE alt_can_frame_write (ALT_CAN_DEV_t *can_dev, uint32_t msg_obj_num, void *buffer)
 
ALT_STATUS_CODE alt_can_data_read (ALT_CAN_DEV_t *can_dev, uint32_t msg_obj_num, void *buffer, uint32_t size, uint32_t *bytes_read)
 
ALT_STATUS_CODE alt_can_data_write (ALT_CAN_DEV_t *can_dev, uint32_t msg_obj_num, void *buffer, uint32_t size)
 

Data Structure Documentation

struct ALT_CAN_MAILBOX_PARAM_s

This type defines a structure for status and parameters of specified mailbox.

Data Fields
uint32_t id Identifier Mask
uint32_t mask Identifier Mask for acceptance filtering of incoming messages.
uint32_t dlc Data Length Code
ALT_CAN_TMOD_t transfer_mode Transfer mode
bool init_done Initialization is completed for specified mailbox if init_done is true
bool extend Extended Identifier true - the 29-bit (extended) identifier will be used for this mailbox. false - the 11-bit (standard) identifier will be used for this Message Object.
bool remote Remote Enable true - at the reception of a Remote Frame, TxRqst is set. false - at the reception of a Remote Frame, TxRqst is left unchanged.
ALT_CAN_FIFO_MODE_t fifo_mode Single message object, or fifo mode
struct ALT_CAN_STATUS_s

This type defines a structure for status of CAN instance.

Data Fields
ALT_CAN_LAST_ERROR_t last_err_code The LEC field holds a code which indicates the type of the last error to occur on the CAN bus. This field will be cleared to 0 when a message has been transferred (reception or transmission) without error..
bool tx_success Since this bit was last reset by a read access of the CPU, a message has been successfully (error free and acknowledged by at least one other node) transmitted. This bit will be reset by reading the Status Register.
bool rx_success Since this bit was last reset by a read access of the CPU, a message has been successfully received (independently of the result of acceptance filtering). This bit will be reset by reading the Status Register.
bool err_passive Limited error signaling and transmission features.
bool warning At least one of the error counters in the EML has reached the error warning limit of 96.
bool bus_off The CAN module is in Bus_Off state.
bool par_error The Parity Check Mechanism has detected a parity error in the Message RAM, this bit will be reset if Status Register is read.
struct ALT_CAN_BITTIME_s

This type defines a structure for status of CAN instance.

Data Fields
uint32_t brp The value by which the oscillator frequency is divided for generating the bit time quanta.
uint32_t sjw Synchronisation jump width in TQs. The actual interpretation by the hardware of this value is such that one more than the value programmed here is used.
uint32_t tseg1 The time segment before the sample point
uint32_t tseg2 The time segment after the sample point
uint32_t brpe By programming BRPE the Baud Rate Prescaler can be extended to values up to 1023. The actual interpretation by the hardware is that one more than the value programmed by BRPE (MSBs) and BRP (LSBs) is used.
struct ALT_CAN_MSG_PARAM_s

This type defines a structure for config parameters of CAN Message Object.

Data Fields
bool auto_inc The behavior of the Message Object Number increment depends on the Transfer Direction, IFxCMR.WR1RD0. Read: The first transfer will be initiated (Busy Bit will set) at write of IFxCMR.MONum. The Message Object Number will be incremented and the next Message Object will be transferred from Message Object RAM to Interface Registers after a read access of Data-Byte 7. Write: The first as well as each other transfer will be started after write access to Data- Byte7. The Message Object Number will be incremented after successful transfer from the Interface Registers to the Message Object RAM..
bool DMA_active Activation of DMA feature for subsequent internal IFx Register Set
bool data_B Access Data Bytes 4-7 Write Direction: false = Data Bytes 4-7 unchanged. true = transfer Data Bytes 4-7 to Message Object. Read Direction: false = Data Bytes 4-7 unchanged. true = transfer Data Bytes 4-7 to IFxDB.
bool data_A Access Data Bytes 0-3 Write Direction: false = Data Bytes 0-3 unchanged. true = transfer Data Bytes 0-3 to Message Object. Read Direction: false = Data Bytes 0-3 unchanged. true = transfer Data Bytes 0-3 to IFxDA.
bool tx_rqst_new_dat Access Transmission Request Bit and NewDat Bit Write Direction: false = TxRqst and NewDat bit will be handled according IFxMCTR.NewDat bit and IFxMCTR.TxRqst bit. true = set TxRqst and NewDat in Message Object to one Note: If a CAN transmission is requested by setting IFxCMR.TxRqst/NewDat, the TxRqst and NewDat bits in the Message Object will be set to one independently of the values in IFxMCTR. Read Direction: false = NewDat bit remains unchanged. true = clear NewDat bit in the Message Object. Note: A read access to a Message Object can be combined with the reset of the control bits IntPnd and NewDat. The values of these bits transferred to the IFxMCTR always reflect the status before resetting them.
bool clr_int_pnd Clear Interrupt Pending Bit Write Direction: Has no influence to Message Object at write transfer. Note: When writing to a Message Object, this bit is ignored and copying of IntPnd flag from IFx Control Register to Message RAM could only be controlled by IFxMTR.IntPnd bit. Read Direction: false = IntPnd bit remains unchanged. true = clear IntPnd bit in the Message Object.
bool control Access control Bits Write Direction: false = Control Bits unchanged. true = transfer Control Bits to Message Object. Note: If IFxCMR.TxRqst/NewDat bit is set, bits IFxMCTR.TxRqst and IFxMCTR.NewDat will be ignored. Read Direction: false = Control Bits unchanged. true = transfer Control Bits to IFxMCTR Register.
bool arbitration Access Arbitration Bits Write Direction: false = Control Bits unchanged. true = transfer Control Bits to Message Object. Note: If IFxCMR.TxRqst/NewDat bit is set, bits IFxMCTR.TxRqst and IFxMCTR.NewDat will be ignored. Read Direction: false = Control Bits unchanged. true = transfer Control Bits to IFxMCTR Register.
bool mask Access mask Bits Write Direction: false = Mask bits unchanged. true = transfer Identifier Mask + MDir + MXtd to Message Object. Read Direction: false = Mask bits unchanged. true = transfer Identifier Mask + MDir + MXtd to IFxMSK Register.
bool write true = write transfer false = read transfer
bool clr_auto_inc Clear the AutoInc bit without starting a transfer, all other bits will be ignored.
struct ALT_CAN_MSG_MSK_s

This type defines a structure for message mask of CAN message object.

Data Fields
uint32_t mask Identifier Mask ID28 - ID0 29-bit Identifier (Extended Frame). ID28 - ID18 11-bit Identifier (Standard Frame).
bool direction Mask Message Direction true = the message direction bit (Dir) is used for acceptance filtering..
bool extended Mask Extended Identifier true = the extended identifier bit (IDE) is used for acceptance filtering..
struct ALT_CAN_MSG_ARB_s

This type defines a structure for message control arbitration of CAN message object.

Data Fields
uint32_t id Identifier Mask ID28 - ID0 29-bit Identifier (Extended Frame). ID28 - ID18 11-bit Identifier (Standard Frame).
bool direction Message Direction On TxRqst, the respective Message Object is transmitted as a Data Frame. On reception of a Remote Frame with matching identifier, the TxRqst bit of this Message Object is set (if RmtEn = one)..
bool extended Extended Identifier true = The 29-bit (extended) Identifier will be used for this Message Object. false = The 11-bit (standard) Identifier will be used for this Message Object.
bool valid Message Valid The CPU must reset the MsgVal bit of all unused Messages Objects during the initialization before it resets bit Init in the CAN Control Register. MsgVal must also be reset if the Messages Object is no longer used in operation. For reconfiguration of Message Objects during normal operation..
struct ALT_CAN_MSG_IFMCTR_s

This type defines a structure for message control parameters of CAN message object.

Data Fields
uint32_t data_len Data Length Code 0-8 Data Frame has 0-8 data bytes. 9-15 Data Frame has 8 data bytes. Note: The Data Length Code of a Message Object must be defined the same as in all the corresponding objects with the same identifier at other nodes. When the Message Handler stores a data frame, it will write the DLC to the value given by the received message.
bool block_end End Of Block Single Message Object or last Message Object of a FIFO Buffer Block.
bool tx_rqst Transmit Request The transmission of this Message Object is requested and is not yet done.
bool remote Remote Enable At the reception of a Remote Frame, TxRqst is set.
bool rx_int Receive Interrupt Enable IntPnd will be set after a successful reception of a frame.
bool tx_int Transmit Interrupt Enable IntPnd will be set after a successful transmission of a frame.
bool accept_mask Use Acceptance Mask (Msk28-0, MXtd, and MDir) for acceptance filtering, formula: ((RTRRx & MDIR) == (~DIR & MDIR)) && ((IDERx & MXtd) == (IDE & MXtd)) && ((IDRx & Msk) == (ID & Msk)) Note: If the UMask bit is set to one, the Message Object's mask bits have to be programmed during initialization of the Message Object before MsgVal is set to one.
bool int_pending Interrupt Pending This message object is the source of an interrupt. The Interrupt Identifier in the Interrupt Register will point to this message object if there is no other interrupt source with higher priority.
bool msg_lost Message Lost The Message Handler stored a new message into this object when NewDat was still set, the CPU has lost a message.
bool new_data New Data The Message Handler or the CPU has written new data into the data portion of this Message Object.
struct ALT_CAN_ERROR_COUNTER_s

This type defines a structure for error counters of CAN controller.

Data Fields
uint32_t tx_error_counter Transmit Error Counter values betwen 0 and 255.
uint32_t rx_error_counter Receive Error Counter Values between 0 and 127.
bool rx_above_passive If receive error counter has reached the error passive level. 0 below, 1 above.

Macro Definitions

#define ALT_CAN_MAILBOXES_COUNT   (128)

The number of mailboxes of the CAN controller.

#define ALT_CAN_DEFAULT_BAUDRATE   (100000)

Default baudrate.

Typedef Documentation

This type enumerates the CAN transfer mode choices.

This type enumerates single message object or FIFO mode for a mailbox.

This type defines a structure for status and parameters of specified mailbox.

This type enumerates the HPS CAN controller instances.

This type enumerates the HPS CAN message interfaces.

This type enumerates the test types for the CAN controller.

This type enumerates interrupt groups for the CAN controller.

This type defines a structure for status of CAN instance.

This type defines a structure for status of CAN instance.

This type defines a structure for config parameters of CAN Message Object.

This type defines a structure for message mask of CAN message object.

This type defines a structure for message control arbitration of CAN message object.

This type defines a structure for message control parameters of CAN message object.

This type enumerates interrupt groups for the CAN controller.

This type defines a structure for error counters of CAN controller.

Enumeration Type Documentation

This type enumerates the CAN transfer mode choices.

Enumerator:
ALT_CAN_TMOD_TX 

Transmit mode

ALT_CAN_TMOD_RX 

Receive mode

This type enumerates single message object or FIFO mode for a mailbox.

Enumerator:
ALT_CAN_FIFO_MODE_SINGLE_MSG 

This mailbox uses single message object. In this mode, after the message object transmits/receives a frame, it'll be automatically reenabled for the next transmission or reception.

ALT_CAN_FIFO_MODE_BUFFER_NOT_LAST 

This mailbox belongs to FIFO buffer block, and is not the last message of that FIFO buffer block. After the message object transmits/receives a frame, it'll be disabled and won't be reused.

ALT_CAN_FIFO_MODE_BUFFER_LAST 

This mailbox belongs to FIFO buffer block, and is the last message of that FIFO buffer block. After the message object transmits/receives a frame, it'll be disabled and won't be reused.

This type enumerates the HPS CAN controller instances.

Enumerator:
ALT_CAN_CAN0 

CAN0 instance.

ALT_CAN_CAN1 

CAN1 instance.

This type enumerates the HPS CAN message interfaces.

Enumerator:
ALT_CAN_INTERFACE_READ 

IF1 Register.

ALT_CAN_INTERFACE_WRITE 

IF2 Register.

This type enumerates the test types for the CAN controller.

This type enumerates interrupt groups for the CAN controller.

Enumerator:
ALT_CAN_STAT_ERROR_NOERROR 

Set together with CSTS.RxOK or CSTS.TxOK.

ALT_CAN_STAT_ERROR_STUFF 

More than 5 equal bits in a sequence have occurred in a part of a received message where this is not allowed.

ALT_CAN_STAT_ERROR_FORM 

A fixed format part of a received frame has the wrong format.

ALT_CAN_STAT_ERROR_ACK 

The message this CAN Core transmitted was not acknowledged by another node.

ALT_CAN_STAT_ERROR_BIT1 

During the transmission of a message (with the exception of the arbitration field), the device wanted to send a recessive level (bit of logical value 1), but the monitored bus value was dominant.

ALT_CAN_STAT_ERROR_BIT0 

During the transmission of a message (or acknowledge bit, or active error flag, or overload flag), the device wanted to send a dominant level (data or identifier bit logical value 0), but the monitored bus value was recessive. During Bus_Off recovery this status is set each time a sequence of 11 recessive bits has been monitored. This enables the CPU to monitor the proceeding of the Bus_Off recovery sequence (indicating the bus is not stuck at dominant or continuously disturbed).

ALT_CAN_STAT_ERROR_CRC 

The CRC checksum was incorrect in the message received, the CRC received for an incoming message does not match with the calculated CRC for the received data.

ALT_CAN_STAT_ERROR_NOCNG 

Any read access to the Status Register re initializes the LEC to 7. When the LEC shows the value 7, no CAN bus event was detected since the last CPU read access to the Status Register..

This type enumerates interrupt groups for the CAN controller.

Enumerator:
ALT_CAN_INT_GROUP_MOD_LINE 

Error and status interrupts (if CCTRL.EIE=1 and CCTRL.SIE=1) will set line CAN_INT_STATUS to one, signal remains one until all pending interrupts are processed. If MIL is disabled, the message object interrupts will also affect this interrupt line.

ALT_CAN_INT_GROUP_STATUS 

When a message transfer is successfully completed or a CAN bus error is detected, indicated by flags CSTS.RxOk, CSTS.TxOk and CSTS.LEC, the interrupt line CAN_INT_STATUS gets active (if ILE=1) and CIR.StatusInt is set.

ALT_CAN_INT_GROUP_ERROR 

If CSTS.PER flag is one, or CSTS.BOff or CSTS. EWarn are changed, the interrupt line CAN_INT_STATUS gets active (if ILE=1) and CIR.StatusInt is set.

ALT_CAN_INT_GROUP_MSG_LINE 

Message object interrupts will set CAN_INT_MO to one, signal remains one until all pending interrupts are processed.

ALT_CAN_INT_GROUP_ALL 

All Combined and Individual Interrupts.

Function Documentation

ALT_STATUS_CODE alt_can_init ( const ALT_CAN_CTLR_t  can,
ALT_CAN_DEV_t *  can_dev 
)

Initializes the specified CAN controller instance for use and return a device handle referencing it.

Parameters
canThe HPS CAN controller instance to initialize.
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_reset ( ALT_CAN_DEV_t *  can_dev)

Resets the specified CAN controller instance for use.

Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_disable ( ALT_CAN_DEV_t *  can_dev)

Disables the CAN controller.

When the CAN controller is disabled, the following occurs:

  • The Init bit in the CAN control register (CCTRL) is set to 1.
  • While the Init bit is 1, messages are not transferred to or from the CAN bus, and the CAN_TXD CAN bus output is held in the high state.
Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_enable ( ALT_CAN_DEV_t *  can_dev)

Enables the CAN controller.

When the CAN controller is enabled, the following occurs:

  • The Init bit in the CAN control register (CCTRL) is cleared to 0.
  • The CAN core synchronizes itself to the data transfer on the CAN bus by waiting for the bus to reach an idle state before it can take part in bus activities and message transfers.
Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_is_enabled ( ALT_CAN_DEV_t *  can_dev)

Returns ALT_E_TRUE if the CAN controller is enabled, ALT_E_FALSE otherwise

Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_TRUEThe CAN controller in question is enabled.
ALT_E_FALSEThe CAN controller in question is disabled.
ALT_STATUS_CODE alt_can_baudrate_set ( ALT_CAN_DEV_t *  can_dev,
const uint32_t  bitrate 
)

Configures the specified CAN controller instance to the desired baudrate.

Parameters
can_devA pointer to the CAN controller device block instance.
bitratebaudrate desired
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_uninit ( ALT_CAN_DEV_t *  can_dev)

Uninitializes the CAN controller referenced by the can_dev handle.

This function attempts to gracefully shutdown the CAN controller by waiting for any incomplete transactions to finish and then putting the CAN controller into reset.

Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_int_disable ( ALT_CAN_DEV_t *  can_dev,
const uint8_t  mask 
)

Disables the specified CAN controller interrupt status conditions identified in the mask.

This function disables one or more of the status conditions as contributors to the ALT_INT_INTERRUPT_CANn_IRQ interrupt signal state.

NOTE: A cleared bit for any status condition in the mask value does not have the effect of enabling it as a contributor to the ALT_INT_INTERRUPT_CANn_IRQ interrupt signal state. The function alt_can_int_enable() is used to enable status source conditions.

Parameters
can_devA pointer to the CAN controller device block instance.
maskSpecifies the status conditions to disable as interrupt source contributors. mask is a mask of logically OR'ed ALT_CAN_STATUS_t values that designate the status conditions to disable.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_int_enable ( ALT_CAN_DEV_t *  can_dev,
const uint8_t  mask 
)

Enables the specified CAN controller interrupt status conditions identified in the mask.

This function enables one or more of the status conditions as contributors to the ALT_INT_INTERRUPT_CANn_IRQ interrupt signal state.

NOTE: A cleared bit for any status condition in the mask value does not have the effect of disabling it as a contributor to the ALT_INT_INTERRUPT_CANn_IRQ interrupt signal state. The function alt_can_int_disable() is used to disable status source conditions.

Parameters
can_devA pointer to the CAN controller device block instance.
maskSpecifies the status conditions to enable as interrupt source contributors. mask is a mask of logically OR'ed ALT_CAN_STATUS_t values that designate the status conditions to enable.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_int_ident_get ( ALT_CAN_DEV_t *  can_dev,
uint32_t *  interrupt 
)

Gets the interrupt identifier of the CAN instance.

Parameters
can_devA pointer to the CAN controller device block instance.
interrupt[out] Pointer to a 32bit structure for holding the returned interrupt identifier.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_int_status_get ( ALT_CAN_DEV_t *  can_dev)

Returns the current CAN controller status interrupt conditions.

This function returns the current value of the CAN controller interrupt status register value which reflects the current CAN controller status conditions that are not disabled (i.e. masked).

Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_TRUEStatus Interrupt has occurred.
ALT_E_FALSEStatus Interrupt has not occurred.
ALT_STATUS_CODE alt_can_bit_timing_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_BITTIME_t params 
)

Gets the current configuration of the CAN bittiming.

Parameters
can_devA pointer to the CAN controller device block instance.
params[out] Pointer to a ALT_CAN_BITTIME_t structure for holding the returned CAN bittiming parameters.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_bit_timing_set ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_BITTIME_t bittime 
)

Sets the configuration of the CAN bittiming.

Parameters
can_devA pointer to the CAN controller device block instance.
bittimePointer to a ALT_CAN_BITTIME_t structure holding the desired CAN bittiming parameters.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_rate_to_bittime ( ALT_CAN_DEV_t *  can_dev,
uint32_t  bitrate,
ALT_CAN_BITTIME_t bittime 
)

Returns CAN controller configurations based on speed parameter(Hz).

Parameters
can_devA pointer to the CAN controller device instance.
bitrateSpeed (Hz) of the can bus.
bittimeA pointer to the structure for bittiming configurations.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_test_mode_disable ( ALT_CAN_DEV_t *  can_dev)

Disables test mode of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_test_mode_enable ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_TEST_TYPE_t  type 
)

Enables test mode of the CAN controler and set type of it.

Parameters
can_devA pointer to the CAN controller device block instance.
typeThe type of test mode. Valid values: ALT_CAN_TEST_SILENT, ALT_CAN_TEST_LOOP_BACK, ALT_CAN_TEST_MIXED.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_test_mode_is_enabled ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_TEST_TYPE_t type 
)

Returns ALT_E_TRUE if the test mode of the CAN controller is enabled.

Parameters
can_devA pointer to the CAN controller device block instance.
typeTest mode type.
Return values
ALT_E_TRUE- test mode is enabled.
ALT_E_FALSE- test mode is not enabled
ALT_E_ERROR- Details about error status code
ALT_STATUS_CODE alt_can_error_counter_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_ERROR_COUNTER_t counter 
)

Returns the error counters of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
counter[out] Pointer to the ALT_CAN_ERROR_COUNTER_t structure for holding Transmit Error Counter, Receive Error Counter and Receive Error Passive.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_status_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_STATUS_t status 
)

Gets the current status of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
status[out] Pointer to a ALT_CAN_STATUS_t structure for holding the returned CAN status.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_cmd_set ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
uint32_t  msg_obj_num,
ALT_CAN_MSG_PARAM_t cmd_params 
)

Sets the message object parameters of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
msg_obj_numMessage Number. 0x01-0x80 Valid Message Number. msg_obj_num is the Message Object in the Message RAM selected for data transfer (up to 128 MsgObj).
cmd_paramsPointer to a ALT_CAN_MSGIF_IF1CMR_t structure for holding the command configurations.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_mask_set ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
ALT_CAN_MSG_MSK_t mask_param 
)

Sets the message object mask of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
mask_paramPointer to a ALT_CAN_MSG_MSK_t structure for holding the message object mask.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_mask_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
ALT_CAN_MSG_MSK_t mask_param 
)

Gets the message object mask of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
mask_param[out]Pointer to a ALT_CAN_MSG_MSK_t structure for holding the message object mask.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_arb_set ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
ALT_CAN_MSG_ARB_t arb_param 
)

Sets the message object arbitration of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
arb_paramPointer to a ALT_CAN_MSG_ARB_t structure for holding the message object mask.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_arb_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
ALT_CAN_MSG_ARB_t arb_param 
)

Gets the message object arbitration of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
arb_param[out]Pointer to a ALT_CAN_MSG_ARB_t structure for holding the message object mask.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_msg_ctrl_set ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
ALT_CAN_MSG_IFMCTR_t ctrl 
)

Sets the message object control of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
ctrlPointer to a ALT_CAN_MSGIF_IF1MCTR_t structure holding the desired CAN message parameters.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_msg_ctrl_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
ALT_CAN_MSG_IFMCTR_t ctrl 
)

Gets the message object control of the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
ctrl[out] Pointer to a ALT_CAN_MSGIF_IF1MCTR_t structure holding the desired CAN message parameters.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_data_set ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
uint32_t  dataA,
uint32_t  dataB 
)

Sets 8 data bytes on the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
dataAValue for holding 1 - 4 bytes of CAN data.
dataBValue for holding 5 - 8 bytes of CAN data.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_if_data_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
uint32_t *  dataA,
uint32_t *  dataB 
)

Gets 8 data bytes from the CAN controller.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
dataA[out] Pointer to integer value for holding 1 - 4 bytes of CAN data.
dataB[out] Pointer to integer value for holding 5 - 8 bytes of CAN data.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_mailbox_reset ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
uint32_t  msg_obj_num 
)

Resets specified mailbox.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_message_is_busy ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index 
)

Returns ALT_E_TRUE if specified message in specified interface is busy.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
Return values
ALT_E_TRUE- Message object is writing.
ALT_E_FALSE- Message object is free.
ALT_E_ERROR- Details about error status code
ALT_STATUS_CODE alt_can_message_put ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
uint32_t  msg_obj_num,
ALT_CAN_MSG_PARAM_t cmd_params 
)

Puts Message Object to mailbox from interface registers.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
cmd_paramsPointer to a ALT_CAN_MSGIF_IF1CMR_t structure for holding the command configurations.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_message_get ( ALT_CAN_DEV_t *  can_dev,
ALT_CAN_INTERFACE_t  if_index,
uint32_t  msg_obj_num,
ALT_CAN_MSG_PARAM_t cmd_params 
)

Gets Message Object from mailbox to interface registers.

Parameters
can_devA pointer to the CAN controller device block instance.
if_indexInterface number. Valid number 1 or 2.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
cmd_paramsPointer to a ALT_CAN_MSGIF_IF1CMR_t structure for holding the command configurations.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_mailbox_init ( ALT_CAN_DEV_t *  can_dev,
uint32_t  msg_obj_num,
uint32_t  id,
uint32_t  id_mask,
ALT_CAN_TMOD_t  transfer_mode,
ALT_CAN_FIFO_MODE_t  fifo_mode 
)

Initializes mailbox for transfer with specified parameters.

Parameters
can_devA pointer to the CAN controller device block instance.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
idIdentifier Mask for message identifier. ID28 - ID0 29-bit Identifier (Extended Frame). ID28 - ID18 11-bit Identifier (Standard Frame).
id_maskIdentifier Mask for filtering. ID28 - ID0 29-bit Identifier (Extended Frame). ID28 - ID18 11-bit Identifier (Standard Frame).
transfer_modeOne transfer mode type of enumerate ALT_CAN_TMOD_t.
fifo_modeone type of enumerate ALT_CAN_FIFO_MODE_t.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_mailbox_uninit ( ALT_CAN_DEV_t *  can_dev,
uint32_t  msg_obj_num 
)

Uninitializes mailbox for transfer.

Parameters
can_devA pointer to the CAN controller device block instance.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_mailboxes_reset ( ALT_CAN_DEV_t *  can_dev)

Resets all mailboxes (uninitialize all mailboxes).

Parameters
can_devA pointer to the CAN controller device block instance.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_frame_read ( ALT_CAN_DEV_t *  can_dev,
uint32_t  msg_obj_num,
void *  buffer,
uint32_t *  frame_size 
)

Reads one frame of the data.

Parameters
can_devA pointer to the CAN controller device block instance.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
buffer[out] Pointer to the memory for saving received data.
frame_size[out] Pointer to the memory for storing frame size in bytes.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_frame_write ( ALT_CAN_DEV_t *  can_dev,
uint32_t  msg_obj_num,
void *  buffer 
)

Writes one frame of the data (size of frame = data length code).

Parameters
can_devA pointer to the CAN controller device block instance.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
bufferPointer to the memory with sending data.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_data_read ( ALT_CAN_DEV_t *  can_dev,
uint32_t  msg_obj_num,
void *  buffer,
uint32_t  size,
uint32_t *  bytes_read 
)

Reads array of the data.

Parameters
can_devA pointer to the CAN controller device block instance.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
buffer[out] Pointer to the memory for saving received data.
sizeThe requested number of data bytes to read from the CAN bus. If size is zero, the function will return as soon as one frame has been received. If size is non-zero, the function will return when all the data requested has been received.
bytes_read[out] Pointer to the memory for storing the length of received data.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code
ALT_STATUS_CODE alt_can_data_write ( ALT_CAN_DEV_t *  can_dev,
uint32_t  msg_obj_num,
void *  buffer,
uint32_t  size 
)

Writes array of the data.

Parameters
can_devA pointer to the CAN controller device block instance.
msg_obj_numMessage Number. Valid values from 1 to ALT_CAN_MAILBOXES_COUNT
buffer[out] Pointer to the memory that stores the data to be written.
sizeThe requested number of data bytes to write to CAN bus.
Return values
ALT_E_SUCCESSSuccessful status.
ALT_E_ERRORDetails about error status code