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

📄 diag.c

📁 these r the codes of arm7 tdmi s3c4510b which r used to write codes for ethernet controller
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************/
/*                                                                       */
/* FILE NAME                                      VERSION                */
/*                                                                       */
/*      diag.c                     KS32C5000, KS32C50100   : version 1.0 */
/*                                                                       */
/* COMPONENT                                                             */
/*                                                                       */
/*                                                                       */
/* DESCRIPTION                                                           */
/*                                                                       */
/*      Dignostic Program to evaluate SNDS100 board                      */
/*                                                                       */
/* AUTHOR                                                                */
/*                                                                       */
/*                                                                       */
/* DATA STRUCTURES                                                       */
/*                                                                       */
/*                                                                       */
/* FUNCTIONS                                                             */
/*                                                                       */
/*      SNDS board initializing routine                                  */
/*                                                                       */
/* DEPENDENCIES                                                          */
/*                                                                       */
/*                                                                       */
/* HISTORY                                                               */
/*                                                                       */
/*************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include "std.h"
#include "snds.h"
#include "diag.h"
#include "memory.h"
#include "flash.h"
#include "down.h"
#include "pollio.h"
#include "uart.h"
#include "isr.h"
#include "lcd.h"
#include "dma.h"
#include "iic.h"
#include "timer.h"
#include "system.h"
#include "mac.h"
#include "hdlc100.h"
#include "kslib.h"
#include "dhry.h"
#include "sysconf.h"
#include "iop.h"


void DRAMTOROM_MAP_RESTORE(void);
extern U32 AllTestResult ;

char       *sndshst = "-KS32C50100 SNDS-";

ITEMS  SelTestItem[MAXTESTITEM] = {
         'a',  "* All Test",
         'm',  "* Memory Test",
         'c',  "* Cache Test",
         'd',  "* GDMA Test",
         't',  "* Timer Test",
         'i',  "* Interrupt Test",
         'l',  "* MAC Test",
         'h',  "* HDLC Test",
         's',  "* I2C Test",
         'u',  "* UART Test",
         'e',  "* ETC Test", 
         'p',  "* Downloading" 
} ;

// C Program Entry Point
void C_Entry(void)
{
       // DiagCmdLi();
        Diag();
}



void  Diag(void)
{
		InitSnds() ;
		Print("\r If you have any other problem, send the mail");
		Print("\r e-mail : jwchoi@sec.samsung.com \r");
	while(1){
		PrintBanner() ;
		TestItemSelect() ;
	}
}

/* 
 * Function : InitSnds
 * Description : Initialize for Command Line Interface
 */
void InitSnds(void) 
{
	int i;

	IOPMOD |= 0xff ; // General Purpose Register Mode Select
	IOPDATA = 0x0 ;

	InitInterrupt() ;
UARTTXH1 = NULL ;
UARTTXH0 = NULL ;
        UART_Initialize();  /* Initialize UART channel 0,1 */
	LCDInit() ;
	IicSetup() ; 
	
//	LanInitialize() ;
	MacInitialize();		// Modifier Ryu  02/22/2001
	
     HdlcInitialize();

        /* Timer0 used for real time clock for this SNDS */ 
	tm_init(TIMER_DEV0,(ONE_SECOND/TICKS_PER_SECOND)); 
	TimerStart(TIMER_DEV0);

        /* Timer1 used for general system clock for this SNDS */ 
        /* This timer can be reset or restart for test purpose */ 

	SysSetInterrupt(nGDMA0_INT, GDMA0isr);
	SysSetInterrupt(nGDMA1_INT, GDMA1isr);
     
        SyscfgInit(CACHE_8K); /* 8k cache on */

	IOPDATA = 0xF ;

	Enable_Int(nGLOBAL_INT);
//for(i=0; i<50; i++) {while(!(UARTSTAT0&USTAT_TX_COMPLET)); i_putc(0, 'A') ;} 
//for(i=0; i<10; i++) {while(!(UARTSTAT1&USTAT_TX_COMPLET)); i_putc(1, 'B') ; }

}



