亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? usb_test.c

?? USB-TEST是USB通信的例子
?? C
字號:
/*********************************************************************************************
* File:		u241mon.c
* Author:	Embest
* Desc:		u241mon entry point,menu,download
* History:	
*			Y.J.Guo, April 28, 2005
*				Modifying and reusing  of S3C2410X u24xmon
*********************************************************************************************/

/*------------------------------------------------------------------------------------------*/
/*                                     include files	                                    */
/*------------------------------------------------------------------------------------------*/
#include <stdlib.h>
#include <string.h>
#include "def.h"
#include "2410lib.h"
#include "2410slib.h"
#include "mmu.h"
#include "profile.h"

#include "usbmain.h"
#include "usbout.h"
#include "usblib.h"
#include "2410usb.h"

/*------------------------------------------------------------------------------------------*/
/*                                     functions declare                                    */
/*------------------------------------------------------------------------------------------*/
void Isr_Init(void);
extern void debug_undef(void);
extern void debug_swi(void);
extern void debug_abort_d(void);
extern void debug_abort_d(void);
void Lcd_Off(void);
void WaitDownload(void);
void Menu(void);
//void (*restart)(void)=(void (*)(void))0x0;
void (*run)(void);

/*------------------------------------------------------------------------------------------*/
/*                                     global variablese                                    */
/*------------------------------------------------------------------------------------------*/
//#define DOWNLOAD_ADDRESS _RAM_STARTADDRESS
volatile UINT32T downloadAddress;

volatile unsigned char *downPt;
volatile UINT32T downloadFileSize;
volatile UINT16T checkSum;
volatile unsigned int err=0;
volatile UINT32T totalDmaCount;

volatile int isUsbdSetConfiguration;

int download_run=0;
UINT32T tempDownloadAddress;
UINT32T test_ram_start;
UINT32T test_ram_end;
int menuUsed=0;

extern char Image_RW_Limit[];
UINT32T *pMagicNum=(UINT32T *)Image_RW_Limit;
int consoleNum;

/*********************************************************************************************
* name:		MemoryTest
* func:		Test Ram 
* para:		none
* ret:		none
* modify:
* comment:	comparing the data writen to RAM and the data read from RAM
*********************************************************************************************/
void MemoryTest(void)
{
    int i;
    UINT32T data;
    int memError=0;
    UINT32T *pt;
    
    // memory test
	uart_printf("\nEnter a start address of ram to test(0x3...):"); 
	test_ram_start = uart_getintnum(); 
	uart_printf("\nEnter a end address of ram to test(0x3...):");
	test_ram_end = uart_getintnum();     
	uart_printf("Memory Test(%xh-%xh):WR",test_ram_start,test_ram_end);

    pt=(UINT32T *)(test_ram_start);
    while((UINT32T)pt<(test_ram_end))
    {
	*pt=(UINT32T)pt;
	pt++;
   }

    uart_printf("\b\bRD");
    pt=(UINT32T *)(test_ram_start);
	
    while((UINT32T)pt<(test_ram_end))
    {
	data=*pt;
	if(data!=(UINT32T)pt)
	{
	    memError=1;
	    uart_printf("\b\bFAIL:0x%x=0x%x\n",i,data);
	    break;
	}
	pt++;
   }

    if(memError==0)uart_printf("\b\bO.K.\n");
}

/*********************************************************************************************
* name:		usb_test
* func:		usb monitor entry
* para:		none
* ret:		none
* modify:
* comment:	
*********************************************************************************************/
void usb_test(void)
{
    char *mode;
    int i;
    UINT8T key;
 
    rGPHCON = rGPHCON&~(0xf<<18)|(0x5<<18);   
    //To enhance the USB signal quality.
    //CLKOUT 0,1=OUTPUT to reduce the power consumption.
    
    Isr_Init();
    if(*pMagicNum!=0x12345678)
    	consoleNum=0;
    else
    	consoleNum=1;
    	
    uart_init(0,115200,UART0);
    uart_select(consoleNum);

    rMISCCR=rMISCCR&~(1<<3); // USBD is selected instead of USBH1 
    rMISCCR=rMISCCR&~(1<<13); // USB port 1 is enabled.

//
//  USBD should be initialized first of all.
//
    isUsbdSetConfiguration=0;

    UsbdMain();
    delay(0);  //calibrate delay()
    
    pISR_SWI=(_ISR_STARTADDRESS+0xf0);    //for pSOS


#if USBDMA
    mode="DMA";
#else
    mode="Int";
#endif

    uart_printf("\n");
    uart_printf("+---------------------------------------------+\n");
    uart_printf("| S3C2410X USB Downloader ver R1.11 APR/29/05 |\n");
    uart_printf("+---------------------------------------------+\n");
    uart_printf("FCLK=%dMHz,%s mode\n",FCLK/1000000,mode); 
    uart_printf("USB: IN_ENDPOINT:1 OUT_ENDPOINT:3\n"); 
    uart_printf("FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>\n");
    uart_printf("NOTE: 1. Power off/on or press the reset button for 1 sec\n");
    uart_printf("         in order to get a valid USB device address.\n");
    uart_printf("      2. For additional menu, Press any key. \n");
    uart_printf("\n");

    download_run=0; //The default menu is the Download mode.

	while(1)
	{
    	if(menuUsed==1) Menu();
    	WaitDownload();
#ifdef BOARDTEST
		break;
#endif
	}
	uart_printf(" end.\n"); 
}


