EasyManua.ls Logo

Cypress EZ-USB FX3 SDK - Page 28

Cypress EZ-USB FX3 SDK
56 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Cypress EZ-USB® FX3™ SDK Quick Start Guide, Version 1.3.1 28
5.4.2 Handling Control Requests
On receiving a USB control request through the setup callback, the user application
can perform one of four actions:
1. Call CyU3PUsbAckSetup() to complete the status handshake part of a
control request with no data phase.
2. Call CyU3PUsbStall(0, CyTrue, CyFalse) to stall endpoint 0 so as to fail the
control request.
3. Call CyU3PUsbSendEP0Data() to send the data associated with a control
request with an IN data phase.
4. Call CyU3PUsbGetEP0Data() to receive the data associated with a control
request with an OUT data phase.
It is possible to make multiple SendEP0Data/GetEP0Data calls to complete the
data phase of a transfer if the amount of data to be transferred is large. In such a
case, the amount of data transferred using each API call should be an integral
multiple of the maximum packet size for the control endpoint (64 bytes for USB 2.0,
512 bytes for USB 3.0).
Please note that the FX3 device architecture does not allow a control transfer to be
stalled after the data phase has been completed. Therefore, the application should
NOT stall the control endpoint if there is an error in handling a control transfer after
the OUT data has been read using the CyU3PUsbGetEP0Data API.
e.g., Do not stall EP0 if the write to I2C slave fails after receiving data through the
CyU3PUsbGetEP0Data() API call.
5.4.3 Endpoint Configuration
All of the FX3 application examples in the SDK configure the non-control endpoints
while processing the SET_CONFIGURATION request. This allows the application
to determine the USB connection speed, and then configure the endpoint
accordingly.
It is also possible to configure the endpoints and DMA channels ahead of the USB
device enumeration. As long as the endpoint and DMA channels are configured
using the USB 3.0 parameters, they will continue to work fine at hi-speed and full
speed as well.
There is one caveat that applies in this case.
If there is an OUT endpoint that has a maximum packet size of N bytes, and the
DMA channel has been created with a buffer size of M * N bytes (where M is an
integer greater than 1); the data received on the endpoint will be accessible to the
consumer only after the buffer is filled up, or a short packet is received.
e.g., If the maximum packet size is 512 bytes and the DMA buffer size is 1024
bytes; the buffer can be read by the consumer only after the buffer is filled up
(receives two full packets) or if a short packet is received. If only one full packet is