USB DMA: how many bytes are received?

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

Parents
  • In this example, USB_DMA_DESCRIPTOR structure is a "custom" structure, specific for this coding, just to hold parameters to pass USB_DMA_Setup() routine. It isn't a real DMA descriptor. As of the real one, refer to the User Manual, Table 251. DMA descriptor.

    Yes, I've started from the USBHID example you mentioned.

    Is the " USB_DMA_Setup()" routine using the "real" Hardware-dma and only the structure is a "custom" structure?
    So that I've only looking for the Present_DMA_count field?

    best regards
    Lars

Reply
  • In this example, USB_DMA_DESCRIPTOR structure is a "custom" structure, specific for this coding, just to hold parameters to pass USB_DMA_Setup() routine. It isn't a real DMA descriptor. As of the real one, refer to the User Manual, Table 251. DMA descriptor.

    Yes, I've started from the USBHID example you mentioned.

    Is the " USB_DMA_Setup()" routine using the "real" Hardware-dma and only the structure is a "custom" structure?
    So that I've only looking for the Present_DMA_count field?

    best regards
    Lars

Children
More questions in this forum