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

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 89 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_ouput(), Usb_read_byte, USB_SETUP_GET_CLASS_INTER, USB_SETUP_GET_STAND_INTERFACE, and USB_SETUP_SET_CLASS_INTER.

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

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

References DIRECTION_IN, EP_MOUSE_IN, NYET_ENABLED, ONE_BANK, SIZE_8, TYPE_INTERRUPT, and usb_configure_endpoint.

00178 {
00179    usb_configure_endpoint( EP_MOUSE_IN,   \
00180                            TYPE_INTERRUPT,\
00181                            DIRECTION_IN,  \
00182                            SIZE_8,        \
00183                            ONE_BANK,      \
00184                            NYET_ENABLED);
00185 }

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

00195 {
00196    return 0;  // Only one alternate setting possible for all interface
00197 }

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

References EP_MOUSE_IN, INTERFACE_NB_MOUSE, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.

00206 {  
00207    // default setting selected = reset data toggle
00208    if( INTERFACE_NB_MOUSE == wInterface )
00209    {
00210       // Interface mouse
00211       Usb_select_endpoint(EP_MOUSE_IN);
00212       Usb_disable_stall_handshake();
00213       Usb_reset_endpoint(EP_MOUSE_IN);
00214       Usb_reset_data_toggle();
00215    }
00216 }

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

00227 {
00228    switch(type)
00229    {
00230       case DESCRIPTOR_STRING:
00231       switch (string)
00232       {
00233          case LANG_ID:
00234          data_to_transfer = sizeof (usb_user_language_id);
00235          pbuffer = &(usb_user_language_id.bLength);
00236          return TRUE;
00237          break;
00238         
00239          case MAN_INDEX:
00240          data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor);
00241          pbuffer = &(usb_user_manufacturer_string_descriptor.bLength);
00242          return TRUE;
00243          break;
00244         
00245          case PROD_INDEX:
00246          data_to_transfer = sizeof (usb_user_product_string_descriptor);
00247          pbuffer = &(usb_user_product_string_descriptor.bLength);
00248          return TRUE;
00249          break;
00250            
00251 #if (USB_DEVICE_SN_USE==ENABLE)              
00252          case SN_INDEX:
00253          data_to_transfer = sizeof (usb_user_serial_number);
00254          pbuffer = &(usb_user_serial_number.bLength);
00255 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00256          f_get_serial_string=TRUE;
00257          data_to_transfer += (SN_LENGTH*4);
00258 #endif
00259          return TRUE;
00260          break;
00261 #endif
00262       }
00263       break;
00264    }
00265    return FALSE;
00266 }


Variable Documentation

code S_usb_device_descriptor usb_dev_desc

Definition at line 68 of file usb_descriptors.c.

code S_usb_user_configuration_descriptor usb_conf_desc

Definition at line 87 of file usb_descriptors.c.

code S_usb_manufacturer_string_descriptor usb_user_manufacturer_string_descriptor

Definition at line 134 of file usb_descriptors.c.

code S_usb_product_string_descriptor usb_user_product_string_descriptor

Definition at line 143 of file usb_descriptors.c.

code S_usb_serial_number usb_user_serial_number

Definition at line 152 of file usb_descriptors.c.

code S_usb_language_id usb_user_language_id

Definition at line 166 of file usb_descriptors.c.


Generated on Fri Sep 11 15:04:26 2009 for ATMEL by  doxygen 1.5.3