When operating Bulk-IN and Control-IN transfers in FX3™ simultaneously at USB 2.0 speed, Bulk-IN transfers are found to corrupt control endpoint data, causing errors in the control pipe. How do you avoid this?
To avoid this issue, ensure that the DMA channel corresponding to the Bulk-IN endpoint is suspended for the duration of the control request and resume it once the control request is completed. Follow the instructions below to do this.
- When configuring the DMA channel, enable callback with callback notification = CY_U3P_DMA_CB_CONS_SUSP. This will generate a callback whenever the channel is successfully suspended.
- In the setup callback function, where all the control standard/vendor requests are handled, check if the device has enumerated in 2.0 mode using the CyU3PUsbGetSpeed() API.
- If CyU3PUsbGetSpeed() returns CY_U3P_HIGH_SPEED, suspend the Bulk pipe and wait until it suspends. Use the CyU3PDmaChannelSetSuspend() API to suspend the channel. Note that this API returns immediately and the channel suspension is confirmed when the DMA channel callback function (enabled in step 1) is invoked.
- After the channel is successfully suspended, you can send the control endpoint data to the host using the CyU3PUsbSendEP0Data() API.
- After the control endpoint data is sent to the host, wait for the transaction stage of the control transfer to complete. The USB event CY_U3P_USB_EVENT_EP0_STAT_CPLT signifies that this has occurred and the event has been handled in the USB event callback function.
- Once the control transfer is successfully completed, the DMA channel for the Bulk-IN endpoint has to be taken out of the suspended state (CyU3PDmaChannelSetSuspend) and resumed (CyU3PDmaChannelResume) again as shown below.
CyU3PDmaChannelSetSuspend (&DMA_channel_handle, CY_U3P_DMA_SCK_SUSP_NONE, CY_U3P_DMA_SCK_SUSP_NONE);
CyU3PDmaChannelResume( &DMA_channel_handle, CyFalse, CyTrue);
Note: The above steps are illustrated in the GpifToUsb example project in the FX3 SDK.
You can find this project at
“<install_path>\EZ-USB FX3 SDK\1.3\firmware\basic_examples\cyfxgpiftousb”.