/*********************************************************************************************
* name:		Menu
* func:		usb monitor Menu
* para:		none
* ret:		none
* modify:
* comment:	
*********************************************************************************************/
void Menu(void)
{
    int i;
    UINT8T key;
    menuUsed=1;
	g_nKeyPress = 1;
	while(g_nKeyPress==1)						// only for board test to exit
	{
	    uart_printf("\n###### Select Menu ######\n");
        //uart_printf(" [0] Download & Run\n");
        uart_printf(" [1] Download Only\n");
        uart_printf(" [2] Test SDRAM \n");
        uart_printf(" [3] Change The Console UART Ch.\n");
        
		while(g_nKeyPress==1)
		{
			if(key = uart_getkey()) break;
		}
        
        switch(key)
        {
        //case '0':
        //    uart_printf("\nDownload&Run is selected.\n\n");
        //    download_run=1;
        //    return;
        case '1':
            uart_printf("\nDownload Only is selected.\n");
            uart_printf("\nEnter a new temporary download address(0x3...):");
            tempDownloadAddress=uart_getintnum();
            download_run=0;
            uart_printf("\nThe temporary download address is 0x%x.\n\n",tempDownloadAddress);
            return;
        case '2':
            uart_printf("\nMemory Test is selected. please wait a little long time.\n");
   
		    MemoryTest();
		    Menu();
			return;
            break;
        case '3':
            uart_printf("\nWhich UART channel do you want to use for the console?[0/1]\n");
            if(uart_getch()!='1')
            {
				*pMagicNum=0x0;
				uart_printf("UART ch.0 will be used for console at next boot.\n");        	    	
			}
		    else
			{
				*pMagicNum=0x12345678;
				uart_printf("UART ch.1 will be used for console at next boot.\n");        
				uart_printf("UART ch.0 will be used after long power-off.\n");
			}
			uart_printf("System is waiting for a reset. Please, Reboot!!!\n");
			while(1);
			break;

        default:
            break;
		}	
   } 

}

