⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sja1000.h

📁 调试9200处理器板卡的一个调试实例
💻 H
字号:
#ifndef	SJA1000_H
#define	SJA1000_H

#include "Dpram.h"
#include "DEF.h"

//时钟频率16MHz
#define 	SJA_FOSC	(16*1000*1000)ul



//SJA1000 Regsters Macro,in pelican mode
/*模式寄存器 bit0-bit4 复位、只听、自检测、验收滤波器、睡眠*/
#define REG_MR		0
#define BIT_RM 		(1<<0)
#define BIT_LOM		(1<<1)
#define BIT_STM		(1<<2)
#define BIT_AFM		(1<<3)
#define BIT_SM		(1<<4)

/*命令寄存器 bit0-bit4 发送请求、中止发送、释放接受缓冲器、清除数据溢出、自接受请求(信息可以同时发送和接收)*/
#define REG_CMR		1
#define BIT_TR		(1<<0)
#define BIT_AT		(1<<1)
#define BIT_RR		(1<<2)
#define BIT_CDO		(1<<3)
#define BIT_SSR		(1<<4)

/*状态寄存器 bit0-bit7 接受缓冲器、数据溢出、发送缓冲器、发送完成、接收、发送、错误、总线状态*/
#define REG_SR		2
#define BIT_RBS		(1<<0)
#define BIT_DOS		(1<<1)
#define BIT_TBS		(1<<2)
#define BIT_TCS		(1<<3)
#define BIT_RS		(1<<4)
#define BIT_TS		(1<<5)
#define BIT_ES		(1<<6)
#define BIT_BS		(1<<7)

/*中断寄存器 bit0-bit4 接收、发送、出错、数据溢出、唤醒中断, 用作中断源识别*/
#define REG_IR		3
#define BIT_RI		(1<<0)
#define BIT_TI		(1<<1)
#define BIT_EI		(1<<2)
#define BIT_DOI		(1<<3)
#define BIT_WUI		(1<<4)

/*中断使能寄存器 bit0-bit4 接收、发送、出错、数据溢出、唤醒中断*/
#define REG_IER		4
#define BIT_RIE		(1<<0)
#define BIT_TIE		(1<<1)
#define BIT_EIE		(1<<2)
#define BIT_DOIE	(1<<3)
#define BIT_WUIE	(1<<4)

//#define EN_IRQ		(BIT_RIE|BIT_TIE|BIT_EIE|BIT_DOIE|BIT_WUIE)
#define DIS_IRQ		0x0

/*总线时序0,总线时序1,输出控制,错误代码捕捉*/
#define REG_BTR0	6
#define REG_BTR1	7
#define REG_OC		8
#define REG_ERR		12

/*验收代码acr0-3,验收屏蔽amr0-3*,时钟分频*/
#define REG_ACR0	16
#define REG_AMR0	20
#define REG_CDR		31



void TsetSJA(void);
void SJA1000_TX(CanMessageStruct * msg);

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -