Functions | |
void | usb_user_endpoint_init (U8) |
This function configures the endpoints of the device application. | |
Bool | usb_user_get_descriptor (U8, U8) |
This function returns the size and the pointer on a user information structure. | |
Bool | usb_user_read_request (U8, U8) |
This function is called by the standard USB read request function when the USB request is not supported. |
void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
This function configures the endpoints of the device application.
This function is called when the set configuration request has been received.
The core of this function should be correctly rewritten depending on the USB device application characteristics (the USB device application has specific endpoint configuration).
This function is called when the set configuration request has been received.
Definition at line 81 of file usb_specific_request.c.
References EP_ATTRIBUTES_1, EP_ATTRIBUTES_2, EP_MS_IN, EP_MS_OUT, EP_SIZE_1_FS, EP_SIZE_1_HS, EP_SIZE_2_FS, EP_SIZE_2_HS, and ms_multiple_drive.
00082 { 00083 ms_multiple_drive = FALSE; 00084 00085 #if (USB_HIGH_SPEED_SUPPORT==ENABLED) 00086 if( !Is_usb_full_speed_mode() ) 00087 { 00088 (void)Usb_configure_endpoint(EP_MS_IN, 00089 EP_ATTRIBUTES_1, 00090 DIRECTION_IN, 00091 EP_SIZE_1_HS, 00092 DOUBLE_BANK); 00093 00094 (void)Usb_configure_endpoint(EP_MS_OUT, 00095 EP_ATTRIBUTES_2, 00096 DIRECTION_OUT, 00097 EP_SIZE_2_HS, 00098 DOUBLE_BANK); 00099 return; 00100 } 00101 #endif 00102 (void)Usb_configure_endpoint(EP_MS_IN, 00103 EP_ATTRIBUTES_1, 00104 DIRECTION_IN, 00105 EP_SIZE_1_FS, 00106 DOUBLE_BANK); 00107 00108 (void)Usb_configure_endpoint(EP_MS_OUT, 00109 EP_ATTRIBUTES_2, 00110 DIRECTION_OUT, 00111 EP_SIZE_2_FS, 00112 DOUBLE_BANK); 00113 }
Bool usb_user_get_descriptor | ( | U8 | , | |
U8 | ||||
) |
This function returns the size and the pointer on a user information structure.
Definition at line 182 of file usb_specific_request.c.
References data_to_transfer, LANG_ID, MAN_INDEX, pbuffer, PROD_INDEX, SN_INDEX, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.
00183 { 00184 pbuffer = NULL; 00185 00186 switch (type) 00187 { 00188 case STRING_DESCRIPTOR: 00189 switch (string) 00190 { 00191 case LANG_ID: 00192 data_to_transfer = sizeof(usb_user_language_id); 00193 pbuffer = &usb_user_language_id; 00194 break; 00195 00196 case MAN_INDEX: 00197 data_to_transfer = sizeof(usb_user_manufacturer_string_descriptor); 00198 pbuffer = &usb_user_manufacturer_string_descriptor; 00199 break; 00200 00201 case PROD_INDEX: 00202 data_to_transfer = sizeof(usb_user_product_string_descriptor); 00203 pbuffer = &usb_user_product_string_descriptor; 00204 break; 00205 00206 case SN_INDEX: 00207 data_to_transfer = sizeof(usb_user_serial_number); 00208 pbuffer = &usb_user_serial_number; 00209 break; 00210 00211 default: 00212 break; 00213 } 00214 break; 00215 00216 default: 00217 break; 00218 } 00219 00220 return pbuffer != NULL; 00221 }
Bool usb_user_read_request | ( | U8 | type, | |
U8 | request | |||
) |
This function is called by the standard USB read request function when the USB request is not supported.
This function returns TRUE when the request is processed. This function returns FALSE if the request is not supported. In this case, a STALL handshake will be automatically sent by the standard USB read request function.
Definition at line 122 of file usb_specific_request.c.
References GET_MAX_LUN, INTERFACE_NB, MASS_STORAGE_RESET, and ms_multiple_drive.
00123 { 00124 U16 wInterface; 00125 U8 wValue_msb; 00126 U8 wValue_lsb; 00127 00128 wValue_lsb = Usb_read_endpoint_data(EP_CONTROL, 8); 00129 wValue_msb = Usb_read_endpoint_data(EP_CONTROL, 8); 00130 00131 //** Specific request from Class MassStorage 00132 if( USB_SETUP_SET_CLASS_INTER == type ) 00133 { 00134 switch( request ) 00135 { 00136 case MASS_STORAGE_RESET: 00137 // wValue must be 0 00138 // wIndex = Interface 00139 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00140 break; 00141 wInterface=Usb_read_endpoint_data(EP_CONTROL, 16); 00142 if( INTERFACE_NB != wInterface ) 00143 break; 00144 Usb_ack_setup_received_free(); 00145 Usb_ack_control_in_ready_send(); 00146 return TRUE; 00147 } 00148 } 00149 if( USB_SETUP_GET_CLASS_INTER == type ) 00150 { 00151 switch( request ) 00152 { 00153 case GET_MAX_LUN: 00154 // wValue must be 0 00155 // wIndex = Interface 00156 if( (0!=wValue_lsb) || (0!=wValue_msb) ) 00157 break; 00158 wInterface=Usb_read_endpoint_data(EP_CONTROL, 16); 00159 if( INTERFACE_NB != wInterface ) 00160 break; 00161 Usb_ack_setup_received_free(); 00162 Usb_reset_endpoint_fifo_access(EP_CONTROL); 00163 Usb_write_endpoint_data(EP_CONTROL, 8, get_nb_lun() - 1); 00164 Usb_ack_control_in_ready_send(); 00165 while (!Is_usb_control_in_ready()); 00166 00167 while(!Is_usb_control_out_received()); 00168 Usb_ack_control_out_received_free(); 00169 00170 ms_multiple_drive = TRUE; 00171 return TRUE; 00172 } 00173 } 00174 00175 return FALSE; 00176 }