Beispiel #1
0
void USB_EndPoint3 (uint32_t event) {
#if USB_DMA
  USB_DMA_DESCRIPTOR DD;

  if (event & USB_EVT_OUT_DMA_EOT) {
    /* End of Transfer */
    if (USB_DMA_BufAdr(0x03) != ((uint32_t)DataBuf + 2*DataIn)) {
      /* Data Available */
      DataIn += P_C*P_S;                    /* Update Data In Index */
      DataIn &= B_S - 1;                    /* Adjust Data In Index */
      if (((DataIn - DataOut) & (B_S - 1)) == (B_S/2)) {
        DataRun = 1;                        /* Data Stream running */
      }
    } else {
      /* No Data */
      DataRun = 0;                          /* Data Stream not running */
      DataOut = DataIn;                     /* Initialize Data Indexes */
    }
  }
  if (event & (USB_EVT_OUT_DMA_EOT) | (USB_EVT_OUT_DMA_NDR)) {
    /* End of Transfer or New Descriptor Request */
    DD.BufAdr  = (uint32_t)DataBuf + 2*DataIn; /* DMA Buffer Address */
    DD.BufLen  = P_C;                       /* DMA Packet Count */
    DD.MaxSize = 0;                         /* Must be 0 for Iso Transfer */
    DD.InfoAdr = (uint32_t)InfoBuf;            /* Packet Info Buffer Address */
    DD.Cfg.Val = 0;                         /* Initial DMA Configuration */
    DD.Cfg.Type.IsoEP = 1;                  /* Iso Endpoint */
    USB_DMA_Setup (0x03, &DD);              /* Setup DMA */
    USB_DMA_Enable(0x03);                   /* Enable DMA */
  }
#else
  event = event;
#endif
}
Beispiel #2
0
void USB_EndPoint2 (uint32_t event) {
#if USB_DMA
  USB_DMA_DESCRIPTOR DD;
#endif

  switch (event) {
    case USB_EVT_OUT:
      MSC_BulkOut();
      break;
    case USB_EVT_IN:
      MSC_BulkIn();
      break;

#if USB_DMA
    case USB_EVT_OUT_DMA_EOT: 
      MSC_BulkOut();

//      USB_DMA_Enable(MSC_EP_OUT);   /* 11.08.09  USB_DMA_Enable is not necessary at this point */
      break;

    case USB_EVT_OUT_DMA_NDR:                    // new DMA Descriptor request
      DD.BufAdr  = (uint32_t)BulkBuf;            // DMA Buffer Address
      DD.BufLen  = MSC_MAX_PACKET;               // DMA Buffer Length in bytes
      DD.MaxSize = MSC_MAX_PACKET;               // Maximum packet size
      DD.Cfg.Val = 0;                            // Initial DMA Configuration
      DD.Cfg.Type.IsoEP = 0;                     // Non-Iso Endpoint

      USB_DMA_Setup (MSC_EP_OUT, &DD);           // Setup DMA
      USB_DMA_Enable(MSC_EP_OUT);                // Enable DMA
      break;


    case USB_EVT_IN_DMA_NDR:                     // new DMA Descriptor request
      MSC_BulkIn();
      break;
    case USB_EVT_IN_DMA_EOT:                     // End of Transfer request 
//      MSC_BulkIn();                 /* 11.08.09 MSC_BulkIn must only be called upon a DMA_NDR interrupt */
      break;
#endif
  }
}