LPCOpen Platform  v1.03
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CHIP: LPC17xx/40xx CAN driver

Detailed Description

Macros

#define CAN_SEG1_DEFAULT_VAL   5
 
#define CAN_SEG2_DEFAULT_VAL   4
 
#define CAN_SJW_DEFAULT_VAL   0
 

Typedefs

typedef IP_CAN_AF_LUT_T CANAF_LUT_T
 CAN structures and definitions.
 
typedef IP_CAN_STD_ID_Entry_T CAN_STD_ID_ENTRY_T
 
typedef IP_CAN_STD_ID_RANGE_Entry_T CAN_STD_ID_RANGE_ENTRY_T
 
typedef IP_CAN_EXT_ID_Entry_T CAN_EXT_ID_ENTRY_T
 
typedef IP_CAN_EXT_ID_RANGE_Entry_T CAN_EXT_ID_RANGE_ENTRY_T
 
typedef IP_CAN_MSG_T CAN_MSG_T
 
typedef IP_CAN_BUFFER_ID_T CAN_BUFFER_ID
 
typedef IP_CAN_AF_RAM_SECTION_T CANAF_RAM_SECTION
 

Enumerations

enum  CHIP_CAN_MODE_T {
  CAN_RESET_MODE = CAN_MOD_RM, CAN_SELFTEST_MODE = CAN_MOD_STM, CAN_TEST_MODE = CAN_MOD_TM, CAN_LISTEN_ONLY_MODE = CAN_MOD_LOM,
  CAN_SLEEP_MODE = CAN_MOD_SM, CAN_OPERATION_MODE = CAN_MOD_OPERATION, CAN_TRANSMIT_PRIORITY_MODE = CAN_MOD_TPM, CAN_RECEIVE_PRIORITY_MODE = CAN_MOD_RPM
}
 CAN Mode definition. More...
 
enum  CHIP_CAN_AF_MODE_T { CAN_AF_NORMAL_MODE = 0, CAN_AF_OFF_MODE = CANAF_AFMR_ACCOFF, CAN_AF_BYBASS_MODE = CANAF_AFMR_ACCBP, CAN_AF_FULL_MODE = CANAF_AFMR_EFCAN }
 CAN AF Mode definition. More...
 

Functions

STATIC INLINE uint32_t Chip_CAN_GetStatus (LPC_CAN_T *pCAN)
 Get the status of the CAN Controller.
 
STATIC INLINE void Chip_CAN_IntEnable (LPC_CAN_T *pCAN, uint32_t IntMask)
 Enable the CAN Interrupts.
 
STATIC INLINE void Chip_CAN_IntDisable (LPC_CAN_T *pCAN, uint32_t IntMask)
 Disable the CAN Interrupts.
 
STATIC INLINE uint32_t Chip_CAN_GetIntStatus (LPC_CAN_T *pCAN)
 Get interrupt status of the given CAN Controller.
 
STATIC INLINE void Chip_CAN_FullCANIntConfig (LPC_CANAF_T *pCANAF, FunctionalState NewState)
 Enable/Disable CAN controller FullCAN Interrupts.
 
STATIC INLINE uint32_t Chip_CAN_GetFullCANIntStatus (LPC_CANAF_T *pCANAF, uint8_t ObjID)
 Get FullCAN interrupt status of the given object.
 
STATIC INLINE void Chip_CAN_SetMode (LPC_CAN_T *pCAN, CHIP_CAN_MODE_T Mode, FunctionalState NewState)
 Set CAN controller enter/exit to a given mode.
 
STATIC INLINE void Chip_CAN_SetAFMode (LPC_CANAF_T *pCANAF, CHIP_CAN_AF_MODE_T AfMode)
 Set CAN AF Mode.
 
STATIC INLINE Status Chip_CAN_SetAFLUT (LPC_CANAF_T *pCANAF, CANAF_LUT_T *pAFSections)
 Set CAN AF LUT.
 
STATIC INLINE Status Chip_CAN_InsertFullCANEntry (LPC_CANAF_T *pCANAF, CAN_STD_ID_ENTRY_T *pEntry)
 Insert a FullCAN Entry into the current LUT.
 
