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

📄 2460mon_otg.cpp

📁 三星 S3C2460 USB OTG监控代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				not_suspend = TRUE;
				not_resume = TRUE;   
				
				sus_res_print = FALSE;	
			
				apOTG_TLI_DEV_G->devIntrMask &= ~OTG_DEV_SUSPEND_INTR;	//enable suspend interrupt
	    		
				break;	
				
		  #if (WHICH_PORT==1)	//only 496pkg supports this	
	        case '8':
	            downloadAddress=_NONCACHE_STARTADDRESS;
	            bank_of_nor = 0x0;	//bank0
	            saved_SROM_BW = rSROM_BW;
	            rSROM_BW = rSROM_BW & ~(0x7<<0) | (0x1<<0);
	            
			    printf("\n[Check AM29LVxxx]\n");
			    switch(AM29F800_CheckId())  //04.01.12 junon
			    {
					case 1 :
					    printf("This device is AM29LV200B!\n");	
					    break;
					case 2 :
					    printf("This device is AM29LV400B!\n");	
					    break;
					case 3 :
					    printf("This device is AM29LV800B!\n");	
					    break;
					case 4 :
					    printf("This device is AM29LV160B!\n");	
					    break;
			    	default:
			    		rSROM_BW = saved_SROM_BW;
			    		bank_of_nor = 0x05000000;	//bank2
	            		rSROM_BW = rSROM_BW & ~(0x7<<3) | (0x1<<3);
	            		switch(AM29F800_CheckId())
	            		{
							case 1 :
							    printf("This device is AM29LV200B!\n");	
							    break;
							case 2 :
							    printf("This device is AM29LV400B!\n");	
							    break;
							case 3 :
							    printf("This device is AM29LV800B!\n");	
							    break;
							case 4 :
							    printf("This device is AM29LV160B!\n");	
							    break;
					    	default:  
					    		printf("ID Check Error!!!\n");
					    		return;          		
	            		}
	            		break;
			    }            
	            
	            ProgramAM29F800();
	            printf("\nProgram AMD NOR Flash Ends.\n");
			    rINTMSK&=~(BIT_USB);  
	   			rINTSUBMSK&=~(BIT_SUB_USBD);
	            break;
		  #endif
	  			
			case '9':
				ISP1301_IIC_FullRead();
				break;
				
			default:
				break;
		}	
  	}	  
}

