📄 kslib.c
字号:
default :
Print("\r Invalid HDLC test item is selected") ;
break ;
}
Print("\n") ;
return NO_ERROR;
}
/*
* Function : IicCmdLi
* Description : Iic Test Program for Command Line
*/
U32 IicCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
if((argc != 2))
{
PrintHelpMessage("iic");
Print("Useage: iic <read/write/auto> \n") ;
return NO_ERROR;
}
ClearLcdDisplay() ;
lPrint("IIC Test ..") ;
if (!str_ncmp(argv[1],"read",sizeofstr(argv[1])))
IICReadTest() ;
else if (!str_ncmp(argv[1],"write",sizeofstr(argv[1])))
IICWriteTest() ;
else if (!str_ncmp(argv[1],"auto",sizeofstr(argv[1])))
IICAutoTest() ;
Print("\n") ;
return NO_ERROR;
}
/*
* Function : MarchTestCmdLi
* Description : All SNDS function test
*/
U32 MarchTestCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
int lcnt ;
if((argc != 3))
{
PrintHelpMessage("march");
Print("Useage: march test [count]\n") ;
return NO_ERROR;
}
ClearLcdDisplay() ;
lPrint("March Test .....") ;
lcnt = strtoint(argv[2], sizeofstr(argv[2]));
while(lcnt--)
{
Print("\n >>> %d'th March Test...",lcnt) ;
March10NAllTest() ;
}
Print("\n") ;
return NO_ERROR;
}
/*
* Function : AllTestCmdLi
* Description : All SNDS function test
*/
U32 AllTestCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
U32 lcnt ;
char *s;
if((argc != 3))
{
PrintHelpMessage("all");
Print("Usage: all test [lcnt]\n") ;
return NO_ERROR;
}
lcnt = strtoint(argv[2], sizeofstr(argv[2]));
l2Print("-NetMCU SNDS100-","Test Start..");
/* TIMER 0,1 Initialize for measuring test time */
tmReset(TIMER_DEV0);
tm_init(TIMER_DEV0,(ONE_SECOND/TICKS_PER_SECOND));
TimerStart(TIMER_DEV0);
AllTestInternal(lcnt) ;
TimerStop(TIMER_DEV0);
s = GetSysTime(TIMER_DEV0);
if (AllTestResult != 0 )
{
Print("\n $$$ All Test Failed !!!!!") ;
Print("\n $$$ Error Occured Count : %d ", AllTestResult) ;
lfPrint(s,"AllTest[%d] FAIL!",lcnt);
IOPDATA = 0x0f ;
}
else
{
Print("\n $$$ All Test Passed !!!!!") ;
lfPrint(s,"AllTest[%d] PASS!",lcnt);
IOPDATA = 0xaa ;
}
AllTestResult = 0 ;
Print("\r-------------------------------------------------\r");
PrtSysTime(TIMER_DEV0,"Total test time");
Print("\r-------------------------------------------------\r");
ClrTimeVar(TIMER_DEV0);
Print("\rType any key to continue...");
get_byte();
return NO_ERROR;
}
/*
* Function : AllTestInternal
* Description : All KS32C50100 Internal function test
*/
U32 AllTestInternal(U32 loopcnt)
{
U32 Reg , i ;
AllErrorReport AllErrorRptNoCache={0.0,0,0,0,0,0} ;
AllErrorReport AllErrorRpt4KCache={0.0,0,0,0,0,0} ;
AllErrorReport AllErrorRpt8KCache={0.0,0,0,0,0,0} ;
// ------------------------------------------------
// Internal SRAM 10N March Test
Print("\n0. Internal SRAM 10N March Test .... ") ;
if ( !March10NAllTest() ) {
AllErrorRpt.SramError = 1 ;
Print("\n $$$ Internal SRAM 10N March FAIL !!! ") ;
l2Print("Cache Test..","->FAIL!");
}
else {
Print("\n $$$ Internal SRAM 10N March PASS !!! ") ;
l2Print("Cache Test..","->PASS!");
}
for (i=0; i<loopcnt ; i++ ) {
SyscfgInit(CACHE_8K);
Print("\n\n========================================") ;
Print("\r All Test with 8K Cache ON") ;
lfPrint("<CACHE 8K MODE>","All Test[%d]",i+1) ;
Print("\r========================================") ;
AllTestFunc() ;
AllErrorRpt8KCache = AllErrorRpt ;
ClrAllErrRpt(); /* Clear Error Report */
Print("\n\n $ All Test Finished !!!!! ") ;
SyscfgInit(CACHE_4K);
Print("\n\n========================================") ;
Print("\r All Test with 4K Cache ON") ;
lfPrint("<CACHE 4K MODE>","All Test[%d]",i+1) ;
Print("\r========================================") ;
AllTestFunc() ;
AllErrorRpt4KCache = AllErrorRpt ;
ClrAllErrRpt(); /* Clear Error Report */
SyscfgInit(CACHE_OFF);
Print("\n\n========================================") ;
Print("\r All Test with Cache OFF") ;
Print("\r========================================") ;
lfPrint("<CACHE OFF MODE>","All Test[%d]",i+1) ;
AllTestFunc() ;
AllErrorRptNoCache = AllErrorRpt ;
ClrAllErrRpt(); /* Clear Error Report */
IOPDATA = 0xF ;
Print("\n\n========================================") ;
Print("\r All Test Error Report") ;
Print("\r========================================") ;
Print("\r $$ Cache OFF Test") ;
if (AllErrorRptNoCache.SramError) {
AllTestResult++ ;
Print("\r $$$ Internal SRAM Test FAIL !") ; }
else if (AllErrorRptNoCache.MemError) {
AllTestResult++ ;
Print("\r $$$ Memory Test FAIL !") ; }
else if (AllErrorRptNoCache.UartError) {
AllTestResult++ ;
Print("\r $$$ UART Test FAIL !") ; }
else if (AllErrorRptNoCache.TimerError) {
AllTestResult++ ;
Print("\r $$$ TIMER Test FAIL !") ; }
else if (AllErrorRptNoCache.DmaError) {
AllTestResult++ ;
Print("\r $$$ DMA Test FAIL !") ; }
else if (AllErrorRptNoCache.IicError) {
AllTestResult++ ;
Print("\r $$$ IIC Test FAIL !") ; }
else if (AllErrorRptNoCache.MacError) {
AllTestResult++ ;
Print("\r $$$ MAC Test FAIL !") ; }
else if (AllErrorRptNoCache.HdlcError) {
AllTestResult++ ;
Print("\r $$$ HDLC Test FAIL !") ; }
else
Print(" : PASS !!!") ;
Print("\r----------------------------------------") ;
Print("\r $$ 4K Cache Test") ;
if (AllErrorRpt4KCache.MemError) {
AllTestResult++ ;
Print("\r $$$ Memory Test FAIL !") ; }
else if (AllErrorRpt4KCache.UartError) {
AllTestResult++ ;
Print("\r $$$ UART Test FAIL !") ; }
else if (AllErrorRpt4KCache.TimerError) {
AllTestResult++ ;
Print("\r $$$ TIMER Test FAIL !") ; }
else if (AllErrorRpt4KCache.DmaError) {
AllTestResult++ ;
Print("\r $$$ DMA Test FAIL !") ; }
else if (AllErrorRpt4KCache.IicError) {
AllTestResult++ ;
Print("\r $$$ IIC Test FAIL !") ; }
else if (AllErrorRpt4KCache.MacError) {
AllTestResult++ ;
Print("\r $$$ MAC Test FAIL !") ; }
else if (AllErrorRpt4KCache.HdlcError) {
AllTestResult++ ;
Print("\r $$$ HDLC Test FAIL !") ; }
else
Print(" : PASS !!!") ;
Print("\r----------------------------------------") ;
Print("\r $$ 8K Cache Test") ;
if (AllErrorRpt8KCache.MemError) {
AllTestResult++ ;
Print("\r $$$ Memory Test FAIL !") ; }
else if (AllErrorRpt8KCache.UartError) {
AllTestResult++ ;
Print("\r $$$ UART Test FAIL !") ; }
else if (AllErrorRpt8KCache.TimerError) {
AllTestResult++ ;
Print("\r $$$ TIMER Test FAIL !") ; }
else if (AllErrorRpt8KCache.DmaError) {
AllTestResult++ ;
Print("\r $$$ DMA Test FAIL !") ; }
else if (AllErrorRpt8KCache.IicError) {
AllTestResult++ ;
Print("\r $$$ IIC Test FAIL !") ; }
else if (AllErrorRpt8KCache.MacError) {
AllTestResult++ ;
Print("\r $$$ MAC Test FAIL !") ; }
else if (AllErrorRpt8KCache.HdlcError) {
AllTestResult++ ;
Print("\r $$$ HDLC Test FAIL !") ; }
else
Print(" : PASS !!!") ;
Print("\r========================================") ;
Print("\r>>> All test loop counter value is %d.",i+1);
Print("\r========================================") ;
}
return NO_ERROR;
}
/* Clear AllErrReport */
void ClrAllErrRpt()
{
// Clear Error Report
AllErrorRpt.MemError = 0 ;
AllErrorRpt.UartError = 0 ;
AllErrorRpt.TimerError = 0 ;
AllErrorRpt.DmaError = 0 ;
AllErrorRpt.IicError = 0 ;
AllErrorRpt.MacError = 0 ;
AllErrorRpt.HdlcError = 0 ;
AllErrorRpt.SramError = 0 ;
}
/*
* Function : All Test Program
* Description : Test of all function
*/
U32 AllTestFunc(void)
{
U32 *src = (U32 *)0x1100000 ; // Memory source address
U32 *dst = (U32 *)0x1200000 ; // Memory destination address
U32 tsize = 0x1000 ; // Memory Test size
int lsize = 1 ; // memory test loop size
// ------------------------------------------------
// MEMORY Test
Print("\n1. Memory Test .... ") ;
if ( !MemTest(src,dst,tsize,lsize) )
{
AllErrorRpt.MemError = 1 ;
Print("\n $$$ Memory Test FAIL !!! ") ;
l2Print("Memory Test..","->FAIL") ;
}
else {
Print("\n $$$ Memory Test PASS !!! ") ;
l2Print("Memory Test..","->PASS") ;
}
// ------------------------------------------------
// UART Test
Print("\n2. UART Test .... ") ;
if (!UARTAutoLoopBack())
{
AllErrorRpt.UartError = 1 ;
Print("\n $$$ UART Test FAIL !!! ") ;
l2Print("UART Test..","->FAIL!");
}
else {
Print("\n $$$ UART Test PASS !!! ") ;
l2Print("UART Test..","->PASS!");
}
// ------------------------------------------------
// GDMA Channel 0/1 Test
Print("\n3. GDMA Channel 0/1 Test .... ") ;
GdmaReset(0);
GdmaReset(1);
GdmaIntEnable(0);
GdmaIntEnable(1);
//if ( !DmaAutoTest(0x1100000,0x1200000,0x10000,10) )
if ( !DmaAutoTest(0x1100000,0x1200000,0x500,3) )
{
AllErrorRpt.DmaError = 1 ;
Print("\n $$$ DMA Test FAIL !!!") ;
l2Print("GDMA Ch0/1 Test..","->FAIL!") ;
}
else
{
Print("\n $$$ DMA Test PASS !!! ") ;
l2Print("GDMA Ch0/1 Test..","->PASS!") ;
}
GdmaIntDisable(0);
GdmaIntDisable(1);
// ------------------------------------------------
// IIC Test
Print("\n4. IIC Test .... ") ;
if ( !IICLoopBackTest() )
{
AllErrorRpt.IicError = 1 ;
Print("\n $$$ IIC Test FAIL !!! ") ;
l2Print("IIC Test..","->FAIL!") ;
}
else {
Print("\n $$$ IIC Test PASS !!! ") ;
l2Print("IIC Test..","->PASS!") ;
}
// ------------------------------------------------
// MAC Test
Print("\n5. MAC Test .... ") ;
MACCON |= MACLoop ; // set Loopback bit(4)
LanInitialize() ;
// if ( !InterruptLoopBackTest() )
if ( !PhyNoColLoopBack() )
{
AllErrorRpt.MacError = 1 ;
Print("\n $$$ MAC Test FAIL !!! ") ;
l2Print("MAC Test..","->FAIL!") ;
}
else {
Print("\n $$$ MAC Test PASS !!! ") ;
l2Print("MAC Test..","->PASS!") ;
}
MACCON &= ~MACLoop ; // Disable Loopback bit(4)
ClearErrReport() ;
// ------------------------------------------------
// HDLC Test
Print("\n6. HDLC Test .... ") ;
if(!(HdlcInternalLoopback(HDLCA,300)&HdlcInternalLoopback(HDLCB,300)))
{
AllErrorRpt.HdlcError = 1 ;
Print("\n $$$ HDLC Test FAIL !!! ") ;
l2Print("HDLC Test..","->FAIL") ;
}
else {
Print("\n $$$ HDLC Test PASS !!! ") ;
l2Print("HDLC Test..","->PASS") ;
}
/* 10 second time delay */
WaitTime_ms(TIMER_DEV1, (ONE_SECOND * 10));
return 1 ;
}
/*
* Function : DownCmdLi
* Description : Download Commandline interface
*/
U32 DownPgmCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
U32 RcvDataSize ;
char *downarea ;
if((argc != 2))
{
PrintHelpMessage("down");
Print("Useage: down <Target Address>\n") ;
return NO_ERROR;
}
IOPDATA = 0x0 ;
ClearLcdDisplay() ;
lPrint("Download ..") ;
downarea = (char *)hexstrtohex(argv[1], sizeofstr(argv[1]));
Print("\r $$ Download Target Address : 0x%08x",downarea) ;
Print("\r $$ Waiting Download .... ") ;
RcvDataSize=GetDataSize(CONSOLE) ;
ReceiveData(downarea,RcvDataSize) ;
if(CRCErrorCheck(downarea,RcvDataSize)) {
Print("Ok !") ;
Print("\r $$ Download Program Size : %d Byte",RcvDataSize) ;
}
else Print("FAIL !!!");
IOPDATA = 0xF ;
Print("\n") ;
return NO_ERROR;
}
/*
* Function : FusePgmCmdLi
* Description : Start Download user program
*/
U32 FusePgmCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
U32 *Src ;
U32 *Dst ;
U32 Size ;
if((argc != 4))
{
PrintHelpMessage("fuse");
Print("Useage: fuse <Download Address> <Target Address> <Size>\n") ;
return NO_ERROR;
}
IOPDATA = 0x0 ;
ClearLcdDisplay() ;
lPrint("Fusing EEPROM ..") ;
Src = (U32 *)hexstrtohex(argv[1], sizeofstr(argv[1]));
Dst = (U32 *)hexstrtohex(argv[2], sizeofstr(argv[2]));
Size = strtoint(argv[3], sizeofstr(argv[3]));
Print("\n>> Source : %08x, Destination : %08x, Size : %d", \
Src,Dst,Size) ;
Program_SST29EE(Src,Dst,Size);
IOPDATA = 0xF ;
Print("\n+--------------------------------------------+") ;
Print("\r| Press 'Reset' Button in SNDS board ....... |") ;
Print("\r+--------------------------------------------+") ;
Print("\n") ;
return NO_ERROR;
}
/*
* Function : GoCmdLi
* Description : Start Download user program
*/
U32 GoPgmCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
U32 *downarea ;
if((argc != 2))
{
PrintHelpMessage("go");
Print("Useage: go <Target Address>\n") ;
return NO_ERROR;
}
downarea = (U32 *)hexstrtohex(argv[1], sizeofstr(argv[1]));
StartDownPgm(downarea) ;
Print("\n") ;
return NO_ERROR;
}
/*
* Function : StartCmdLi
* Description : Start Download user program
*/
U32 StartCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
if((argc != 1))
{
PrintHelpMessage("start");
Print("Useage: go <Target Address>\n") ;
return NO_ERROR;
}
StartUserPgm() ;
Print("\n") ;
return NO_ERROR;
}
/*
* Function : BootCmdLi
* Description : Start pSOS in User EEPROM(in ROM Bank 1)
*/
U32 BootCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
if((argc != 1))
{
PrintHelpMessage("boot");
Print("Useage: boot\n") ;
return NO_ERROR;
}
StartDownPgm( (U32 *)0x200000 ) ;
return NO_ERROR;
}
/*
* Function : ExitCmdLi
* Description : Start Download user program
*/
U32 ExitCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
// Call Menu mode diag program
Diag() ;
Print("\n") ;
return NO_ERROR;
}
/*
* Function : ResetCmdLi
* Description : Reset SNDS, Jump to Reset Handler
*/
U32 ResetCmdLi(U8 argc, char (*argv)[MAX_LENGTHOF_ARGS],CMDPOOL *pCmd)
{
if((argc != 1))
{
PrintHelpMessage("reset");
Print("Useage: reset\n") ;
return NO_ERROR;
}
Reset_Boot_Rom() ;
Print("\n") ;
return NO_ERROR;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -