USB device standard requests decoding module


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. The device high level application should tests this before performing any applicative requests.
#define Is_device_not_enumerated()   ((usb_configuration_nb!=0) ? FALSE : TRUE)

Functions

void usb_process_request (void)
 This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. When exiting of the usb_read_request function, the device is ready to manage the next request.

Variables

U8 usb_configuration_nb

Define Documentation

#define ATTACHED   0

Definition at line 41 of file usb_standard_request.h.

#define POWERED   1

Definition at line 42 of file usb_standard_request.h.

#define DEFAULT   2

Definition at line 43 of file usb_standard_request.h.

#define ADDRESSED   3

Definition at line 44 of file usb_standard_request.h.

#define CONFIGURED   4

Definition at line 45 of file usb_standard_request.h.

#define SUSPENDED   5

Definition at line 46 of file usb_standard_request.h.

#define USB_CONFIG_ATTRIBUTES_RESERVED   0x80

Definition at line 48 of file usb_standard_request.h.

#define USB_CONFIG_BUSPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x00)

Definition at line 49 of file usb_standard_request.h.

#define USB_CONFIG_SELFPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x40)

Definition at line 50 of file usb_standard_request.h.

#define USB_CONFIG_REMOTEWAKEUP   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x20)

Definition at line 51 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 57 of file usb_standard_request.h.

Referenced by hid_task().

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

Definition at line 58 of file usb_standard_request.h.


Function Documentation

void usb_process_request ( void   ) 

This function reads the SETUP request sent to the default control endpoint and calls the appropriate function. When exiting of the usb_read_request function, the device is ready to manage the next request.

usb_process_request.

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 95 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().

00096 {
00097    U8  bmRequest;
00098 
00099    bmRequestType = Usb_read_byte();
00100    bmRequest     = Usb_read_byte();
00101 
00102    switch (bmRequest)
00103    {
00104     case GET_DESCRIPTOR:
00105          if (0x80 == bmRequestType) { usb_get_descriptor(); }
00106          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00107          break;
00108 
00109     case GET_CONFIGURATION:
00110          if (0x80 == bmRequestType) { usb_get_configuration(); }
00111          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00112          break;
00113 
00114     case SET_ADDRESS:
00115          if (0x00 == bmRequestType) { usb_set_address(); }
00116          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00117          break;
00118 
00119     case SET_CONFIGURATION:
00120          if (0x00 == bmRequestType) { usb_set_configuration(); }
00121          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00122          break;
00123 
00124     case CLEAR_FEATURE:
00125          if (0x02 >= bmRequestType) { usb_clear_feature(); }
00126          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00127          break;
00128 
00129     case SET_FEATURE:
00130          if (0x02 >= bmRequestType) { usb_set_feature(); }
00131          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00132          break;
00133 
00134     case GET_STATUS:
00135          if ((0x7F < bmRequestType) & (0x82 >= bmRequestType))
00136                                     { usb_get_status(); }
00137          else                       { usb_user_read_request(bmRequestType, bmRequest); }
00138          break;
00139 
00140     case GET_INTERFACE:
00141           if (bmRequestType == 0x81) { usb_get_interface(); }
00142           else { usb_user_read_request(bmRequestType, bmRequest); }
00143           break;
00144 
00145 
00146     case SET_INTERFACE:
00147       if (bmRequestType == 0x01) {usb_set_interface();}
00148       break;
00149 
00150     case SET_DESCRIPTOR:
00151     case SYNCH_FRAME:
00152     default: 
00153          if(usb_user_read_request(bmRequestType, bmRequest) == FALSE)
00154          {
00155             Usb_enable_stall_handshake();
00156             Usb_ack_receive_setup();
00157             return;
00158          }
00159          break;
00160   }
00161 }

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 Jan 26 17:33:10 2007 for Atmel by  doxygen 1.5.1-p1