void WaitDownload(void)
{
	unsigned int i;
	unsigned int j;
	unsigned short cs;
	unsigned int temp;
	unsigned short dnCS;
	float time;
	unsigned char tempMem[16];
	unsigned char key;

	checkSum=0;
	downloadAddress=(unsigned int)tempMem; //_RAM_STARTADDRESS; 
	downPt=(unsigned char *)downloadAddress;
	//This address is used for receiving first 8 byte.
	downloadFileSize=0;

#if 0
	MMU_DisableICache(); 
	    //For multi-ICE. 
	    //If ICache is not turned-off, debugging is started with ICache-on.
#endif

	/*******************************/
	/*    Test program download    */
	/*******************************/
	j=0;

	UsbOtgDevMain(); 
	ConfigEp3IntMode();
  #if USBOTG_DMA
	totalRxCountInDMA = 0;
  #endif

	if(isUsbOtgSetConfiguration==0)
	{
		printf("USB OTG is not connected yet with DNW.\n");	
		
	}
    
    while(downloadFileSize==0)
    {
		if(first==1 && isUsbOtgSetConfiguration!=0)
        {
            printf("USB OTG is connected with DNW. Waiting a download.\n");
			
		    //->
		    //khs.050117
		    //	added for debug
		   #ifdef KHS_USBD_DEBUG
		   	if(first == 1)
		   	{
			    printf("\nIf you want to check USB OTG enumeration sequence, press 'y/Y' key\n");
			    printf(" Otherwise, press any key except 'y/Y'\n");
			    while(!(temp = Uart_GetKey()));
			    if((temp=='y') || (temp=='Y'))
			    {
			    	extern Usbd_Ep0_Data_s Usbd_Ep0_Data[100];
					extern unsigned char count_Ep0_Data; 
					int i;
					if(count_Ep0_Data != 0)
					{
						for(i=0;i<count_Ep0_Data;i++)
						{
							if(Usbd_Ep0_Data[i].direction==0)
							{
								printf("\n\n[RX at state:%2d : ",Usbd_Ep0_Data[i].state);
							}else
							{
								printf("\n [TX at state:%2d : ",Usbd_Ep0_Data[i].state);
							}
							for(j=0;j<Usbd_Ep0_Data[i].cnt;j++)
								printf("0x%02x ",Usbd_Ep0_Data[i].data[j]);
						}
						count_Ep0_Data=0;
					}
			    	printf("\n\n");
			    }
	   			printf("\nAnd then, If you want to see menu, Press any key. \n");
	   		}
		   #endif
		    //<-  	
		    
	     	first=0;
        }
       
		if(j%0x100000==0)Led_Display(0x6);
		if(j%0x100000==0x80000)Led_Display(0x9);
		j++;

		key=Uart_GetKey();

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

    Timer_InitEx();      
    Timer_StartEx();   

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

#if USBOTG_DMA    
    j=0x10000;

    while(1)
    {
    	if(totalRxCountInDMA>=j)
		{
	    	printf("\b\b\b\b\b\b\b\b%8d",j);
   	    	j+=0x10000;
		}
		if(totalRxCountInDMA>=downloadFileSize)
		{
			break;
		}
    }

#else

    j=0x10000;


    while(((unsigned int)downPt-downloadAddress)<(downloadFileSize-8))
    {
		if( ((unsigned int)downPt-downloadAddress)>=j)
		{
		    printf("\b\b\b\b\b\b\b\b%8d",j);
	   	    j+=0x10000;
		}
    }
#endif    

    time=Timer_StopEx();
    
    printf("\b\b\b\b\b\b\b\b%8d",downloadFileSize);	
    printf("(%5.1fKB/S,%3.1fS)\n",(float)(downloadFileSize/time/1024.),time);
    
    /*******************************/
    /*     Verify check sum        */
    /*******************************/

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

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

    i=(downloadAddress+downloadFileSize-10)&0xfffffffc;
    j=(downloadAddress+downloadFileSize-10);
    while(i<j)
    {
  		cs+=*((unsigned char *)i++);
    }
    
    checkSum=cs;

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

	printf("\nChecksum Value => MEM:%x DN:%x\n\n",checkSum,dnCS);
    
    if(checkSum!=dnCS)
    {
		printf("Checksum Error!!!");
		//return;
    }
    else
    {
	    printf("Download O.K.\n\n");
	}


    if(download_run==1)
    {
        rINTMSK=BIT_ALLMSK;
    	run=(void (*)(void))downloadAddress;
   
	  #if (ONLY_ICACHE_ENABLED == TRUE)
    	MMU_DisableICache();
      
      #else    
	    MMU_DisableDCache();
	    MMU_DisableICache();
	    for(i=0;i<4;i++)
	    	for(j=0;j<128;j++)
	    	    MMU_CleanInvalidateDCacheSET((i<<30)|(j<<5));
	    MMU_InvalidateICache();
	    
	    MMU_DisableMMU();
	    MMU_InvalidateTLB();
	  #endif
	  
		Delay(0);
		run();
    }
}


void Isr_Init(void)
{
    pISR_UNDEF=(unsigned)HaltUndef;
    pISR_SWI  =(unsigned)HaltSwi;
    pISR_PABORT=(unsigned)HaltPabort;
    pISR_DABORT=(unsigned)HaltDabort;
	pISR_IRQ	=	(unsigned)IsrIRQ;

    rINTMOD=0x0;	  // All=IRQ mode
    rINTMSK=BIT_ALLMSK;	  // All interrupt is masked.
    rINTSUBMSK=BIT_ALLMSK;
    rINTSUBMSK2=BIT_ALLMSK;

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

#if 1
    pISR_USB =(unsigned)IsrUsbOtgDev;
   #if USBOTG_DMA
    pISR_DMA_SBUS =(unsigned)IsrOtgDma2;
   #endif
#else
    pISR_IRQ =(unsigned)IsrUsbOtgDev;
    	//Why doesn't it receive the big file if use this. (???)
    	//It always stops when 327680 bytes are received.
#endif    
    ClearPending(BIT_DMA_SBUS);
    ClearPending(BIT_USB);
    rSUBSRCPND=BIT_SUB_USBD;
    rSUBSRCPND=BIT_SUB_OTG;
    rSUBSRCPND=BIT_SUB_DMA2;

	//External interrupt will be falling edge triggered.
	rEINTCON0	= 0x22222222;			//EINT2~0
	rEINTCON1 	= 0x22222222;		//EINT10~3

    CLR_IF();
    
    //pISR_FIQ,pISR_IRQ must be initialized
}




⌨️ 快捷键说明

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