To safely add a dTD, the DCD must
be follow this procedure which will handle the event where the device controller reaches
the end of the dTD list at the same time a new dTD is being added to the end of the
list.
Determine whether the link list is empty: Check to see if pipe is empty (internal software representation of linked-list should indicate if any packets are outstanding).
Case 1: Link list is
empty
- Write dQH next pointer and the dQH terminate bit to 0 as a single DWord operation.
- Clear active and halt bit in dQH (in case set from a previous error).
- Prime endpoint by writing 1 to correct bit position in usb.ENDPTPRIME.
Case 2: Link list is not empty
- Add dTD to end of linked list.
- Read correct prime bit in usb.ENDPTPRIME - if 1 DONE.
- Set the usb.USBCMD [ATDTW] bit = 1 .
- Read correct status bit in usb.ENDPTSTAT. (store in tmp. variable for later)
- Read usb.USBCMD [ATDTW] bit.
- If 0 go to step 3.
- If 1 continue to step 6.
- Write usb.USBCMD [ATDTW] bit = 0.
- If status bit read in (4) is 1 DONE.
- If status bit read in (4) is 0 then Go to Case 1: step 1.