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

📄 usbfifo.c

📁 USB-TEST是USB通信的例子
💻 C
字号:
/*********************************************************************************************
* File:		usbfifo.c
* Author:	embest
* Desc:		S3C2410 USB FIFO Test
* History:	
*			R.X.Huang, March 12, 2005
*				Programming modify, style of the program: nomenclature, commentary
*			Y.J.Guo, April 28, 2005
*				Modifying and reusing  of S3C2410X u24xmon
*********************************************************************************************/

/*------------------------------------------------------------------------------------------*/
/*                                     include files	                                    */
/*------------------------------------------------------------------------------------------*/
#include <string.h>

#include "2410lib.h"

/*------------------------------------------------------------------------------------------*/
/*                                     global variables                                     */
/*------------------------------------------------------------------------------------------*/
int MarchError;

/*------------------------------------------------------------------------------------------*/
/*                                     function declare                                     */
/*------------------------------------------------------------------------------------------*/
void _MarchSub1(unsigned int *pt,int unit,unsigned int pattern,int incdec);
void MarchCMinus32(int address,int unit,unsigned int pattern);

/*********************************************************************************************
* name:		usb_fifo_test
* func:		USB FIFO Test
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
int usb_fifo_test(void)
{
    int saveSyscfg;
    uart_printf(" USB FIFO Cell Test by March C-\n");
    
    // Make test mode
    *(int *)0x52000280 = 0x1;

    MarchError=0;

    //00->01->11<->10

    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;
   }
}

/*********************************************************************************************
* name:		_MarchSub1
* func:		_MarchSub1
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void _MarchSub1(unsigned int *pt,int unit,unsigned int pattern,int incdec)
{
    unsigned int i,rp;

    for(i=0;i<=unit;i++)
    {
        rp=*pt;
        //uart_printf(" RP=%x",*pt);
        *pt=pattern;
        //uart_printf(" j=%x,p=%x,pt=%x\n",rp,(~pattern),pt);
        if(rp!=(~pattern))
        {
            MarchError=1;
            uart_printf(" ERROR1 : Address= 0x%8x,    Write= 0x%8x,    Read= 0x%8x\n",pt,(~pattern),rp);         
       }
        pt+=incdec;
   }
}

/*********************************************************************************************
* name:		MarchCMinus32
* func:		MarchCMinus32
* para:		none
* ret:		none
* modify:
* comment:		
*********************************************************************************************/
void MarchCMinus32(int address,int unit,unsigned int pattern)
{
    int i;
    unsigned int *tempPt;
    
    tempPt=(unsigned int *)address;
    
    for(i=0;i<=unit;i++)
    {
        //uart_printf(" P=%x",pattern);
        *tempPt++=pattern;
        //uart_printf(" A=%x,P=%x\n",tempPt,*tempPt);
   }
    
	uart_printf(" Waitting 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:%x\n",tempPt);
            uart_printf(" ERROR0 : Address= 0x%8x,    Write= 0x%8x,    Read= 0x%8x\n",tempPt,pattern,*tempPt);           
       }
        tempPt++;
   }
    //uart_printf(" RP=%x,RA=%x\n",*tempPt,tempPt);
}

⌨️ 快捷键说明

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