using the BULK transfer, DMA mode Please help us to see, the use of DMA transfer in batch mode to the normal reception can not be delivered, why? void USB_EndPoint2 (DWORD event) {
USB_DMA_DESCRIPTOR DD;
/ / Receive data from the PC can receive data properly if (event & (USB_EVT_OUT_DMA_EOT) | (USB_EVT_OUT_DMA_NDR)) { / * End of Transfer or New Descriptor Request * / DD.BufAdr = (DWORD) DataBuf + 2 * DataIn; / * DMA Buffer Address * / DD.BufLen = B_S; / * DMA Packet Count * / DD.MaxSize = 64; / * Must be 0 for Iso Transfer * / DD.InfoAdr = (DWORD) InfoBuf; / * Packet Info Buffer Address * / DD.Cfg.Val = 0; / * Initial DMA Configuration * / DD.Cfg.Type.IsoEP = 0; / * Iso Endpoint * / USB_DMA_Setup (0x02, & DD); / * Setup DMA * / USB_DMA_Enable (0x02); / * Enable DMA * / } if (event & USB_EVT_OUT_DMA_EOT) { / * End of Transfer * / if (USB_DMA_BufAdr (0x02)! = ((DWORD) DataBuf + 2 * DataIn)) { / * Data Available * / DataIn + = 64; / * Update Data In Index * / DataIn & = B_S - 1; / * Adjust Data In Index * / if (DataIn & (B_S - 1)) == B_S / 2) { DataRun = 1; / * Data Stream running * / } } } //////////////////////////////////// Send data to a PC, can not send data if (DataRun == 1) { if (event & (USB_EVT_IN_DMA_EOT) | (USB_EVT_IN_DMA_NDR)) { DD.BufAdr = (DWORD) DataBuf + 2 * DataOut; / * DMA Buffer Address * / DD.BufLen = B_S; / * DMA Packet Count * / DD.MaxSize = 64; / * Must be 0 for Iso Transfer * / DD.InfoAdr = (DWORD) InfoBuf; / * Packet Info Buffer Address * / DD.Cfg.Val = 1; / * Initial DMA Configuration * / DD.Cfg.Type.IsoEP = 0; / * Iso Endpoint * / USB_DMA_Setup (0x82, & DD); / * Setup DMA * / USB_DMA_Enable (0x82); / * Enable DMA * / } if (event & USB_EVT_IN_DMA_EOT) { DataOut + = 64; / * Update Data In Index * / DataOut & = B_S - 1; / * Adjust Data In Index * / if (DataIn == DataOut) { DataRun = 0; / * Data Stream running * / DataOut = DataIn; / * Initialize Data Indexes * / } } } }
Program is to use keil comes usbaudio code change overnight, and now receives should be normal, but the PC can not receive any data to send, I receive the parts separately to no avail, as such can not receive data: void USB_EndPoint1 (DWORD event) { USB_DMA_DESCRIPTOR DD; DWORD DataLen; BYTE DBuf [0x10]; switch (event) { case USB_EVT_IN: / / control the transmission of input from the PC to send the total length of bytes transferred break; case USB_EVT_OUT: / / control the transmission output from the PC to receive all commands / / USB_ClrStallEP (USB_ENDPOINT_OUT (1)); DataLen = 0; DataLen = USB_ReadEP (USB_ENDPOINT_OUT (1), DBuf); DD.BufAdr = (DWORD) DataBuf; / * DMA Buffer Address * / DD.BufLen = B_S; / * DMA Packet Count * / DD.MaxSize = 64; / * Must be 0 for Iso Transfer * / DD.InfoAdr = (DWORD) InfoBuf; / * Packet Info Buffer Address * / DD.Cfg.Val = 1; / * Initial DMA Configuration * / DD.Cfg.Type.IsoEP = 0; / * Iso Endpoint * / USB_DMA_Setup (0x82, & DD); / * Setup DMA * / USB_DMA_Enable (0x82); / * Enable DMA * / break; } }