EasyManua.ls Logo

Cypress EX-USB FX3 - Page 60

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...
60 FX3 Programmers Manual, Doc. # 001-64707 Rev. *C
FX3 Firmware
5.2.1.1 USB Device Mode
The USB device mode handling is described in the following sections.
USB Descriptors
Descriptors must be formed by the application and passed on to the USB driver. Each descriptor
(such as Device, Device Qualifier, String, and Config) must be framed as an array and passed to the
USB driver through an API call.
Endpoint Configuration
When configured as a USB device, the FX3 has 32 endpoints. Endpoint 0 is the control endpoint in
both IN and OUT directions, and the other 30 endpoints are fully configurable. The endpoints are
mapped to USB sockets in the corresponding directions. The mapping is normally one-to-one and
fixed – endpoint 1 is mapped to socket 1 and so on. The only exception is when one or more USB
3.0 bulk endpoints are enabled for bulk streams. In this case, it is possible to map additional sockets
that are not in use to the stream enabled endpoints.
Endpoint descriptors are formed by the application and passed to the USB driver which then
completes the endpoint configuration. An API is provided to pass the configuration to the USB driver,
this API must be invoked for each endpoint.
Enumeration
The next step in the initialization sequence is USB enumeration. After descriptor and endpoint
configuration, the Connect API is issued to the USB driver. This enables the USB PHY and the
pull-up on the D+ pin. This makes the USB device visible to a connected USB host and the
enumeration continues.
Setup Request
By default, the USB driver handles all Setup Request packets that are issued by the host. The appli-
cation can register a callback for setup requests. If a callback is registered:
It is issued for every setup request with the setup data
The application can perform the necessary actions in this callback
The application must return the handling status whether the request was handled or not. This is
required as the application may not want to handle every setup request
If the request is handled in the application, the USB driver does not perform any additional
handling
If the request is not handled, the USB driver performs the default handling
Class/Vendor-specific Setup Request
Setup request packets can be issued for vendor commands or class specific requests such as MSC.
The application must register for the setup callback (described earlier) to handle these setup request
packets.
When a vendor command (or a class specific request) is received, the USB driver issues the call-
back with the setup data received in the setup request. The user application needs to perform the
requisite handling and return from the callback with the correct (command handled) status.
Events
All USB events are handled by the USB driver. These include Connect, Disconnect, Suspend,
Resume, Reset, Set Configuration, Speed Change, Clear Feature, and Setup Packet.
The user application can register for specific USB events. Callbacks are issued to the user
application with the event type specified in the callback.

Table of Contents