#include "reg51.h"
#include "uart.h"
#include "string.h"
#include "sja1000.h"
sbit KEY=P2^5;
void main(void)
{
unsigned char init,state,num,i=0;
UART_Init();
if(SJA_Interface_Test())
{
UART_Send_String("\r\nSJA TO CPU Right!\r\n");
}
else
{
UART_Send_String("\r\nSJA TO CPU Error!\r\n");
}
init=SJA_Init();
if(init==0)
{
UART_Send_String("\r\nSJA Init OK!\r\n");
}
else
{
UART_Send_String("\r\nSJA Init Error!\r\n");
UART_Send_Byte(init);
}
while(1)
{
if(KEY==0)
{
DelayMs(10);
if(KEY==0)
{
CAN_Send_Str("ILoveY\r\n");
Display(num);
if(num++==14) num=0;
}
DelayMs(200);
}
SJA_BCANAdr = REG_STATUS;
state=*SJA_BCANAdr;
if((state&0x40)==0x40) { UART_Send_String("\r\nSJA Error count overflow!!\r\n"); SJA_Init(); }
if((state&0x20)==0x20) UART_Send_String("SJA1000 CAN BUS is transmiting!\r\n");
}
}
1