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

📄 ethernet.c

📁 在arm realview下的s3c2410开发板测试工程及代码
💻 C
字号:
//ethernet.c
#include "ethernet.h"
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"

#define BASE_ADDR 0x19000000

#define Read_Reg(reg) (*(volatile unsigned char*)(BASE_ADDR+reg))
#define Write_Reg(v, reg) (*(volatile unsigned char*)(BASE_ADDR+reg))=v
#define CS8900_Tacs     (0x3)   // 0clk
#define CS8900_Tcos     (0x0)   // 4clk
#define CS8900_Tacc     (0x7)   // 14clk
#define CS8900_Tcoh     (0x1)   // 1clk
#define CS8900_Tah      (0x3)   // 4clk
#define CS8900_Tacp     (0x3)   // 6clk
#define CS8900_PMC      (0x0)   // normal(1data)

void Test_Ethernet(void)
{
	unsigned char id1;
	unsigned char id2;
	int i;
	//wrie command reg
        rBWSCON  = (rBWSCON&~(0xf<<12));//|(0xc<<12);  /*  nWAIT */
        //      rGSTATUS0;              /* Read Only */
        rGPACON;  /* look up uncomress.h */
        rGPGCON = (rGPGCON&~(3<<2))|(2<<2); /* EXINT 9 */
        rBANKCON3=((CS8900_Tacs<<13)+(CS8900_Tcos<<11)+(CS8900_Tacc<<8)
                   +(CS8900_Tcoh<<6)+(CS8900_Tah<<4)+(CS8900_Tacp<<2)+(CS8900_PMC));
        //rEXTINT1 = (rEXTINT1&~(7<<4))|(1<<4); /* Rising Edge Detect Mode */
	rINTMSK=0xffffff;

	Write_Reg(0x08,00);
	id1=Read_Reg(0x0a);
	if(id1==0x50)
		Uart_Printf("RTL8019 is ok,ID1 =0x%x\n",id1);
	else
	    Uart_Printf("[ RTL8019 does not work, id1=0x%x is wrong!\n",id1);
		
	
	for(i=0;i<1000;i++);
	Write_Reg(0x08,00);
	id2=Read_Reg(0x0b);
	if(id2==0x70)
		Uart_Printf("RTL8019 is ok,ID1 =0x%x\n",id2);
	else
	    Uart_Printf("[ RTL8019 does not work, id2=0x%x is wrong!\n",id2);
	    
	return;
}

⌨️ 快捷键说明

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