- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# usb_specific_request.h File Reference

`#include "config.h"`

Include dependency graph for usb_specific_request.h:

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

Go to the source code of this file.

## Data Structures
struct | S_usb_hid_report_descriptor
| Usb HID Report Descriptor HID generic. More...
## Functions
Bool | usb_user_read_request (U8, U8)
| This function checks the specific request and if known then processes it
void | usb_user_endpoint_init (U8)
U8 | usb_user_interface_get (U16 wInterface)
void | usb_user_interface_reset (U16 wInterface, U8 alternate_setting)
Bool | usb_user_get_descriptor (U8, U8)
| This function fills the global descriptor.
## Variables
code S_usb_device_descriptor | usb_dev_desc
code S_usb_user_configuration_descriptor | usb_conf_desc
code S_usb_manufacturer_string_descriptor | usb_user_manufacturer_string_descriptor
code S_usb_product_string_descriptor | usb_user_product_string_descriptor
code S_usb_serial_number | usb_user_serial_number
code S_usb_language_id | usb_user_language_id

## Detailed Description

Specific enumeration process requests header file - Compiler: IAR EWAVR and GNU GCC for AVR

- Supported devices: AT90USB1287, AT90USB1286, AT90USB647, AT90USB646
  Author:
    Atmel Corporation: http://www.atmel.com
    Support and FAQ: http://support.atmel.no/

Definition in file usb_specific_request.h.

## Function Documentation

Bool usb_user_read_request | ( | U8 | type,
|  | U8 | request |
| ) |  |  |

This function checks the specific request and if known then processes it

Parameters:

  | type | corresponding at bmRequestType (see USB specification)
  | request | corresponding at bRequest (see USB specification)

Returns:
  TRUE, when the request is processed

  FALSE, if the request is'nt know (STALL handshake is managed by the main standard request function).

Definition at line 88 of file usb_specific_request.c.

References DESCRIPTOR_HID, DESCRIPTOR_PHYSICAL, DESCRIPTOR_REPORT, FALSE, hid_get_hid_descriptor(), hid_get_report_descriptor(), REPORT_TYPE_FEATURE, REPORT_TYPE_INPUT, REPORT_TYPE_OUTPUT, SETUP_GET_DESCRIPTOR, SETUP_HID_GET_IDLE, SETUP_HID_GET_PROTOCOL, SETUP_HID_GET_REPORT, SETUP_HID_SET_IDLE, SETUP_HID_SET_PROTOCOL, SETUP_HID_SET_REPORT, TRUE, usb_hid_get_idle(), usb_hid_set_idle(), usb_hid_set_report_feature(), usb_hid_set_report_ouput(), Usb_read_byte, USB_SETUP_GET_CLASS_INTER, USB_SETUP_GET_STAND_INTERFACE, and USB_SETUP_SET_CLASS_INTER.

    00089 {
    00090    U8    wValue_msb;
    00091    U8    wValue_lsb;
    00092
    00093    // Read wValue
    00094    wValue_lsb = Usb_read_byte();
    00095    wValue_msb = Usb_read_byte();
    00096
    00097    //** Specific request from Class HID
    00098    if( USB_SETUP_GET_STAND_INTERFACE == type )
    00099    {
    00100       switch( request )
    00101       {
    00102          case SETUP_GET_DESCRIPTOR:
    00103          switch( wValue_msb ) // Descriptor ID
    00104          {
    00105             case DESCRIPTOR_HID:
    00106             hid_get_hid_descriptor();
    00107             return TRUE;
    00108             break;
    00109
    00110             case DESCRIPTOR_REPORT:
    00111             hid_get_report_descriptor();
    00112             return TRUE;
    00113
    00114             case DESCRIPTOR_PHYSICAL:
    00115             // TODO
    00116             break;
    00117          }
    00118          break;
    00119       }
    00120    }
    00121    if( USB_SETUP_SET_CLASS_INTER == type )
    00122    {
    00123       switch( request )
    00124       {
    00125          case SETUP_HID_SET_REPORT:
    00126          // The MSB wValue field specifies the Report Type
    00127          // The LSB wValue field specifies the Report ID
    00128          switch (wValue_msb)
    00129          {
    00130             case REPORT_TYPE_INPUT:
    00131             // TODO
    00132             break;
    00133
    00134             case REPORT_TYPE_OUTPUT:
    00135             usb_hid_set_report_ouput();
    00136             return TRUE;
    00137             break;
    00138
    00139             case REPORT_TYPE_FEATURE:
    00140             usb_hid_set_report_feature();
    00141             return TRUE;
    00142             break;
    00143          }
    00144          break;
    00145
    00146          case SETUP_HID_SET_IDLE:
    00147          usb_hid_set_idle(wValue_lsb,wValue_msb);
    00148          return TRUE;
    00149
    00150          case SETUP_HID_SET_PROTOCOL:
    00151          // TODO
    00152          break;
    00153       }
    00154    }
    00155    if( USB_SETUP_GET_CLASS_INTER == type )
    00156    {
    00157       switch( request )
    00158       {
    00159          case SETUP_HID_GET_REPORT:
    00160          // TODO
    00161          break;
    00162          case SETUP_HID_GET_IDLE:
    00163          usb_hid_get_idle(wValue_lsb);
    00164          return TRUE;
    00165          case SETUP_HID_GET_PROTOCOL:
    00166          // TODO
    00167          break;
    00168       }
    00169    }
    00170    return FALSE;  // No supported request
    00171 }

Here is the call graph for this function:

void usb_user_endpoint_init | ( | U8 | conf_nb | ) |

This function configures the endpoints

Parameters:

  | conf_nb | configuration number choosed by USB host

Definition at line 178 of file usb_specific_request.c.

References DIRECTION_IN, DIRECTION_OUT, EP_HID_IN, EP_HID_OUT, NYET_ENABLED, ONE_BANK, SIZE_8, TYPE_INTERRUPT, and usb_configure_endpoint.

    00179 {
    00180    usb_configure_endpoint( EP_HID_IN,   \
    00181                            TYPE_INTERRUPT,\
    00182                            DIRECTION_IN,  \
    00183                            SIZE_8,        \
    00184                            ONE_BANK,      \
    00185                            NYET_ENABLED);
    00186
    00187    usb_configure_endpoint( EP_HID_OUT,    \
    00188                            TYPE_INTERRUPT,\
    00189                            DIRECTION_OUT, \
    00190                            SIZE_8,        \
    00191                            ONE_BANK,      \
    00192                            NYET_ENABLED);
    00193 }

U8 usb_user_interface_get | ( | U16 | wInterface | ) |

This function returns the interface alternate setting

Parameters:

  | wInterface | Interface selected

Returns:
  alternate setting configurated

Definition at line 202 of file usb_specific_request.c.

    00203 {
    00204    return 0;  // Only one alternate setting possible for all interface
    00205 }

void usb_user_interface_reset | ( | U16 | wInterface,
|  | U8 | alternate_setting |
| ) |  |  |

This function selects (and resets) the interface alternate setting

Parameters:

  | wInterface | Interface selected
  | alternate_setting | alternate setting selected

Definition at line 213 of file usb_specific_request.c.

References EP_HID_IN, EP_HID_OUT, INTERFACE_NB, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.

    00214 {
    00215    // default setting selected = reset data toggle
    00216    if( INTERFACE_NB == wInterface )
    00217    {
    00218       // Interface HID
    00219       Usb_select_endpoint(EP_HID_IN);
    00220       Usb_disable_stall_handshake();
    00221       Usb_reset_endpoint(EP_HID_IN);
    00222       Usb_reset_data_toggle();
    00223       Usb_select_endpoint(EP_HID_OUT);
    00224       Usb_disable_stall_handshake();
    00225       Usb_reset_endpoint(EP_HID_OUT);
    00226       Usb_reset_data_toggle();
    00227    }
    00228 }

Bool usb_user_get_descriptor | ( | U8 | type,
|  | U8 | string |
| ) |  |  |

This function fills the global descriptor.

Parameters:

  | type | corresponding at MSB of wValue (see USB specification)
  | string | corresponding at LSB of wValue (see USB specification)

Returns:
  FALSE, if the global descriptor no filled

Definition at line 238 of file usb_specific_request.c.

References S_usb_serial_number::bLength, S_usb_product_string_descriptor::bLength, S_usb_manufacturer_string_descriptor::bLength, S_usb_language_id::bLength, data_to_transfer, DESCRIPTOR_STRING, f_get_serial_string, FALSE, LANG_ID, MAN_INDEX, pbuffer, PROD_INDEX, SN_INDEX, TRUE, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.

    00239 {
    00240    switch(type)
    00241    {
    00242       case DESCRIPTOR_STRING:
    00243       switch (string)
    00244       {
    00245          case LANG_ID:
    00246          data_to_transfer = sizeof (usb_user_language_id);
    00247          pbuffer = &(usb_user_language_id.bLength);
    00248          return TRUE;
    00249          break;
    00250
    00251          case MAN_INDEX:
    00252          data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
    00253          pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
    00254          return TRUE;
    00255          break;
    00256
    00257          case PROD_INDEX:
    00258          data_to_transfer = sizeof (usb_user_product_string_descriptor);
    00259          pbuffer = &(usb_user_product_string_descriptor.bLength);
    00260          return TRUE;
    00261          break;
    00262
    00263 #if (USB_DEVICE_SN_USE==ENABLE)
    00264          case SN_INDEX:
    00265          data_to_transfer = sizeof (usb_user_serial_number);
    00266          pbuffer = &(usb_user_serial_number.bLength);
    00267 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
    00268          f_get_serial_string=TRUE;
    00269          data_to_transfer += (SN_LENGTH*4);
    00270 #endif
    00271          return TRUE;
    00272          break;
    00273 #endif
    00274       }
    00275       break;
    00276    }
    00277    return FALSE;
    00278 }

## Variable Documentation

code S_usb_device_descriptor usb_dev_desc

Definition at line 66 of file usb_descriptors.c.

code S_usb_user_configuration_descriptor usb_conf_desc

Definition at line 85 of file usb_descriptors.c.

code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor

Definition at line 140 of file usb_descriptors.c.

code S_usb_product_string_descriptor usb_user_product_string_descriptor

Definition at line 149 of file usb_descriptors.c.

code S_usb_serial_number usb_user_serial_number

Definition at line 158 of file usb_descriptors.c.

code S_usb_language_id usb_user_language_id

Definition at line 172 of file usb_descriptors.c.