資源簡介
編譯環(huán)境arm-linux-gcc 分別有查詢與中斷兩種工作方式
代碼片段和文件信息
#include?“cs8900.h“
#include?“UART.h“
#include?“addr.h“
/***********************************************************
? ?函數(shù)聲明
**********************************************************/
static?U16?get_reg_init_bus?(U32?regno);
static?void?InitBank3(void);
static?void?put_reg?(U32?regno?U16?val);
static?U16?get_reg?(U32?regno);
static?void?eth_reset?(void);
static?void?eth_reginit?(void);
static?void?delay(U32?time);
int?eth_send?(volatile?void?*packet?int?length);
static?void?eth_init?(void);
static?void?InitIsqCs8900(void);
static?void?InitIsqCpu(void);
void?HandleCs8900Isr(void);
int?eth_rx?(U8?*pszBuf);
void?Main()
{
U32?chipId?=?0;
//U32?dataLen?=?0;
//U8?szBuf[100];
//U32?i;
delay(6000000); //等待網(wǎng)卡OK
//
InitBank3();
//
chipId?=?get_reg_init_bus(PP_ChipID);
Print_Com(“chipId?is:%x?\r\n“chipId);
//
eth_init();
//
InitIsqCpu();
//
InitIsqCs8900();
//
Print_Com(“wait?for?interrput?\r\n“);
/*while(1)
{
dataLen?=?eth_rx(szBuf);
if?(?dataLen?>?0?){
Print_Com(“the?len?is:%d\r\n“dataLen);
for(i=0;i Print_Com(“%c?“&szBuf[i]);
if(?(i+1)%16?==?0)
Print_Com(“\r\n“);
}
}
}*/
while(1);
}
/***********************************************************
? ?函數(shù)名:eth_rx
??? ?功能: ?接收數(shù)據(jù)包
?參數(shù): ?
?返回值: ?
??? ?DATE:???08-1-2008
??? ?MODIFY:?08-1-2008
**********************************************************/
?int?eth_rx?(U8?*pszBuf)
{
int?i;
unsigned?short?rxlen;
unsigned?short?*addr;
unsigned?short?status;
status?=?get_reg?(PP_RER);
if?((status?&?PP_RER_RxOK)?==?0)
return?0;
if?((status?&?PP_RER_IA)?==?0) //過濾不同MAC的包
return?0;
//要分字節(jié)讀取,否則有錯
status?=?CS8900_BUS16_1; /*?stat?*/
status?=?((status<<8)|CS8900_BUS16_0);
Print_Com(“%x?\r\n“status);
rxlen?=?CS8900_RTDATA0; /*?len?*/
for?(addr?=?(unsigned?short?*)?pszBuf?i?=?rxlen?>>?1;?i?>?0;i--)
*addr++?=?CS8900_RTDATA0;
if?(rxlen?&?1)
*addr++?=?CS8900_RTDATA0;
return?rxlen;
}
/***********************************************************
? ?函數(shù)名:eth_send
??? ?功能: ?發(fā)送數(shù)據(jù)包
?參數(shù): ?
?返回值: ?
??? ?DATE:???07-31-2008
??? ?MODIFY:?07-31-2008
**********************************************************/
/*?Send?a?data?block?via?Ethernet.?*/
int?eth_send?(volatile?void?*packet?int?length)
{
volatile?unsigned?short?*addr;
unsigned?short?s;
Print_Com(“enter?send?packet!\r\n“);
CS8900_TxCMD?=?PP_TxCmd_TxStart_Full;
CS8900_TxLEN?=?length;
if?((get_reg?(PP_BusSTAT)?&?PP_BusSTAT_TxRDY)?==?0)?{
Print_Com?(“unable?to?send?packet\r\n“);
}
/*?Write?the?contents?of?the?packet?*/
for(addr?=?packet;?length?>?0;?length?-=?2)
CS8900_RTDATA0?=?*addr++;
/*?wait?for?transfer?to?succeed?*/
//tmo?=?get_timer?(0)?+?5?*?CFG_HZ;
while?((s?=?get_reg?(PP_TER)?&?~0x1F)?==?0)?{
Print_Com(“is?sending\r\n“);
}
/*?nothing?*/?;
if?((s?&?(PP_TER_CRS?|?PP_TER_TxOK))?!=?PP_TER_TxOK)?
Print_Com?(“\ntransmiss
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5223??2008-03-10?12:00??網(wǎng)卡\cs8900-0802基本OK中斷方式\addr.h
?????文件???????4172??2008-03-10?11:57??網(wǎng)卡\cs8900-0802基本OK中斷方式\cs8900
?????文件???????9952??2008-03-10?12:01??網(wǎng)卡\cs8900-0802基本OK中斷方式\cs8900.c
?????文件??????41596??2008-03-10?11:57??網(wǎng)卡\cs8900-0802基本OK中斷方式\cs8900.elf
?????文件???????9691??2008-03-10?12:00??網(wǎng)卡\cs8900-0802基本OK中斷方式\cs8900.h
?????文件????????506??2008-03-10?11:11??網(wǎng)卡\cs8900-0802基本OK中斷方式\cs8900.lds
?????文件???????4300??2008-03-10?11:51??網(wǎng)卡\cs8900-0802基本OK中斷方式\cs8900.o
?????文件???????1784??2008-03-10?11:57??網(wǎng)卡\cs8900-0802基本OK中斷方式\head.o
?????文件???????3171??2008-03-10?12:00??網(wǎng)卡\cs8900-0802基本OK中斷方式\head.s
?????文件???????1717??2008-03-10?11:57??網(wǎng)卡\cs8900-0802基本OK中斷方式\IIC.map
?????文件????????686??2008-03-10?12:21??網(wǎng)卡\cs8900-0802基本OK中斷方式\makefile
?????文件???????7546??2008-03-10?14:09??網(wǎng)卡\cs8900-0802基本OK中斷方式\nand.c
?????文件???????1986??2008-03-10?14:09??網(wǎng)卡\cs8900-0802基本OK中斷方式\nand.h
?????文件????????904??2008-03-10?11:57??網(wǎng)卡\cs8900-0802基本OK中斷方式\nand.o
?????文件???????6134??2008-03-10?10:43??網(wǎng)卡\cs8900-0802基本OK中斷方式\net.c
?????文件???????1652??2008-03-10?16:00??網(wǎng)卡\cs8900-0802基本OK中斷方式\net.h
?????文件???????6478??2008-03-10?12:20??網(wǎng)卡\cs8900-0802基本OK中斷方式\UART.c
?????文件????????963??2008-03-10?10:24??網(wǎng)卡\cs8900-0802基本OK中斷方式\UART.h
?????文件???????2276??2008-03-10?11:57??網(wǎng)卡\cs8900-0802基本OK中斷方式\UART.o
?????文件???????5223??2008-03-10?16:00??網(wǎng)卡\cs8900發(fā)送程序\addr.h
?????文件???????5640??2008-03-10?13:44??網(wǎng)卡\cs8900發(fā)送程序\cs8900
?????文件??????10158??2008-08-02?14:27??網(wǎng)卡\cs8900發(fā)送程序\cs8900.c
?????文件??????44323??2008-03-10?18:30??網(wǎng)卡\cs8900發(fā)送程序\cs8900.elf
?????文件???????9709??2008-03-10?18:03??網(wǎng)卡\cs8900發(fā)送程序\cs8900.h
?????文件????????506??2008-03-10?11:11??網(wǎng)卡\cs8900發(fā)送程序\cs8900.lds
?????文件???????4448??2008-03-10?18:30??網(wǎng)卡\cs8900發(fā)送程序\cs8900.o
?????文件???????1784??2008-03-10?16:24??網(wǎng)卡\cs8900發(fā)送程序\head.o
?????文件???????3171??2008-03-10?16:00??網(wǎng)卡\cs8900發(fā)送程序\head.s
?????文件???????2191??2008-03-10?18:30??網(wǎng)卡\cs8900發(fā)送程序\IIC.map
?????文件????????692??2008-08-01?09:23??網(wǎng)卡\cs8900發(fā)送程序\makefile
............此處省略15個文件信息
- 上一篇:軟件工程實例訂票系統(tǒng)
- 下一篇:JS操作本地網(wǎng)頁串口源碼
評論
共有 條評論