#include "config.h"
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 |
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 92 of file usb_specific_request.c.
References DESCRIPTOR_HID, DESCRIPTOR_PHYSICAL, DESCRIPTOR_REPORT, FALSE, get_nb_lun(), hid_get_hid_descriptor(), hid_get_report_descriptor(), INTERFACE_NB, Is_usb_in_ready, Is_usb_receive_out, LSB, ms_multiple_drive, MSB, 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, SETUP_MASS_STORAGE_GET_MAX_LUN, SETUP_MASS_STORAGE_RESET, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, usb_hid_get_idle(), usb_hid_set_idle(), usb_hid_set_report_ouput(), Usb_read_byte, Usb_send_control_in, USB_SETUP_GET_CLASS_INTER, USB_SETUP_GET_STAND_INTERFACE, USB_SETUP_SET_CLASS_INTER, and Usb_write_byte.
00093 { 00094 U16 wInterface; 00095 U8 wValue_msb; 00096 U8 wValue_lsb; 00097 00098 // Read wValue 00099 wValue_lsb = Usb_read_byte(); 00100 wValue_msb = Usb_read_byte(); 00101 00102 //** Specific request from Class HID 00103 if( USB_SETUP_GET_STAND_INTERFACE == type ) 00104 { 00105 switch( request ) 00106 { 00107 case SETUP_GET_DESCRIPTOR: 00108 switch( wValue_msb ) // Descriptor ID 00109 { 00110 case DESCRIPTOR_HID: 00111 hid_get_hid_descriptor(); 00112 return TRUE; 00113 break; 00114 00115 case DESCRIPTOR_REPORT: 00116 hid_get_report_descriptor(); 00117 return TRUE; 00118 00119 case DESCRIPTOR_PHYSICAL: 00120 // TODO 00121 break; 00122 } 00123 break; 00124 } 00125 } 00126 if( USB_SETUP_SET_CLASS_INTER == type ) 00127 { 00128 switch( request ) 00129 { 00130 case SETUP_HID_SET_REPORT: 00131 // The MSB wValue field specifies the Report Type 00132 // The LSB wValue field specifies the Report ID 00133 switch (wValue_msb) 00134 { 00135 case REPORT_TYPE_INPUT: 00136 // TODO 00137 break; 00138 00139 case REPORT_TYPE_OUTPUT: 00140 usb_hid_set_report_ouput(); 00141 return TRUE; 00142 break; 00143 00144 case REPORT_TYPE_FEATURE: 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 00174 //** Specific request from Class MassStorage 00175 if( USB_SETUP_SET_CLASS_INTER == type ) 00176 { 00177 switch( request ) 00178 { 00179 case SETUP_MASS_STORAGE_RESET: 00180 // wValue must be 0 00181 // wIndex = Interface 00182 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00183 break; 00184 LSB(wInterface)=Usb_read_byte(); 00185 MSB(wInterface)=Usb_read_byte(); 00186 if( INTERFACE_NB != wInterface ) 00187 break; 00188 Usb_ack_receive_setup(); 00189 Usb_send_control_in(); 00190 while(!Is_usb_in_ready()); 00191 return TRUE; 00192 break; 00193 } 00194 } 00195 if( USB_SETUP_GET_CLASS_INTER == type ) 00196 { 00197 switch( request ) 00198 { 00199 case SETUP_MASS_STORAGE_GET_MAX_LUN: 00200 // wValue must be 0 00201 // wIndex = Interface 00202 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00203 break; 00204 LSB(wInterface)=Usb_read_byte(); 00205 MSB(wInterface)=Usb_read_byte(); 00206 if( INTERFACE_NB != wInterface ) 00207 break; 00208 Usb_ack_receive_setup(); 00209 Usb_write_byte( (get_nb_lun()-1) ); 00210 Usb_send_control_in(); 00211 while(!Is_usb_in_ready()); 00212 while( !Is_usb_receive_out() ); 00213 Usb_ack_receive_out(); 00214 ms_multiple_drive = 1; 00215 return TRUE; 00216 break; 00217 } 00218 } 00219 00220 return FALSE; // No supported request 00221 }
| void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
This function configures the endpoints
| conf_nb | configuration number choosed by USB host |
Definition at line 228 of file usb_specific_request.c.
References DIRECTION_IN, DIRECTION_OUT, EP_MOUSE_IN, EP_MS_IN, EP_MS_OUT, NYET_ENABLED, ONE_BANK, SIZE_64, SIZE_8, TYPE_BULK, TYPE_INTERRUPT, and usb_configure_endpoint.
00229 { 00230 usb_configure_endpoint( EP_MOUSE_IN, \ 00231 TYPE_INTERRUPT,\ 00232 DIRECTION_IN, \ 00233 SIZE_8, \ 00234 ONE_BANK, \ 00235 NYET_ENABLED); 00236 00237 usb_configure_endpoint( EP_MS_IN, \ 00238 TYPE_BULK, \ 00239 DIRECTION_IN, \ 00240 SIZE_64, \ 00241 ONE_BANK, \ 00242 NYET_ENABLED); 00243 00244 usb_configure_endpoint( EP_MS_OUT, \ 00245 TYPE_BULK, \ 00246 DIRECTION_OUT, \ 00247 SIZE_64, \ 00248 ONE_BANK, \ 00249 NYET_ENABLED); 00250 }
This function returns the interface alternate setting
| wInterface | Interface selected |
Definition at line 259 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 270 of file usb_specific_request.c.
References EP_MOUSE_IN, EP_MS_IN, EP_MS_OUT, INTERFACE_NB, INTERFACE_NB_MOUSE, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.
00271 { 00272 // default setting selected = reset data toggle 00273 if( INTERFACE_NB_MOUSE == wInterface ) 00274 { 00275 // Interface mouse 00276 Usb_select_endpoint(EP_MOUSE_IN); 00277 Usb_disable_stall_handshake(); 00278 Usb_reset_endpoint(EP_MOUSE_IN); 00279 Usb_reset_data_toggle(); 00280 } 00281 if( INTERFACE_NB == wInterface ) 00282 { 00283 // Interface Mass Storage 00284 Usb_select_endpoint(EP_MS_IN); 00285 Usb_disable_stall_handshake(); 00286 Usb_reset_endpoint(EP_MS_IN); 00287 Usb_reset_data_toggle(); 00288 Usb_select_endpoint(EP_MS_OUT); 00289 Usb_disable_stall_handshake(); 00290 Usb_reset_endpoint(EP_MS_OUT); 00291 Usb_reset_data_toggle(); 00292 } 00293 }
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 303 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.
00304 { 00305 switch(type) 00306 { 00307 case DESCRIPTOR_STRING: 00308 switch (string) 00309 { 00310 case LANG_ID: 00311 data_to_transfer = sizeof (usb_user_language_id); 00312 pbuffer = &(usb_user_language_id.bLength); 00313 return TRUE; 00314 break; 00315 00316 case MAN_INDEX: 00317 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00318 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00319 return TRUE; 00320 break; 00321 00322 case PROD_INDEX: 00323 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00324 pbuffer = &(usb_user_product_string_descriptor.bLength); 00325 return TRUE; 00326 break; 00327 00328 #if (USB_DEVICE_SN_USE==ENABLE) 00329 case SN_INDEX: 00330 data_to_transfer = sizeof (usb_user_serial_number); 00331 pbuffer = &(usb_user_serial_number.bLength); 00332 #if (USE_DEVICE_SN_UNIQUE==ENABLE) 00333 f_get_serial_string=TRUE; 00334 data_to_transfer += (SN_LENGTH*4); 00335 #endif 00336 return TRUE; 00337 break; 00338 #endif 00339 } 00340 break; 00341 } 00342 return FALSE; 00343 }
Definition at line 69 of file usb_descriptors.c.
Definition at line 88 of file usb_descriptors.c.
Definition at line 164 of file usb_descriptors.c.
Definition at line 173 of file usb_descriptors.c.
Definition at line 182 of file usb_descriptors.c.
Definition at line 197 of file usb_descriptors.c.
1.5.3