STATIC INLINE Status Chip_CAN_InsertIndividualSTDEntry (LPC_CANAF_T *pCANAF, CAN_STD_ID_ENTRY_T *pEntry)
 Insert an individual Standard Entry into the current LUT.
 
STATIC INLINE Status Chip_CAN_InsertGroupSTDEntry (LPC_CANAF_T *pCANAF, CAN_STD_ID_RANGE_ENTRY_T *pEntry)
 Insert an Group Standard Entry into the current LUT.
 
STATIC INLINE Status Chip_CAN_InsertIndividualEXTEntry (LPC_CANAF_T *pCANAF, CAN_EXT_ID_ENTRY_T *pEntry)
 Insert an individual Extended Entry into the current LUT.
 
STATIC INLINE Status Chip_CAN_InsertGroupEXTEntry (LPC_CANAF_T *pCANAF, CAN_EXT_ID_RANGE_ENTRY_T *pEntry)
 Insert an Group Extended Entry into the current LUT.
 
STATIC INLINE Status Chip_CAN_RemoveFullCANEntry (LPC_CANAF_T *pCANAF, int16_t Position)
 Remove a FullCAN Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_RemoveIndividualSTDEntry (LPC_CANAF_T *pCANAF, int16_t Position)
 Remove an individual Standard Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_RemoveGroupSTDEntry (LPC_CANAF_T *pCANAF, int16_t Position)
 Remove an Group Standard Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_RemoveIndividualEXTEntry (LPC_CANAF_T *pCANAF, int16_t Position)
 Remove an individual Extended Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_RemoveGroupEXTEntry (LPC_CANAF_T *pCANAF, int16_t Position)
 Remove an Group Extended Entry from the current LUT.
 
STATIC INLINE uint16_t Chip_CAN_GetEntriesNum (LPC_CANAF_T *pCANAF, CANAF_RAM_SECTION SectionID)
 Get the number of entries in the given section.
 
STATIC INLINE Status Chip_CAN_ReadFullCANEntry (LPC_CANAF_T *pCANAF, uint16_t Position, CAN_STD_ID_ENTRY_T *pEntry)
 Read a FullCAN Entry into from current LUT.
 
STATIC INLINE Status Chip_CAN_ReadIndividualSTDEntry (LPC_CANAF_T *pCANAF, uint16_t Position, CAN_STD_ID_ENTRY_T *pEntry)
 Read an individual Standard Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_ReadGroupSTDEntry (LPC_CANAF_T *pCANAF, uint16_t Position, CAN_STD_ID_RANGE_ENTRY_T *pEntry)
 Read an Group Standard Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_ReadIndividualEXTEntry (LPC_CANAF_T *pCANAF, uint16_t Position, CAN_EXT_ID_ENTRY_T *pEntry)
 Read an individual Extended Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_ReadGroupEXTEntry (LPC_CANAF_T *pCANAF, uint16_t Position, CAN_EXT_ID_RANGE_ENTRY_T *pEntry)
 Read an Group Extended Entry from the current LUT.
 
STATIC INLINE Status Chip_CAN_Receive (LPC_CAN_T *pCAN, CAN_MSG_T *pMsg)
 Get message received by the CAN Controller.
 
STATIC INLINE Status Chip_CAN_FullCANReceive (LPC_CANAF_T *pCANAF, uint8_t ObjID, CAN_MSG_T *pMsg, uint8_t *pSCC)
 Get message received automatically by the AF.
 
STATIC INLINE Status Chip_CAN_Send (LPC_CAN_T *pCAN, CAN_BUFFER_ID TxBufID, CAN_MSG_T *pMsg)
 Request the given CAN Controller to send message.
 
void Chip_CAN_Init (LPC_CAN_T *pCAN)
 Initialize CAN Interface.
 
void Chip_CAN_DeInit (LPC_CAN_T *pCAN)
 De-Initialize CAN Interface.
 
Status Chip_CAN_SetBitRate (LPC_CAN_T *pCAN, uint32_t BitRate)
 Set CAN bitrate.
 
CAN_BUFFER_ID Chip_CAN_GetFreeTxBuf (LPC_CAN_T *pCAN)
 Get Free TxBuffer.
 

Macro Definition Documentation

#define CAN_SEG1_DEFAULT_VAL   5

Definition at line 44 of file can_17xx_40xx.h.

#define CAN_SEG2_DEFAULT_VAL   4

