📄 usbfifo.c
字号:
/*
*********************************************************
* Copyright (c)
* All rights reserved.
*
* 文件名称:usbfifo.c
* 文件标识:
* 摘 要:本文件是对usbfifo的测试程序。
* 当前版本:1.0
* 作 者:刘征
* 完成日期:2005.4.3
*
* 取代版本:
* 作 者:
* 完成日期:
*********************************************************
*/
/*
*********************************************************
* 头文件
*********************************************************
*/
#include <string.h>
#include "2410addr.h"
#include "2410lib.h"
#include "def.h"
/*
*********************************************************
* 函数原型
*********************************************************
*/
void MarchCMinus32(int address,int unit,unsigned int pattern);
void _MarchSub1(unsigned int *pt,int unit,unsigned int pattern,int incdec);
/*
*********************************************************
* 变量
*********************************************************
*/
int MarchError;
/*
*********************************************************
* 函数介绍:本函数被使用来usbfifo测试。
* 输入参数:无
* 输出参数:无
* 返回值 :无
*********************************************************
*/
int Test_USBFIFO(void)
{
int saveSyscfg;
Uart_Printf("USB FIFO Cell Test by March C-\n");
// Make test mode
*(int *)0x52000280 = 0x1;
*(int *)0x52000100=0xffffffff;
Uart_Printf("0x%x\n",*(int *)0x52000100);
MarchError=0;
//00->01->11<->10
//64字节FIFO(0--63),如果将这里的63设置成大于63的值如:68。将会出现FIFO出错报告
MarchCMinus32(0x52000000,63,0x00000000);
MarchCMinus32(0x52000000,63,0x0f0f0f0f);
MarchCMinus32(0x52000000,63,0x33333333);
MarchCMinus32(0x52000000,63,0x55555555);
MarchCMinus32(0x52000000,63,0xaaaaaaaa);
if(MarchError==0)
{
Uart_Printf("USB FIFO is tested... OK!!\n");
return 1;
}
else
{
Uart_Printf("USB FIFO is tested... Fail!!\n");
return 0;
}
}
/*
*********************************************************
* 函数介绍:本函数被读、写数据测试。
* 输入参数:无
* 输出参数:无
* 返回值 :无
*********************************************************
*/
void MarchCMinus32(int address,int unit,unsigned int pattern)
{
int i;
unsigned int *tempPt;
tempPt=(unsigned int *)address;
for(i=0;i<=unit;i++)
{
*tempPt++=pattern;
}
Uart_Printf("\nWaitting 1 Sec\n");
Delay(10000);
Uart_Printf("Start\n");
_MarchSub1((unsigned int *)address,unit,~pattern,1);
_MarchSub1((unsigned int *)address,unit,pattern,1);
_MarchSub1((unsigned int *)address+unit,unit,~pattern,-1);
_MarchSub1((unsigned int *)address+unit,unit,pattern,-1);
tempPt=(unsigned int *)address;
for(i=0;i<=unit;i++)
{
if(*tempPt!=pattern)
{
MarchError=1;
Uart_Printf("ERROR0 : Address= 0x%8x, Write= 0x%8x, Read= 0x%8x\n",tempPt,pattern,*tempPt);
}
tempPt++;
}
}
/*
*********************************************************
* 函数介绍:本函数被读、写数据测试。
* 输入参数:无
* 输出参数:无
* 返回值 :无
*********************************************************
*/
void _MarchSub1(unsigned int *pt,int unit,unsigned int pattern,int incdec)
{
unsigned int i,rp;
for(i=0;i<=unit;i++)
{
rp=*pt;
*pt=pattern;
if(rp!=(~pattern))
{
MarchError=1;
Uart_Printf("ERROR1 : Address= 0x%8x, Write= 0x%8x, Read= 0x%8x\n",pt,(~pattern),rp);
}
pt+=incdec;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -