Functions | Variables

Descriptor Items
[Public API]

Items defined by the application which are involved in the enumeration of the device. More...

Functions

int16_t USB_STRING_DESCRIPTOR_FUNC (uint8_t string_number, const void **ptr)
 String Descriptor Function.

Variables

struct device_descriptor USB_DEVICE_DESCRIPTOR
 Device Descriptor.
struct configuration_descriptorUSB_CONFIG_DESCRIPTOR_MAP []
 Configuration Descriptor.

Detailed Description

Items defined by the application which are involved in the enumeration of the device.

The items listed in this section are macro names. An application needs to define these macro names in usb_config.h to whatever actual C names are used in the application for these items (typically in usb_descriptors.c).

It is required that the application define these items in the application's usb_config.h so the USB stack can retrieve the Chapter 9 descriptors to send to the host.

While this sounds complex, it is not. See the example programs and their usb_descriptors.c that come with the USB stack for an example of what is required and how to easily implement it.


Function Documentation

int16_t USB_STRING_DESCRIPTOR_FUNC ( uint8_t  string_number,
const void **  ptr 
)

String Descriptor Function.

The USB stack will call this function to retrieve string descriptors from the application. This allows the flexibility for the application to read some strings (like serial numbers) from non-const locations (like EEPROM).

Parameters:
string_numberThe string number requested
ptrA pointer to a pointer which should be set to the requested string descriptor by this function.
Returns:
Return the length of the string descriptor in bytes or -1 if the string requested does not exist.

Variable Documentation

Configuration Descriptor.

This is an array of the device's configuration descriptors, as defined by the USB specification, chapter 9. USB_CONFIG_DESCRIPTOR_MAP must be defined to be the name of an array of pointers to configuration_descriptor objects, often in the application's usb_descriptors.c. The order is not important because the bConfigurationValue field is used by the USB stack to determine the configuration number for each configuration descriptor. It is important that wTotalLength in each configuration descriptor be correct, as this is used by the USB stack to determine the number of bytes to use (It is recommended to use the sizeof() operator for this field).

See the example programs that come with the USB stack (specificallyl usb_descriptors.c) for a simple example of what is required.

Device Descriptor.

This is the device's device descriptor as defined by the USB specification, chapter 9. USB_DEVICE_DESCRIPTOR must be defined in usb_config.h to be the name of the device descriptor structure, which will often be located in the application's usb_descriptors.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator