LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IP: CCAN register block and driver

Detailed Description

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.
 

Macro Definition Documentation

#define CCAN_ARB   (1 << 5) /* 1 is transfer the ARB bits to the message object, 0 is not */

Definition at line 159 of file ccan_001.h.

#define CCAN_CLRINTPND   (1 << 3)

Definition at line 157 of file ccan_001.h.

#define CCAN_CTRL   (1 << 4) /* 1 is transfer the CTRL bit to the message object, 0 is not */

Definition at line 158 of file ccan_001.h.

#define CCAN_CTRL_CCE   (1 << 6)

Definition at line 200 of file ccan_001.h.

#define CCAN_CTRL_DAR   (1 << 5)

Definition at line 199 of file ccan_001.h.

#define CCAN_CTRL_EIE   (1 << 3)

Definition at line 198 of file ccan_001.h.

#define CCAN_CTRL_IE   (1 << 1)

Definition at line 196 of file ccan_001.h.

#define CCAN_CTRL_INIT   (1 << 0)

Definition at line 195 of file ccan_001.h.

#define CCAN_CTRL_SIE   (1 << 2)

Definition at line 197 of file ccan_001.h.

#define CCAN_CTRL_TEST   (1 << 7)

Definition at line 201 of file ccan_001.h.

#define CCAN_DATAA   (1 << 1) /* 1 is transfer data byte 0-3 to message object, 0 is not */

Definition at line 155 of file ccan_001.h.

#define CCAN_DATAB   (1 << 0) /* 1 is transfer data byte 4-7 to message object, 0 is not */

Definition at line 154 of file ccan_001.h.

#define CCAN_DLC   0x000F /* bit mask for DLC */

Definition at line 186 of file ccan_001.h.

#define CCAN_DLC_MASK   0x0F

Definition at line 190 of file ccan_001.h.

#define CCAN_EOB   (1 << 7) /* End of buffer, always write to 1 */

Definition at line 185 of file ccan_001.h.

#define CCAN_ID_DIR (   n)    (((n) & 0x01) << 13) /* 1 direction bit is used in the RX filter unit, 0 is not */

Definition at line 172 of file ccan_001.h.

#define CCAN_ID_EXT_MASK   0x1FFFFFFF

Definition at line 189 of file ccan_001.h.

#define CCAN_ID_MTD   (1 << 14) /* 1 extended identifier bit is used in the RX filter unit, 0 is not */

Definition at line 171 of file ccan_001.h.

#define CCAN_ID_MVAL   (1 << 15) /* Message valid bit, 1 is valid in the MO handler, 0 is ignored */

Definition at line 170 of file ccan_001.h.

#define CCAN_ID_STD_MASK   0x07FF

Definition at line 188 of file ccan_001.h.

#define CCAN_IF_Read (   LPCx,
  reg,
  IFsel 
)    (( ## LPCx ## ->IF ## [IFsel] ## . ## IF ## _ ## reg))

Definition at line 141 of file ccan_001.h.

#define CCAN_IF_Write (   LPCx,
  reg,
  IFsel,
  val 
)    (( ## LPCx ## ->IF ## [IFsel] ## . ## IF ## _ ## reg) = (val))

Definition at line 142 of file ccan_001.h.

#define CCAN_IFCREQ_BUSY
Value:
0x8000 /* 1 is writing is progress, cleared when
RD/WR done */

Definition at line 193 of file ccan_001.h.

#define CCAN_INTP   (1 << 13) /* 1 indicates message object is an interrupt source */

Definition at line 177 of file ccan_001.h.

#define CCAN_MASK   (1 << 6) /* 1 is transfer the MASK bit to the message object, 0 is not */

Definition at line 160 of file ccan_001.h.

#define CCAN_MASK_MDIR (   n)    (((n) & 0x01) << 14) /* 1 direction bit is used in the RX filter unit, 0 is not */

Definition at line 167 of file ccan_001.h.

#define CCAN_MASK_MXTD   (1 << 15) /* 1 extended identifier bit is used in the RX filter unit, 0 is not */

Definition at line 166 of file ccan_001.h.

#define CCAN_MLST   (1 << 14) /* 1 indicates a message loss. */

Definition at line 176 of file ccan_001.h.

#define CCAN_NEWD   (1 << 15) /* 1 indicates new data is in the message buffer. */

Definition at line 175 of file ccan_001.h.

#define CCAN_NEWDAT   (1 << 2) /* Clear NEWDAT bit in the message object */

Definition at line 156 of file ccan_001.h.

#define CCAN_RD   0UL

Definition at line 163 of file ccan_001.h.

#define CCAN_RMTEN (   n)    (((n) & 1UL) << 9) /* 1 is remote frame enabled */

Definition at line 182 of file ccan_001.h.

#define CCAN_RW (   n)    (((n) & 1UL) << 7) /* 0 is READ, 1 is WRITE */

Definition at line 161 of file ccan_001.h.

#define CCAN_RX_DIR   0UL

Definition at line 151 of file ccan_001.h.

#define CCAN_RXIE   (1 << 10) /* 1 is RX interrupt enabled */

Definition at line 180 of file ccan_001.h.

#define CCAN_STATUS_INT   0x8000

Definition at line 148 of file ccan_001.h.

#define CCAN_TX_DIR   1UL

Definition at line 150 of file ccan_001.h.

#define CCAN_TXIE   (1 << 11) /* 1 is TX interrupt enabled */

Definition at line 179 of file ccan_001.h.

#define CCAN_TXRQ   (1 << 8) /* 1 is TxRqst enabled */

Definition at line 184 of file ccan_001.h.

#define CCAN_UMSK   (1 << 12) /* 1 is to use the mask for the receive filter mask. */

Definition at line 178 of file ccan_001.h.

#define CCAN_WR   1UL

Definition at line 162 of file ccan_001.h.

Enumeration Type Documentation

Enumerator:
CCAN_MODULE_INT 
CCAN_STATUS_CHANGE_INT 
CCAN_ERR_INT 

Definition at line 104 of file ccan_001.h.

Enumerator:
IF1 
IF2 

Definition at line 118 of file ccan_001.h.

Enumerator:
CCAN_STAT_LEC 
CCAN_STAT_TXOK 
CCAN_STAT_RXOK 
CCAN_STAT_EPASS 
CCAN_STAT_EWARN 
CCAN_STAT_BOFF 

Definition at line 122 of file ccan_001.h.

Enumerator:
CCAN_BASIC_TEST_MODE 
CCAN_SILENT_TEST_MODE 
CCAN_LOOPBACK_TEST_MODE 

Definition at line 98 of file ccan_001.h.

I2S transmit/receive mode for configuration.

Enumerator:
CCAN_TX_MODE 
CCAN_RX_MODE 

Definition at line 134 of file ccan_001.h.

Function Documentation

void IP_CCAN_AutoRetransmitEnable ( IP_CCAN_001_T pCCAN,
FunctionalState  NewState 
)

Enable/Disable automatic retransmission.

Parameters
pCCAN: The base of CCAN peripheral on the chip
NewState: New state, ENABLE or DISABLE
Returns
Nothing

Definition at line 102 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
IFsel: The Message interface to be used
msg_num: Message number
Returns
Nothing

Definition at line 159 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
IFsel: The Message interface to be used
msg_num: Message number
Returns
Nothing

Definition at line 150 of file ccan_001.c.

uint32_t IP_CCAN_Get_IntID ( IP_CCAN_001_T pCCAN)

Get the source ID of an interrupt.

Parameters
pCCAN: The base of CCAN peripheral on the chip
Returns
Interrupt source ID

Definition at line 131 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
TRMode: Transmit/Receive mode, should be CCAN_TX_MODE or CCAN_RX_MODE
Returns
Current value of the transmit/receive error counter

Definition at line 113 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
IFsel: The Message interface to be used
msg_num: The number of message object in message RAM to be get
msg_buf: Pointer of the message buffer
Returns
Nothing

Definition at line 251 of file ccan_001.c.

uint32_t IP_CCAN_GetStatus ( IP_CCAN_001_T pCCAN)

Get the CCAN status register.

Parameters
pCCAN: The base of CCAN peripheral on the chip
Returns
CCAN status register

Definition at line 119 of file ccan_001.c.

uint32_t IP_CCAN_GetTxRQST ( IP_CCAN_001_T pCCAN)

Get the transmit repuest bit in all message objects.

Parameters
pCCAN: The base of CCAN peripheral on the chip
Returns
A 32 bits value, each bit corresponds to transmit request bit in message objects

Definition at line 192 of file ccan_001.c.

uint32_t IP_CCAN_GetValidMsg ( IP_CCAN_001_T pCCAN)

Check the message objects is valid or not.

Parameters
pCCAN: The base of CCAN peripheral on the chip
Returns
A 32 bits value, each bit corresponds to a message objects form 0 to 31 (1 is valid, 0 is invalid)

Definition at line 186 of file ccan_001.c.

void IP_CCAN_IntEnable ( IP_CCAN_001_T pCCAN,
IP_CCAN_INT_T  Int_type,
FunctionalState  NewState 
)

Enable/Disable CCAN Interrupts.

Parameters
pCCAN: The base of CCAN peripheral on the chip
Int_type: Type of interrupt
NewState: New state, ENABLE or DISABLE
Returns
Nothing

Definition at line 91 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
IFsel: The Message interface to be used
direction: Select the message object is used for transmiting or receiving, should be CCAN_TX_DIR or CCAN_RX_DIR
RemoteEnable,:Enable/Disable passives transmit by using remote frame
msg_num: Message number
msg_ptr: Pointer of message to be set
Returns
Nothing

Definition at line 198 of file ccan_001.c.

void IP_CCAN_SetStatus ( IP_CCAN_001_T pCCAN,
uint32_t  val 
)

Set the CCAN status.

Parameters
pCCAN: The base of CCAN peripheral on the chip
val: Value to be set for status register
Returns
Nothing

Definition at line 125 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
IFsel: The Message interface to be used
msg_num: Message number
NewState,:New state, ENABLE or DISABLE
Returns
Nothing

Definition at line 168 of file ccan_001.c.

void IP_CCAN_SWInit ( IP_CCAN_001_T pCCAN,
FunctionalState  NewState 
)

Initialize the CAN controller.

Parameters
pCCAN: The base of CCAN peripheral on the chip
NewState: New state, ENABLE for starting initialization, DISABLE for normal operation
Returns
Nothing

Definition at line 62 of file ccan_001.c.

void IP_CCAN_TestModeEnable ( IP_CCAN_001_T pCCAN,
IP_CCAN_TEST_MODE_T  test_mode,
FunctionalState  NewState 
)

Enable/Disable test mode in CCAN.

Parameters
pCCAN: The base of CCAN peripheral on the chip
test_mode: Selected mode, the different test functions may be combined
NewState: New state, ENABLE or DISABLE
Returns
Nothing

Definition at line 137 of file ccan_001.c.

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.

Parameters
pCCAN: The base of CCAN peripheral on the chip
ClkDiv: Set the clock divider
BaudRatePrescaler: Set the baud rate Prescaler
SynJumpWidth: Set the synchronization jump width
Tseg1: Set the Phase buffer segment 1
Tseg2: Set the Phase buffer segment 2
Returns
Nothing

Definition at line 74 of file ccan_001.c.