#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 dependency graph for usb_specific_request.c:

Go to the source code of this file.
Functions | |
| Bool | usb_user_read_request (U8 type, U8 request) |
| usb_user_read_request(type, request); | |
| void | usb_user_endpoint_init (U8 conf_nb) |
| usb_user_endpoint_init. | |
| Bool | usb_user_get_descriptor (U8 type, U8 string) |
| usb_user_get_descriptor. | |
| void | hid_get_report (void) |
| hid_get_report. | |
| void | hid_set_report (void) |
| hid_set_report. | |
| void | usb_hid_set_idle (void) |
| usb_hid_set_idle. | |
| void | usb_hid_get_interface (void) |
| usb_hid_get_interface. | |
| void | hid_get_hid_descriptor (void) |
| hid_get_hid_descriptor. | |
Variables | |
| bit | ms_multiple_drive |
| U8 code * | pbuffer |
| U8 | data_to_transfer |
| code S_usb_hid_report_descriptor_mouse | usb_hid_report_descriptor_mouse |
| U16 | wInterface |
Copyright (c) 2004 Atmel.
Use of this program is subject to Atmel's End User License Agreement. Please read file license.txt for copyright notice.
This file contains the user call-back functions corresponding to the application:
Definition in file usb_specific_request.c.
usb_user_read_request(type, 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.
| none |
Definition at line 62 of file usb_specific_request.c.
References FALSE, GET_DESCRIPTOR, GET_INTERFACE, HID, hid_get_hid_descriptor(), hid_get_report(), hid_set_report(), REPORT, SET_CONFIGURATION, SET_REPORT, TRUE, usb_hid_get_interface(), and Usb_read_byte.
Referenced by usb_process_request().
00063 { 00064 U8 descriptor_type ; 00065 U8 string_type ; 00066 00067 string_type = Usb_read_byte(); 00068 descriptor_type = Usb_read_byte(); 00069 switch(request) 00070 { 00071 case GET_DESCRIPTOR: 00072 switch (descriptor_type) 00073 { 00074 case REPORT: 00075 hid_get_report(); 00076 return TRUE; 00077 break; 00078 case HID: 00079 hid_get_hid_descriptor(); 00080 return TRUE; 00081 break; 00082 default: 00083 return FALSE; 00084 break; 00085 } 00086 break; 00087 00088 case SET_CONFIGURATION: 00089 switch (descriptor_type) 00090 { 00091 case SET_REPORT: 00092 hid_set_report(); 00093 return TRUE; 00094 break; 00095 default: 00096 return FALSE; 00097 break; 00098 } 00099 break; 00100 00101 case GET_INTERFACE: 00102 // usb_hid_set_idle(); 00103 usb_hid_get_interface(); 00104 return TRUE; 00105 break; 00106 default: 00107 return FALSE; 00108 break; 00109 } 00110 return FALSE; 00111 }
Here is the call graph for this function:

| void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
usb_user_endpoint_init.
This function configures the endpoints.
| none |
Definition at line 125 of file usb_specific_request.c.
References DIRECTION_IN, EP_SPIDER_IN, NYET_ENABLED, ONE_BANK, SIZE_8, TYPE_INTERRUPT, and usb_configure_endpoint.
Referenced by usb_set_configuration().
00126 { 00127 usb_configure_endpoint(EP_SPIDER_IN, \ 00128 TYPE_INTERRUPT, \ 00129 DIRECTION_IN, \ 00130 SIZE_8, \ 00131 ONE_BANK, \ 00132 NYET_ENABLED); 00133 }
usb_user_get_descriptor.
This function returns the size and the pointer on a user information structure
| none |
Definition at line 147 of file usb_specific_request.c.
References S_usb_language_id::bLength, S_usb_manufacturer_string_descriptor::bLength, S_usb_product_string_descriptor::bLength, S_usb_serial_number::bLength, data_to_transfer, FALSE, LANG_ID, MAN_INDEX, pbuffer, PROD_INDEX, SN_INDEX, STRING_DESCRIPTOR, TRUE, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.
Referenced by usb_get_descriptor().
00148 { 00149 switch(type) 00150 { 00151 case STRING_DESCRIPTOR: 00152 switch (string) 00153 { 00154 case LANG_ID: 00155 data_to_transfer = sizeof (usb_user_language_id); 00156 pbuffer = &(usb_user_language_id.bLength); 00157 return TRUE; 00158 break; 00159 case MAN_INDEX: 00160 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00161 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00162 return TRUE; 00163 break; 00164 case PROD_INDEX: 00165 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00166 pbuffer = &(usb_user_product_string_descriptor.bLength); 00167 return TRUE; 00168 break; 00169 case SN_INDEX: 00170 data_to_transfer = sizeof (usb_user_serial_number); 00171 pbuffer = &(usb_user_serial_number.bLength); 00172 return TRUE; 00173 break; 00174 default: 00175 return FALSE; 00176 } 00177 default: 00178 return FALSE; 00179 } 00180 00181 return FALSE; 00182 }
| void hid_get_report | ( | void | ) |
hid_get_report.
This function manages hit get repport request.
| none |
< read wLength
< clear the receive setup flag
< send only requested number of data
< Send data until necessary
< Check endpoint 0 size
Definition at line 195 of file usb_specific_request.c.
References data_to_transfer, EP_CONTROL_LENGTH, FALSE, Is_usb_read_control_enabled, Is_usb_receive_out, LSB, MSB, pbuffer, S_usb_hid_report_descriptor_mouse::report, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, usb_hid_report_descriptor_mouse, Usb_read_byte, Usb_send_control_in, Usb_write_byte, wInterface, and zlp.
Referenced by usb_user_read_request().
00196 { 00197 00198 U16 wLength; 00199 U8 nb_byte; 00200 bit zlp=0; 00201 00202 LSB(wInterface)=Usb_read_byte(); 00203 MSB(wInterface)=Usb_read_byte(); 00204 00205 data_to_transfer = sizeof(usb_hid_report_descriptor_mouse); 00206 pbuffer = &(usb_hid_report_descriptor_mouse.report[0]); 00207 00208 LSB(wLength) = Usb_read_byte(); 00209 MSB(wLength) = Usb_read_byte(); 00210 Usb_ack_receive_setup() ; 00211 00212 if (wLength > data_to_transfer) 00213 { 00214 if ((data_to_transfer % EP_CONTROL_LENGTH) == 0) { zlp = TRUE; } 00215 else { zlp = FALSE; } 00216 } 00217 else 00218 { 00219 data_to_transfer = (U8)wLength; 00220 } 00221 00222 while((data_to_transfer != 0) && (!Is_usb_receive_out())) 00223 { 00224 while(!Is_usb_read_control_enabled()); 00225 00226 nb_byte=0; 00227 while(data_to_transfer != 0) 00228 { 00229 if(nb_byte++==EP_CONTROL_LENGTH) 00230 { 00231 break; 00232 } 00233 #ifndef AVRGCC 00234 Usb_write_byte(*pbuffer++); 00235 #else // AVRGCC does not support point to PGM space 00236 #warning with avrgcc assumes devices descriptors are stored in the lower 64Kbytes of on-chip flash memory 00237 Usb_write_byte(pgm_read_byte_near((unsigned int)pbuffer++)); 00238 #endif 00239 data_to_transfer --; 00240 } 00241 Usb_send_control_in(); 00242 } 00243 00244 Usb_send_control_in(); 00245 00246 if(Is_usb_receive_out()) { Usb_ack_receive_out(); return; } 00247 if(zlp == TRUE) { Usb_send_control_in(); } 00248 00249 while(!Is_usb_receive_out()); 00250 Usb_ack_receive_out(); 00251 }
| void hid_set_report | ( | void | ) |
hid_set_report.
This function manages hit set report request.
| none |
Definition at line 265 of file usb_specific_request.c.
References Is_usb_receive_out, Usb_ack_receive_out, Usb_ack_receive_setup, and Usb_send_control_in.
Referenced by usb_user_read_request().
00266 { 00267 Usb_ack_receive_setup(); 00268 Usb_send_control_in(); 00269 00270 while(!Is_usb_receive_out()); 00271 Usb_ack_receive_out(); 00272 Usb_send_control_in(); 00273 00274 }
| void usb_hid_set_idle | ( | void | ) |
usb_hid_set_idle.
This function manages hid set idle request.
| none |
Definition at line 287 of file usb_specific_request.c.
References Is_usb_in_ready, LSB, MSB, Usb_ack_receive_setup, Usb_read_byte, Usb_send_control_in, and wInterface.
00288 { 00289 U8 dummy; 00290 dummy = Usb_read_byte(); 00291 dummy = Usb_read_byte(); 00292 LSB(wInterface)=Usb_read_byte(); 00293 MSB(wInterface)=Usb_read_byte(); 00294 00295 Usb_ack_receive_setup(); 00296 00297 Usb_send_control_in(); // send a ZLP for STATUS phase 00298 while(!Is_usb_in_ready()); 00299 }
| void usb_hid_get_interface | ( | void | ) |
usb_hid_get_interface.
This function manages hid get interface request.
| none |
Definition at line 312 of file usb_specific_request.c.
References Is_usb_in_ready, LSB, MSB, Usb_ack_receive_setup, Usb_read_byte, Usb_send_control_in, and wInterface.
Referenced by usb_user_read_request().
00313 { 00314 U8 dummy; 00315 dummy = Usb_read_byte(); 00316 dummy = Usb_read_byte(); 00317 LSB(wInterface)=Usb_read_byte(); 00318 MSB(wInterface)=Usb_read_byte(); 00319 00320 Usb_ack_receive_setup(); 00321 00322 Usb_send_control_in(); // send a ZLP for STATUS phase 00323 while(!Is_usb_in_ready()); 00324 }
| void hid_get_hid_descriptor | ( | void | ) |
hid_get_hid_descriptor.
This function manages hid get hid descriptor request.
| none |
< read wLength
< clear the receive setup flag
< send only requested number of data
< Send data until necessary
< Check endpoint 0 size
Definition at line 336 of file usb_specific_request.c.
References S_usb_hid_descriptor::bLength, data_to_transfer, EP_CONTROL_LENGTH, FALSE, S_usb_user_configuration_descriptor::hid_mouse, Is_usb_read_control_enabled, Is_usb_receive_out, LSB, MSB, pbuffer, TRUE, Usb_ack_receive_out, Usb_ack_receive_setup, usb_conf_desc, Usb_read_byte, Usb_send_control_in, Usb_write_byte, wInterface, and zlp.
Referenced by usb_user_read_request().
00337 { 00338 U16 wLength; 00339 U8 nb_byte; 00340 bit zlp=0; 00341 00342 00343 00344 LSB(wInterface)=Usb_read_byte(); 00345 MSB(wInterface)=Usb_read_byte(); 00346 00347 data_to_transfer = sizeof(usb_conf_desc.hid_mouse); 00348 pbuffer = &(usb_conf_desc.hid_mouse.bLength); 00349 00350 LSB(wLength) = Usb_read_byte(); 00351 MSB(wLength) = Usb_read_byte(); 00352 Usb_ack_receive_setup() ; 00353 00354 if (wLength > data_to_transfer) 00355 { 00356 if ((data_to_transfer % EP_CONTROL_LENGTH) == 0) { zlp = TRUE; } 00357 else { zlp = FALSE; } 00358 } 00359 else 00360 { 00361 data_to_transfer = (U8)wLength; 00362 } 00363 00364 while((data_to_transfer != 0) && (!Is_usb_receive_out())) 00365 { 00366 while(!Is_usb_read_control_enabled()); 00367 00368 nb_byte=0; 00369 while(data_to_transfer != 0) 00370 { 00371 if(nb_byte++==EP_CONTROL_LENGTH) 00372 { 00373 break; 00374 } 00375 #ifndef AVRGCC 00376 Usb_write_byte(*pbuffer++); 00377 #else // AVRGCC does not support point to PGM space 00378 #warning with avrgcc assumes devices descriptors are stored in the lower 64Kbytes of on-chip flash memory 00379 Usb_write_byte(pgm_read_byte_near((unsigned int)pbuffer++)); 00380 #endif 00381 data_to_transfer --; 00382 } 00383 Usb_send_control_in(); 00384 } 00385 00386 Usb_send_control_in(); 00387 00388 if(Is_usb_receive_out()) { Usb_ack_receive_out(); return; } 00389 if(zlp == TRUE) { Usb_send_control_in(); } 00390 00391 while(!Is_usb_receive_out()); 00392 Usb_ack_receive_out(); 00393 }
Definition at line 31 of file usb_specific_request.c.
Definition at line 62 of file usb_standard_request.c.
Referenced by hid_get_hid_descriptor(), hid_get_report(), usb_get_descriptor(), and usb_user_get_descriptor().
Definition at line 64 of file usb_standard_request.c.
Referenced by hid_get_hid_descriptor(), hid_get_report(), usb_get_descriptor(), and usb_user_get_descriptor().
Definition at line 66 of file usb_standard_request.c.
Referenced by hid_get_hid_descriptor(), hid_get_report(), usb_hid_get_interface(), and usb_hid_set_idle().
1.5.1-p1