Hi
if studied the keil usb-audio example: and there are two things I didn't understand. Maybe someone of you could give me some hints / explanations to these two code lines
DataIn &= B_S - 1; /* Adjust Data In Index */ if (((DataIn - DataOut) & (B_S - 1)) == (B_S/2)) { DataRun = 1; /* Data Stream running */ }
B_S = 1024 | DataIn shows the received data of the B_S pkt. But what means "adjust datain index? and why is the stream only running if the data pkt count size is B_S/2?
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 }
best regards Jan
View all questions in Keil forum