📄 lpc17xx_can.h.svn-base
字号:
**********************************************************************/
/** CAN Priority */
#define CAN_TFI_PRIO(n) ((uint32_t)(n&0xFF))
/** CAN Data Length Code */
#define CAN_TFI_DLC(n) ((uint32_t)((n&0xF)<<16))
/** CAN Remote Frame Transmission */
#define CAN_TFI_RTR ((uint32_t)(1<<30))
/** CAN control 11-bit or 29-bit Identifier */
#define CAN_TFI_FF ((uint32_t)(1<<31))
/*********************************************************************//**
* Macro defines for CAN Transmit Identifier Register
**********************************************************************/
/** CAN 11-bit Identifier */
#define CAN_TID_ID11(n) ((uint32_t)(n&0x7FF))
/** CAN 11-bit Identifier */
#define CAN_TID_ID29(n) ((uint32_t)(n&0x1FFFFFFF))
/*********************************************************************//**
* Macro defines for CAN Transmit Data A Register
**********************************************************************/
/** CAN Transmit Data 1 */
#define CAN_TDA_DATA1(n) ((uint32_t)(n&0xFF))
/** CAN Transmit Data 2 */
#define CAN_TDA_DATA2(n) ((uint32_t)((n&0xFF)<<8))
/** CAN Transmit Data 3 */
#define CAN_TDA_DATA3(n) ((uint32_t)((n&0xFF)<<16))
/** CAN Transmit Data 4 */
#define CAN_TDA_DATA4(n) ((uint32_t)((n&0xFF)<<24))
/*********************************************************************//**
* Macro defines for CAN Transmit Data B Register
**********************************************************************/
/** CAN Transmit Data 5 */
#define CAN_TDA_DATA5(n) ((uint32_t)(n&0xFF))
/** CAN Transmit Data 6 */
#define CAN_TDA_DATA6(n) ((uint32_t)((n&0xFF)<<8))
/** CAN Transmit Data 7 */
#define CAN_TDA_DATA7(n) ((uint32_t)((n&0xFF)<<16))
/** CAN Transmit Data 8 */
#define CAN_TDA_DATA8(n) ((uint32_t)((n&0xFF)<<24))
/*********************************************************************//**
* Macro defines for CAN Sleep Clear Register
**********************************************************************/
/** CAN1 Sleep mode */
#define CAN1SLEEPCLR ((uint32_t)(1<<1))
/** CAN2 Sleep Mode */
#define CAN2SLEEPCLR ((uint32_t)(1<<2))
/*********************************************************************//**
* Macro defines for CAN Wake up Flags Register
**********************************************************************/
/** CAN1 Sleep mode */
#define CAN_WAKEFLAGES_CAN1WAKE ((uint32_t)(1<<1))
/** CAN2 Sleep Mode */
#define CAN_WAKEFLAGES_CAN2WAKE ((uint32_t)(1<<2))
/*********************************************************************//**
* Macro defines for Central transmit Status Register
**********************************************************************/
/** CAN Transmit 1 */
#define CAN_TSR_TS1 ((uint32_t)(1))
/** CAN Transmit 2 */
#define CAN_TSR_TS2 ((uint32_t)(1<<1))
/** CAN Transmit Buffer Status 1 */
#define CAN_TSR_TBS1 ((uint32_t)(1<<8))
/** CAN Transmit Buffer Status 2 */
#define CAN_TSR_TBS2 ((uint32_t)(1<<9))
/** CAN Transmission Complete Status 1 */
#define CAN_TSR_TCS1 ((uint32_t)(1<<16))
/** CAN Transmission Complete Status 2 */
#define CAN_TSR_TCS2 ((uint32_t)(1<<17))
/*********************************************************************//**
* Macro defines for Central Receive Status Register
**********************************************************************/
/** CAN Receive Status 1 */
#define CAN_RSR_RS1 ((uint32_t)(1))
/** CAN Receive Status 1 */
#define CAN_RSR_RS2 ((uint32_t)(1<<1))
/** CAN Receive Buffer Status 1*/
#define CAN_RSR_RB1 ((uint32_t)(1<<8))
/** CAN Receive Buffer Status 2*/
#define CAN_RSR_RB2 ((uint32_t)(1<<9))
/** CAN Data Overrun Status 1 */
#define CAN_RSR_DOS1 ((uint32_t)(1<<16))
/** CAN Data Overrun Status 1 */
#define CAN_RSR_DOS2 ((uint32_t)(1<<17))
/*********************************************************************//**
* Macro defines for Central Miscellaneous Status Register
**********************************************************************/
/** Same CAN Error Status in CAN1GSR */
#define CAN_MSR_E1 ((uint32_t)(1))
/** Same CAN Error Status in CAN2GSR */
#define CAN_MSR_E2 ((uint32_t)(1<<1))
/** Same CAN Bus Status in CAN1GSR */
#define CAN_MSR_BS1 ((uint32_t)(1<<8))
/** Same CAN Bus Status in CAN2GSR */
#define CAN_MSR_BS2 ((uint32_t)(1<<9))
/*********************************************************************//**
* Macro defines for Acceptance Filter Mode Register
**********************************************************************/
/** CAN Acceptance Filter Off mode */
#define CAN_AFMR_AccOff ((uint32_t)(1))
/** CAN Acceptance File Bypass mode */
#define CAN_AFMR_AccBP ((uint32_t)(1<<1))
/** FullCAN Mode Enhancements */
#define CAN_AFMR_eFCAN ((uint32_t)(1<<2))
/*********************************************************************//**
* Macro defines for Standard Frame Individual Start Address Register
**********************************************************************/
/** The start address of the table of individual Standard Identifier */
#define CAN_STT_sa(n) ((uint32_t)((n&1FF)<<2))
/*********************************************************************//**
* Macro defines for Standard Frame Group Start Address Register
**********************************************************************/
/** The start address of the table of grouped Standard Identifier */
#define CAN_SFF_GRP_sa(n) ((uint32_t)((n&3FF)<<2))
/*********************************************************************//**
* Macro defines for Extended Frame Start Address Register
**********************************************************************/
/** The start address of the table of individual Extended Identifier */
#define CAN_EFF_sa(n) ((uint32_t)((n&1FF)<<2))
/*********************************************************************//**
* Macro defines for Extended Frame Group Start Address Register
**********************************************************************/
/** The start address of the table of grouped Extended Identifier */
#define CAN_Eff_GRP_sa(n) ((uint32_t)((n&3FF)<<2))
/*********************************************************************//**
* Macro defines for End Of AF Table Register
**********************************************************************/
/** The End of Table of AF LookUp Table */
#define CAN_EndofTable(n) ((uint32_t)((n&3FF)<<2))
/*********************************************************************//**
* Macro defines for LUT Error Address Register
**********************************************************************/
/** CAN Look-Up Table Error Address */
#define CAN_LUTerrAd(n) ((uint32_t)((n&1FF)<<2))
/*********************************************************************//**
* Macro defines for LUT Error Register
**********************************************************************/
/** CAN Look-Up Table Error */
#define CAN_LUTerr ((uint32_t)(1))
/*********************************************************************//**
* Macro defines for Global FullCANInterrupt Enable Register
**********************************************************************/
/** Global FullCANInterrupt Enable */
#define CAN_FCANIE ((uint32_t)(1))
/*********************************************************************//**
* Macro defines for FullCAN Interrupt and Capture Register 0
**********************************************************************/
/** FullCAN Interrupt and Capture (0-31)*/
#define CAN_FCANIC0_IntPnd(n) ((uint32_t)(1<<n))
/*********************************************************************//**
* Macro defines for FullCAN Interrupt and Capture Register 1
**********************************************************************/
/** FullCAN Interrupt and Capture (0-31)*/
#define CAN_FCANIC1_IntPnd(n) ((uint32_t)(1<<(n-32)))
/* ---------------- CHECK PARAMETER DEFINITIONS ---------------------------- */
/** Macro to determine if it is valid CAN peripheral or not */
#define PARAM_CANx(x) ((((uint32_t*)x)==((uint32_t *)LPC_CAN1)) \
||(((uint32_t*)x)==((uint32_t *)LPC_CAN2)))
/* Macro to determine if it is valid CANAF or not*/
#define PARAM_CANAFx(x) (((uint32_t*)x)== ((uint32_t*)LPC_CANAF))
/* Macro to determine if it is valid CANAF RAM or not*/
#define PARAM_CANAFRAMx(x) (((uint32_t*)x)== (uint32_t*)LPC_CANAF_RAM)
/* Macro to determine if it is valid CANCR or not*/
#define PARAM_CANCRx(x) (((uint32_t*)x)==((uint32_t*)LPC_CANCR))
/** Macro to check Data to send valid */
#define PARAM_I2S_DATA(data) ((data>=0)&&(data <= 0xFFFFFFFF))
/** Macro to check frequency value */
#define PRAM_I2S_FREQ(freq) ((freq>=16000)&&(freq <= 96000))
/** Macro to check Frame Identifier */
#define PARAM_ID_11(n) ((n>>11)==0) /*-- 11 bit --*/
#define PARAM_ID_29(n) ((n>>29)==0) /*-- 29 bit --*/
/** Macro to check DLC value */
#define PARAM_DLC(n) ((n>>4)==0) /*-- 4 bit --*/
/** Macro to check ID format type */
#define PARAM_ID_FORMAT(n) ((n==STD_ID_FORMAT)||(n==EXT_ID_FORMAT))
/** Macro to check Group identifier */
#define PARAM_GRP_ID(x, y) ((x<=y))
/** Macro to check Frame type */
#define PARAM_FRAME_TYPE(n) ((n==DATA_FRAME)||(n==REMOTE_FRAME))
/** Macro to check Control/Central Status type parameter */
#define PARAM_CTRL_STS_TYPE(n) ((n==CANCTRL_GLOBAL_STS)||(n==CANCTRL_INT_CAP) \
||(n==CANCTRL_ERR_WRN)||(n==CANCTRL_STS))
/** Macro to check CR status type */
#define PARAM_CR_STS_TYPE(n) ((n==CANCR_TX_STS)||(n==CANCR_RX_STS) \
||(n==CANCR_MS))
/** Macro to check AF Mode type parameter */
#define PARAM_AFMODE_TYPE(n) ((n==CAN_Normal)||(n==CAN_AccOff) \
||(n==CAN_AccBP)||(n==CAN_eFCAN))
/** Macro to check Operation Mode */
#define PARAM_MODE_TYPE(n) ((n==CAN_OPERATING_MODE)||(n==CAN_RESET_MODE) \
||(n==CAN_LISTENONLY_MODE)||(n==CAN_SELFTEST_MODE) \
||(n==CAN_TXPRIORITY_MODE)||(n==CAN_SLEEP_MODE) \
||(n==CAN_RXPOLARITY_MODE)||(n==CAN_TEST_MODE))
/** Macro define for struct AF_Section parameter */
#define PARAM_CTRL(n) ((n==CAN1_CTRL)|(n==CAN2_CTRL))
/** Macro define for struct AF_Section parameter */
#define PARAM_MSG_DISABLE(n) ((n==MSG_ENABLE)|(n==MSG_DISABLE))
/**Macro to check Interrupt Type parameter */
#define PARAM_INT_EN_TYPE(n) ((n==CANINT_RIE)||(n==CANINT_TIE1) \
||(n==CANINT_EIE)||(n==CANINT_DOIE) \
||(n==CANINT_WUIE)||(n==CANINT_EPIE) \
||(n==CANINT_ALIE)||(n==CANINT_BEIE) \
||(n==CANINT_IDIE)||(n==CANINT_TIE2) \
||(n==CANINT_TIE3)||(n==CANINT_FCE))
/** Macro to check AFLUT Entry type */
#define PARAM_AFLUT_ENTRY_TYPE(n) ((n==FULLCAN_ENTRY)||(n==EXPLICIT_STANDARD_ENTRY)\
||(n==GROUP_STANDARD_ENTRY)||(n==EXPLICIT_EXTEND_ENTRY) \
||(n==GROUP_EXTEND_ENTRY))
/** Macro to check position */
#define PARAM_POSITION(n) ((n>=0)&&(n<512))
/**
* @}
*/
/* Public Types --------------------------------------------------------------- */
/** @defgroup CAN_Public_Types CAN Public Types
* @{
*/
/** CAN configuration structure */
/***********************************************************************
* CAN device configuration commands (IOCTL commands and arguments)
**********************************************************************/
/**
* @brief CAN ID format definition
*/
typedef enum {
STD_ID_FORMAT = 0, /**< Use standard ID format (11 bit ID) */
EXT_ID_FORMAT = 1 /**< Use extended ID format (29 bit ID) */
} CAN_ID_FORMAT_Type;
/**
* @brief AFLUT Entry type definition
*/
typedef enum {
FULLCAN_ENTRY = 0,
EXPLICIT_STANDARD_ENTRY,
GROUP_STANDARD_ENTRY,
EXPLICIT_EXTEND_ENTRY,
GROUP_EXTEND_ENTRY
} AFLUT_ENTRY_Type;
/**
* @brief Symbolic names for type of CAN message
*/
typedef enum {
DATA_FRAME = 0, /**< Data frame */
REMOTE_FRAME = 1 /**< Remote frame */
} CAN_FRAME_Type;
/**
* @brief CAN Control status definition
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -