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_mouse
 Usb HID Report Descriptor Mouse. More...
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

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

References DESCRIPTOR_HID, DESCRIPTOR_PHYSICAL, DESCRIPTOR_REPORT, FALSE, get_nb_lun(), hid_get_hid_descriptor(), hid_get_report_descriptor(), INTERFACE_NB, Is_usb_in_ready, Is_usb_receive_out, LSB, ms_multiple_drive, MSB, 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, SETUP_MASS_STORAGE_GET_MAX_LUN, SETUP_MASS_STORAGE_RESET, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, usb_hid_get_idle(), usb_hid_set_idle(), usb_hid_set_report_feature(), usb_hid_set_report_ouput(), Usb_read_byte, Usb_send_control_in, USB_SETUP_GET_CLASS_INTER, USB_SETUP_GET_STAND_INTERFACE, USB_SETUP_SET_CLASS_INTER, and Usb_write_byte.

00096 {
00097    U16   wInterface;
00098    U8    wValue_msb;
00099    U8    wValue_lsb;
00100 
00101    // Read wValue
00102    wValue_lsb = Usb_read_byte();
00103    wValue_msb = Usb_read_byte();
00104 
00105    //** Specific request from Class HID
00106    if( USB_SETUP_GET_STAND_INTERFACE == type )
00107    {
00108       switch( request )
00109       {
00110          case SETUP_GET_DESCRIPTOR:
00111          switch( wValue_msb ) // Descriptor ID
00112          {
00113             case DESCRIPTOR_HID:
00114             hid_get_hid_descriptor();
00115             return TRUE;
00116             break;
00117    
00118             case DESCRIPTOR_REPORT:
00119             hid_get_report_descriptor();
00120             return TRUE;
00121    
00122             case DESCRIPTOR_PHYSICAL:
00123             // TODO
00124             break;
00125          }
00126          break;
00127       }
00128    }
00129    if( USB_SETUP_SET_CLASS_INTER == type )
00130    {
00131       switch( request )
00132       {
00133          case SETUP_HID_SET_REPORT:
00134          // The MSB wValue field specifies the Report Type
00135          // The LSB wValue field specifies the Report ID
00136          switch (wValue_msb)
00137          {
00138             case REPORT_TYPE_INPUT:
00139             // TODO
00140             break;
00141             
00142             case REPORT_TYPE_OUTPUT:
00143             usb_hid_set_report_ouput();
00144             return TRUE;
00145             break;
00146 
00147             case REPORT_TYPE_FEATURE:
00148             usb_hid_set_report_feature();
00149             return TRUE;
00150             break;
00151          }
00152          break;
00153 
00154          case SETUP_HID_SET_IDLE:
00155          usb_hid_set_idle(wValue_lsb,wValue_msb);
00156          return TRUE;
00157    
00158          case SETUP_HID_SET_PROTOCOL:
00159          // TODO
00160          break;
00161       }
00162    }
00163    if( USB_SETUP_GET_CLASS_INTER == type )
00164    {
00165       switch( request )
00166       {
00167          case SETUP_HID_GET_REPORT:
00168          // TODO
00169          break;
00170          case SETUP_HID_GET_IDLE:
00171          usb_hid_get_idle(wValue_lsb);
00172          return TRUE;
00173          case SETUP_HID_GET_PROTOCOL:
00174          // TODO
00175          break;
00176       }
00177    }
00178  
00179    //** Specific request from Class MassStorage
00180    if( USB_SETUP_SET_CLASS_INTER == type )
00181    {
00182       switch( request )
00183       {
00184          case SETUP_MASS_STORAGE_RESET:
00185          // wValue must be 0
00186          // wIndex = Interface
00187          if( (0!=wValue_lsb) || (0!=wValue_msb) )
00188             break;
00189          LSB(wInterface)=Usb_read_byte();
00190          MSB(wInterface)=Usb_read_byte();
00191          if( INTERFACE_NB != wInterface )
00192             break;
00193          Usb_ack_receive_setup();
00194          Usb_send_control_in();
00195          while(!Is_usb_in_ready());
00196          return TRUE;
00197          break;
00198       }
00199    }
00200    if( USB_SETUP_GET_CLASS_INTER == type )
00201    {
00202       switch( request )
00203       {
00204          case SETUP_MASS_STORAGE_GET_MAX_LUN:
00205          // wValue must be 0
00206          // wIndex = Interface
00207          if( (0!=wValue_lsb) || (0!=wValue_msb) )
00208             break;
00209          LSB(wInterface)=Usb_read_byte();
00210          MSB(wInterface)=Usb_read_byte();
00211          if( INTERFACE_NB != wInterface )
00212             break;
00213          Usb_ack_receive_setup();
00214          Usb_write_byte( (get_nb_lun()-1) );
00215          Usb_send_control_in();
00216          while(!Is_usb_in_ready());
00217          while( !Is_usb_receive_out() );
00218          Usb_ack_receive_out();
00219          ms_multiple_drive = 1;
00220          return TRUE;
00221          break;
00222       }
00223    }
00224    
00225    return FALSE;  // No supported request
00226 }

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

References DIRECTION_IN, DIRECTION_OUT, EP_HID_IN, EP_HID_OUT, EP_MOUSE_IN, EP_MS_IN, EP_MS_OUT, NYET_ENABLED, ONE_BANK, SIZE_64, SIZE_8, TWO_BANKS, TYPE_BULK, TYPE_INTERRUPT, and usb_configure_endpoint.

