Hi,
I've written a small programm using usb bulktransfer with dma support for the LPC17xx processor. My starting point was the USB-HID example from Keil.
I'm able to tx pkts to the host device and I also get the notification from the dma if the LPC processor received a usb pkt. So far so good: Do you know if there's an option or register where the dma will let me know how many bytes are received?
#define CDC_DEP_OUT 0x02 void USB_EndPoint2 (unsigned int event) { unsigned int status=0; unsigned int num, nxt; USB_DMA_DESCRIPTOR DD, *pDD; /* End of Transfer */ if(event == USB_EVT_OUT_DMA_EOT) { /* End of Transfer */ if (USB_DMA_BufAdr(CDC_DEP_OUT) != ((unsigned int)DataBuf + DataInBuf)) { /* Data Available */ status = USB_DMA_Status(CDC_DEP_OUT); num = EPAdr(CDC_DEP_OUT); nxt = UDCA[num]; pDD = (USB_DMA_DESCRIPTOR *)nxt; /* update index to the next dma data buffer */ DataBuf += DMA_BUF_SIZEOF; if(DataBuf == DMA_EP_BUF_SIZE) DataBuf = 0; } } }
I thought that the USB_DMA_DESCRIPTOR will contain some additional information about the usb-dma-transfer from the host to my LPC usb device controller. Unfortunatley I couldn't found anything helpful in this struct.
best regards Lars
USB_DMA_Setup() routine fills the "real" DMA descriptor, arranging the fields of the USB_DMA_DESCRIPTOR parameter. Look in this routine closely.
This code places the DMA descriptors on two arrays, DD_NISO_Mem[] for bulk/interrupt (non-iso) and DD_ISO_Mem[] for isochronous. Non-iso array starts from DD_NISO_ADR (0x20080000 + 128). Iso array follows just after non-iso.
Each bit of DDMemMap[0] (non-iso) and DDMemMap[1] (iso) indicates if the member of the array, indexed by the bit position, is in-use or not.
First, USB_DMA_Setup() finds a free member of the array (target DD: DMA Descriptor). And then, this routine fills the target DD with fields of USB_DMA_DESCRIPTOR parameter, arranging each field of USB_DMA_DESCRIPTOR so that it matches to real DD. Unfortunately, this code doesn't define the "real" DMA Descriptor structure.
As your code assumes that USB_DMA_DESCRIPTOR would be the real DD structure, it doesn't work at all.
You'll get the received size using USB_DMA_BufCnt(CDC_DEP_OUT)
Tsuneo