/*********************************************************************************************
* name:		WaitDownload
* func:		usb downloader
* para:		none
* ret:		none
* modify:
* comment:	
*********************************************************************************************/
void WaitDownload(void)
{
    UINT32T i;
    UINT32T j;
    UINT16T cs;
    UINT32T temp;
    UINT16T dnCS;
    int first=1;
    float time;
    UINT8T tempMem[16];
    UINT8T key;
    
    checkSum=0;
    downloadAddress=(UINT32T)tempMem; //_RAM_STARTADDRESS; 
    downPt=(unsigned char *)downloadAddress;
	//This address is used for receiving first 8 byte.
    downloadFileSize=0;
    
#if 1
    MMU_DisableICache(); 
        //For multi-ICE. 
        //If ICache is not turned-off, debugging is started with ICache-on.
#endif

    /*******************************/
    /*    Test program download    */
    /*******************************/

    if(isUsbdSetConfiguration==0)
    {
		uart_printf("USB host is not connected yet.\n");
	}

    while(downloadFileSize==0)
    {
		if(first==1 && isUsbdSetConfiguration!=0)
		{
			uart_printf("USB host is connected. Waiting a download.\n");
			first=0;
		}

		key=uart_getkey();
		if(key!=0)
		{
			Menu();
			first=1; //To display the message,"USB host ...."
		}

	}

    timer_initex();      
    timer_startex();  

#if USBDMA    

    rINTMSK &= ~(BIT_DMA2);  

    ClearEp3OutPktReady(); 
    	// indicate the first packit is processed.
    	// has been delayed for DMA2 cofiguration.

    if(downloadFileSize>EP3_PKT_SIZE)
    {
        if(downloadFileSize<=(0x80000))
		{
			ConfigEp3DmaMode(downloadAddress+EP3_PKT_SIZE-8,downloadFileSize-EP3_PKT_SIZE);	
			//wait until DMA reload occurs.
			while((rDSTAT2&0xfffff)==0);

			//will not be used.
			rDIDST2=(downloadAddress+downloadFileSize-EP3_PKT_SIZE);  
			rDIDSTC2=(0<<1)|(0<<0);  
			rDCON2=rDCON2&~(0xfffff)|(0);        	    
		}
      	else
      	{
      	    ConfigEp3DmaMode(downloadAddress+EP3_PKT_SIZE-8,0x80000-EP3_PKT_SIZE);
			//wait until DMA reload occurs.
			while((rDSTAT2&0xfffff)==0);
      	    
			if(downloadFileSize>(0x80000*2))//for 1st autoreload
			{
				rDIDST2=(downloadAddress+0x80000-8);  //for 1st autoreload.
				rDIDSTC2=(0<<1)|(0<<0);  
    	        rDCON2=rDCON2&~(0xfffff)|(0x80000);        	  

				while(rEP3_DMA_TTC<0xfffff)
				{
					rEP3_DMA_TTC_L=0xff; 
					rEP3_DMA_TTC_M=0xff;
		  			rEP3_DMA_TTC_H=0xf;
				}
			}	
	 	    else
	 		{
	 			rDIDST2=(downloadAddress+0x80000-8);  //for 1st autoreload.
	   			rDIDSTC2=(0<<1)|(0<<0);  
				rDCON2=rDCON2&~(0xfffff)|(downloadFileSize-0x80000); 		
	
				while(rEP3_DMA_TTC<0xfffff)
				{
					rEP3_DMA_TTC_L=0xff; 
	 				rEP3_DMA_TTC_M=0xff;
					rEP3_DMA_TTC_H=0xf;
				}
			}
		}
		totalDmaCount=0;
	}
    else
	{
		totalDmaCount=downloadFileSize;
	}
#endif

    uart_printf("\nNow, Downloading [ADDRESS:%xh,TOTAL:%d]\n",
    		downloadAddress,downloadFileSize);
    uart_printf("RECEIVED FILE SIZE:%8d",0);

#if USBDMA    
    j=0x10000;

    while(1)
    {
    	if( (rDCDST2-(UINT32T)downloadAddress+8)>=j)
	{
	    uart_printf("\b\b\b\b\b\b\b\b%8d",j);
   	    j+=0x10000;
	}
	if(totalDmaCount>=downloadFileSize)break;
   }

#else
    j=0x10000;

    while(((UINT32T)downPt-downloadAddress)<(downloadFileSize-8))
    {
	if( ((UINT32T)downPt-downloadAddress)>=j)
	{
	    uart_printf("\b\b\b\b\b\b\b\b%8d",j);
   	    j+=0x10000;
	}
   }
#endif
    time=timer_stopex();
    uart_printf("\b\b\b\b\b\b\b\b%8d",downloadFileSize);	
    uart_printf("(%5.1fKB/S,%3.1fS)\n",(float)(downloadFileSize/time/1000.),time);
    
#if USBDMA    
    /*******************************/
    /*     Verify check sum        */
    /*******************************/

    uart_printf("Now, Checksum calculation\n");

    cs=0;    
    i=(downloadAddress);
    j=(downloadAddress+downloadFileSize-10)&0xfffffffc;
    while(i<j)
    {
    	temp=*((UINT32T *)i);
    	i+=4;
    	cs+=(UINT16T)(temp&0xff);
    	cs+=(UINT16T)((temp&0xff00)>>8);
    	cs+=(UINT16T)((temp&0xff0000)>>16);
    	cs+=(UINT16T)((temp&0xff000000)>>24);
	}

    i=(downloadAddress+downloadFileSize-10)&0xfffffffc;
    j=(downloadAddress+downloadFileSize-10);
    while(i<j)
	{
		cs+=*((UINT8T *)i++);
	}
    
    checkSum=cs;
#else
    //checkSum was calculated including dnCS. So, dnCS should be subtracted.
    checkSum=checkSum - *((unsigned char *)(downloadAddress+downloadFileSize-8-2))
	     - *( (unsigned char *)(downloadAddress+downloadFileSize-8-1) );	
#endif	  

    dnCS=*((unsigned char *)(downloadAddress+downloadFileSize-8-2))+
	(*( (unsigned char *)(downloadAddress+downloadFileSize-8-1) )<<8);

	if(downloadFileSize<1024*4)
	for (i=0;i<downloadFileSize;i++)
		uart_printf("%c",*(unsigned char *)(downloadAddress+i));
	
    if(checkSum!=dnCS)
    {
		uart_printf(" Checksum Error!!! MEM:%x DN:%x\n",checkSum,dnCS);
		return;
	}

    uart_printf("\n Download O.K.\n\n");
    uart_txempty(consoleNum);
	
    if(download_run==1)
	{
        rINTMSK = BIT_ALLMSK;
    	run=(void (*)(void))downloadAddress;
		run();
	}
}