00234 {
00235    usb_configure_endpoint( EP_MOUSE_IN,   \
00236                            TYPE_INTERRUPT,\
00237                            DIRECTION_IN,  \
00238                            SIZE_8,        \
00239                            ONE_BANK,      \
00240                            NYET_ENABLED);
00241 
00242    usb_configure_endpoint( EP_MS_IN,      \
00243                            TYPE_BULK,     \
00244                            DIRECTION_IN,  \
00245                            SIZE_64,       \
00246                            TWO_BANKS,     \
00247                            NYET_ENABLED);
00248 
00249    usb_configure_endpoint( EP_MS_OUT,     \
00250                            TYPE_BULK,     \
00251                            DIRECTION_OUT, \
00252                            SIZE_64,       \
00253                            TWO_BANKS,     \
00254                            NYET_ENABLED);
00255 
00256    usb_configure_endpoint( EP_HID_IN,     \
00257                            TYPE_INTERRUPT,\
00258                            DIRECTION_IN,  \
00259                            SIZE_8,        \
00260                            ONE_BANK,      \
00261                            NYET_ENABLED);
00262 
00263    usb_configure_endpoint( EP_HID_OUT,    \
00264                            TYPE_INTERRUPT,\
00265                            DIRECTION_OUT, \
00266                            SIZE_8,        \
00267                            ONE_BANK,      \
00268                            NYET_ENABLED);
00269 }

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

00279 {
00280    return 0;  // Only one alternate setting possible for all interface
00281 }

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

References EP_HID_IN, EP_HID_OUT, EP_MOUSE_IN, EP_MS_IN, EP_MS_OUT, INTERFACE_NB, INTERFACE_NB_HID, INTERFACE_NB_MOUSE, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.

00290 {  
00291    // default setting selected = reset data toggle
00292    if( INTERFACE_NB_MOUSE == wInterface )
00293    {
00294       // Interface mouse
00295       Usb_select_endpoint(EP_MOUSE_IN);
00296       Usb_disable_stall_handshake();
00297       Usb_reset_endpoint(EP_MOUSE_IN);
00298       Usb_reset_data_toggle();
00299    }
00300    if( INTERFACE_NB == wInterface )
00301    {
00302       // Interface Mass Storage
00303       Usb_select_endpoint(EP_MS_IN);
00304       Usb_disable_stall_handshake();
00305       Usb_reset_endpoint(EP_MS_IN);
00306       Usb_reset_data_toggle();
00307       Usb_select_endpoint(EP_MS_OUT);
00308       Usb_disable_stall_handshake();
00309       Usb_reset_endpoint(EP_MS_OUT);
00310       Usb_reset_data_toggle();
00311    }
00312    if( INTERFACE_NB_HID == wInterface )
00313    {
00314       // Interface Mass Storage
00315       Usb_select_endpoint(EP_HID_IN);
00316       Usb_disable_stall_handshake();
00317       Usb_reset_endpoint(EP_HID_IN);
00318       Usb_reset_data_toggle();
00319       Usb_select_endpoint(EP_HID_OUT);
00320       Usb_disable_stall_handshake();
00321       Usb_reset_endpoint(EP_HID_OUT);
00322       Usb_reset_data_toggle();
00323    }
00324 }

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

00335 {
00336    switch(type)
00337    {
00338       case DESCRIPTOR_STRING:
00339       switch (string)
00340       {
00341          case LANG_ID:
00342          data_to_transfer = sizeof (usb_user_language_id);
00343          pbuffer = &(usb_user_language_id.bLength);
00344          return TRUE;
00345          break;
00346         
00347          case MAN_INDEX:
00348          data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
00349          pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
00350          return TRUE;
00351          break;
00352         
00353          case PROD_INDEX:
00354          data_to_transfer = sizeof (usb_user_product_string_descriptor);
00355          pbuffer = &(usb_user_product_string_descriptor.bLength);
00356          return TRUE;
00357          break;
00358            
00359 #if (USB_DEVICE_SN_USE==ENABLE)              
00360          case SN_INDEX:
00361          data_to_transfer = sizeof (usb_user_serial_number);
00362          pbuffer = &(usb_user_serial_number.bLength);
00363 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00364          f_get_serial_string=TRUE;
00365          data_to_transfer += (SN_LENGTH*4);
00366 #endif
00367          return TRUE;
00368          break;
00369 #endif
00370       }
00371       break;
00372    }
00373    return FALSE;
00374 }


Variable Documentation

code S_usb_device_descriptor usb_dev_desc

Definition at line 69 of file usb_descriptors.c.

code S_usb_user_configuration_descriptor usb_conf_desc

Definition at line 88 of file usb_descriptors.c.

code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor

Definition at line 205 of file usb_descriptors.c.

code S_usb_product_string_descriptor usb_user_product_string_descriptor

Definition at line 214 of file usb_descriptors.c.

code S_usb_serial_number usb_user_serial_number

Definition at line 223 of file usb_descriptors.c.

code S_usb_language_id usb_user_language_id

Definition at line 237 of file usb_descriptors.c.


Generated on Wed Sep 23 09:33:30 2009 for ATMEL by  doxygen 1.5.3