include/usb/function.h File Reference

USB device function interface. More...

#include <types.h>

Include dependency graph for function.h:

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

Go to the source code of this file.

Functions

void usb_func_reset (struct udc *udc)
 Reset the USB function driver.
int usb_func_get_descriptor (struct udc *udc, uint16_t value, uint16_t index, uint16_t len)
 Handle a standard GET_DESCRIPTOR request.
int usb_func_set_configuration (struct udc *udc, uint16_t config_id)
 Set the active configuration.
int usb_func_get_interface (struct udc *udc, uint16_t iface_id)
 Get the currently active alternate setting of an interface.
int usb_func_set_interface (struct udc *udc, uint16_t iface_id, uint16_t alt_setting)
 Select an alternate setting for an interface.
int usb_func_process_setup_request (struct udc *udc, struct usb_setup_req *req)
 Handle a class- or vendor-defined setup request.


Detailed Description

USB device function interface.

This file defines the interface implemented by all USB function drivers, i.e. the layer above the UDC driver.

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

Definition in file function.h.


Function Documentation

int usb_func_get_descriptor ( struct udc udc,
uint16_t  value,
uint16_t  index,
uint16_t  len 
)

Handle a standard GET_DESCRIPTOR request.

This is called when the host sends a GET_DESCRIPTOR request. The function driver will queue one or more IN buffers with the requested descriptor data if available.

After the descriptor data has been successfully sent, which may happen after this function returns, udc_ep0_expect_status() will be called.

Parameters:
udc USB Device Controller instance
value The wValue of the request in native byte order
index The wIndex of the request in native byte order
len The wLength of the request in native byte order. The function driver will never queue more than this number of bytes even if the requested descriptor is larger.
Return values:
0 The request was handled successfully.
-1 The request failed, so ep0 should be stalled.

Definition at line 339 of file usb_function_core.c.

References usb_configuration_descriptor::bDescriptorType, buffer_init_tx(), dbg_printf, usb_func_config::desc, usb_request::flags, min, usb_request::req_done, set_bit(), udc::speed, udc_ep0_submit_in_req(), usb_req_add_buffer(), usb_req_init(), and USB_REQ_SHORT_PKT.

Here is the call graph for this function:

int usb_func_get_interface ( struct udc udc,
uint16_t  iface_id 
)

Get the currently active alternate setting of an interface.

Queue a IN packet with a single byte indicating the currently selected alternate setting of the specified interface.

Parameters:
udc USB Device Controller instance
iface_id The bInterfaceNumber of the interface to query
Return values:
0 The request was handled successfully, and the IN packet was queued.
-1 The request failed, so ep0 should be stalled.

Definition at line 519 of file usb_function_core.c.

References usb_interface_descriptor::bAlternateSetting, usb_func_iface::cur_setting, dbg_printf, usb_func_iface_setting::fs_desc, usb_func_config::interface, udc_ep0_expect_status(), and udc_ep0_write_sync().

Here is the call graph for this function:

int usb_func_process_setup_request ( struct udc udc,
struct usb_setup_req req 
)

Handle a class- or vendor-defined setup request.

This function is called when a SETUP request whose Type field in bmRequestType does not indicate a standard request. It is completely up to the function driver to decide which requests to support.

This function may queue one or more data or status packets asynchronously, and call udc_ep0_expect_status() when any queued IN data has been sent.

Note that the fields in req are in USB (little-endian) byte order.

Parameters:
udc USB Device Controller instance
req USB SETUP request
Return values:
0 The request was handled successfully.
-1 The request failed, so ep0 should be stalled.

Definition at line 586 of file usb_function_core.c.

References usb_setup_req::bmRequestType, usb_func_iface::cur_setting, dbg_printf, usb_func_config::interface, usb_func_iface_setting::ops, usb_func_iface_ops::setup, and usb_setup_req::wIndex.

Referenced by udc_lib_process_setup_request().

void usb_func_reset ( struct udc udc  ) 

Reset the USB function driver.

This is called when a USB bus reset is detected, and when the device is disconnected from the host.

Parameters:
udc USB Device Controller instance

Definition at line 578 of file usb_function_core.c.

References udc::config, dbg_printf, udc::speed, and usb_func_set_configuration().

Referenced by usbb_udc_softirq().

Here is the call graph for this function:

int usb_func_set_configuration ( struct udc udc,
uint16_t  config_id 
)

Set the active configuration.

This function will deselect the currently active configuration, and optionally select a new one. If config_id is zero, no new configuration will be selected, but the function will still report success. If config_id is higher than the number of supported configurations, the function will report failure.

Parameters:
udc USB Device Controller instance
config_id The bConfigurationValue of the new configuration, or zero if the device is to change to the Address state.
Return values:
0 The request was handled successfully.
-1 The request failed, so ep0 should be stalled.

Definition at line 482 of file usb_function_core.c.

References udc::config, dbg_printf, and usb_func_config::desc.

Referenced by usb_func_reset().

int usb_func_set_interface ( struct udc udc,
uint16_t  iface_id,
uint16_t  alt_setting 
)

Select an alternate setting for an interface.

Select alternate setting alt_setting for interface iface_id.

Parameters:
udc USB Device Controller instance
iface_id The bInterfaceNumber of the interface
alt_setting The bAlternateSetting to be selected
Return values:
0 The request was handled successfully.
-1 The request failed, so ep0 should be stalled.

Definition at line 540 of file usb_function_core.c.

References usb_func_iface::cur_setting, dbg_printf, usb_func_iface_ops::disable, usb_func_iface_ops::enable, usb_func_config::interface, usb_func_iface::nr_settings, usb_func_iface_setting::ops, and usb_func_iface::setting.


Generated on Tue Sep 15 10:21:40 2009 for libavr32 by  doxygen 1.5.8