00001
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 #ifndef _USB_DESCRIPTORS_H_
00045 #define _USB_DESCRIPTORS_H_
00046
00047
00048
00049 #include "config.h"
00050 #include "modules/usb/device_chap9/usb_standard_request.h"
00051 #include "conf_usb.h"
00052
00053
00054
00055 #define Usb_get_dev_desc_pointer() (&(usb_dev_desc.bLength))
00056 #define Usb_get_dev_desc_length() (sizeof (usb_dev_desc))
00057 #define Usb_get_conf_desc_pointer() (&(usb_conf_desc.cfg.bLength))
00058 #define Usb_get_conf_desc_length() (sizeof (usb_conf_desc))
00059
00060
00061
00062
00063
00064
00065 #define USB_SPECIFICATION 0x0200
00066 #define DEVICE_CLASS 0 // each configuration has its own class
00067 #define DEVICE_SUB_CLASS 0 // each configuration has its own sub-class
00068 #define DEVICE_PROTOCOL 0 // each configuration has its own protocol
00069 #define EP_CONTROL_LENGTH 64
00070 #define VENDOR_ID VID_ATMEL
00071 #define PRODUCT_ID PID_MegaAUDIO_IN
00072 #define RELEASE_NUMBER 0x1000
00073 #define MAN_INDEX 0x01
00074 #define PROD_INDEX 0x02
00075 #if (USB_DEVICE_SN_USE==ENABLE)
00076 #define SN_INDEX 0x03
00077 #else
00078 #define SN_INDEX 0x00 // No serial number field
00079 #endif
00080 #define NB_CONFIGURATION 1
00081
00082
00083
00084 #define NB_INTERFACE 2 // Audio Control + Audio Stream IN (Micro) interface
00085 #define CONF_NB 1
00086 #define CONF_INDEX 0
00087 #define CONF_ATTRIBUTES USB_CONFIG_BUSPOWERED
00088 #define MAX_POWER 50 // 100 mA
00089
00090
00091 #define AC_INTERFACE_NB 0 // Interface's number
00092 #define AC_ALTERNATE 0
00093 #define AC_NB_ENDPOINT 0 // No endpoint for AC interface
00094 #define AC_INTERFACE_CLASS AUDIO_CLASS // Audio Class
00095 #define AC_INTERFACE_SUB_CLASS AUDIO_SUB_CLASS_CONTROL// Audio_control sub class
00096 #define AC_INTERFACE_PROTOCOL NO_PROTOCOL // Unused
00097 #define AC_INTERFACE_INDEX 0
00098
00099
00100 #define ENDPOINT_NB_1 (EP_AUDIO_IN | USB_ENDPOINT_IN)
00101 #define EP_ATTRIBUTES_1 0x01 // BULK = 0x02, INTERUPT = 0x03
00102 #define EP_IN_LENGTH 16
00103 #define EP_SIZE_1 EP_IN_LENGTH
00104 #define EP_INTERVAL_1 0x01 // One packet per frame
00105
00106
00107 #define NB_OF_STREAMING_INTERFACE 0x01
00108
00109 #define INPUT_TERMINAL_ID 0x01
00110 #define INPUT_TERMINAL_TYPE AUDIO_TE_TYPE_INPUT_MICROPHONE // Terminal is microphone
00111 #define INPUT_TERMINAL_ASSOCIATION 0x00 // No association
00112 #define INPUT_TERMINAL_NB_CHANNELS 0x01 // One channel for input terminal
00113 #define INPUT_TERMINAL_CHANNEL_CONF AUDIO_CHANNEL_NO_POSITION // Mono sets no position
00114 #define INPUT_TERMINAL_CH_NAME_ID 0x00 // No channel name
00115
00116 #define FEATURE_UNIT_ID 0x02
00117 #define FEATURE_UNIT_SOURCE_ID INPUT_TERMINAL_ID
00118 #define FEATURE_UNIT_CTRL_CH_MASTER (AUDIO_FU_CONTROL_CS_MUTE|AUDIO_FU_CONTROL_CS_VOLUME) // Mute + Volume control on master channel
00119 #define FEATURE_UNIT_CTRL_CH_1 0x00 // No control on channel 1
00120
00121 #define OUTPUT_TERMINAL_ID 0x03
00122 #define OUTPUT_TERMINAL_TYPE AUDIO_TE_TYPE_USB_STREAMING // USB Streaming
00123 #define OUTPUT_TERMINAL_ASSOCIATION 0x00 // No association
00124 #define OUTPUT_TERMINAL_SOURCE_ID FEATURE_UNIT_ID // From Feature Unit Terminal
00125
00126 #define STD_AS_INTERFACE_NB 0x01 // Index of Std AS Interface
00127
00128 #define ALT0_AS_INTERFACE_INDEX 0x00 // Index of Std AS interface Alt0
00129 #define ALT0_AS_NB_ENDPOINT 0x00 // Nb od endpoints for alt0 interface
00130 #define ALT0_AS_INTERFACE_CLASS AUDIO_CLASS // Audio class
00131 #define ALT0_AS_INTERFACE_SUB_CLASS AUDIO_SUB_CLASS_STREAMING // Audio streamn sub class
00132 #define ALT0_AS_INTERFACE_PROTOCOL NO_PROTOCOL // Unused
00133
00134 #define ALT1_AS_INTERFACE_INDEX 0x01 // Index of Std AS interface Alt1
00135 #define ALT1_AS_NB_ENDPOINT 0x01 // Nb od endpoints for alt1 interface
00136 #define ALT1_AS_INTERFACE_CLASS AUDIO_CLASS // Audio class
00137 #define ALT1_AS_INTERFACE_SUB_CLASS AUDIO_SUB_CLASS_STREAMING // Audio streamn sub class
00138 #define ALT1_AS_INTERFACE_PROTOCOL NO_PROTOCOL // Unused
00139
00140 #define AS_TERMINAL_LINK 0x03 // Unit Id of the output terminal
00141 #define AS_DELAY 0x01 // Interface delay
00142 #define AS_FORMAT_TAG AUDIO_FORMAT_TI_PCM // PCM Format
00143
00144 #define FORMAT_TYPE AUDIO_FORMAT_TYPE_I // Format TypeI
00145 #define FORMAT_NB_CHANNELS 0x01 // One Channel
00146 #define FORMAT_FRAME_SIZE 0x02 // Two bytes per audio sample
00147 #define FORMAT_BIT_RESOLUTION 0x10 // 16 bits per sample
00148 #define FORMAT_SAMPLE_FREQ_NB 0x01 // One frequency supported
00149 #define FORMAT_LSBYTE_SAMPLE_FREQ 0x1F40 // 0x001F40=8kHz Sample frequency
00150 #define FORMAT_MSBYTE_SAMPLE_FREQ 0x00 // MsByte of 0x001F40
00151
00152
00153 #define AUDIO_EP_ATRIBUTES 0x00 // No sampling freq, no pitch, no pading
00154 #define AUDIO_EP_DELAY_UNIT 0x00 // Unused
00155 #define AUDIO_EP_LOCK_DELAY 0x0000 // Unused
00156
00157 #define LANG_ID 0x00
00158 #define DEVICE_STATUS USB_DEVICE_STATUS_BUS_POWERED
00159
00160
00161 #define USB_MN_LENGTH 5
00162 #define USB_MANUFACTURER_NAME \
00163 { Usb_unicode('A') \
00164 , Usb_unicode('T') \
00165 , Usb_unicode('M') \
00166 , Usb_unicode('E') \
00167 , Usb_unicode('L') \
00168 }
00169
00170 #define USB_PN_LENGTH 18
00171 #define USB_PRODUCT_NAME \
00172 { Usb_unicode('A') \
00173 ,Usb_unicode('V') \
00174 ,Usb_unicode('R') \
00175 ,Usb_unicode(' ') \
00176 ,Usb_unicode('U') \
00177 ,Usb_unicode('S') \
00178 ,Usb_unicode('B') \
00179 ,Usb_unicode(' ') \
00180 ,Usb_unicode('A') \
00181 ,Usb_unicode('U') \
00182 ,Usb_unicode('D') \
00183 ,Usb_unicode('I') \
00184 ,Usb_unicode('O') \
00185 ,Usb_unicode(' ') \
00186 ,Usb_unicode('D') \
00187 ,Usb_unicode('E') \
00188 ,Usb_unicode('M') \
00189 ,Usb_unicode('O') \
00190 }
00191
00192 #define USB_SN_LENGTH 0x05
00193 #define USB_SERIAL_NUMBER \
00194 { Usb_unicode('0') \
00195 ,Usb_unicode('0') \
00196 ,Usb_unicode('0') \
00197 ,Usb_unicode('0') \
00198 ,Usb_unicode('0') \
00199 }
00200
00201 #define AUDIO_CHANNEL_NAME \
00202 { Usb_unicode('A') \
00203 , Usb_unicode('T') \
00204 , Usb_unicode('M') \
00205 , Usb_unicode('E') \
00206 , Usb_unicode('L') \
00207 }
00208
00209 #define LANGUAGE_ID 0x0409
00210
00211
00213 typedef struct
00214 {
00215 U8 bmRequestType;
00216 U8 bRequest;
00217 U16 wValue;
00218 U16 wIndex;
00219 U16 wLength;
00220 } S_UsbRequest;
00221
00222
00224 typedef struct {
00225 U8 bLength;
00226 U8 bDescriptorType;
00227 U16 bscUSB;
00228 U8 bDeviceClass;
00229 U8 bDeviceSubClass;
00230 U8 bDeviceProtocol;
00231 U8 bMaxPacketSize0;
00232 U16 idVendor;
00233 U16 idProduct;
00234 U16 bcdDevice;
00235 U8 iManufacturer;
00236 U8 iProduct;
00237 U8 iSerialNumber;
00238 U8 bNumConfigurations;
00239 } S_usb_device_descriptor;
00240
00241
00243 typedef struct {
00244 U8 bLength;
00245 U8 bDescriptorType;
00246 U16 wTotalLength;
00247 U8 bNumInterfaces;
00248 U8 bConfigurationValue;
00249 U8 iConfiguration;
00250 U8 bmAttibutes;
00251 U8 MaxPower;
00252 } S_usb_configuration_descriptor;
00253
00254
00256 typedef struct {
00257 U8 bLength;
00258 U8 bDescriptorType;
00259 U8 bInterfaceNumber;
00260 U8 bAlternateSetting;
00261 U8 bNumEndpoints;
00262 U8 bInterfaceClass;
00263 U8 bInterfaceSubClass;
00264 U8 bInterfaceProtocol;
00265 U8 iInterface;
00266 } S_usb_interface_descriptor;
00267
00268
00271 typedef struct {
00272 U8 bLength;
00273 U8 bDescriptorType;
00274 U8 bDescritorSubtype;
00275 U16 bcdADC;
00276 U16 wTotalLength;
00277 U8 bInCollection;
00278 U8 baInterface1;
00279 } S_usb_ac_interface_descriptor;
00280
00282 typedef struct{
00283 U8 bLenght;
00284 U8 bDescriptorType;
00285 U8 bDescriptorSubType;
00286 U8 bTerminalID;
00287 U16 wTerminalType;
00288 U8 bAssocTerminal;
00289 U8 bNrChannels;
00290 U16 wChannelConfig;
00291 U8 iChannelNames;
00292 U8 iTerminal;
00293 } S_usb_in_ter_descriptor;
00294
00296 typedef struct{
00297 U8 bLenght;
00298 U8 bDescriptorType;
00299 U8 bDescriptorSubType;
00300 U8 bUnitID;
00301 U8 bSourceID;
00302 U8 bControSize;
00303 U8 bmaControlMaster;
00304 U8 bmaControlCh1;
00305 } S_usb_feature_unit_descriptor;
00306
00308 typedef struct{
00309 U8 bLenght;
00310 U8 bDescriptorType;
00311 U8 bDescriptorSubType;
00312 U8 bTerminalID;
00313 U16 wTerminalType;
00314 U8 bAssocTerminal;
00315 U8 bSourceID;
00316 U8 iTerminal;
00317 } S_usb_out_ter_descriptor;
00318
00320 typedef struct{
00321 U8 bLenght;
00322 U8 bDescriptorType;
00323 U8 bDescriptorSubType;
00324 U8 bTerminalLink;
00325 U8 bDelay;
00326 U16 wFormatTag;
00327 } S_usb_as_interface_descriptor;
00328
00330 typedef struct{
00331 U8 bLenght;
00332 U8 bDescriptorType;
00333 U8 bDescriptorSubType;
00334 U8 bFormatType;
00335 U8 bNrChannels;
00336 U8 bSubFrameSize;
00337 U8 bBitResolution;
00338 U8 bSampleFreqType;
00339 U16 wLsbyteiSamFreq;
00340 U8 bMsbyteiSamFreq;
00341 } S_usb_format_type;
00342
00344 typedef struct{
00345 U8 bLenght;
00346 U8 bDescriptorType;
00347 U8 bDescriptorSubType;
00348 U8 bmAttributes;
00349 U8 bLockDelayUnits;
00350 U16 wLockDelay;
00351 }S_usb_endpoint_audio_specific;
00352
00354 typedef struct {
00355 U8 bLength;
00356 U8 bDescriptorType;
00357 U8 bEndpointAddress;
00358 U8 bmAttributes;
00359 U16 wMaxPacketSize;
00360 U8 bInterval;
00361 U8 bRefresh;
00362 U8 bSynAddress;
00363 } S_usb_endpoint_audio_descriptor;
00364
00366 typedef struct {
00367 U8 bLength;
00368 U8 bDescriptorType;
00369 U8 bEndpointAddress;
00370 U8 bmAttributes;
00371 U16 wMaxPacketSize;
00372 U8 bInterval;
00373 } S_usb_endpoint_descriptor;
00374
00375
00377 typedef struct {
00378 U8 bLength;
00379 U8 bDescriptorType;
00380 U16 wlangid;
00381 } S_usb_language_id;
00382
00383
00384
00385
00386
00387
00388 typedef struct {
00389 U8 bLength;
00390 U8 bDescriptorType;
00391 U16 wstring[USB_MN_LENGTH];
00392 } S_usb_manufacturer_string_descriptor;
00393
00394
00395
00396
00397
00398
00399 typedef struct {
00400 U8 bLength;
00401 U8 bDescriptorType;
00402 U16 wstring[USB_PN_LENGTH];
00403 } S_usb_product_string_descriptor;
00404
00405
00406
00407
00408
00409 #if (USB_DEVICE_SN_USE==ENABLE)
00410
00411 typedef struct {
00412 U8 bLength;
00413 U8 bDescriptorType;
00414 #if (USE_DEVICE_SN_UNIQUE==ENABLE)
00415
00416 #else
00417 U16 wstring[USB_SN_LENGTH];
00418 #endif
00419 } S_usb_serial_number;
00420 #endif
00421
00422
00423
00424
00425 typedef struct
00426 {
00427 S_usb_configuration_descriptor cfg;
00428 S_usb_interface_descriptor ifc;
00429 S_usb_ac_interface_descriptor audioac;
00430 S_usb_in_ter_descriptor mic_in_ter;
00431 S_usb_feature_unit_descriptor mic_fea_unit;
00432 S_usb_out_ter_descriptor mic_out_ter;
00433 S_usb_interface_descriptor mic_as_alt0;
00434 S_usb_interface_descriptor mic_as_alt1;
00435 S_usb_as_interface_descriptor mic_g_as;
00436 S_usb_format_type mic_format_type;
00437 S_usb_endpoint_audio_descriptor ep1;
00438 S_usb_endpoint_audio_specific ep1_s;
00439 } S_usb_user_configuration_descriptor;
00440
00441 #endif
00442