Wednesday, April 9, 2014

Discovery: CyU3PUsbGetEP0Data and CyU3PUsbSendEP0Data Mystery??

How the Vendor/Class Request is handled in the FX3 ? 
The API CyU3PUsbRegisterSetupCallback() will register a callback function which will handle vendor/class/standard requests. If the fastEnum bit in the function parameter is set then the device hardware itself handles the standard request, we only need to handle the class/vendor requests.
The registered setup callback function will be executed whenever a control request is received. Two 4 byte callback function parameters will specify the 8 byte setup packet. Handling of each setup request involve one and only one of the following API calls.
1. CyU3PUsbSendEP0Data, [Called to perform any IN-data phase associated with the request]
2. CyU3PUsbGetEP0Data,  [Called to perform any OUT-data phase associated with the request]
3. CyU3PUsbAckSetup,[Called to complete the status handshake (ACK) phase of a request that does not involve any data transfer]
4. CyU3PUsbStall,[Called to stall EP0 to fail the setup request]
If the setup callback function successfully handled the request then the user should return CyTrue, or else the user should return CyFalse.
Flowcharts and code examples are also attached for the following,
1. Stalling Vendor / Class request.
2. Handling Vendor / Class request with Data Phase.
3. Handling Vendor / Class request without Data Phase.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.