Definition at line 45 of file can_17xx_40xx.h.

#define CAN_SJW_DEFAULT_VAL   0

Definition at line 46 of file can_17xx_40xx.h.

Typedef Documentation

CAN Buffer ID definition

Definition at line 64 of file can_17xx_40xx.h.

Extended Identifier Entry Structure

Definition at line 58 of file can_17xx_40xx.h.

Extended Identifier Range Entry Structure

Definition at line 60 of file can_17xx_40xx.h.

CAN Message Structure

Definition at line 62 of file can_17xx_40xx.h.

Standard Identifier Entry Structure

Definition at line 54 of file can_17xx_40xx.h.

Standard Identifier Range Entry Structure

Definition at line 56 of file can_17xx_40xx.h.

CAN structures and definitions.

AF Look-up Tables structure

Definition at line 52 of file can_17xx_40xx.h.

CAN Look-up Table Definition

Definition at line 66 of file can_17xx_40xx.h.

Enumeration Type Documentation

CAN AF Mode definition.

Enumerator:
CAN_AF_NORMAL_MODE 

Acceptance Filter Normal Mode

CAN_AF_OFF_MODE 

Acceptance Filter Off Mode

CAN_AF_BYBASS_MODE 

Acceptance Fileter Bypass Mode

CAN_AF_FULL_MODE 

FullCAN Mode Enhancement

Definition at line 85 of file can_17xx_40xx.h.

CAN Mode definition.

Enumerator:
CAN_RESET_MODE 

CAN Reset Mode

CAN_SELFTEST_MODE 

CAN Selftest Mode

CAN_TEST_MODE 

CAN Test Mode

CAN_LISTEN_ONLY_MODE 

CAN Listen Only Mode

CAN_SLEEP_MODE 

CAN Sleep Mode

CAN_OPERATION_MODE 

CAN Operation Mode

CAN_TRANSMIT_PRIORITY_MODE 

CAN Transmit Priority Mode

CAN_RECEIVE_PRIORITY_MODE 

CAN Receive Priority Mode

Definition at line 71 of file can_17xx_40xx.h.

Function Documentation

void Chip_CAN_DeInit ( LPC_CAN_T pCAN)

De-Initialize CAN Interface.

Parameters
pCAN: Pointer to CAN controller register block
Returns
Nothing

Definition at line 114 of file can_17xx_40xx.c.

STATIC INLINE void Chip_CAN_FullCANIntConfig ( LPC_CANAF_T pCANAF,
FunctionalState  NewState 
)

Enable/Disable CAN controller FullCAN Interrupts.

Parameters
pCANAF: Pointer to CAN AF Register block
NewState: Enable/Disable
Returns
Nothing

Definition at line 140 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_FullCANReceive ( LPC_CANAF_T pCANAF,
uint8_t  ObjID,
CAN_MSG_T pMsg,
uint8_t *  pSCC 
)

Get message received automatically by the AF.

Parameters
pCANAF: Pointer to CAN AF Register block
ObjID: Object ID
pMsg: Pointer to the buffer storing the information of the received message
pSCC: Pointer to the buffer storing the controller ID of the received message
Returns
SUCCESS (message information saved) or ERROR (no message received)

Definition at line 395 of file can_17xx_40xx.h.

STATIC INLINE uint16_t Chip_CAN_GetEntriesNum ( LPC_CANAF_T pCANAF,
CANAF_RAM_SECTION  SectionID 
)

Get the number of entries in the given section.

Parameters
pCANAF: Pointer to CAN AF Register block
SectionID: Section ID
Returns
Number of entries

Definition at line 306 of file can_17xx_40xx.h.

CAN_BUFFER_ID Chip_CAN_GetFreeTxBuf ( LPC_CAN_T pCAN)

Get Free TxBuffer.

Parameters
pCAN: Pointer to CAN controller register block
Returns
Buffer ID

Definition at line 164 of file can_17xx_40xx.c.

STATIC INLINE uint32_t Chip_CAN_GetFullCANIntStatus ( LPC_CANAF_T pCANAF,
uint8_t  ObjID 
)

Get FullCAN interrupt status of the given object.

Parameters
pCANAF: Pointer to CAN AF Register block
ObjID: Object ID
Returns
Status

