# include/usb/function_core.h File Reference

USB device function core layer interface. More...

`#include <buffer.h>`

Include dependency graph for function_core.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures
struct | usb_func_iface_ops
| USB device interface driver operations. More...
struct | usb_func_iface_setting
| An alternate setting of an interface. More...
struct | usb_func_iface
| A USB device interface. More...
struct | usb_func_config
| A USB device configuration. More...
## Functions
void | usb_func_add_interface (struct usb_func_config *config, struct usb_func_iface *iface)
| Add an interface to a configuration.
struct usb_func_config * | usb_func_add_config (struct usb_configuration_descriptor *desc)
| Add a device configuration.

## Detailed Description

USB device function core layer interface.

- Compiler: IAR EWAVR32 and GNU GCC for AVR32
- Supported devices: All devices with a USB Device Controller
- AppNote:

Author:
  Atmel Corporation: http://www.atmel.com
  Support and FAQ: http://support.atmel.no/

Definition in file function_core.h.

## Function Documentation

struct usb_func_config* usb_func_add_config | ( | struct usb_configuration_descriptor * | desc | ) | `[read]`

Add a device configuration.

This function will add a new configuration of the device.

Note:
  The contents of desc will be altered during normal operation.

Parameters:

  | desc | The configuration descriptor of the new configuration.

Returns:
  An object representing the new configuration.

Precondition:
  - desc must have a bConfigurationValue less than or equal to CONFIG_USB_FUNC_NR_CONFIGURATIONS.
  - Two configurations can not have the same bConfigurationValue.

Definition at line 185 of file usb_function_core.c.

References assert, usb_configuration_descriptor::bConfigurationValue, usb_configuration_descriptor::bNumInterfaces, dbg_printf, usb_func_config::desc, usb_func_config::interface, and memset().

Here is the call graph for this function:

void usb_func_add_interface | ( | struct usb_func_config * | config,
|  | struct usb_func_iface * | iface |
| ) |  |  |

Add an interface to a configuration.

This function will associate an interface with an existing configuration so that it will be automatically enabled when the configuration is selected, and the interface descriptor(s) will be included in the configuration descriptor for this configuration.

If no high-speed descriptors are provided, they will be assumed to be the same as the full-speed descriptors.

Parameters:

  | config | The USB function configuration.
  | iface | The interface to be added to config.

Precondition:
  - iface must have at least one alternate setting.
  - iface must have a bInterfaceNumber less than bNumInterfaces of config.
  - An interface with the same bInterfaceNumber must not have been registered before to the same configuration.
  - All settings must have the same bInterfaceNumber.
  - Each setting's high-speed descriptor, if present, must have the same bInterfaceNumber as the full-speed descriptor.

Definition at line 137 of file usb_function_core.c.

References assert, usb_interface_descriptor::bInterfaceNumber, dbg_printf, usb_func_iface_setting::fs_desc, usb_func_iface_setting::fs_desc_size, usb_func_iface_setting::hs_desc, usb_func_iface_setting::hs_desc_size, usb_func_config::interface, usb_func_iface::nr_settings, usb_func_iface_setting::ops, and usb_func_iface::setting.