#include "config.h"
Go to the source code of this file.
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 83 of file usb_specific_request.c.
References FALSE, get_nb_lun(), INTERFACE_NB, Is_usb_in_ready, Is_usb_receive_out, LSB, ms_multiple_drive, MSB, SETUP_MASS_STORAGE_GET_MAX_LUN, SETUP_MASS_STORAGE_RESET, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, Usb_read_byte, Usb_send_control_in, USB_SETUP_GET_CLASS_INTER, USB_SETUP_SET_CLASS_INTER, and Usb_write_byte.
00084 { 00085 U16 wInterface; 00086 U8 wValue_msb; 00087 U8 wValue_lsb; 00088 00089 // Read wValue 00090 wValue_lsb = Usb_read_byte(); 00091 wValue_msb = Usb_read_byte(); 00092 00093 //** Specific request from Class MassStorage 00094 if( USB_SETUP_SET_CLASS_INTER == type ) 00095 { 00096 switch( request ) 00097 { 00098 case SETUP_MASS_STORAGE_RESET: 00099 // wValue must be 0 00100 // wIndex = Interface 00101 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00102 break; 00103 LSB(wInterface)=Usb_read_byte(); 00104 MSB(wInterface)=Usb_read_byte(); 00105 if( INTERFACE_NB != wInterface ) 00106 break; 00107 Usb_ack_receive_setup(); 00108 Usb_send_control_in(); 00109 while(!Is_usb_in_ready()); 00110 return TRUE; 00111 break; 00112 } 00113 } 00114 if( USB_SETUP_GET_CLASS_INTER == type ) 00115 { 00116 switch( request ) 00117 { 00118 case SETUP_MASS_STORAGE_GET_MAX_LUN: 00119 // wValue must be 0 00120 // wIndex = Interface 00121 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00122 break; 00123 LSB(wInterface)=Usb_read_byte(); 00124 MSB(wInterface)=Usb_read_byte(); 00125 if( INTERFACE_NB != wInterface ) 00126 break; 00127 Usb_ack_receive_setup(); 00128 Usb_write_byte( (get_nb_lun()-1) ); 00129 Usb_send_control_in(); 00130 while(!Is_usb_in_ready()); 00131 while( !Is_usb_receive_out() ); 00132 Usb_ack_receive_out(); 00133 ms_multiple_drive = 1; 00134 return TRUE; 00135 break; 00136 } 00137 } 00138 00139 return FALSE; // No supported request 00140 }
void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
This function configures the endpoints
conf_nb | configuration number choosed by USB host |
Definition at line 147 of file usb_specific_request.c.
References DIRECTION_IN, DIRECTION_OUT, EP_MS_IN, EP_MS_OUT, NYET_ENABLED, SIZE_64, TWO_BANKS, TYPE_BULK, and usb_configure_endpoint.
00148 { 00149 usb_configure_endpoint(EP_MS_IN, \ 00150 TYPE_BULK, \ 00151 DIRECTION_IN, \ 00152 SIZE_64, \ 00153 TWO_BANKS, \ 00154 NYET_ENABLED); 00155 usb_configure_endpoint(EP_MS_OUT, \ 00156 TYPE_BULK, \ 00157 DIRECTION_OUT, \ 00158 SIZE_64, \ 00159 TWO_BANKS, \ 00160 NYET_ENABLED); 00161 }
This function returns the interface alternate setting
wInterface | Interface selected |
Definition at line 170 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 181 of file usb_specific_request.c.
References EP_MS_IN, EP_MS_OUT, INTERFACE_NB, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.
00182 { 00183 // default setting selected = reset data toggle 00184 if( INTERFACE_NB == wInterface ) 00185 { 00186 // Interface Mass Storage 00187 Usb_select_endpoint(EP_MS_IN); 00188 Usb_disable_stall_handshake(); 00189 Usb_reset_endpoint(EP_MS_IN); 00190 Usb_reset_data_toggle(); 00191 Usb_select_endpoint(EP_MS_OUT); 00192 Usb_disable_stall_handshake(); 00193 Usb_reset_endpoint(EP_MS_OUT); 00194 Usb_reset_data_toggle(); 00195 } 00196 }
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 206 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.
00207 { 00208 switch(type) 00209 { 00210 case DESCRIPTOR_STRING: 00211 switch (string) 00212 { 00213 case LANG_ID: 00214 data_to_transfer = sizeof (usb_user_language_id); 00215 pbuffer = &(usb_user_language_id.bLength); 00216 return TRUE; 00217 break; 00218 00219 case MAN_INDEX: 00220 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00221 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00222 return TRUE; 00223 break; 00224 00225 case PROD_INDEX: 00226 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00227 pbuffer = &(usb_user_product_string_descriptor.bLength); 00228 return TRUE; 00229 break; 00230 00231 #if (USB_DEVICE_SN_USE==ENABLE) 00232 case SN_INDEX: 00233 data_to_transfer = sizeof (usb_user_serial_number); 00234 pbuffer = &(usb_user_serial_number.bLength); 00235 #if (USE_DEVICE_SN_UNIQUE==ENABLE) 00236 f_get_serial_string=TRUE; 00237 data_to_transfer += (SN_LENGTH*4); 00238 #endif 00239 return TRUE; 00240 break; 00241 #endif 00242 } 00243 break; 00244 } 00245 return FALSE; 00246 }
Definition at line 69 of file usb_descriptors.c.
Definition at line 88 of file usb_descriptors.c.
Definition at line 133 of file usb_descriptors.c.
Definition at line 142 of file usb_descriptors.c.
Definition at line 151 of file usb_descriptors.c.
Definition at line 165 of file usb_descriptors.c.