Definition at line 151 of file can_17xx_40xx.h.

STATIC INLINE uint32_t Chip_CAN_GetIntStatus ( LPC_CAN_T pCAN)

Get interrupt status of the given CAN Controller.

Parameters
pCAN: Pointer to CAN controller register block
Returns
Status (Or'ed bit values of CAN_ICR_* )

Definition at line 129 of file can_17xx_40xx.h.

STATIC INLINE uint32_t Chip_CAN_GetStatus ( LPC_CAN_T pCAN)

Get the status of the CAN Controller.

Parameters
pCAN: Pointer to CAN controller register block
Returns
Status (Or'ed bit values of CAN_SR_*(n) with n = CAN_BUFFER_1/2/3).

Definition at line 97 of file can_17xx_40xx.h.

void Chip_CAN_Init ( LPC_CAN_T pCAN)

Initialize CAN Interface.

Parameters
pCAN: Pointer to CAN controller register block
Returns
Nothing

Definition at line 98 of file can_17xx_40xx.c.

STATIC INLINE Status Chip_CAN_InsertFullCANEntry ( LPC_CANAF_T pCANAF,
CAN_STD_ID_ENTRY_T pEntry 
)

Insert a FullCAN Entry into the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
pEntry: Pointer to the entry which will be inserted
Returns
SUCCESS/ERROR

Definition at line 196 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_InsertGroupEXTEntry ( LPC_CANAF_T pCANAF,
CAN_EXT_ID_RANGE_ENTRY_T pEntry 
)

Insert an Group Extended Entry into the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
pEntry: Pointer to the entry which will be inserted
Returns
SUCCESS/ERROR

Definition at line 240 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_InsertGroupSTDEntry ( LPC_CANAF_T pCANAF,
CAN_STD_ID_RANGE_ENTRY_T pEntry 
)

Insert an Group Standard Entry into the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
pEntry: Pointer to the entry which will be inserted
Returns
SUCCESS/ERROR

Definition at line 218 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_InsertIndividualEXTEntry ( LPC_CANAF_T pCANAF,
CAN_EXT_ID_ENTRY_T pEntry 
)

Insert an individual Extended Entry into the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
pEntry: Pointer to the entry which will be inserted
Returns
SUCCESS/ERROR

Definition at line 229 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_InsertIndividualSTDEntry ( LPC_CANAF_T pCANAF,
CAN_STD_ID_ENTRY_T pEntry 
)

Insert an individual Standard Entry into the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
pEntry: Pointer to the entry which will be inserted
Returns
SUCCESS/ERROR

Definition at line 207 of file can_17xx_40xx.h.

STATIC INLINE void Chip_CAN_IntDisable ( LPC_CAN_T pCAN,
uint32_t  IntMask 
)

Disable the CAN Interrupts.

Parameters
pCAN: Pointer to CAN controller register block
IntMask: Interrupt Mask (Or-ed bits value of CAN_IER_*)
Returns
Nothing

Definition at line 119 of file can_17xx_40xx.h.

STATIC INLINE void Chip_CAN_IntEnable ( LPC_CAN_T pCAN,
uint32_t  IntMask 
)

Enable the CAN Interrupts.

Parameters
pCAN: Pointer to CAN controller register block
IntMask: Interrupt Mask (Or-ed bits value of CAN_IER_*)
Returns
Nothing

Definition at line 108 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_ReadFullCANEntry ( LPC_CANAF_T pCANAF,
uint16_t  Position,
CAN_STD_ID_ENTRY_T pEntry 
)

Read a FullCAN Entry into from current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry in the given section (started from 0)
pEntry: Pointer to the entry which will be read
Returns
SUCCESS/ERROR

Definition at line 318 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_ReadGroupEXTEntry ( LPC_CANAF_T pCANAF,
uint16_t  Position,
CAN_EXT_ID_RANGE_ENTRY_T pEntry 
)

Read an Group Extended Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry in the given section (started from 0)
pEntry: Pointer to the entry which will be read
Returns
SUCCESS/ERROR

Definition at line 370 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_ReadGroupSTDEntry ( LPC_CANAF_T pCANAF,
uint16_t  Position,
CAN_STD_ID_RANGE_ENTRY_T pEntry 
)

Read an Group Standard Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry in the given section (started from 0)
pEntry: Pointer to the entry which will be read
Returns
SUCCESS/ERROR

Definition at line 344 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_ReadIndividualEXTEntry ( LPC_CANAF_T pCANAF,
uint16_t  Position,
CAN_EXT_ID_ENTRY_T pEntry 
)

Read an individual Extended Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry in the given section (started from 0)
pEntry: Pointer to the entry which will be read
Returns
SUCCESS/ERROR

Definition at line 357 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_ReadIndividualSTDEntry ( LPC_CANAF_T pCANAF,
uint16_t  Position,
CAN_STD_ID_ENTRY_T pEntry 
)

Read an individual Standard Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry in the given section (started from 0)
pEntry: Pointer to the entry which will be read
Returns
SUCCESS/ERROR

Definition at line 331 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_Receive ( LPC_CAN_T pCAN,
CAN_MSG_T pMsg 
)

Get message received by the CAN Controller.

Parameters
pCAN: Pointer to CAN controller register block
pMsg: Pointer to the buffer storing the information of the received message
Returns
SUCCESS (message information saved) or ERROR (no message received)

Definition at line 382 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_RemoveFullCANEntry ( LPC_CANAF_T pCANAF,
int16_t  Position 
)

Remove a FullCAN Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry removed
Returns
SUCCESS/ERROR

Definition at line 251 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_RemoveGroupEXTEntry ( LPC_CANAF_T pCANAF,
int16_t  Position 
)

Remove an Group Extended Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry removed
Returns
SUCCESS/ERROR

Definition at line 295 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_RemoveGroupSTDEntry ( LPC_CANAF_T pCANAF,
int16_t  Position 
)

Remove an Group Standard Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry removed
Returns
SUCCESS/ERROR

Definition at line 273 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_RemoveIndividualEXTEntry ( LPC_CANAF_T pCANAF,
int16_t  Position 
)

Remove an individual Extended Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry removed
Returns
SUCCESS/ERROR

Definition at line 284 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_RemoveIndividualSTDEntry ( LPC_CANAF_T pCANAF,
int16_t  Position 
)

Remove an individual Standard Entry from the current LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
Position: Position of the entry removed
Returns
SUCCESS/ERROR

Definition at line 262 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_Send ( LPC_CAN_T pCAN,
CAN_BUFFER_ID  TxBufID,
CAN_MSG_T pMsg 
)

Request the given CAN Controller to send message.

Parameters
pCAN: Pointer to CAN controller register block
TxBufID: ID of the buffer which will be used for transmission
pMsg: Pointer to the buffer of message which will be sent
Returns
SUCCESS (message information saved) or ERROR (no message received)

Definition at line 407 of file can_17xx_40xx.h.

STATIC INLINE Status Chip_CAN_SetAFLUT ( LPC_CANAF_T pCANAF,
CANAF_LUT_T pAFSections 
)

Set CAN AF LUT.

Parameters
pCANAF: Pointer to CAN AF Register block
pAFSections: Pointer to buffer storing AF Section Data
Returns
SUCCESS/ERROR

Definition at line 185 of file can_17xx_40xx.h.

STATIC INLINE void Chip_CAN_SetAFMode ( LPC_CANAF_T pCANAF,
CHIP_CAN_AF_MODE_T  AfMode 
)

Set CAN AF Mode.

Parameters
pCANAF: Pointer to CAN AF Register block
AfMode: Mode selected
Returns
None

Definition at line 174 of file can_17xx_40xx.h.

Status Chip_CAN_SetBitRate ( LPC_CAN_T pCAN,
uint32_t  BitRate 
)

Set CAN bitrate.

Parameters
pCAN: Pointer to CAN controller register block
BitRate: Expected bitrate
Returns
SUCCESS/ERROR

Definition at line 121 of file can_17xx_40xx.c.

STATIC INLINE void Chip_CAN_SetMode ( LPC_CAN_T pCAN,
CHIP_CAN_MODE_T  Mode,
FunctionalState  NewState 
)

Set CAN controller enter/exit to a given mode.

Parameters
pCAN: Pointer to CAN controller register block
Mode: Mode selected
NewState: ENABLE: enter, DISABLE: exit
Returns
None

Definition at line 163 of file can_17xx_40xx.h.