#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. | |
| void | audio_micro_set_mute (void) |
| void | audio_micro_get_mute (void) |
| void | audio_micro_set_volume (void) |
| void | audio_micro_get_vol_cur (void) |
| void | audio_micro_get_vol_min (void) |
| void | audio_micro_get_vol_max (void) |
| void | audio_micro_get_vol_res (void) |
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 98 of file usb_specific_request.c.
References AUDIO_FU_CONTROL_CS_MUTE, AUDIO_FU_CONTROL_CS_VOLUME, audio_micro_get_mute(), audio_micro_get_vol_cur(), audio_micro_get_vol_max(), audio_micro_get_vol_min(), audio_micro_get_vol_res(), audio_micro_set_mute(), audio_micro_set_volume(), check_audio_control_request(), st_audio_cmd::cs, FALSE, SETUP_AUDIO_GET_CUR, SETUP_AUDIO_GET_MAX, SETUP_AUDIO_GET_MEM, SETUP_AUDIO_GET_MIN, SETUP_AUDIO_GET_RES, SETUP_AUDIO_GET_STAT, SETUP_AUDIO_SET_CUR, SETUP_AUDIO_SET_MAX, SETUP_AUDIO_SET_MEM, SETUP_AUDIO_SET_MIN, SETUP_AUDIO_SET_RES, st_audio_cmd::target, TARGET_MICRO, TRUE, USB_SETUP_GET_CLASS_ENDPOINT, USB_SETUP_GET_CLASS_INTER, USB_SETUP_SET_CLASS_ENDPOINT, and USB_SETUP_SET_CLASS_INTER.
00099 { 00100 st_audio_cmd cmd; 00101 00102 //** Specific request from Class Audio 00103 //* AudioControl Requests 00104 if( USB_SETUP_SET_CLASS_INTER == type ) 00105 { 00106 switch( request ) 00107 { 00108 case SETUP_AUDIO_SET_CUR: 00109 cmd = check_audio_control_request(); 00110 switch( cmd.target ) 00111 { 00112 case TARGET_MICRO: 00113 switch( cmd.cs ) 00114 { 00115 case AUDIO_FU_CONTROL_CS_MUTE: 00116 audio_micro_set_mute(); 00117 return TRUE; 00118 break; 00119 case AUDIO_FU_CONTROL_CS_VOLUME: 00120 audio_micro_set_volume(); 00121 return TRUE; 00122 break; 00123 } 00124 break; 00125 } 00126 break; 00127 00128 case SETUP_AUDIO_SET_MIN: 00129 case SETUP_AUDIO_SET_MAX: 00130 case SETUP_AUDIO_SET_RES: 00131 // TODO 00132 break; 00133 } 00134 } 00135 00136 if( USB_SETUP_GET_CLASS_INTER == type ) 00137 { 00138 switch( request ) 00139 { 00140 case SETUP_AUDIO_GET_CUR: 00141 cmd = check_audio_control_request(); 00142 switch( cmd.target ) 00143 { 00144 case TARGET_MICRO: 00145 switch( cmd.cs ) 00146 { 00147 case AUDIO_FU_CONTROL_CS_MUTE: 00148 audio_micro_get_mute(); 00149 return TRUE; 00150 break; 00151 case AUDIO_FU_CONTROL_CS_VOLUME: 00152 audio_micro_get_vol_cur(); 00153 return TRUE; 00154 break; 00155 } 00156 break; 00157 } 00158 break; 00159 00160 case SETUP_AUDIO_GET_MIN: 00161 cmd = check_audio_control_request(); 00162 switch( cmd.target ) 00163 { 00164 case TARGET_MICRO: 00165 switch( cmd.cs ) 00166 { 00167 case AUDIO_FU_CONTROL_CS_MUTE: 00168 audio_micro_get_mute(); 00169 return TRUE; 00170 break; 00171 case AUDIO_FU_CONTROL_CS_VOLUME: 00172 audio_micro_get_vol_min(); 00173 return TRUE; 00174 break; 00175 } 00176 break; 00177 } 00178 break; 00179 00180 case SETUP_AUDIO_GET_MAX: 00181 cmd = check_audio_control_request(); 00182 switch( cmd.target ) 00183 { 00184 case TARGET_MICRO: 00185 switch( cmd.cs ) 00186 { 00187 case AUDIO_FU_CONTROL_CS_MUTE: 00188 audio_micro_get_mute(); 00189 return TRUE; 00190 break; 00191 case AUDIO_FU_CONTROL_CS_VOLUME: 00192 audio_micro_get_vol_max(); 00193 return TRUE; 00194 break; 00195 } 00196 break; 00197 } 00198 break; 00199 00200 case SETUP_AUDIO_GET_RES: 00201 cmd = check_audio_control_request(); 00202 switch( cmd.target ) 00203 { 00204 case TARGET_MICRO: 00205 switch( cmd.cs ) 00206 { 00207 case AUDIO_FU_CONTROL_CS_MUTE: 00208 audio_micro_get_mute(); 00209 return TRUE; 00210 break; 00211 case AUDIO_FU_CONTROL_CS_VOLUME: 00212 audio_micro_get_vol_res(); 00213 return TRUE; 00214 break; 00215 } 00216 break; 00217 } 00218 break; 00219 } 00220 } 00221 00222 //* AudioStreaming Requests 00223 if( USB_SETUP_SET_CLASS_ENDPOINT == type ) 00224 { 00225 switch( request ) 00226 { 00227 case SETUP_AUDIO_SET_MEM: 00228 case SETUP_AUDIO_SET_MIN: 00229 case SETUP_AUDIO_SET_MAX: 00230 case SETUP_AUDIO_SET_RES: 00231 // TODO 00232 break; 00233 } 00234 } 00235 if( USB_SETUP_GET_CLASS_ENDPOINT == type ) 00236 { 00237 switch( request ) 00238 { 00239 case SETUP_AUDIO_GET_CUR: 00240 case SETUP_AUDIO_GET_MIN: 00241 case SETUP_AUDIO_GET_MAX: 00242 case SETUP_AUDIO_GET_RES: 00243 // TODO 00244 break; 00245 } 00246 } 00247 00248 //* Additional Requests 00249 // Set Memory Request 00250 if( USB_SETUP_SET_CLASS_INTER == type ) 00251 { 00252 switch( request ) 00253 { 00254 case SETUP_AUDIO_SET_MEM: 00255 // TODO 00256 break; 00257 } 00258 } 00259 if( USB_SETUP_SET_CLASS_ENDPOINT == type ) 00260 { 00261 switch( request ) 00262 { 00263 case SETUP_AUDIO_SET_MEM: 00264 // TODO 00265 break; 00266 } 00267 } 00268 // Get Memory Request 00269 if( USB_SETUP_GET_CLASS_INTER == type ) 00270 { 00271 switch( request ) 00272 { 00273 case SETUP_AUDIO_GET_MEM: 00274 // TODO 00275 break; 00276 } 00277 } 00278 if( USB_SETUP_GET_CLASS_ENDPOINT == type ) 00279 { 00280 switch( request ) 00281 { 00282 case SETUP_AUDIO_GET_MEM: 00283 // TODO 00284 break; 00285 } 00286 } 00287 // Get Status Request 00288 if( USB_SETUP_GET_CLASS_INTER == type ) 00289 { 00290 switch( request ) 00291 { 00292 case SETUP_AUDIO_GET_STAT: 00293 // TODO 00294 break; 00295 } 00296 } 00297 if( USB_SETUP_GET_CLASS_ENDPOINT == type ) 00298 { 00299 switch( request ) 00300 { 00301 case SETUP_AUDIO_GET_STAT: 00302 // TODO 00303 break; 00304 } 00305 } 00306 return FALSE; // No supported request 00307 }
| void usb_user_endpoint_init | ( | U8 | conf_nb | ) |
This function configures the endpoints
| conf_nb | configuration number choosed by USB host |
Definition at line 314 of file usb_specific_request.c.
References DIRECTION_IN, EP_AUDIO_IN, NYET_ENABLED, SIZE_16, TWO_BANKS, TYPE_ISOCHRONOUS, and usb_configure_endpoint.
00315 { 00316 usb_configure_endpoint(EP_AUDIO_IN, \ 00317 TYPE_ISOCHRONOUS,\ 00318 DIRECTION_IN, \ 00319 SIZE_16, \ 00320 TWO_BANKS, \ 00321 NYET_ENABLED); 00322 }
This function returns the interface alternate setting
| wInterface | Interface selected |
Definition at line 331 of file usb_specific_request.c.
References interface_status.
00332 { 00333 return interface_status[wInterface]; 00334 }
This function selects (and resets) the interface alternate setting
| wInterface | Interface selected | |
| alternate_setting | alternate setting selected |
Definition at line 342 of file usb_specific_request.c.
References EP_AUDIO_IN, interface_status, NB_OF_STREAMING_INTERFACE, Usb_disable_stall_handshake, Usb_reset_data_toggle, Usb_reset_endpoint, and Usb_select_endpoint.
00343 { 00344 interface_status[wInterface] = alternate_setting; 00345 // default setting selected = reset data toggle 00346 if((NB_OF_STREAMING_INTERFACE == wInterface ) 00347 && (1 == alternate_setting)) 00348 { 00349 // Interface for Microphone, alternate setting with endpoint 00350 Usb_select_endpoint(EP_AUDIO_IN); 00351 Usb_disable_stall_handshake(); 00352 Usb_reset_endpoint(EP_AUDIO_IN); 00353 Usb_reset_data_toggle(); 00354 } 00355 }
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 365 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, TRUE, usb_user_language_id, usb_user_manufacturer_string_descriptor, usb_user_product_string_descriptor, and usb_user_serial_number.
00366 { 00367 switch(type) 00368 { 00369 case DESCRIPTOR_STRING: 00370 switch (string) 00371 { 00372 case LANG_ID: 00373 data_to_transfer = sizeof (usb_user_language_id); 00374 pbuffer = &(usb_user_language_id.bLength); 00375 return TRUE; 00376 break; 00377 00378 case MAN_INDEX: 00379 data_to_transfer = sizeof (usb_user_manufacturer_string_descriptor); 00380 pbuffer = &(usb_user_manufacturer_string_descriptor.bLength); 00381 return TRUE; 00382 break; 00383 00384 case PROD_INDEX: 00385 data_to_transfer = sizeof (usb_user_product_string_descriptor); 00386 pbuffer = &(usb_user_product_string_descriptor.bLength); 00387 return TRUE; 00388 break; 00389 00390 #if (USB_DEVICE_SN_USE==ENABLE) 00391 case SN_INDEX: 00392 data_to_transfer = sizeof (usb_user_serial_number); 00393 pbuffer = &(usb_user_serial_number.bLength); 00394 #if (USE_DEVICE_SN_UNIQUE==ENABLE) 00395 f_get_serial_string=TRUE; 00396 data_to_transfer += (SN_LENGTH*4); 00397 #endif 00398 return TRUE; 00399 break; 00400 #endif 00401 } 00402 break; 00403 } 00404 return FALSE; 00405 }
| void audio_micro_set_mute | ( | void | ) |
Definition at line 450 of file usb_specific_request.c.
References b_micro_mute, Is_usb_receive_out, Usb_ack_receive_out, Usb_read_byte, and Usb_send_control_in.
00451 { 00452 while(!Is_usb_receive_out()); 00453 b_micro_mute=Usb_read_byte(); 00454 Usb_ack_receive_out(); 00455 Usb_send_control_in(); // send a ZLP 00456 }
| void audio_micro_get_mute | ( | void | ) |
Definition at line 457 of file usb_specific_request.c.
References b_micro_mute, Is_usb_receive_out, Usb_ack_receive_out, Usb_send_control_in, and Usb_write_byte.
00458 { 00459 Usb_write_byte(b_micro_mute); 00460 Usb_send_control_in(); 00461 while(!Is_usb_receive_out()); // send a ZLP 00462 Usb_ack_receive_out(); 00463 }
| void audio_micro_set_volume | ( | void | ) |
Definition at line 464 of file usb_specific_request.c.
References Is_usb_receive_out, LSB, MSB, s16_micro_volume, Usb_ack_receive_out, Usb_read_byte, and Usb_send_control_in.
00465 { 00466 while(!Is_usb_receive_out()); 00467 LSB(s16_micro_volume)=Usb_read_byte(); 00468 MSB(s16_micro_volume)=Usb_read_byte(); 00469 Usb_ack_receive_out(); 00470 Usb_send_control_in(); // send a ZLP 00471 }
| void audio_micro_get_vol_cur | ( | void | ) |
Definition at line 472 of file usb_specific_request.c.
References Is_usb_receive_out, LSB, MSB, s16_micro_volume, Usb_ack_receive_out, Usb_send_control_in, and Usb_write_byte.
00473 { 00474 Usb_write_byte(LSB(s16_micro_volume)); 00475 Usb_write_byte(MSB(s16_micro_volume)); 00476 Usb_send_control_in(); 00477 while(!Is_usb_receive_out()); // send a ZLP 00478 Usb_ack_receive_out(); 00479 }
| void audio_micro_get_vol_min | ( | void | ) |
Definition at line 480 of file usb_specific_request.c.
References HIGH, Is_usb_receive_out, LOW, MICRO_VOL_MIN, Usb_ack_receive_out, Usb_send_control_in, and Usb_write_byte.
00481 { 00482 Usb_write_byte(LOW(MICRO_VOL_MIN)); 00483 Usb_write_byte(HIGH(MICRO_VOL_MIN)); 00484 Usb_send_control_in(); 00485 while(!Is_usb_receive_out()); // send a ZLP 00486 Usb_ack_receive_out(); 00487 }
| void audio_micro_get_vol_max | ( | void | ) |
Definition at line 488 of file usb_specific_request.c.
References HIGH, Is_usb_receive_out, LOW, MICRO_VOL_MAX, Usb_ack_receive_out, Usb_send_control_in, and Usb_write_byte.
00489 { 00490 Usb_write_byte(LOW(MICRO_VOL_MAX)); 00491 Usb_write_byte(HIGH(MICRO_VOL_MAX)); 00492 Usb_send_control_in(); 00493 while(!Is_usb_receive_out()); // send a ZLP 00494 Usb_ack_receive_out(); 00495 }
| void audio_micro_get_vol_res | ( | void | ) |
Definition at line 496 of file usb_specific_request.c.
References HIGH, Is_usb_receive_out, LOW, MICRO_VOL_RES, Usb_ack_receive_out, Usb_send_control_in, and Usb_write_byte.
00497 { 00498 Usb_write_byte(LOW(MICRO_VOL_RES)); 00499 Usb_write_byte(HIGH(MICRO_VOL_RES)); 00500 Usb_send_control_in(); 00501 while(!Is_usb_receive_out()); // send a ZLP 00502 Usb_ack_receive_out(); 00503 }
Definition at line 66 of file usb_descriptors.c.
Definition at line 85 of file usb_descriptors.c.
Definition at line 225 of file usb_descriptors.c.
Definition at line 234 of file usb_descriptors.c.
Definition at line 243 of file usb_descriptors.c.
Definition at line 257 of file usb_descriptors.c.
1.5.3