// Print Banner
void PrintBanner(void)
{
//int i;
	Print("\n\n") ;
	Print("            DIAGNOSTIC TEST ITEMS     Any Day June. 2001 \r\r") ;
	Print("-----------------------------------------------------------\r") ;
	Print("  1. User Pgm Download  -[P]   2. Flash Download     -[F]  \r") ;
	Print("  3. Cache/SRAM Test    -[C]   4. Memory Test        -[M]  \r") ;
	Print("  5. GDMA Test          -[D]   6. Timer Test         -[T]  \r") ;
	Print("  7. Interrupt Test     -[I]   8. MAC/Ethernet Test  -[L]  \r") ;
	Print("  9. HDLC Test          -[H]   10.I2C Test           -[S]  \r") ;
	Print("  11.UART Test          -[U]   12.I/O Port Functions -[G]  \r") ;
	Print("  13.All Test           -[A]   15.ETC Test           -[E]  \r") ;
	Print("  15.View Configuration -[V]   17.Benchmarking       -[B]  \r") ;
        Print("  18.LCD Only Test Mode -[O]                               \r") ;
	Print("-----------------------------------------------------------\r") ;
	Print("> To enter the command line debugging mode, Type \"E\".    \r") ;
	Print("-----------------------------------------------------------\r") ;
	Print("!!!   This is Test Code !!! \r") ;	    
//for(i=0; i<100; i++) {while(!(UARTSTAT1&USTAT_TX_COMPLET)); i_putc(1, '!') ;} 

}



// Test Item Select
void TestItemSelect(void)
{
	char ItemSel ;

		Print("\rSelect Test Item : ") ;
		lPrint("Select Key ...") ;
#ifdef SNDS1_2
		ItemSel = get_byte();
#else
		ItemSel = get_key();
#endif	
		switch(ItemSel)
		{
			case 'M' : case 'm' : MemTestDiag() ; break ;
			case 'C' : case 'c' : CacheTestDiag() ; break ;
			case 'I' : case 'i' : IntTestDiag() ; break ;
			case 'D' : case 'd' : DmaTestDiag() ; break ;
			case 'T' : case 't' : TimerTestDiag() ; break ;
			case 'L' : case 'l' : MacTestDiag() ; break ;
			case 'H' : case 'h' : HdlcTestDiag() ; break ;
			case 'S' : case 's' : I2CTestDiag() ; break ;
			case 'U' : case 'u' : UartTestDiag() ; break ;
			case 'E' : case 'e' : EtcTestDiag() ; break ;
			case 'A' : case 'a' : AllTestDiag() ; break ;
			case 'B' : case 'b' : BenchMarkDiag() ; break ;
			case 'P' : case 'p' : DownloadDiag() ; break ;
			case 'F' : case 'f' : FusingDiag() ; break ;
			case 'V' : case 'v' : SysConfig() ; break ;
			case 'O' : case 'o' : LcdOnlyTestMode() ; break ;
			case 'G' : case 'g' : IoFuncDiag(); break ;
			default : Print("\nNo Test Item Selected") ; 
				break ;
		}

	//IOPDATA = 0xF ;
	Print("\n Press Any Key to Continue"); 
	lPrint("Press Any Key"); 
#ifdef SNDS1_2
        get_byte();
#else
	get_key();
#endif
	return ;
}


