USB device standard requests decoding module


Defines

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

Functions

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

Variables

volatile U8 usb_configuration_nb


Define Documentation

#define ADDRESSED   3

Definition at line 84 of file usb_standard_request.h.

#define ATTACHED   0

Definition at line 81 of file usb_standard_request.h.

#define CONFIGURED   4

Definition at line 85 of file usb_standard_request.h.

#define DEFAULT   2

Definition at line 83 of file usb_standard_request.h.

 
#define Is_device_enumerated (  )     (usb_configuration_nb != 0)

Returns TRUE when device connected and correctly enumerated with a host.

The device high-level application should test this before performing any applicative request.

Definition at line 98 of file usb_standard_request.h.

Referenced by device_template_task().

#define POWERED   1

Definition at line 82 of file usb_standard_request.h.

#define SUSPENDED   5

Definition at line 86 of file usb_standard_request.h.

#define USB_CONFIG_ATTRIBUTES_RESERVED   0x80

Definition at line 88 of file usb_standard_request.h.

#define USB_CONFIG_BUSPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x00)

Definition at line 89 of file usb_standard_request.h.

#define USB_CONFIG_REMOTEWAKEUP   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x20)

Definition at line 91 of file usb_standard_request.h.

#define USB_CONFIG_SELFPOWERED   (USB_CONFIG_ATTRIBUTES_RESERVED | 0x40)

Definition at line 90 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.

If the received request is not supported or a non-standard USB request, the function will call the custom decoding function in usb_specific_request module.

Note:
List of supported requests: GET_DESCRIPTOR GET_CONFIGURATION SET_ADDRESS SET_CONFIGURATION CLEAR_FEATURE SET_FEATURE GET_STATUS
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.

If the received request is not supported or a non-standard USB request, the function will call the custom decoding function in usb_specific_request module.

Note:
List of supported requests: GET_DESCRIPTOR GET_CONFIGURATION SET_ADDRESS SET_CONFIGURATION CLEAR_FEATURE SET_FEATURE GET_STATUS

< unsupported request => call to user read request

Definition at line 115 of file usb_standard_request.c.

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

Referenced by usb_device_task().

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


Variable Documentation

volatile U8 usb_configuration_nb


Generated on Fri Feb 19 02:27:52 2010 for AVR32 - USB Enumeration Example by  doxygen 1.5.5