/*********************************************************************************************
* name:		Isr_Init
* func:		Initialization of Isr
* para:		none
* ret:		none
* modify:
* comment:	
*********************************************************************************************/
void Isr_Init(void)
{
    pISR_UNDEF=(unsigned)debug_undef;
    pISR_SWI  =(unsigned)debug_swi;
    pISR_PABORT=(unsigned)debug_abort_d;
    pISR_DABORT=(unsigned)debug_abort_d;
    rINTMOD=0x0;                                                // All=IRQ mode
    rSRCPND    = rSRCPND;                 // clear all interrupt
    rINTPND    = rINTPND;                 // clear all interrupt
    rINTMSK    = BIT_ALLMSK;              // All interrupt is masked.
    rINTSUBMSK = BIT_SUB_ALLMSK;          // All sub-interrupt is masked.

    //pISR_URXD0=(unsigned)Uart0_RxInt;	
    //rINTMSK=~(BIT_URXD0);   //enable UART0 RX Default value=0xffffffff

#if 1
    pISR_USBD =(unsigned)IsrUsbd;
    pISR_DMA2 =(unsigned)IsrDma2;
#else
    pISR_IRQ =(unsigned)IsrUsbd;	
    	//Why doesn't it receive the big file if use this. (???)
    	//It always stops when 327680 bytes are received.
#endif    
    ClearPending(BIT_DMA2);
    ClearPending(BIT_USBD);
    //rINTMSK&=~(BIT_USBD);  
   
    //pISR_FIQ,pISR_IRQ must be initialized
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产禁国产网站cc| 天堂精品中文字幕在线| 国产清纯白嫩初高生在线观看91 | 日韩制服丝袜先锋影音| 一区二区三区鲁丝不卡| 亚洲精品亚洲人成人网 | 国产自产2019最新不卡| 久久福利视频一区二区| 久久av资源网| 国内精品嫩模私拍在线| 韩国精品主播一区二区在线观看| 免费看日韩精品| 日本欧美在线观看| 蜜乳av一区二区| 精品亚洲国产成人av制服丝袜| 久久不见久久见免费视频7| 久久激情五月婷婷| 国产一区二区在线观看视频| 麻豆国产91在线播放| 极品美女销魂一区二区三区| 国产九色sp调教91| 成人高清视频免费观看| 91视频免费播放| 欧美少妇xxx| 欧美一级艳片视频免费观看| 精品日韩在线一区| 国产欧美日韩在线看| 国产精品国产三级国产aⅴ无密码| 亚洲欧洲成人自拍| 亚洲国产精品久久人人爱蜜臀| 亚洲成人福利片| 美国十次了思思久久精品导航| 国产伦精品一区二区三区视频青涩 | 午夜久久久久久电影| 蜜桃一区二区三区四区| 国产一区二区免费看| av福利精品导航| 欧美色电影在线| 精品av综合导航| 亚洲天堂久久久久久久| 午夜精品久久久久影视| 国产在线日韩欧美| 91网站在线播放| 制服丝袜激情欧洲亚洲| 国产欧美一区二区精品婷婷| 亚洲一区成人在线| 极品少妇xxxx精品少妇| 91免费观看在线| 日韩欧美一级在线播放| 国产精品毛片久久久久久久| 午夜久久久久久| 风间由美中文字幕在线看视频国产欧美 | 成人激情黄色小说| 欧美伦理电影网| 欧美高清在线视频| 亚洲18色成人| 国产精品综合在线视频| 91激情五月电影| 久久亚洲综合av| 亚洲福中文字幕伊人影院| 国产精品自拍在线| 欧美日精品一区视频| 亚洲国产精品成人综合色在线婷婷| 亚洲国产精品一区二区久久| 国产99久久久国产精品免费看| 欧美人牲a欧美精品| 国产精品免费视频一区| 美女爽到高潮91| 在线观看视频一区二区欧美日韩| 久久精品人人做人人综合| 亚洲电影激情视频网站| 不卡大黄网站免费看| 精品久久久久久久久久久院品网| 亚洲专区一二三| 成人综合在线视频| 精品对白一区国产伦| 亚洲国产日韩精品| 91香蕉视频在线| 国产欧美综合在线观看第十页| 免费成人在线播放| 欧美日韩综合在线免费观看| 亚洲丝袜精品丝袜在线| 丁香桃色午夜亚洲一区二区三区| 日韩欧美色电影| 婷婷一区二区三区| 欧美天堂一区二区三区| 中文字幕一区二区三区不卡在线| 国产精品综合在线视频| 欧美va亚洲va| 麻豆国产精品777777在线| 欧美挠脚心视频网站| 亚洲综合在线视频| 一道本成人在线| 国产精品久久久久久久久久久免费看 | 欧美精品tushy高清| 亚洲午夜三级在线| 日本精品一级二级| 亚洲欧美一区二区三区久本道91 | 欧美精品日韩一本| 亚洲二区在线视频| 欧美性三三影院| 一区二区三区在线观看欧美| 91老师国产黑色丝袜在线| 中文字幕一区二区三| 波多野洁衣一区| 国产精品福利一区| 91日韩一区二区三区| 亚洲免费在线视频| 欧美在线观看18| 亚洲成av人片观看| 欧美一区二区三区爱爱| 免费成人在线播放| 精品裸体舞一区二区三区| 激情综合色综合久久| 精品国产一区a| 国产精华液一区二区三区| 久久精品一区二区| 99在线视频精品| 一区二区三区免费在线观看| 欧美亚洲一区二区在线观看| 亚州成人在线电影| 欧美一区二区三区影视| 极品少妇xxxx精品少妇偷拍| 久久久精品2019中文字幕之3| 粉嫩久久99精品久久久久久夜| 国产精品久久久久精k8| 91蜜桃免费观看视频| 亚洲国产aⅴ天堂久久| 91精品久久久久久蜜臀| 国产在线国偷精品产拍免费yy| 国产欧美一区二区三区在线看蜜臀 | 成人午夜av在线| 亚洲视频 欧洲视频| 在线一区二区三区四区五区| 视频一区欧美精品| 久久这里都是精品| 91小视频免费看| 免费在线看成人av| 亚洲国产精品二十页| 91传媒视频在线播放| 男女视频一区二区| 国产精品免费丝袜| 欧美久久久久免费| 国产福利91精品一区| 亚洲精品菠萝久久久久久久| 制服丝袜亚洲色图| 成人激情电影免费在线观看| 亚洲一二三四区不卡| 欧美精品一区二区蜜臀亚洲| 99久久婷婷国产综合精品电影 | 亚洲欧洲av一区二区三区久久| 欧美日韩一二区| 国产老女人精品毛片久久| 亚洲乱码中文字幕| 精品国产一区二区三区久久影院| 99久久er热在这里只有精品15| 五月婷婷综合网| 欧美高清在线精品一区| 欧美日产国产精品| 成人免费视频caoporn| 日韩黄色免费网站| 中文字幕五月欧美| 精品久久久久一区二区国产| 色欧美乱欧美15图片| 国产精品原创巨作av| 亚洲成人自拍偷拍| 国产精品电影一区二区三区| 日韩精品一区二区三区在线播放| 色呦呦国产精品| 国产精品主播直播| 日韩一区精品视频| 亚洲精选免费视频| 国产视频亚洲色图| 日韩久久免费av| 欧美日韩美少妇| 91蝌蚪porny| 风间由美一区二区三区在线观看| 日韩va欧美va亚洲va久久| 亚洲欧美一区二区不卡| 久久精品在线免费观看| 日韩一区二区在线播放| 色就色 综合激情| 成人av在线一区二区三区| 久久精品国产77777蜜臀| 午夜精品免费在线| 亚洲精品成人精品456| 亚洲欧美自拍偷拍色图| 久久天天做天天爱综合色| 欧美一区二区免费| 欧美无砖砖区免费| 色综合久久久久综合体| 成人高清免费观看| 国产99久久久精品| 国产麻豆精品95视频| 国产专区欧美精品| 老司机精品视频在线| 日本aⅴ精品一区二区三区| 亚洲国产视频a| 亚洲成人自拍网| 五月激情六月综合|