// get_key : get character from uart or Key-pad
char get_key(void) 
{
    	char ch ;
    	int  selcnt = 0;
    	int  Keyflag = 0;
    	int  KeyValue;

        /* Key scan check */
        while(!Keyflag) 
        {
            KeyValue = keyscan();

            if(KeyValue != INVALID_KEY) 
            {
                 switch(KeyValue)
	         {
	            case EINT0 : /* P8(ENTER): get item character */
	                          l2Print(sndshst,SelTestItem[selcnt].help);
	                          ch = SelTestItem[selcnt].item; 
	                          Keyflag = 1;
	                          //return ch;
	                          break ; // P8

	            case EINT1 : /* P9(UP):Count down for to select items */ 
		      	           if (selcnt == 0) selcnt = MAXTESTITEM ; 
		      	           else selcnt-- ; 
	                          l2Print(sndshst,SelTestItem[selcnt].help);
			           continue;

	            case EINT2 : /* P10(DOWN):Count up for to select items */    
		         	   if (selcnt < MAXTESTITEM) selcnt++ ; 
			           else selcnt = 0  ; 
	                           l2Print(sndshst,SelTestItem[selcnt].help);
			            continue;

	            case EINT3 :/* P11(RESET), Reset item */
	                           selcnt = 0 ; 
	                           l2Print(sndshst,SelTestItem[selcnt].help);
			           continue;

	            default :  /* get from console when key time out*/
	                       Keyflag = 0;
	         }
            }
            else
            {   /* No key then get from consol port */
                if(CONSOLE) 
                {
                     if(UARTSTAT1 & USTAT_RCV_READY) {
                          ch = UARTRXB1;
                          Keyflag = 1;
                     } 
                }
                else 
                {
                       if(UARTSTAT0 & USTAT_RCV_READY) {
                            ch = UARTRXB0;
                            Keyflag = 1;
                       } 
                }     
            }

	}

	lPut_byte(ch);
	return(ch);
}


void LcdOnlyTestMode(void)
{
	int i,SelCount = 0 ;
	char ch ;
	ITEM TestItemSel[] = { 
			"* All Test",
	 		"* Memory Test",
	 		"* Cache Test",
	 		"* GDMA Test",
	 		"* Timer Test",
	 		"* Interrupt Test",
	 		"* MAC Test",
	 		"* HDLC Test",
	 		"* I2C Test",
	 		"* UART Test",
	 		"* ETC Test", 
	 		"* Downloading", 
	 		"* Quit Test Mode" 
			} ;

	Print("\n >>   LCD Only Mode is Selected    <<") ;
	Print("\r >> Use Function Key in SNDS Board <<\n\n") ;

	for (i = 0; i < MAXTESTITEM; i++)
    		SelTestItemFunc[i] = DummyTestItem;

	InitTestItemSelFunction(0 ,AllTestDiag) ;
	InitTestItemSelFunction(1 ,MemTestDiag) ;
	InitTestItemSelFunction(2 ,CacheTestDiag) ; 
	InitTestItemSelFunction(3 ,DmaTestDiag) ;
	InitTestItemSelFunction(4 ,TimerTestDiag) ; 
	InitTestItemSelFunction(5 ,IntTestDiag) ;
	InitTestItemSelFunction(6 ,MacTestDiag) ;
	InitTestItemSelFunction(7 ,HdlcTestDiag) ;
	InitTestItemSelFunction(8 ,I2CTestDiag) ;
	InitTestItemSelFunction(9 ,UartTestDiag) ; 
	InitTestItemSelFunction(10 ,EtcTestDiag) ;
	InitTestItemSelFunction(11 ,DownloadDiag) ;

	while(1) {

	// ** For Test
	//Print("\r SelCount : %2d -> ",SelCount) ;
	//dbg_out("%s",TestItemSel[SelCount].TestItem) ;

	ClearLcdDisplay() ;
	lPrint(TestItemSel[SelCount].TestItem) ;

        switch(keyscan())
	{
	      case EINT0 : ch = 'S';   break ; // P8
	      case EINT1 : ch = 'D';   break ; // P9
	      case EINT2 : ch = 'U';   break ; // P10
	      case EINT3 :                     // P11
	      default :    ch = ' ';   break;
	}


⌨️ 快捷键说明

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