#include "config.h"#include "conf_usb.h"#include "lib_mcu/usb/usb_drv.h"#include "usb_descriptors.h"#include "modules/usb/device_chap9/usb_standard_request.h"#include "usb_specific_request.h"#include "modules/control_access/ctrl_access.h"#include "lib_mcu/flash/flash_drv.h"
Go to the source code of this file.
Functions | |
| Bool | usb_user_read_request (U8 type, U8 request) |
| This function checks the specific request and if known then processes it | |
| void | usb_user_endpoint_init (U8 conf_nb) |
| U8 | usb_user_interface_get (U16 wInterface) |
| void | usb_user_interface_reset (U16 wInterface, U8 alternate_setting) |
| Bool | usb_user_get_descriptor (U8 type, U8 string) |
| This function fills the global descriptor. | |
Variables | |
| bit | ms_multiple_drive |
| U8 code * | pbuffer |
| U8 | data_to_transfer |
Definition in file usb_specific_request.c.
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 80 of file usb_specific_request.c.
Referenced by usb_process_request().
00081 { 00082 U16 wInterface; 00083 U8 wValue_msb; 00084 U8 wValue_lsb; 00085 00086 // Read wValue 00087 wValue_lsb = Usb_read_byte(); 00088 wValue_msb = Usb_read_byte(); 00089 00090 //** Specific request from Class MassStorage 00091 if( USB_SETUP_SET_CLASS_INTER == type ) 00092 { 00093 switch( request ) 00094 { 00095 case SETUP_MASS_STORAGE_RESET: 00096 // wValue must be 0 00097 // wIndex = Interface 00098 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00099 break; 00100 LSB(wInterface)=Usb_read_byte(); 00101 MSB(wInterface)=Usb_read_byte(); 00102 if( INTERFACE_NB != wInterface ) 00103 break; 00104 Usb_ack_receive_setup(); 00105 Usb_send_control_in(); 00106 return TRUE; 00107 break; 00108 } 00109 } 00110 if( USB_SETUP_GET_CLASS_INTER == type ) 00111 { 00112 switch( request ) 00113 { 00114 case SETUP_MASS_STORAGE_GET_MAX_LUN: 00115 // wValue must be 0 00116 // wIndex = Interface 00117 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00118 break; 00119 LSB(wInterface)=Usb_read_byte(); 00120 MSB(wInterface)=Usb_read_byte(); 00121 if( INTERFACE_NB != wInterface ) 00122 break; 00123 Usb_ack_receive_setup(); 00124 Usb_write_byte( (get_nb_lun()-1) ); 00125 Usb_send_control_in(); 00126 ms_multiple_drive = 1; 00127 return TRUE; 00128 break; 00129 } 00130 } 00131 00132 return FALSE; // No supported request 00133 }
| void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
This function configures the endpoints
| conf_nb | configuration number choosed by USB host |
Definition at line 140 of file usb_specific_request.c.
Referenced by usb_set_configuration().
00141 { 00142 usb_configure_endpoint(EP_MS_IN, \ 00143 TYPE_BULK, \ 00144 DIRECTION_IN, \ 00145 SIZE_64, \ 00146 TWO_BANKS, \ 00147 NYET_ENABLED); 00148 usb_configure_endpoint(EP_MS_OUT, \ 00149 TYPE_BULK, \ 00150 DIRECTION_OUT, \ 00151 SIZE_64, \ 00152 TWO_BANKS, \ 00153 NYET_ENABLED); 00154 }
This function returns the interface alternate setting
| wInterface | Interface selected |
Definition at line 163 of file usb_specific_request.c.
Referenced by usb_get_interface().
This function selects (and resets) the interface alternate setting
| wInterface | Interface selected | |
| alternate_setting | alternate setting selected |
Definition at line 174 of file usb_specific_request.c.
Referenced by usb_set_interface().
00175 { 00176 // default setting selected = reset data toggle 00177 if( INTERFACE_NB == wInterface ) 00178 { 00179 // Interface Mass Storage 00180 Usb_select_endpoint(EP_MS_IN); 00181 Usb_disable_stall_handshake(); 00182 Usb_reset_endpoint(EP_MS_IN); 00183 Usb_reset_data_toggle(); 00184 Usb_select_endpoint(EP_MS_OUT); 00185 Usb_disable_stall_handshake(); 00186 Usb_reset_endpoint(EP_MS_OUT); 00187 Usb_reset_data_toggle(); 00188 } 00189 }
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 199 of file usb_specific_request.c.
Referenced by usb_get_descriptor().
00200 { 00201 switch(type) 00202 { 00203 case DESCRIPTOR_STRING: 00204 switch (string) 00205 { 00206 case LANG_ID: 00207 data_to_transfer = sizeof (usb_user_language_id); 00208 pbuffer = &(usb_user_language_id.bLength); 00209 return TRUE; 00210 break; 00211 00212 case MAN_INDEX: 00213 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00214 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00215 return TRUE; 00216 break; 00217 00218 case PROD_INDEX: 00219 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00220 pbuffer = &(usb_user_product_string_descriptor.bLength); 00221 return TRUE; 00222 break; 00223 00224 #if (USB_DEVICE_SN_USE==ENABLE) 00225 case SN_INDEX: 00226 data_to_transfer = sizeof (usb_user_serial_number); 00227 pbuffer = &(usb_user_serial_number.bLength); 00228 #if (USE_DEVICE_SN_UNIQUE==ENABLE) 00229 f_get_serial_string=TRUE; 00230 data_to_transfer += (SN_LENGTH*4); 00231 #endif 00232 return TRUE; 00233 break; 00234 #endif 00235 } 00236 break; 00237 } 00238 return FALSE; 00239 }
Definition at line 60 of file usb_specific_request.c.
Definition at line 91 of file usb_standard_request.c.
Referenced by usb_get_descriptor(), and usb_user_get_descriptor().
Definition at line 96 of file usb_standard_request.c.
Referenced by usb_get_descriptor(), and usb_user_get_descriptor().
1.5.3