📄 canreg.h
字号:
/****************************************Copyright (c)****************************************************
** Guangzhou ZHIYUAN electronics Co.,LTD.
**
** http://www.embedtools.com
**
**--------------File Info---------------------------------------------------------------------------------
** File name: CANREG.H
** Last modified Date: 2004年2月23日
** Last Version: V1.0
** Descriptions: CAN模块寄存器类型定义、地址定义头文件
**--------------------------------------------------------------------------------------------------------
** Created by: 滕欣欣
** Created date: 2007年4月12日
** Version: 1.00
** Descriptions: The original version
**--------------------------------------------------------------------------------------------------------
** Modified by:
** Modified date:
** Version:
** Descriptions:
*********************************************************************************************************/
#ifndef _CANREG_H_
#define _CANREG_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*********************************************************************************************************
验收滤波器RAM首地址
*********************************************************************************************************/
#define CANAFRAM_BADR 0xE0038000
/*********************************************************************************************************
CAN寄存器基地址定义
*********************************************************************************************************/
#define CANMOD_BADR 0xE0044000 /* 模式寄存器 */
#define CANCMR_BADR 0xE0044004 /* 命令寄存器 */
#define CANGSR_BADR 0xE0044008 /* 全局状态寄存器 */
#define CANICR_BADR 0xE004400C /* 中断及捕获寄存器 */
#define CANIER_BADR 0xE0044010 /* 中断使能寄存器 */
#define CANBTR_BADR 0xE0044014 /* 总线时序寄存器 */
#define CANEWL_BADR 0xE0044018 /* 报警限制寄存器 */
#define CANSR_BADR 0xE004401C /* 状态寄存器 */
#define CANRFS_BADR 0xE0044020 /* 接收帧信息寄存器 */
#define CANRID_BADR 0xE0044024 /* 接收报文ID寄存器 */
#define CANRDA_BADR 0xE0044028 /* 接收数据1~4 */
#define CANRDB_BADR 0xE004402C /* 接收数据5~8 */
#define CANTFI1_BADR 0xE0044030 /* CAN发送缓冲区1帧信息寄存器 */
#define CANTID1_BADR 0xE0044034 /* CAN发送缓冲区1报文ID寄存器 */
#define CANTDA1_BADR 0xE0044038 /* CAN发送缓冲区1发送数据1~4 */
/* 寄存器 */
#define CANTDB1_BADR 0xE004403C /* CAN发送缓冲区1发送数据5~8 */
/* 寄存器 */
#define CANTFI2_BADR 0xE0044040 /* CAN发送缓冲区2帧信息寄存器 */
#define CANTID2_BADR 0xE0044044 /* CAN发送缓冲区2报文ID寄存器 */
#define CANTDA2_BADR 0xE0044048 /* CAN发送缓冲区2发送数据1~4 */
/* 寄存器 */
#define CANTDB2_BADR 0xE004404C /* CAN发送缓冲区2发送数据5~8 */
/* 寄存器 */
#define CANTFI3_BADR 0xE0044050 /* CAN发送缓冲区3帧信息寄存器 */
#define CANTID3_BADR 0xE0044054 /* CAN发送缓冲区3报文ID寄存器 */
#define CANTDA3_BADR 0xE0044058 /* CAN发送缓冲区3发送数据1~4 */
/* 寄存器 */
#define CANTDB3_BADR 0xE004405C /* CAN发送缓冲区3发送数据5~8 */
/* 寄存器 */
#define CAN_OFFSET_ADR 0x4000
/*********************************************************************************************************
定义RxBUF的基地址
*********************************************************************************************************/
#define RxBUF_BADR 0xE0044020
/*********************************************************************************************************
定义TxBUF的基地址
*********************************************************************************************************/
#define TxBUF1_BADR 0xE0044030 /* CAN发送缓冲区1首地址 */
#define TxBUF2_BADR 0xE0044040 /* CAN发送缓冲区2首地址 */
#define TxBUF3_BADR 0xE0044050 /* CAN发送缓冲区3首地址 */
/*********************************************************************************************************
定义全局应用的寄存器
*********************************************************************************************************/
#define CANTxSR_GADR 0xE0040000 /* 发送状态寄存器 */
#define CANRxSR_GADR 0xE0040004 /* 接收状态寄存器 */
#define CANMSR_GADR 0xE0040008 /* 错误状态寄存器 */
#define CANAFMR_GADR 0xE003C000 /* 验收滤波控制 */
#define CANSFF_sa_GADR 0xE003C004 /* 标准帧表格 */
#define CANSFF_GRP_sa_GADR 0xE003C008 /* 标准帧组表格 */
#define CANEFF_sa_GADR 0xE003C00C /* 扩展帧表格 */
#define CANEFF_GRP_sa_GADR 0xE003C010 /* 扩展帧组表格 */
#define CANENDofTable_GADR 0xE003C014 /* 表格结束地址 */
#define CANLUTerrAd_GADR 0xE003C018 /* LUT错误地址地址寄存器 */
#define CANLUTerr_GADR 0xE003C01C /* LUT错误寄存器 */
/*********************************************************************************************************
定义 CANMOD 寄存器:
1.This register controls the basic operating mode of the CAN Controller.
2.Bits not listed read as 0 and should be written as 0.
*********************************************************************************************************/
typedef union _canmod_
{
INT32U DWord;
struct {
INT32U RM :1; /* 定义RM位(复位位) */
INT32U LOM :1; /* 定义LOM位(只听模式位) */
INT32U STM :1; /* 定义STM位 "0"发送的信息必须 */
/* 被应答才被认可 */
/* "1"自测试模式,CANCMR的SRR位 */
/* 一起使用,可以达到自发自收 */
/* 的效果 */
INT32U TPM :1; /* 定义TPM位 "0"3个发送缓冲区的*/
/* 优先级由各自的CAN ID决定 */
/* "1"3个发送缓冲区的优先级 */
/* 由各自的Tx优先级域决定 */
INT32U SM :1; /* 定义SM位(睡眠模式位) */
INT32U RPM :1; /* 定义RPM位 "0"如果传输的 */
/* 是显性位,Rx和Tx脚为低电平 */
/* "1"翻转极性模式--如果传输的 */
/* 是显性位,Rx脚为高电平 */
INT32U RSV1 :1; /* 保留位 */
INT32U TM :1; /* 定义TM位(测试模式) */
INT32U RSV24 :24; /* 保留位 */
}Bits;
}uCANMod,*P_uCANMod;
#define CANMOD(CanNum) (*((volatile P_uCANMod)(CANMOD_BADR+CanNum* CAN_OFFSET_ADR)))
/*********************************************************************************************************
定义 CANCMR 寄存器:
1.Writing to this write-only register initiates an action.
2.Bits not listed should be written as 0. Reading this register yields zeroes.
*********************************************************************************************************/
typedef union _cancmr_
{
INT32U DWord;
struct
{
INT32U TR :1; /* 定义TR位(发送请求) */
INT32U AT :1; /* 定义AT位(发送中止) */
INT32U RRB :1; /* 定义RRB位(接收缓冲区释放) */
INT32U CDO :1; /* 清除数据溢出位 */
INT32U SRR :1; /* 定义SRR位(自接收请求) */
INT32U STB1 :1; /* 定义SEND TxBUF1位(BUF1发送) */
INT32U STB2 :1; /* 定义SEND TxBUF2位(BUF2发送) */
INT32U STB3 :1; /* 定义SEND TxBUF3位(BUF3发送) */
INT32U RSV24 :24; /* 保留位 */
}Bits;
}uCANCMR,*P_uCANCMR;
#define CANCMR(CanNum) (*((volatile P_uCANCMR)(CANCMR_BADR+CanNum* CAN_OFFSET_ADR )))
/*********************************************************************************************************
定义 CANGSR 寄存器:
1.This register is read-only, except that the Error Counters can be written when the RM bit in the CANMOD register is 1.
2.Bits not listed read as 0 and should be written as 0.
*********************************************************************************************************/
typedef union _cangsr_
{
INT32U DWord; /* 字操作定义 */
struct
{
INT32U RBS :1; /* 接收缓冲区状态位 */
INT32U DOS :1; /* 数据溢出状态位 */
INT32U TBS :1; /* 发送缓冲区状态锁定位 */
INT32U TCS :1; /* 发送完成状态位 */
INT32U RS :1; /* 正在接收状态 */
INT32U TS :1; /* 正在发送状态 */
INT32U ES :1; /* 错误状态 */
INT32U BS :1; /* 总线关闭 */
INT32U RSV8 :8; /* 保留位 */
INT32U RXERR :8; /* 接收错误计数 */
INT32U TXERR :8; /* 发送错误计数 */
}Bits;
}uCANGSR,*P_uCANGSR;
#define CANGSR(CanNum) (*((volatile P_uCANGSR)( CANGSR_BADR+CanNum* CAN_OFFSET_ADR )))
/*********************************************************************************************************
定义 CANICR 寄存器:
1.Bits in this register indicate information about events on the CAN bus. This register is read-only.
2.Bits not listed read as 0 and should be written as 0.
3.The clearing of bits 1-9 and the releasing of bits 16-23 and 24-31 all occur on any read from CANICR,
regardless of whether part or all of the register is read.This means that software should always
read CANICR as a DWord,and and process and deal with all bits of the register as appropriate
for the application.
*********************************************************************************************************/
typedef union _canicr_
{
INT32U DWord; /* 字操作定义 */
struct
{
INT32U RI :1; /* 接收中断位 */
INT32U TI1 :1; /* TxBUF1发送成功中断位 */
INT32U EI :1; /* 错误报警中断位 */
INT32U DOI :1; /* 数据溢出中断位 */
INT32U WUI :1; /* 睡眠唤醒中断位 */
INT32U EPI :1; /* 错误认可中断位 */
INT32U ALI :1; /* 仲裁错误中断位 */
INT32U BEI :1; /* 总线错误中断 */
INT32U IDI :1; /* 接收到CAN标识符中断位 */
INT32U TI2 :1; /* TxBUF2发送成功中断位 */
INT32U TI3 :1; /* TxBUF3发送成功中断位 */
INT32U RSV5 :5; /* 保留位 */
INT32U ERRBIT :5; /* 错误代码捕获 */
INT32U ERRDIR :1; /* 错误方向 */
INT32U ERRC :2; /* 错误类型 */
INT32U ALCBIT :5; /* 仲裁错误代码捕获 */
INT32U RSV3 :3; /* 保留 */
}Bits;
}uCANICR;
#define CANICR(CanNum) (*((volatile P_uCANICR)( CANICR_BADR + CanNum*CAN_OFFSET_ADR)))
/*********************************************************************************************************
定义 CANIER 寄存器:
1.This read/write register controls whether various events on the CAN controller will result in an
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -