- 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.

## 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 80 of file usb_specific_request.c.

References FALSE, get_nb_lun(), INTERFACE_NB, LSB, ms_multiple_drive, MSB, SETUP_MASS_STORAGE_GET_MAX_LUN, SETUP_MASS_STORAGE_RESET, TRUE, Usb_ack_receive_setup, Usb_read_byte, Usb_send_control_in, USB_SETUP_GET_CLASS_INTER, USB_SETUP_SET_CLASS_INTER, and Usb_write_byte.

    00081 {
    00082    U16   wInterface;
    00083    U8    wValue_msb;
    00084    U8    wValue_lsb;
    00085
    00086    // Read wValue
    00087    wValue_lsb = Usb_read_byte();
    00088    wValue_msb = Usb_read_byte();
    00089
    00090    //** Specific request from Class MassStorage
    00091    if( USB_SETUP_SET_CLASS_INTER == type )
    00092    {
    00093       switch( request )
    00094       {
    00095          case SETUP_MASS_STORAGE_RESET:
    00096          // wValue must be 0
    00097          // wIndex = Interface
    00098          if( (0!=wValue_lsb) || (0!=wValue_msb) )
    00099             break;
    00100          LSB(wInterface)=Usb_read_byte();
    00101          MSB(wInterface)=Usb_read_byte();
    00102          if( INTERFACE_NB != wInterface )
    00103             break;
    00104          Usb_ack_receive_setup();
    00105          Usb_send_control_in();
    00106          return TRUE;
    00107          break;
    00108       }
    00109    }
    00110    if( USB_SETUP_GET_CLASS_INTER == type )
    00111    {
    00112       switch( request )
    00113       {
    00114          case SETUP_MASS_STORAGE_GET_MAX_LUN:
    00115          // wValue must be 0
    00116          // wIndex = Interface
    00117          if( (0!=wValue_lsb) || (0!=wValue_msb) )
    00118             break;
    00119          LSB(wInterface)=Usb_read_byte();
    00120          MSB(wInterface)=Usb_read_byte();
    00121          if( INTERFACE_NB != wInterface )
    00122             break;
    00123          Usb_ack_receive_setup();
    00124          Usb_write_byte( (get_nb_lun()-1) );
    00125          Usb_send_control_in();
    00126          ms_multiple_drive = 1;
    00127          return TRUE;
    00128          break;
    00129       }
    00130    }
    00131
    00132    return FALSE;  // No supported request
    00133 }

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 140 of file usb_specific_request.c.

References DIRECTION_IN, DIRECTION_OUT, EP_MS_IN, EP_MS_OUT, NYET_ENABLED, SIZE_64, TWO_BANKS, TYPE_BULK, and usb_configure_endpoint.

    00141 {
    00142    usb_configure_endpoint(EP_MS_IN,      \
    00143                           TYPE_BULK,     \
    00144                           DIRECTION_IN,  \
    00145                           SIZE_64,       \
    00146                           TWO_BANKS,     \
    00147                           NYET_ENABLED);
    00148    usb_configure_endpoint(EP_MS_OUT,     \
    00149                           TYPE_BULK,     \
    00150                           DIRECTION_OUT, \
    00151                           SIZE_64,       \
    00152                           TWO_BANKS,     \
    00153                           NYET_ENABLED);
    00154 }

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 163 of file usb_specific_request.c.

    00164 {
    00165    return 0;  // Only one alternate setting possible for all interface
    00166 }

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 174 of file usb_specific_request.c.

References EP_MS_IN, EP_MS_OUT, INTERFACE_NB, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.

    00175 {
    00176    // default setting selected = reset data toggle
    00177    if( INTERFACE_NB == wInterface )
    00178    {
    00179       // Interface Mass Storage
    00180       Usb_select_endpoint(EP_MS_IN);
    00181       Usb_disable_stall_handshake();
    00182       Usb_reset_endpoint(EP_MS_IN);
    00183       Usb_reset_data_toggle();
    00184       Usb_select_endpoint(EP_MS_OUT);
    00185       Usb_disable_stall_handshake();
    00186       Usb_reset_endpoint(EP_MS_OUT);
    00187       Usb_reset_data_toggle();
    00188    }
    00189 }

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 199 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, SN_LENGTH, TRUE, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.

    00200 {
    00201    switch(type)
    00202    {
    00203       case DESCRIPTOR_STRING:
    00204       switch (string)
    00205       {
    00206          case LANG_ID:
    00207          data_to_transfer = sizeof (usb_user_language_id);
    00208          pbuffer = &(usb_user_language_id.bLength);
    00209          return TRUE;
    00210          break;
    00211
    00212          case MAN_INDEX:
    00213          data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
    00214          pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
    00215          return TRUE;
    00216          break;
    00217
    00218          case PROD_INDEX:
    00219          data_to_transfer = sizeof (usb_user_product_string_descriptor);
    00220          pbuffer = &(usb_user_product_string_descriptor.bLength);
    00221          return TRUE;
    00222          break;
    00223
    00224 #if (USB_DEVICE_SN_USE==ENABLE)
    00225          case SN_INDEX:
    00226          data_to_transfer = sizeof (usb_user_serial_number);
    00227          pbuffer = &(usb_user_serial_number.bLength);
    00228 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
    00229          f_get_serial_string=TRUE;
    00230          data_to_transfer += (SN_LENGTH*4);
    00231 #endif
    00232          return TRUE;
    00233          break;
    00234 #endif
    00235       }
    00236       break;
    00237    }
    00238    return FALSE;
    00239 }

## 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 130 of file usb_descriptors.c.

code S_usb_product_string_descriptor usb_user_product_string_descriptor

Definition at line 139 of file usb_descriptors.c.

code S_usb_serial_number usb_user_serial_number

Definition at line 148 of file usb_descriptors.c.

code S_usb_language_id usb_user_language_id

Definition at line 162 of file usb_descriptors.c.