LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ccan_001.h File Reference
#include "sys_config.h"
#include "cmsis.h"

Go to the source code of this file.

Data Structures

struct  IP_CCAN_001_IF_T
 CCAN message interface register block structure. More...
 
struct  IP_CCAN_001_T
 CCAN Controller Area Network register block structure. More...
 
struct  message_object
 CAN message object structure. More...
 

Macros

#define CCAN_IF_Read(LPCx, reg, IFsel)   (( ## LPCx ## ->IF ## [IFsel] ## . ## IF ## _ ## reg))
 
#define CCAN_IF_Write(LPCx, reg, IFsel, val)   (( ## LPCx ## ->IF ## [IFsel] ## . ## IF ## _ ## reg) = (val))
 
#define CCAN_STATUS_INT   0x8000
 
#define CCAN_TX_DIR   1UL
 
#define CCAN_RX_DIR   0UL
 
#define CCAN_DATAB   (1 << 0) /* 1 is transfer data byte 4-7 to message object, 0 is not */
 
#define CCAN_DATAA   (1 << 1) /* 1 is transfer data byte 0-3 to message object, 0 is not */
 
#define CCAN_NEWDAT   (1 << 2) /* Clear NEWDAT bit in the message object */
 
#define CCAN_CLRINTPND   (1 << 3)
 
#define CCAN_CTRL   (1 << 4) /* 1 is transfer the CTRL bit to the message object, 0 is not */
 
#define CCAN_ARB   (1 << 5) /* 1 is transfer the ARB bits to the message object, 0 is not */
 
#define CCAN_MASK   (1 << 6) /* 1 is transfer the MASK bit to the message object, 0 is not */
 
#define CCAN_RW(n)   (((n) & 1UL) << 7) /* 0 is READ, 1 is WRITE */
 
#define CCAN_WR   1UL
 
#define CCAN_RD   0UL
 
#define CCAN_MASK_MXTD   (1 << 15) /* 1 extended identifier bit is used in the RX filter unit, 0 is not */
 
#define CCAN_MASK_MDIR(n)   (((n) & 0x01) << 14) /* 1 direction bit is used in the RX filter unit, 0 is not */
 
#define CCAN_ID_MVAL   (1 << 15) /* Message valid bit, 1 is valid in the MO handler, 0 is ignored */
 
#define CCAN_ID_MTD   (1 << 14) /* 1 extended identifier bit is used in the RX filter unit, 0 is not */
 
#define CCAN_ID_DIR(n)   (((n) & 0x01) << 13) /* 1 direction bit is used in the RX filter unit, 0 is not */
 
#define CCAN_NEWD   (1 << 15) /* 1 indicates new data is in the message buffer. */
 
#define CCAN_MLST   (1 << 14) /* 1 indicates a message loss. */
 
#define CCAN_INTP   (1 << 13) /* 1 indicates message object is an interrupt source */
 
#define CCAN_UMSK   (1 << 12) /* 1 is to use the mask for the receive filter mask. */
 
#define CCAN_TXIE   (1 << 11) /* 1 is TX interrupt enabled */
 
#define CCAN_RXIE   (1 << 10) /* 1 is RX interrupt enabled */
 
#define CCAN_RMTEN(n)   (((n) & 1UL) << 9) /* 1 is remote frame enabled */
 
#define CCAN_TXRQ   (1 << 8) /* 1 is TxRqst enabled */
 
#define CCAN_EOB   (1 << 7) /* End of buffer, always write to 1 */
 
#define CCAN_DLC   0x000F /* bit mask for DLC */
 
#define CCAN_ID_STD_MASK   0x07FF
 
#define CCAN_ID_EXT_MASK   0x1FFFFFFF
 
#define CCAN_DLC_MASK   0x0F
 
#define CCAN_IFCREQ_BUSY
 
#define CCAN_CTRL_INIT   (1 << 0)
 
#define CCAN_CTRL_IE   (1 << 1)
 
#define CCAN_CTRL_SIE   (1 << 2)
 
#define CCAN_CTRL_EIE   (1 << 3)
 
#define CCAN_CTRL_DAR   (1 << 5)
 
#define CCAN_CTRL_CCE   (1 << 6)
 
#define CCAN_CTRL_TEST   (1 << 7)
 

Enumerations

