?? 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 + -