資源描述:
《自收自發(fā)文件清單.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫(kù)。
1、頭文件:can_selfdef.h//對(duì)管腳分配進(jìn)行了定義//對(duì)子函數(shù)進(jìn)行了聲明#defineucharunsignedchar#defineuintunsignedint#defineNOP5{_nop_();_nop_();_nop_();_nop_();_nop_();}/*延時(shí)5us*/#defineN_can13//一幀字節(jié)數(shù)bitTXD_flag=0;//若為1,要求發(fā)送處理bitRXD_flag=0;//有無(wú)數(shù)據(jù)可以接收;0無(wú) ,1有ucharcodeled[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x0
2、7,0x7f,0x6f,0x00};//0,1,2,3,4,5ucharRX_buffer[13];//接收的數(shù)據(jù)ucharTX_buffer[13];//接收的數(shù)據(jù)ucharTxd_data=0;//CAN總線要發(fā)送的數(shù)據(jù),也是要在數(shù)碼管1-2位置顯示的數(shù)據(jù)ucharRxd_data=0;//CAN總線要接收的數(shù)據(jù),也是要在數(shù)碼管3-4位置顯示的數(shù)據(jù)/*P2口分配*/sbitLED_RED=P2^1;sbitLED_GRE=P2^2;sbitSJA_RST=P2^3;//SJA1000復(fù)位管腳sbitSJA_CS=P2^0;//SJA1000片選管腳/
3、*CAN總線SJA1000寄存器地址定義(用的是PeliCAN模式,擴(kuò)展幀EFF模式)*/#defineMODR(*(unsignedcharvolatilexdata*)0xFE00)//模式寄存器#defineCMR(*(unsignedcharvolatilexdata*)0xFE01)//命令寄存器#defineSR(*(unsignedcharvolatilexdata*)0xFE02)//狀態(tài)寄存器#defineIR(*(unsignedcharvolatilexdata*)0xFE03)//中斷寄存器#defineIER(*(unsigne
4、dcharvolatilexdata*)0xFE04)//中斷使能寄存器#defineBTR0(*(unsignedcharvolatilexdata*)0xFE06)//總線定時(shí)寄存器0;總線波特率的選擇#defineBTR1(*(unsignedcharvolatilexdata*)0xFE07)//總線定時(shí)寄存器1;總線波特率的選擇#defineOCR(*(unsignedcharvolatilexdata*)0xFE08)//輸出控制寄存器#defineACR(*(unsignedcharvolatilexdata*)0xFE10)//#defi
5、neACR1(*(unsignedcharvolatilexdata*)0xFE11)//#defineACR2(*(unsignedcharvolatilexdata*)0xFE12)//#defineACR3(*(unsignedcharvolatilexdata*)0xFE13)//接收代碼(0x16_0x19);接收過(guò)濾位的選擇*******復(fù)位模式#defineAMR(*(unsignedcharvolatilexdata*)0xFE14)//#defineAMR1(*(unsignedcharvolatilexdata*)0xFE15)//#
6、defineAMR2(*(unsignedcharvolatilexdata*)0xFE16)//#defineAMR3(*(unsignedcharvolatilexdata*)0xFE17)//掩碼(0x20_0x23);接收過(guò)濾位的選擇*******復(fù)位模式#defineCDR(*(unsignedcharvolatilexdata*)0xFE1F)//時(shí)鐘分頻器#defineALC(*(unsignedcharvolatilexdata*)0xFE0B)//仲裁丟失捕捉寄存器#defineECC(*(unsignedcharvolatilexda
7、ta*)0xFE0C)//誤碼捕捉寄存器#defineTBSR(*(unsignedcharvolatilexdata*)0xFE10)//發(fā)送緩沖器地址(0x16_0x28)#defineTBSR1(*(unsignedcharvolatilexdata*)0xFE11)//#defineTBSR2(*(unsignedcharvolatilexdata*)0xFE12)//#defineTBSR3(*(unsignedcharvolatilexdata*)0xFE13)//#defineTBSR4(*(unsignedcharvolatilexdat
8、a*)0xFE14)//#defineTBSR5(*(unsignedcharv