EasyManua.ls Logo

Cypress EX-USB FX3 - Page 92

Cypress EX-USB FX3
192 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...
92 FX3 Programmers Manual, Doc. # 001-64707 Rev. *C
FX3 Application Structure
The next step is to register for callbacks. In this example, callbacks are registered for USB Setup
requests and USB Events.
/* The fast enumeration is the easiest way to setup a USB connection,
* where all enumeration phase is handled by the library. Only the
* class / vendor requests need to be handled by the application. */
CyU3PUsbRegisterSetupCallback(CyFxSlFifoApplnUSBSetupCB, CyTrue);
/* Setup the callback to handle the USB events. */
CyU3PUsbRegisterEventCallback(CyFxSlFifoApplnUSBEventCB);
The callback functions and the call back handling are described in later sections.
The USB descriptors are set. This is done by invoking the USB set descriptor call for each
descriptor.
/* Set the USB Enumeration descriptors */
/* Device Descriptor */
apiRetStatus = CyU3PUsbSetDesc(CY_U3P_USB_SET_HS_DEVICE_DESCR, NULL,
(uint8_t *)CyFxUSB20DeviceDscr);
.
.
.
The code snippet above is for setting the Device Descriptor. The other descriptors set in the example
are Device Qualifier, Other Speed, Configuration, BOS (for Super Speed) and String Descriptors.
The USB pins are connected. The FX3 USB device is visible to the host only after this action.
Hence it is important that all setup is completed before the USB pins are connected.
/* Connect the USB Pins */
/* Enable Super Speed operation */
apiRetStatus = CyU3PConnectState(CyTrue, CyTrue);
8.1.2.4 Endpoint Setup
The endpoint is configured on recieving a SET_CONFIGURATION request. Two endpoints 1 IN and
1 OUT are configured as bulk endpoints. The endpoint maxPacketSize is updated based on the
speed.
CyU3PUSBSpeed_t usbSpeed = CyU3PUsbGetSpeed();
/* First identify the usb speed. Once that is identified,
* create a DMA channel and start the transfer on this. */
/* Based on the Bus Speed configure the endpoint packet size */
switch (usbSpeed)
{
case CY_U3P_FULL_SPEED:
size = 64;
break;
case CY_U3P_HIGH_SPEED:
size = 512;

Table of Contents