Specifications

3
6263A–ATARM–10-Oct-06
Application Note
A pointer to an S_usb instance is needed to use all of the USB API methods. This pointer is
passed as an argument to callbacks so they do not require direct access to it.
The information stored in an S_usb object can be accessed using the following macros:
USB_GetEndpoint: returns a pointer to the specified endpoint
USB_GetSetup: returns a pointer to the last setup request received
USB_GetDriverInterface, USB_GetDriverID, USB_GetDriverPMC: see Section 3.2.2.
This structure should be a constant to save RAM.
3.2.2 S_usb_driver
The S_usb_driver structure defines several parameters which are USB controller-dependent.
This includes:
Address of the USB controller peripheral on the chip
Peripheral ID
ID to activate the 48 MHz clock in the Power Management Controller (PMC)
Pointer to the driver-dependent methods
A default driver is provided for a chip if it has only one USB controller. Simply point to the sDe-
faultDriver variable when declaring your S_usb instance.
There are three methods to access the driver attributes:
USB_GetDriverInterface: returns the address of USB controller peripheral
USB_GetDriverID: returns the peripheral ID of the controller
USB_GetDriverPMC: returns the PMC ID of the driver
Note that these functions take an S_usb (not a S_usb_driver) pointer as an argument. This is to
avoid having to extract the driver pointer from the S_usb object every time a driver attribute must
be accessed.
This structure should be a constant to save RAM.
3.2.3 S_usb_endpoint
Each USB endpoint used by the application must have a corresponding S_usb_endpoint
instance associated with it. The endpoint list is then stored in the S_usb structure (see Section
3.2.1).
Several attributes of an endpoint are stored in this structure, but only the number of FIFO banks
to use can be specified by the user. Other attributes include the endpoint current state, the cur-
rent transfer descriptor, etc.
Two macros, USB_ENDPOINT_SINGLEBANK and USB_ENDPOINT_DUALBANK, are pro-
vided to easily declare endpoints. Please refer to the documentation of the corresponding USB
controller for information about the number of available FIFO banks for each endpoint.
3.2.4 S_usb_callbacks
This structure holds pointers to the various user-defined callbacks (see Section 3.4 on page 8
for a description of the callback API). The USB API uses those pointers to invoke the callbacks
when needed.
They are stored in the following order:
•Init