drivers/usb/core/dev_mux.c File Reference

USB device multiplexing layer. More...

#include <assert.h>
#include <byteorder.h>
#include <debug.h>
#include <dmapool.h>
#include <interrupt.h>
#include <malloc.h>
#include <status_codes.h>
#include <string.h>
#include <util.h>
#include <usb/dev.h>
#include <usb/dev_mux.h>
#include <usb/request.h>
#include <usb/udc.h>
#include <app/usb.h>

Go to the source code of this file.

Defines

USB Device Strings

#define USB_STRING_DEV_PRODUCT   0
 String ID representing the name of the product.
#define USB_STRING_DEV_SERIAL   0
 String ID representing the serial number of the device.

Functions

status_t usb_dev_get_descriptor (struct udc *udc, uint16_t value, uint16_t index, uint16_t len)
 Handle a standard GET_DESCRIPTOR request.
status_t usb_dev_set_configuration (struct udc *udc, uint16_t config_id)
 Set the active configuration.
status_t usb_dev_get_interface (struct udc *udc, uint16_t iface_id)
 Get the currently active alternate setting of an interface.
status_t usb_dev_set_interface (struct udc *udc, uint16_t iface_id, uint16_t alt_setting)
 Select an alternate setting for an interface.
void usb_dev_reset (struct udc *udc)
 Reset the USB device.
status_t usb_dev_process_setup_request (struct udc *udc, struct usb_setup_req *setup)
 Handle a class- or vendor-defined setup request.
Configuration Management

The following functions may be called by the application to create configurations and associate interfaces with them. The interface objects are typically returned by the initialization function of a USB Device Interface Driver.

udm_create_config() returns a configuration object which can be passed as a parameter to the other configuration management functions. The configuration descriptor is managed by the UDM layer, but the application may alter certain fields by calling udm_config_set_self_powered(), udm_config_set_bus_powered(), and udm_config_set_max_power(). The application must not create more than one configuration with a given value, and it must not attempt to create more configurations than specified by APP_USB_DEVICE_NR_CONFIGS.

void udm_config_add_interface (struct udm_config *config, struct udm_interface *iface)
 Add an interface to a configuration.
struct udm_configudm_create_config (uint8_t value, uint8_t nr_interfaces)
 Create a new USB device configuration.
void udm_config_set_max_power (struct udm_config *config, unsigned int milliamps)
 Set the maximum power consumption of a configuration.
void udm_config_set_self_powered (struct udm_config *config)
 Mark a configuration as self-powered.
void udm_config_set_bus_powered (struct udm_config *config)
 Mark a configuration as bus-powered.
USB String Descriptor Support

The following functions may be used by the application to implement support for USB string descriptors. Such descriptors are optional according to the USB spec, so by default, all string descriptor requests are rejected.

To support string descriptors, the application must implement the function app_usb_get_string_descriptor() and provide a preprocessor define named HAVE_APP_USB_GET_STRING_DESCRIPTOR (which will disable the default implementation).

int udm_submit_utf16le_string_desc (struct udc *udc, struct usb_request *req, const le16_t *str, uint16_t max_len)
 Add a string descriptor buffer initialized from a UTF-16LE encoded string.
int udm_submit_ascii_string_desc (struct udc *udc, struct usb_request *req, const char *str, uint16_t max_len)
 Add a string descriptor buffer initialized from an 8-bit ASCII encoded string.
static int app_usb_get_string_descriptor (struct udc *udc, struct usb_request *req, uint8_t index, uint16_t langid, uint16_t len)
 Application-specific hook for retrieving a USB String descriptor.

Detailed Description

USB device multiplexing layer.

This file implements a glue layer for easier device interface driver implementation, and for supporting multiple configurations and/or interfaces provided by separate drivers.

Copyright (C) 2009 Atmel Corporation. All rights reserved.

Definition in file dev_mux.c.

Generated on Thu Apr 29 14:10:34 2010 for xplain-bc by  doxygen 1.6.3