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

📄 lan9115.c

📁 samsung 最新芯片2450 的测试程序.
💻 C
字号:
#include "System.h"
#include "lan9115.h"


#define LAN9115_MEM_BASE 	0x20000000 // CS4

#define LAN9115_REG_BASE  	LAN9115_MEM_BASE

void Detect_LAN9115(void);

void * func_lan9115_test[][2]=
{	
    //        					"12345678901234567890"
    //Clock test
    (void *)Detect_LAN9115,		"Detect LAN9115       ",
    0,0
};

void Test_LAN9115(void)
{
    	int i;

	rSMBIDCYR4 = 0xf;
	rSMBWSTRDR4 = 20;  //14clk
	rSMBWSTWRR4 = 20;
	rSMBWSTOENR4 = 5;
	rSMBWSTWENR4 = 5;

	//printf("rSMBCR=%x\n",rSMBCR4);
	//rSMBCR4 = rSMBCR4 & ~(3<<4) | (1<<15)|(1<<7)|(1<<4)|(1<<2)|(1); 
	// OE&WE delay 1,5&2 clk, CS delay 1clk, memory width 16bit, WaitEn, Read byte lane enable

    while(1)
    {
	i=0;
	printf("\n\n");
	while(1)
	{   //display menu
	    printf("%2d:%s",i,func_lan9115_test[i][1]);
	    i++;
	    if((int)(func_lan9115_test[i][0])==0)
	    {
		printf("\n");
		break;
	    }
	    if((i%3)==0)
	    printf("\n");
	}

	printf("\nSelect (Press enter key to exit) : ");
	i = GetIntNum();
	if(i==-1) 
	    break;		// return.
	if(i>=0 && (i<((sizeof(func_lan9115_test)-1)/8)) )	// select and execute...
	    ( (void (*)(void)) (func_lan9115_test[i][0]) )();
    }
    printf("\nCS8900_Test program end.\n");
}



void Detect_LAN9115(void)
{
	unsigned int reg = 0;

	printf(" Detect LAN9115 \r\n");
	
	rSMBCR4 = rSMBCR4 & ~(3<<4) | (1<<4); // memory width 16bit, WaitEn, Read byte lane enable

	reg = smsc9115_reg_read(ID_REV);
	//printf("\nreg = 0x%x\r\n", ((reg>>16)&0xffff));

	if (((reg>>16)&0xffff) != ChipID)
		printf("\nID Error = 0x%x\r", ((reg>>16)&0xffff));

	printf("\nDevice ID = 0x%x", (reg>>16)&0xffff);
	printf("\nRevision number = 0x%x", reg&0xffff);
	printf("\n\nLan9115 is Detected..\n");
}

int smsc9115_reg_read(U32 reg)
{
	U32 reg_val;
	
	reg_val = ((*((U16 *)(LAN9115_REG_BASE + reg + 2)) & 0xffff) << 16) | (*((U16 *)(LAN9115_REG_BASE + reg)) & 0xffff);
	return reg_val;
}	  

⌨️ 快捷键说明

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