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