Ejemplo n.º 1
0
void ClearEp3OutPktReady(void)
{
    U8 out_csr3;
    rINDEX_REG=3;
    out_csr3=rOUT_CSR1_REG;
    CLR_EP3_OUT_PKT_READY();
}
Ejemplo n.º 2
0
void ClearEp3OutPktReady(void)
{
    U8 out_csr3;
    usbdevregs->INDEX_REG=3;
    out_csr3=usbdevregs->OUT_CSR1_REG;
    CLR_EP3_OUT_PKT_READY();
}
Ejemplo n.º 3
0
void ClearEp3OutPktReady(void)
{
	struct s3c24x0_usb_device * const usbdevregs = s3c24x0_get_base_usb_device();
    U8 out_csr3;
    usbdevregs->INDEX_REG = 3;
    out_csr3 = usbdevregs->OUT_CSR1_REG;
    CLR_EP3_OUT_PKT_READY();
}
Ejemplo n.º 4
0
void Ep3Handler(void)
{
	struct s3c24x0_interrupt *intregs = s3c24x0_get_base_interrupt();
	struct s3c24x0_usb_device *const usbdevregs	= s3c24x0_get_base_usb_device();
    U8 out_csr3;
    int fifoCnt;

    usbdevregs->INDEX_REG = 3;
    out_csr3 = usbdevregs->OUT_CSR1_REG;
    
    DbgPrintf("<3:%x]",out_csr3);

    if(out_csr3 & EPO_OUT_PKT_READY) {   
        fifoCnt = usbdevregs->OUT_FIFO_CNT1_REG; 

        if (downloadFileSize == 0) {
            RdPktEp3((U8 *)downPt, 8); 	

            if(download_run == 0) {
                downloadAddress = tempDownloadAddress;
            } else {
                downloadAddress = *((U32 *)downPt);
                dwUSBBufReadPtr = downloadAddress;
                dwUSBBufWritePtr = downloadAddress;
            }
            downloadFileSize = *((U32 *)(downPt + 4));
            DbgPrintf("[dwaddr = %x, dwsize = %x]\n", 
                    downloadAddress, downloadFileSize);

            checkSum = 0;
            downPt = (U8 *)downloadAddress;
            /* The first 8-bytes are deleted. */
            RdPktEp3_CheckSum((U8 *)downPt, fifoCnt-8); 	    
            downPt += fifoCnt - 8;  
  	    
#if USBDMA
            /*
             * 传输由中断发起(只接收头一个Pkg),由DMA完成.
             * 因此发生中断后就禁止USBD中断,在DMA传输完成
             * 后再次开启.
             */
     	    intregs->INTMSK |= BIT_USBD;   
      	    return;	
#endif	
        } else {
            RdPktEp3_CheckSum((U8 *)downPt, fifoCnt); 	    
            downPt += fifoCnt;     //fifoCnt = 64
        }
        CLR_EP3_OUT_PKT_READY();
        return;
    }
    
    if (out_csr3 & EPO_SENT_STALL) {   
        DbgPrintf("[STALL]");
        CLR_EP3_SENT_STALL();
        return;
    }	
}
Ejemplo n.º 5
0
void IsrDma2(void)
{
    U8 out_csr3;
    U32 dwEmptyCnt;
    U8 saveIndexReg=usbdevregs->INDEX_REG;
    usbdevregs->INDEX_REG=3;
    out_csr3=usbdevregs->OUT_CSR1_REG;

    ClearPending_my(BIT_DMA2);	    

    /* thisway.diy, 2006.06.22 
     * When the first DMA interrupt happened, it has received max (0x80000 + EP3_PKT_SIZE) bytes data from PC
     */
    if (!totalDmaCount) 
        totalDmaCount = dwWillDMACnt + EP3_PKT_SIZE;
    else
        totalDmaCount+=dwWillDMACnt;

//    dwUSBBufWritePtr = ((dwUSBBufWritePtr + dwWillDMACnt - USB_BUF_BASE) % USB_BUF_SIZE) + USB_BUF_BASE; /* thisway.diy, 2006.06.21 */
    dwUSBBufWritePtr = ((dwUSBBufWritePtr + dwWillDMACnt - dwUSBBufBase) % dwUSBBufSize) + dwUSBBufBase;

    if(totalDmaCount>=downloadFileSize)// is last?
    {
    	totalDmaCount=downloadFileSize;
	
    	ConfigEp3IntMode();	

    	if(out_csr3& EPO_OUT_PKT_READY)
    	{
       	    CLR_EP3_OUT_PKT_READY();
	    }
        intregs->INTMSK|=BIT_DMA2;  
        intregs->INTMSK&=~(BIT_USBD);  
    }
    else
    {
    	if((totalDmaCount+0x80000)<downloadFileSize)	
    	{
    	    dwWillDMACnt = 0x80000;
	    }
    	else
    	{
    	    dwWillDMACnt = downloadFileSize - totalDmaCount;
    	}

        // dwEmptyCnt = (dwUSBBufReadPtr - dwUSBBufWritePtr - 1 + USB_BUF_SIZE) % USB_BUF_SIZE; /* thisway.diy, 2006.06.21 */
        dwEmptyCnt = (dwUSBBufReadPtr - dwUSBBufWritePtr - 1 + dwUSBBufSize) % dwUSBBufSize;
        if (dwEmptyCnt >= dwWillDMACnt)
        {
    	    ConfigEp3DmaMode(dwUSBBufWritePtr, dwWillDMACnt);
        }
        else
        {
            bDMAPending = 1;
        }
    }
    usbdevregs->INDEX_REG = saveIndexReg;
}
Ejemplo n.º 6
0
void IsrDma2()
{
	struct s3c24x0_interrupt *intregs = s3c24x0_get_base_interrupt();
	struct s3c24x0_usb_device *usbdevregs = s3c24x0_get_base_usb_device();
    U8 out_csr3;
    U32 dwEmptyCnt;
    U8 saveIndexReg = usbdevregs->INDEX_REG;
    usbdevregs->INDEX_REG = 3;
    out_csr3 = usbdevregs->OUT_CSR1_REG;

    ClearPending_my((int)BIT_DMA2);	    

    if (!totalDmaCount) 
        totalDmaCount = dwWillDMACnt + EP3_PKT_SIZE;
    else
        totalDmaCount += dwWillDMACnt;

    dwUSBBufWritePtr = ((dwUSBBufWritePtr + dwWillDMACnt - dwUSBBufBase) % 
                        dwUSBBufSize) + dwUSBBufBase;

    if (totalDmaCount >= downloadFileSize) {    /* last */
    	totalDmaCount = downloadFileSize;
	
    	ConfigEp3IntMode();	

    	if (out_csr3 & EPO_OUT_PKT_READY) 
       	    CLR_EP3_OUT_PKT_READY();
	    /* 关闭DMA2中断并重新开启USBD中断 */ 
        intregs->INTMSK |= BIT_DMA2;    
        intregs->INTMSK &= ~(BIT_USBD);  
    } else {
    	if ((totalDmaCount + 0x80000) < downloadFileSize) 
    	    dwWillDMACnt = 0x80000;
    	else
    	    dwWillDMACnt = downloadFileSize - totalDmaCount;

        dwEmptyCnt = (dwUSBBufReadPtr - dwUSBBufWritePtr - 1 + dwUSBBufSize) % 
                     dwUSBBufSize;

        if (dwEmptyCnt >= dwWillDMACnt)
    	    ConfigEp3DmaMode(dwUSBBufWritePtr, dwWillDMACnt);
    }
    usbdevregs->INDEX_REG = saveIndexReg;
}
Ejemplo n.º 7
0
void Ep3Handler(void)
{
    U8 out_csr3;
    int fifoCnt;
    rINDEX_REG=3;

    out_csr3=rOUT_CSR1_REG;
    
    DbgPrintf("<3:%x]",out_csr3);

    if(out_csr3 & EPO_OUT_PKT_READY)
    {   
	fifoCnt=rOUT_FIFO_CNT1_REG; 
#if 0
	RdPktEp3(ep3Buf,fifoCnt);
	PrintEpoPkt(ep3Buf,fifoCnt);
#else

	if(downloadFileSize==0)
	{
   	    RdPktEp3((U8 *)downPt,8); 	
   	    
   	    if(download_run==0)
   	    {
		downloadAddress=tempDownloadAddress;
	    }
	    else
	    {
	    	downloadAddress=
	    		*((U8 *)(downPt+0))+
			(*((U8 *)(downPt+1))<<8)+
			(*((U8 *)(downPt+2))<<16)+
			(*((U8 *)(downPt+3))<<24);
	    }
	    downloadFileSize=
	    	*((U8 *)(downPt+4))+
		(*((U8 *)(downPt+5))<<8)+
		(*((U8 *)(downPt+6))<<16)+
		(*((U8 *)(downPt+7))<<24);
	    checkSum=0;
	    downPt=(U8 *)downloadAddress;

  	    RdPktEp3_CheckSum((U8 *)downPt,fifoCnt-8); //The first 8-bytes are deleted.	    
  	    downPt+=fifoCnt-8;  
  	    
  	#if USBDMA
     	    //CLR_EP3_OUT_PKT_READY() is not executed. 
     	    //So, USBD may generate NAK until DMA2 is configured for USB_EP3;
     	    rINTMSK|=BIT_USBD; //for debug
      	    return;	
  	#endif	
	}
	else
	{
	#if USBDMA    	
	    Uart_Printf("<ERROR>");
	#endif    
	    RdPktEp3_CheckSum((U8 *)downPt,fifoCnt); 	    
	    downPt+=fifoCnt;  //fifoCnt=64
	}
#endif
   	CLR_EP3_OUT_PKT_READY();

       if(((rOUT_CSR1_REG&0x1)==1) && ((rEP_INT_REG & 0x8)==0))
  		{
  		fifoCnt=rOUT_FIFO_CNT1_REG; 
		RdPktEp3_CheckSum((U8 *)downPt,fifoCnt); 	    
	       downPt+=fifoCnt;  //fifoCnt=64
	       CLR_EP3_OUT_PKT_READY();
		}
  	return;
    }

    
    //I think that EPO_SENT_STALL will not be set to 1.
    if(out_csr3 & EPO_SENT_STALL)
    {   
   	DbgPrintf("[STALL]");
   	CLR_EP3_SENT_STALL();
   	return;
    }	
}
Ejemplo n.º 8
0
void __irq IsrDma2(void)
{
    U8 out_csr3;
    U32 nextTotalDmaCount;
    U8 saveIndexReg=rINDEX_REG;

    
    rINDEX_REG=3;
    out_csr3=rOUT_CSR1_REG;
    
    ClearPending(BIT_DMA2);	    
    
    totalDmaCount+=0x80000;

    if(totalDmaCount>=downloadFileSize)// is last?
    {
       totalDmaCount=downloadFileSize;
	
    	ConfigEp3IntMode();	

    	if(out_csr3& EPO_OUT_PKT_READY)
    	{
   	    CLR_EP3_OUT_PKT_READY();
	}
        rINTMSK|=BIT_DMA2;  
        rINTMSK&=~(BIT_USBD); 
	
    }
    else
    {
    	if((totalDmaCount+0x80000)<downloadFileSize)	
    	{
	    nextTotalDmaCount=totalDmaCount+0x80000;
    
    	    if((nextTotalDmaCount+0x80000)<downloadFileSize)
    	    {
    	       
        	//for (2~n)th autoreload.	 
		rDIDST2=((U32)downloadAddress+nextTotalDmaCount-8);  
		rDIDSTC2=(1<<2)|(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;
    	    	    //0xfffff;
    	    	}
    	    }
 	    else
 	    {
 	        
   	        rDIDST2=((U32)downloadAddress+nextTotalDmaCount-8);  
      	        rDIDSTC2=(0<<1)|(0<<0);  
      	        rDCON2=rDCON2&~(0xfffff)|(downloadFileSize-nextTotalDmaCount); 
		
    	    	while(rEP3_DMA_TTC<0xfffff)
    	    	{
    	    	    rEP3_DMA_TTC_L=0xff;
    	    	    rEP3_DMA_TTC_M=0xff;
    	    	    rEP3_DMA_TTC_H=0xf;
    	    	    //0xfffff;
    	    	}
	    }
	}
	else
	{
	      
  	//    rDIDST2=((U32)downloadAddress+downloadFileSize-8);  //for next autoreload.	    		
  	    rDIDSTC2=(0<<1)|(0<<0);  // reload is occurred when Curr_TC is 0
  	//    rDCON2=rDCON2&~(0xfffff)|(0); 		
		//There is no 2nd autoreload. This will not be used.  	    
	    	//rDMA_TX+=0x0; //USBD register		
	}
    }
    rINDEX_REG=saveIndexReg;
}