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 189 of file usb_specific_request.c.
References EP_ATTRIBUTES_1, EP_HID_MOUSE_IN, EP_SIZE_1_FS, and EP_SIZE_1_HS.
00190 { 00191 #if (USB_HIGH_SPEED_SUPPORT==DISABLED) 00192 (void)Usb_configure_endpoint(EP_HID_MOUSE_IN, 00193 EP_ATTRIBUTES_1, 00194 DIRECTION_IN, 00195 EP_SIZE_1_FS, 00196 SINGLE_BANK); 00197 00198 #else 00199 if( Is_usb_full_speed_mode() ) 00200 { 00201 (void)Usb_configure_endpoint(EP_HID_MOUSE_IN, 00202 EP_ATTRIBUTES_1, 00203 DIRECTION_IN, 00204 EP_SIZE_1_FS, 00205 SINGLE_BANK); 00206 }else{ 00207 (void)Usb_configure_endpoint(EP_HID_MOUSE_IN, 00208 EP_ATTRIBUTES_1, 00209 DIRECTION_IN, 00210 EP_SIZE_1_HS, 00211 SINGLE_BANK); 00212 } 00213 #endif 00214 }
Bool usb_user_get_descriptor | ( | U8 | , | |
U8 | ||||
) |
This function returns the size and the pointer on a user information structure.
Definition at line 337 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.
00338 { 00339 pbuffer = NULL; 00340 00341 switch (type) 00342 { 00343 case STRING_DESCRIPTOR: 00344 switch (string) 00345 { 00346 case LANG_ID: 00347 data_to_transfer = sizeof(usb_user_language_id); 00348 pbuffer = &usb_user_language_id; 00349 break; 00350 00351 case MAN_INDEX: 00352 data_to_transfer = sizeof(usb_user_manufacturer_string_descriptor); 00353 pbuffer = &usb_user_manufacturer_string_descriptor; 00354 break; 00355 00356 case PROD_INDEX: 00357 data_to_transfer = sizeof(usb_user_product_string_descriptor); 00358 pbuffer = &usb_user_product_string_descriptor; 00359 break; 00360 00361 case SN_INDEX: 00362 data_to_transfer = sizeof(usb_user_serial_number); 00363 pbuffer = &usb_user_serial_number; 00364 break; 00365 00366 default: 00367 break; 00368 } 00369 break; 00370 00371 default: 00372 break; 00373 } 00374 00375 return pbuffer != NULL; 00376 }
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 223 of file usb_specific_request.c.
References HID_DESCRIPTOR, hid_get_descriptor(), HID_GET_IDLE, HID_GET_PROTOCOL, HID_GET_REPORT, S_usb_user_configuration_descriptor::hid_mouse, HID_PHYSICAL_DESCRIPTOR, HID_REPORT_DESCRIPTOR, HID_REPORT_FEATURE, HID_REPORT_INPUT, HID_REPORT_OUTPUT, HID_SET_IDLE, HID_SET_PROTOCOL, HID_SET_REPORT, usb_conf_desc_fs, usb_conf_desc_hs, usb_hid_get_idle(), usb_hid_report_descriptor_mouse, and usb_hid_set_idle().
00224 { 00225 U8 wValue_msb; 00226 U8 wValue_lsb; 00227 00228 // Read wValue 00229 wValue_lsb = Usb_read_endpoint_data(EP_CONTROL, 8); 00230 wValue_msb = Usb_read_endpoint_data(EP_CONTROL, 8); 00231 /* 00232 U8 descriptor_type; 00233 00234 Usb_read_endpoint_data(EP_CONTROL, 8); // string_type 00235 descriptor_type = Usb_read_endpoint_data(EP_CONTROL, 8); 00236 */ 00237 00238 //** Specific request from Class HID 00239 if( 0x81 == type ) // USB_SETUP_GET_STAND_INTERFACE 00240 { 00241 switch( request ) 00242 { 00243 case GET_DESCRIPTOR: 00244 switch( wValue_msb ) // Descriptor ID 00245 { 00246 #if (USB_HIGH_SPEED_SUPPORT==DISABLED) 00247 case HID_DESCRIPTOR: 00248 hid_get_descriptor( 00249 sizeof(usb_conf_desc_fs.hid_mouse) 00250 , (const U8*)&usb_conf_desc_fs.hid_mouse); 00251 return TRUE; 00252 #else 00253 case HID_DESCRIPTOR: 00254 if( Is_usb_full_speed_mode() ) 00255 { 00256 hid_get_descriptor( 00257 sizeof(usb_conf_desc_fs.hid_mouse) 00258 , (const U8*)&usb_conf_desc_fs.hid_mouse); 00259 }else{ 00260 hid_get_descriptor( 00261 sizeof(usb_conf_desc_hs.hid_mouse) 00262 , (const U8*)&usb_conf_desc_hs.hid_mouse); 00263 } 00264 return TRUE; 00265 #endif 00266 00267 case HID_REPORT_DESCRIPTOR: 00268 hid_get_descriptor( 00269 sizeof(usb_hid_report_descriptor_mouse) 00270 , usb_hid_report_descriptor_mouse); 00271 return TRUE; 00272 00273 case HID_PHYSICAL_DESCRIPTOR: 00274 // TODO 00275 break; 00276 } 00277 break; 00278 } 00279 } 00280 if( 0x21 == type ) // USB_SETUP_SET_CLASS_INTER 00281 { 00282 switch( request ) 00283 { 00284 case HID_SET_REPORT: 00285 // The MSB wValue field specifies the Report Type 00286 // The LSB wValue field specifies the Report ID 00287 switch (wValue_msb) 00288 { 00289 case HID_REPORT_INPUT: 00290 // TODO 00291 break; 00292 00293 case HID_REPORT_OUTPUT: 00294 Usb_ack_setup_received_free(); 00295 while (!Is_usb_control_out_received()); 00296 Usb_ack_control_out_received_free(); 00297 Usb_ack_control_in_ready_send(); 00298 while (!Is_usb_control_in_ready()); 00299 return TRUE; 00300 00301 case HID_REPORT_FEATURE: 00302 break; 00303 } 00304 break; 00305 00306 case HID_SET_IDLE: 00307 usb_hid_set_idle(wValue_lsb, wValue_msb); 00308 return TRUE; 00309 00310 case HID_SET_PROTOCOL: 00311 // TODO 00312 break; 00313 } 00314 } 00315 if( 0xA1 == type ) // USB_SETUP_GET_CLASS_INTER 00316 { 00317 switch( request ) 00318 { 00319 case HID_GET_REPORT: 00320 // TODO 00321 break; 00322 case HID_GET_IDLE: 00323 usb_hid_get_idle(wValue_lsb); 00324 return TRUE; 00325 case HID_GET_PROTOCOL: 00326 // TODO 00327 break; 00328 } 00329 } 00330 return FALSE; // No supported request 00331 }