enum  IP_CCAN_TEST_MODE_T { CCAN_BASIC_TEST_MODE = 1 << 2, CCAN_SILENT_TEST_MODE = 1 << 3, CCAN_LOOPBACK_TEST_MODE = 1 << 4 }
 
enum  IP_CCAN_INT_T { CCAN_MODULE_INT = 1 << 1, CCAN_STATUS_CHANGE_INT = 1 << 2, CCAN_ERR_INT = 1 << 3 }
 
enum  IP_CCAN_MSG_INTERFACE_T { IF1 = 0x00, IF2 = 1 }
 
enum  IP_CCAN_STATUS_T {
  CCAN_STAT_LEC = (0x7 << 0), CCAN_STAT_TXOK = (1 << 3), CCAN_STAT_RXOK = (1 << 4), CCAN_STAT_EPASS = (1 << 5),
  CCAN_STAT_EWARN = (1 << 6), CCAN_STAT_BOFF = (1 << 7)
}
 
enum  IP_CCAN_TRX_MODE_T { CCAN_TX_MODE, CCAN_RX_MODE }
 I2S transmit/receive mode for configuration. More...
 

Functions

void IP_CCAN_TimingCfg (IP_CCAN_001_T *pCCAN, uint32_t ClkDiv, uint32_t BaudRatePrescaler, uint8_t SynJumpWidth, uint8_t Tseg1, uint8_t Tseg2)
 Configure the bit timing for CCAN bus.
 
void IP_CCAN_SWInit (IP_CCAN_001_T *pCCAN, FunctionalState NewState)
 Initialize the CAN controller.
 
void IP_CCAN_IntEnable (IP_CCAN_001_T *pCCAN, IP_CCAN_INT_T Int_type, FunctionalState NewState)
 Enable/Disable CCAN Interrupts.
 
void IP_CCAN_AutoRetransmitEnable (IP_CCAN_001_T *pCCAN, FunctionalState NewState)
 Enable/Disable automatic retransmission.
 
uint8_t IP_CCAN_GetErrCounter (IP_CCAN_001_T *pCCAN, IP_CCAN_TRX_MODE_T TRMode)
 Get the current value of the transmit/receive error counter.
 
uint32_t IP_CCAN_GetStatus (IP_CCAN_001_T *pCCAN)
 Get the CCAN status register.
 
void IP_CCAN_SetStatus (IP_CCAN_001_T *pCCAN, uint32_t val)
 Set the CCAN status.
 
uint32_t IP_CCAN_Get_IntID (IP_CCAN_001_T *pCCAN)
 Get the source ID of an interrupt.
 
void IP_CCAN_TestModeEnable (IP_CCAN_001_T *pCCAN, IP_CCAN_TEST_MODE_T test_mode, FunctionalState NewState)
 Enable/Disable test mode in CCAN.
 
void IP_CCAN_ClearIntPend (IP_CCAN_001_T *pCCAN, IP_CCAN_MSG_INTERFACE_T IFsel, uint8_t msg_num)
 Clear interrupt pending bit in the message object.
 
void IP_CCAN_Clear_NewDataFlag (IP_CCAN_001_T *pCCAN, IP_CCAN_MSG_INTERFACE_T IFsel, uint8_t msg_num)
 Clear new data flag bit in the message object.
 
void IP_CCAN_SetValidMsg (IP_CCAN_001_T *pCCAN, IP_CCAN_MSG_INTERFACE_T IFsel, uint8_t msg_num, FunctionalState NewState)
 Enable/Disable the message object to valid.
 
uint32_t IP_CCAN_GetValidMsg (IP_CCAN_001_T *pCCAN)
 Check the message objects is valid or not.
 
uint32_t IP_CCAN_GetTxRQST (IP_CCAN_001_T *pCCAN)
 Get the transmit repuest bit in all message objects.
 
void IP_CCAN_SetMsgObject (IP_CCAN_001_T *pCCAN, IP_CCAN_MSG_INTERFACE_T IFsel, uint8_t direction, uint32_t RemoteEnable, uint8_t msg_num, const message_object *msg_ptr)
 Set a message into the message object in message RAM.
 
void IP_CCAN_GetMsgObject (IP_CCAN_001_T *pCCAN, IP_CCAN_MSG_INTERFACE_T IFsel, uint8_t msg_num, message_object *msg_buf)
 Get a message object in message RAM into the message buffer.