USB device standard requests decoding module

Collaboration diagram for USB device standard requests decoding module:


Modules

 Standard requests defines

Defines

#define ATTACHED   0
#define POWERED   1
#define DEFAULT   2
#define ADDRESSED   3
#define CONFIGURED   4
#define SUSPENDED   5
#define USB_CONFIG_ATTRIBUTES_RESERVED   0x80
#define USB_CONFIG_BUSPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x00)
#define USB_CONFIG_SELFPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x40)
#define USB_CONFIG_REMOTEWAKEUP   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x20)
#define Is_device_enumerated()   ((usb_configuration_nb!=0) ? TRUE : FALSE)
 Returns true when device connected and correctly enumerated with an host.
#define Is_device_not_enumerated()   ((usb_configuration_nb!=0) ? FALSE : TRUE)

Functions

void usb_var_init (void)
void usb_process_request (void)
 This function reads the SETUP request sent to the default control endpoint and calls the appropriate function.

Variables

U8 usb_configuration_nb
 Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /.

Define Documentation

#define ATTACHED   0
 

Definition at line 92 of file usb_standard_request.h.

#define POWERED   1
 

Definition at line 93 of file usb_standard_request.h.

#define DEFAULT   2
 

Definition at line 94 of file usb_standard_request.h.

#define ADDRESSED   3
 

Definition at line 95 of file usb_standard_request.h.

#define CONFIGURED   4
 

Definition at line 96 of file usb_standard_request.h.

#define SUSPENDED   5
 

Definition at line 97 of file usb_standard_request.h.

#define USB_CONFIG_ATTRIBUTES_RESERVED   0x80
 

Definition at line 99 of file usb_standard_request.h.

#define USB_CONFIG_BUSPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x00)
 

Definition at line 100 of file usb_standard_request.h.

#define USB_CONFIG_SELFPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x40)
 

Definition at line 101 of file usb_standard_request.h.

#define USB_CONFIG_REMOTEWAKEUP   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x20)
 

Definition at line 102 of file usb_standard_request.h.

 
#define Is_device_enumerated  )     ((usb_configuration_nb!=0) ? TRUE : FALSE)
 

Returns true when device connected and correctly enumerated with an host.

The device high level application should tests this before performing any applicative requests

Definition at line 108 of file usb_standard_request.h.

Referenced by hid_task().

 
#define Is_device_not_enumerated  )     ((usb_configuration_nb!=0) ? FALSE : TRUE)
 

Definition at line 109 of file usb_standard_request.h.


Function Documentation

void usb_var_init void   ) 
 

void usb_process_request void   ) 
 

This function reads the SETUP request sent to the default control endpoint and calls the appropriate function.

Parameters:
none 
Returns:
none
Note:
list of supported requests: GET_DESCRIPTOR GET_CONFIGURATION SET_ADDRESS SET_CONFIGURATION CLEAR_FEATURE SET_FEATURE GET_STATUS
< un-supported request => call to user read request

Definition at line 119 of file usb_standard_request.c.

References bmRequestType, CLEAR_FEATURE, FALSE, GET_CONFIGURATION, GET_DESCRIPTOR, GET_INTERFACE, GET_STATUS, SET_ADDRESS, SET_CONFIGURATION, SET_DESCRIPTOR, SET_FEATURE, SET_INTERFACE, SYNCH_FRAME, Usb_ack_receive_setup, usb_clear_feature(), Usb_enable_stall_handshake, usb_get_configuration(), usb_get_descriptor(), usb_get_interface(), usb_get_status(), Usb_read_byte, usb_set_address(), usb_set_configuration(), usb_set_feature(), usb_set_interface(), and usb_user_read_request().

Referenced by usb_device_task().

00120 {
00121    U8  bmRequest;
00122 
00123    bmRequestType = Usb_read_byte();
00124    bmRequest     = Usb_read_byte();
00125 
00126    switch (bmRequest)
00127    {
00128     case GET_DESCRIPTOR:
00129          if (0x80 == bmRequestType) { usb_get_descriptor(); }
00130          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00131          break;
00132 
00133     case GET_CONFIGURATION:
00134          if (0x80 == bmRequestType) { usb_get_configuration(); }
00135          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00136          break;
00137 
00138     case SET_ADDRESS:
00139          if (0x00 == bmRequestType) { usb_set_address(); }
00140          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00141          break;
00142 
00143     case SET_CONFIGURATION:
00144          if (0x00 == bmRequestType) { usb_set_configuration(); }
00145          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00146          break;
00147 
00148     case CLEAR_FEATURE:
00149          if (0x02 >= bmRequestType) { usb_clear_feature(); }
00150          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00151          break;
00152 
00153     case SET_FEATURE:
00154          if (0x02 >= bmRequestType) { usb_set_feature(); }
00155          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00156          break;
00157 
00158     case GET_STATUS:
00159          if ((0x7F < bmRequestType) & (0x82 >= bmRequestType))
00160                                     { usb_get_status(); }
00161          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00162          break;
00163 
00164     case GET_INTERFACE:
00165           if (bmRequestType == 0x81) { usb_get_interface(); }
00166           else { usb_user_read_request(bmRequestType, bmRequest); }
00167           break;
00168 
00169 
00170     case SET_INTERFACE:
00171       if (bmRequestType == 0x01) {usb_set_interface();}
00172       break;
00173 
00174     case SET_DESCRIPTOR:
00175     case SYNCH_FRAME:
00176     default: 
00177          if(usb_user_read_request(bmRequestType, bmRequest) == FALSE)
00178          {
00179             Usb_enable_stall_handshake();
00180             Usb_ack_receive_setup();
00181             return;
00182          }
00183          break;
00184   }
00185 }

Here is the call graph for this function:


Variable Documentation

U8 usb_configuration_nb
 

Public : (U8) usb_configuration_nb Store the number of the USB configuration used by the USB device when its value is different from zero, it means the device mode is enumerated Used with USB_DEVICE_FEATURE == ENABLED only /.

Definition at line 70 of file usb_standard_request.c.


Generated on Fri Mar 17 16:02:13 2006 for Atmel by  doxygen 1.4.6-NO