#include "config.h"
Go to the source code of this file.
Data Structures | |
| 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 |
Definition in file usb_specific_request.h.
This function checks the specific request and if known then processes it
| type | corresponding at bmRequestType (see USB specification) | |
| request | corresponding at bRequest (see USB specification) |
FALSE, if the request is'nt know (STALL handshake is managed by the main standard request function).
Definition at line 91 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_feature(), usb_hid_set_report_ouput(), Usb_read_byte, USB_SETUP_GET_CLASS_INTER, USB_SETUP_GET_STAND_INTERFACE, and USB_SETUP_SET_CLASS_INTER.
00092 { 00093 U8 wValue_msb; 00094 U8 wValue_lsb; 00095 00096 // Read wValue 00097 wValue_lsb = Usb_read_byte(); 00098 wValue_msb = Usb_read_byte(); 00099 00100 //** Specific request from Class HID 00101 if( USB_SETUP_GET_STAND_INTERFACE == type ) 00102 { 00103 switch( request ) 00104 { 00105 case SETUP_GET_DESCRIPTOR: 00106 switch( wValue_msb ) // Descriptor ID 00107 { 00108 case DESCRIPTOR_HID: 00109 hid_get_hid_descriptor(); 00110 return TRUE; 00111 break; 00112 00113 case DESCRIPTOR_REPORT: 00114 hid_get_report_descriptor(); 00115 return TRUE; 00116 00117 case DESCRIPTOR_PHYSICAL: 00118 // TODO 00119 break; 00120 } 00121 break; 00122 } 00123 } 00124 if( USB_SETUP_SET_CLASS_INTER == type ) 00125 { 00126 switch( request ) 00127 { 00128 case SETUP_HID_SET_REPORT: 00129 // The MSB wValue field specifies the Report Type 00130 // The LSB wValue field specifies the Report ID 00131 switch (wValue_msb) 00132 { 00133 case REPORT_TYPE_INPUT: 00134 // TODO 00135 break; 00136 00137 case REPORT_TYPE_OUTPUT: 00138 usb_hid_set_report_ouput(); 00139 return TRUE; 00140 break; 00141 00142 case REPORT_TYPE_FEATURE: 00143 usb_hid_set_report_feature(); 00144 return TRUE; 00145 break; 00146 } 00147 break; 00148 00149 case SETUP_HID_SET_IDLE: 00150 usb_hid_set_idle(wValue_lsb,wValue_msb); 00151 return TRUE; 00152 00153 case SETUP_HID_SET_PROTOCOL: 00154 // TODO 00155 break; 00156 } 00157 } 00158 if( USB_SETUP_GET_CLASS_INTER == type ) 00159 { 00160 switch( request ) 00161 { 00162 case SETUP_HID_GET_REPORT: 00163 // TODO 00164 break; 00165 case SETUP_HID_GET_IDLE: 00166 usb_hid_get_idle(wValue_lsb); 00167 return TRUE; 00168 case SETUP_HID_GET_PROTOCOL: 00169 // TODO 00170 break; 00171 } 00172 } 00173 return FALSE; // No supported request 00174 }
| void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
This function configures the endpoints
| conf_nb | configuration number choosed by USB host |
Definition at line 181 of file usb_specific_request.c.
References DIRECTION_IN, DIRECTION_OUT, EP_HID_IN, EP_HID_OUT, NYET_ENABLED, ONE_BANK, SIZE_8, TYPE_INTERRUPT, and usb_configure_endpoint.
00182 { 00183 usb_configure_endpoint( EP_HID_IN, \ 00184 TYPE_INTERRUPT,\ 00185 DIRECTION_IN, \ 00186 SIZE_8, \ 00187 ONE_BANK, \ 00188 NYET_ENABLED); 00189 00190 usb_configure_endpoint( EP_HID_OUT, \ 00191 TYPE_INTERRUPT,\ 00192 DIRECTION_OUT, \ 00193 SIZE_8, \ 00194 ONE_BANK, \ 00195 NYET_ENABLED); 00196 }
This function returns the interface alternate setting
| wInterface | Interface selected |
Definition at line 205 of file usb_specific_request.c.
This function selects (and resets) the interface alternate setting
| wInterface | Interface selected | |
| alternate_setting | alternate setting selected |
Definition at line 216 of file usb_specific_request.c.
References EP_HID_IN, EP_HID_OUT, INTERFACE_NB, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.
00217 { 00218 // default setting selected = reset data toggle 00219 if( INTERFACE_NB == wInterface ) 00220 { 00221 // Interface HID 00222 Usb_select_endpoint(EP_HID_IN); 00223 Usb_disable_stall_handshake(); 00224 Usb_reset_endpoint(EP_HID_IN); 00225 Usb_reset_data_toggle(); 00226 Usb_select_endpoint(EP_HID_OUT); 00227 Usb_disable_stall_handshake(); 00228 Usb_reset_endpoint(EP_HID_OUT); 00229 Usb_reset_data_toggle(); 00230 } 00231 }
This function fills the global descriptor.
| type | corresponding at MSB of wValue (see USB specification) | |
| string | corresponding at LSB of wValue (see USB specification) |
Definition at line 241 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.
00242 { 00243 switch(type) 00244 { 00245 case DESCRIPTOR_STRING: 00246 switch (string) 00247 { 00248 case LANG_ID: 00249 data_to_transfer = sizeof (usb_user_language_id); 00250 pbuffer = &(usb_user_language_id.bLength); 00251 return TRUE; 00252 break; 00253 00254 case MAN_INDEX: 00255 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00256 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00257 return TRUE; 00258 break; 00259 00260 case PROD_INDEX: 00261 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00262 pbuffer = &(usb_user_product_string_descriptor.bLength); 00263 return TRUE; 00264 break; 00265 00266 #if (USB_DEVICE_SN_USE==ENABLE) 00267 case SN_INDEX: 00268 data_to_transfer = sizeof (usb_user_serial_number); 00269 pbuffer = &(usb_user_serial_number.bLength); 00270 #if (USE_DEVICE_SN_UNIQUE==ENABLE) 00271 f_get_serial_string=TRUE; 00272 data_to_transfer += (SN_LENGTH*4); 00273 #endif 00274 return TRUE; 00275 break; 00276 #endif 00277 } 00278 break; 00279 } 00280 return FALSE; 00281 }
Definition at line 69 of file usb_descriptors.c.
Definition at line 88 of file usb_descriptors.c.
Definition at line 143 of file usb_descriptors.c.
Definition at line 152 of file usb_descriptors.c.
Definition at line 161 of file usb_descriptors.c.
Definition at line 175 of file usb_descriptors.c.
1.5.3