📄 canreg.h
字号:
INT32U RSV10 :10; //保留
INT32U RTR :1; //远程帧、数据帧识别位
INT32U FF :1; //扩展帧、标准帧识别位
}Bits;
}uCANRFS,*P_uCANRFS;
#define CANRFS(CanNum) (*((volatile P_uCANRFS)( CANRFS_BADR+CanNum* CAN_OFFSET_ADR )))
/*
**********************************************************************************************************************
** 定义 CANRID 寄存器:
1.This register contains the Identifier field of the current received message.
2.It is read-only in normal operation, but can be written for testing purposes if the RM bit in CANmod is 1.
3.It has two different formats depending on the FF bit in CANRFS. FF=0 (11 Bits 10:0)
FF=1 (29 Bits 28:0)
**********************************************************************************************************************
*/
typedef union _canrid_
{
INT32U Word; //字操作定义
struct
{
INT32U ID :29;
INT32U RSV3 :3;
}Bits;
}uCANRID,*P_uCANRID;
#define CANRID(CanNum) (*((volatile P_uCANRID)(CANRID_BADR+CanNum* CAN_OFFSET_ADR)))
#define CANTID1(CanNum) (*((volatile P_uCANRID)(CANTID1_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTID2(CanNum) (*((volatile P_uCANRID)(CANTID2_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTID3(CanNum) (*((volatile P_uCANRID)(CANTID3_BADR+CanNum*CAN_OFFSET_ADR)))
/*
**********************************************************************************************************************
** 定义 CANRDx 寄存器:
1.This register contains the Data bytes of the current received message.
2.It is read-only in normal operation, but can be written for testing purposes if the RM bit in CANMOD is 1.
**********************************************************************************************************************
*/
typedef union _canrdx_
{
INT32U Word; //字操作定义
struct
{
INT32U Data1 :8; //数据字节
INT32U Data2 :8;
INT32U Data3 :8;
INT32U Data4 :8;
}Bits;
}uCANRDx,*P_uCANRDx;
#define CANRDA(CanNum) (*((volatile P_uCANRDx)(CANRDA_BADR+CanNum* CAN_OFFSET_ADR))) //1-4 Data bytes
#define CANRDB(CanNum) (*((volatile P_uCANRDx)(CANRDB_BADR+CanNum* CAN_OFFSET_ADR))) //5-8 Data bytes
#define CANTDA1(CanNum) (*((volatile P_uCANRDx)(CANTDA1_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTDB1(CanNum) (*((volatile P_uCANRDx)(CANTDB1_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTDA2(CanNum) (*((volatile P_uCANRDx)(CANTDA2_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTDB2(CanNum) (*((volatile P_uCANRDx)(CANTDB2_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTDA3(CanNum) (*((volatile P_uCANRDx)(CANTDA3_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTDB3(CanNum) (*((volatile P_uCANRDx)(CANTDB3_BADR+CanNum*CAN_OFFSET_ADR)))
/*
**********************************************************************************************************************
** 定义 CANTFIx 寄存器:
1.When the corresponding TBS bit in CANSR is 1, software can write to one of these registers to define the format of
the next transmit message for that Tx buffer.
2.Bits not listed read as 0 and should be written as 0.
**********************************************************************************************************************
*/
typedef union _cantfix_
{
INT32U Word; //字节操作定义
struct
{
INT32U PRIO :8; //缓冲区数据发送优先级的值
INT32U RSV8 :8;
INT32U DLC :4; //发送数据长度
INT32U RSV10 :10;
INT32U RTR :1; //远程帧、数据帧辨别位
INT32U FF :1; //扩展帧、标准帧辨别位
}Bits;
}uCANTFIx,*P_uCANTFIx;
#define CANTFI1(CanNum) (*((volatile P_uCANTFIx)(CANTFI1_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTFI2(CanNum) (*((volatile P_uCANTFIx)(CANTFI2_BADR+CanNum*CAN_OFFSET_ADR)))
#define CANTFI3(CanNum) (*((volatile P_uCANTFIx)(CANTFI3_BADR+CanNum*CAN_OFFSET_ADR)))
/*
**********************************************************************************************************************
** 定义发送帧的结构
**********************************************************************************************************************
*/
typedef struct _stcTXBUF_
{
uCANTFIx TxFrameInfo; //发送帧信息结构
uCANRID TxCANID; //发送帧信息ID
uCANRDx TDA; //发送数据1~4字节
uCANRDx TDB; //发送数据5~8字节
}*P_stcTxBUF,stcTxBUF;
#define TxBUF1(CanNum) (*((volatile P_stcTxBUF)( TxBUF1_BADR+CanNum*CAN_OFFSET_ADR)))
#define TxBUF2(CanNum) (*((volatile P_stcTxBUF)( TxBUF2_BADR+CanNum*CAN_OFFSET_ADR)))
#define TxBUF3(CanNum) (*((volatile P_stcTxBUF)( TxBUF3_BADR+CanNum*CAN_OFFSET_ADR)))
/*
**********************************************************************************************************************
** 定义 CANTxSR 寄存器:
**********************************************************************************************************************
*/
typedef union _uCANTxSR_
{
INT32U Word; //字操作定义
struct
{
INT32U TS1 :1; //CAN1正在发送状态
INT32U TS2 :1; //CAN2正在发送状态
INT32U TS3 :1; //CAN3正在发送状态
INT32U TS4 :1; //CAN4正在发送状态
INT32U RSV1 :4; //保留
INT32U TBS1 :1; //CAN1发送缓冲区锁定状态
INT32U TBS2 :1; //CAN2发送缓冲区锁定状态
INT32U TBS3 :1; //CAN3发送缓冲区锁定状态
INT32U TBS4 :1; //CAN4发送缓冲区锁定状态
INT32U RSV2 :4; //
INT32U TCS1 :1; //CAN1发送完成状态
INT32U TCS2 :1; //CAN2发送完成状态
INT32U TCS3 :1; //CAN3发送完成状态
INT32U TCS4 :1; //CAN4发送完成状态
INT32U RSV12 :12; //保留
}Bits;
}*P_uCANTxSR,uCANTxSR;
#define _CANTxSR (*((volatile P_uCANTxSR) CANTxSR_GADR))
/*
**********************************************************************************************************************
** 定义 CANRxSR 寄存器:
**********************************************************************************************************************
*/
typedef union _uCANRxSR_
{
INT32U Word; //字操作定义
struct
{
INT32U RS1 :1; //CAN1正在接收状态
INT32U RS2 :1; //CAN2正在接收状态
INT32U RS3 :1; //CAN3正在接收状态
INT32U RS4 :1; //CAN4正在接收状态
INT32U RSV1 :4; //保留
INT32U RBS1 :1; //CAN1接收缓冲区有效
INT32U RBS2 :1; //CAN2接收缓冲区有效
INT32U RBS3 :1; //CAN3接收缓冲区有效
INT32U RBS4 :1; //CAN4接收缓冲区有效
INT32U RSV2 :4; //
INT32U DOS1 :1; //CAN1接收缓冲区溢出
INT32U DOS2 :1; //CAN2接收缓冲区溢出
INT32U DOS3 :1; //CAN3接收缓冲区溢出
INT32U DOS4 :1; //CAN4接收缓冲区溢出
INT32U RSV12 :12; //保留
}Bits;
}*P_uCANRxSR, uCANRxSR;
#define _CANRxSR (*((volatile P_uCANRxSR) CANRxSR_GADR))
/*
**********************************************************************************************************************
** 定义接收帧的结构
**********************************************************************************************************************
*/
typedef struct _stcRXBUF_
{
uCANRFS CANRcvFS;
uCANRID RxCANID;
uCANRDx RDA;
uCANRDx RDB;
}*P_stcRxBUF,stcRxBUF;
#define RxBUF(CanNum) (*((volatile P_stcRxBUF)( RxBUF_BADR+CanNum*CAN_OFFSET_ADR)))
/*
**********************************************************************************************************************
** 定义 CANMSR 寄存器:
**********************************************************************************************************************
*/
typedef union _uCANMSR_
{
INT32U Word; //字操作定义
struct
{
INT32U ES1 :1; //CAN1错误报警
INT32U ES2 :1; //CAN2错误报警
INT32U ES3 :1; //CAN3错误报警
INT32U ES4 :1; //CAN4错误报警
INT32U RSV1 :4; //保留
INT32U BS1 :1; //CAN1总线脱离
INT32U BS2 :1; //CAN2总线脱离
INT32U BS3 :1; //CAN3总线脱离
INT32U BS4 :1; //CAN4总线脱离
INT32U RSV20 :20; //保留
}Bits;
}*P_uCANMSR, uCANMSR;
#define _CANMSR (*((volatile P_uCANMSR) CANMSR_GADR))
/*
**********************************************************************************************************************
** 定义 CANAFMR 寄存器:
**********************************************************************************************************************
*/
typedef union _canafmr_
{
INT32U Word;
struct
{
INT32U AccOff :1; //1-when"1":if AccBP is 0, the Acceptance Filter is not operational.
// All Rx messages on all CAN buses are ignored.
INT32U AccBP :1; //1-when"1":all Rx messages are accepted on enabled CAN controllers.
// Software must set this bit before modifying the contents of any
// of the registers described below
//2-when"0":When both this bit and AccOff are 0, the Acceptance filter
// operates to screen received CAN Identifiers.
INT32U eFCAN :1; //1-when"1":the Acceptance Filter itself will take care of receiving and
// storing messages for selected Standard ID values on selected
// CAN buses.
//2-when"0":software must read all messages for all enabled IDs on all
// enabled CAN buses,from the receiving CAN controllers.
INT32U RSV29 :29;
}Bits;
}uCANAFMR,*P_uCANAFMR;
#define _CANAFMR (*((volatile P_uCANAFMR) CANAFMR_GADR))
/*
**********************************************************************************************************************
** FullCAN滤波器和标准帧表格数据类型定义
**********************************************************************************************************************
*/
typedef struct _AF_SFF_CELL_
{
INT32U UpId :11; // 11bit ID1
INT32U UpRsv :1; //
INT32U UpDis :1; // 禁能位
INT32U UpCh :3; // CAN控制器号
INT32U LoId :11; // 11bit ID0
INT32U LoRsv :1; //
INT32U LoDis :1; // 禁能位
INT32U LoCh :3; // CAN控制器号
}stcAF_SFF_CELL,*P_stcAF_SFF_CELL;
/*
************************************************************************************
** CAN滤波器扩展帧表格数据类型定义
************************************************************************************
*/
typedef struct _AF_EFF_CELL_
{
INT32U Id :29; // 29bit EFF ID
INT32U Ch :3; // CAN控制器号
}stcAF_EFF_CELL,*P_stcAF_EFF_CELL;
/*
***************************************************************************************
** FullCAN模式下自动接收的帧的结构
***************************************************************************************
*/
typedef struct _AF_AUTOSTORE_MSG
{
struct tag_Head
{
INT32U ID :11;
INT32U RSV5 :5;
INT32U DLC :4;
INT32U RSV12:4;
INT32U SEM :2;
INT32U RSV41:4;
INT32U RTR :1;
INT32U FF :1;
}Head;
uCANRDx da;
uCANRDx db;
}stcAF_AUTOSTORE_MSG,*P_stcAF_AUTOSTORE_MSG;
/*
**********************************************************************************************************************
** 定义 SFF_sa 寄存器:
**1-The start address of the table of individual Standard Identifiers in AF Lookup RAM.If the table is empty,
write the same value in this register and the SFF_GRP_sa register described below.
**2-If the eFCAN bit in the AFMR is 1, this value also indicates the size of the table of Standard IDs which
the Acceptance Filter will search and (if found) automatically store received messages in Acceptance Filter RAM.
**********************************************************************************************************************
*/
typedef union _canF_sa_
{
INT32U Word;
struct
{
INT32U RSV2 :2;
INT32U SADR :9;
INT32U RSV21 :21;
}Bits;
}uCANF_sa,*P_uCANF_sa;
#define _CANSFF_sa (*((volatile P_uCANF_sa)(CANSFF_sa_GADR)))
#define _CANEFF_sa (*((volatile P_uCANF_sa)(CANEFF_sa_GADR)))
#define _CANLUTerrAd (*((volatile P_uCANF_sa)(CANLUTerrAd_GADR)))
/*
**********************************************************************************************************************
** 定义 SFF_GRP_sa 寄存器:
**1-The start address of the table of grouped Standard Identifiers in AF Lookup RAM. If the table is empty,
write the same value in this register and the EFF_sa register described below.
**2-The largest value that should be written to this register is 0x800, when only the Standard Individual
table is used, and the last word (address 0x7FC) in AF Lookup Table RAM is used.
**********************************************************************************************************************
*/
typedef union _canGRP_sa_
{
INT32U Word;
struct
{
INT32U RSV2 :2;
INT32U SADR :10;
INT32U RSV20 :20;
}Bits;
}uCANGRP_sa,*P_uCANGRP_sa;
#define _CANSFF_GRP_sa (*((volatile P_uCANGRP_sa)(CANSFF_GRP_sa_GADR)))
#define _CANEFF_GRP_sa (*((volatile P_uCANGRP_sa)(CANEFF_GRP_sa_GADR)))
#define _CANENDofTable (*((volatile P_uCANGRP_sa)(CANENDofTable_GADR)))
/*
**********************************************************************************************************************
** 定义 LUTerr 寄存器:
**1-This read-only bit is set to 1 if the Acceptance Filter encounters an error in the content of the
tables in AF RAM. It is cleared when software reads the LUTerrAd register. This condition
is ORed with the “other CAN” interrupts from the CAN controllers, to produce the request for
a VIC interrupt channel.
**********************************************************************************************************************
*/
typedef union _canLUTerr
{
INT32U Word;
struct
{
INT32U LERR :1;
INT32U RSV31 :31;
}Bits;
}uCANLUTerr,*P_uCANLUTerr;
#define _CANLUTerr (*((volatile P_uCANLUTerr)( CANLUTerr_GADR)))
/*
*********************************************************************************************************
** End Of File
********************************************************************************************************
*/
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -