Could you help teach me, how to add a microphone input to this usb audio code.
MCB1700 Sample Code Bundle for LPC17xx Peripherals using Keil's MDK-ARM V2.00 (Jan 10, 2011) ics.nxp.com/.../mcb1700.code.bundle.lpc17xx.keil.zip
Could we start with the usbuser.c file and the changes that must be made,
thankyou.
The USB Audio spec shows a descriptor example for Microphone. www.usb.org/.../audio10.pdf Appendix B. Example 1: USB Microphone (Informative)
Modify the descriptors (usbdesc.c) of the example, first.
For Audio Control Interface, - Append "B.3.3.3 Input Terminal Descriptor" and "B.3.3.4 Output Terminal Descriptor" from the microphone example after the original Audio Output Terminal. - Tune the bTerminalID and bSourceID values of these descriptors, so that they don't conflict with the original speaker's. (bTerminalID = 4, 5 bSourceID = 4) - Increase wTotalLength of Class-specific AC Interface Descriptor by these terminal descriptors.
For the extra Audio Streaming Interface of microphone, - Append the descriptors from "B.3.4.1.1.1 Standard AS Interface Descriptor" to "B.3.4.2.1.5 Class-specific Isochronous Audio Data Endpoint Descriptor" on the spec, after the last descriptor of the original. - Change bInterfaceNumber of two Interface descriptors into 2 - Match bTerminalLink of "Class-specific AS General Interface Descriptor" with the bTerminalID (5) of above Output Terminal Descriptor
Lastly, tune the Config descriptor - wTotalLength: Add the size of extra descriptors - bNumInterfaces: from 2 to 3
At this stage of modification, the microphone interface should be recognized by your PC. When you finish this modification successfully, we move to the next step ;-)
Tsuneo
I try my best to do but I am struggling with the highlighted in red
/* USB Standard Device Descriptor */ const uint8_t USB_DeviceDescriptor[] = { USB_DEVICE_DESC_SIZE, /* bLength */ USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL(0x0200), /* 2.00 */ /* bcdUSB */ 0x00, /* bDeviceClass */ 0x00, /* bDeviceSubClass */ 0x00, /* bDeviceProtocol */ USB_MAX_PACKET0, /* bMaxPacketSize0 */ WBVAL(0x1FD3), /* idVendor */ WBVAL(0x4063), /* idProduct */ WBVAL(0x0100), /* 1.00 */ /* bcdDevice */ 0x01, /* iManufacturer */ 0x02, /* iProduct */ 0x03, /* iSerialNumber */ 0x01 /* bNumConfigurations: one possible configuration*/ }; /* USB Configuration Descriptor */ /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ const uint8_t USB_ConfigDescriptor[] = { /* Configuration 1 */ USB_CONFIGUARTION_DESC_SIZE, /* bLength */ USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ WBVAL( /* wTotalLength */ USB_CONFIGUARTION_DESC_SIZE + USB_INTERFACE_DESC_SIZE + AUDIO_CONTROL_INTERFACE_DESC_SZ(1) + AUDIO_INPUT_TERMINAL_DESC_SIZE + AUDIO_FEATURE_UNIT_DESC_SZ(1,1) + AUDIO_OUTPUT_TERMINAL_DESC_SIZE + AUDIO_INPUT_TERMINAL_DESC_SIZE + AUDIO_OUTPUT_TERMINAL_DESC_SIZE + USB_INTERFACE_DESC_SIZE + AUDIO_STREAMING_INTERFACE_DESC_SIZE + USB_INTERFACE_DESC_SIZE + AUDIO_STREAMING_INTERFACE_DESC_SIZE + AUDIO_STREAMING_GENERAL + AUDIO_FEATURE_UNIT_DESC_SZ(1,1) + USB_INTERFACE_DESC_SIZE + USB_INTERFACE_DESC_SIZE + AUDIO_STREAMING_INTERFACE_DESC_SIZE + AUDIO_FORMAT_TYPE_I_DESC_SZ(1) + AUDIO_STANDARD_ENDPOINT_DESC_SIZE + AUDIO_STREAMING_ENDPOINT_DESC_SIZE + AUDIO_STANDARD_ENDPOINT_DESC_SIZE ), 0x03, /* bNumInterfaces */ 0x01, /* bConfigurationValue */ 0x00, /* iConfiguration */ USB_CONFIG_BUS_POWERED, /* bmAttributes */ USB_CONFIG_POWER_MA(100), /* bMaxPower */ /* Interface 0, Alternate Setting 0, Audio Control */ USB_INTERFACE_DESC_SIZE, /* bLength */ USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 0x00, /* bInterfaceNumber */ 0x00, /* bAlternateSetting */ 0x00, /* bNumEndpoints */ USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass */ AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 0x00, /* iInterface */ /* Audio Control Interface */ AUDIO_CONTROL_INTERFACE_DESC_SZ(1), /* bLength */ AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */ WBVAL(0x0100), /* 1.00 */ /* bcdADC */ WBVAL( /* wTotalLength */ AUDIO_CONTROL_INTERFACE_DESC_SZ(1) + AUDIO_INPUT_TERMINAL_DESC_SIZE + AUDIO_FEATURE_UNIT_DESC_SZ(1,1) + AUDIO_OUTPUT_TERMINAL_DESC_SIZE ), 0x02, /* bInCollection */ 0x01, /* baInterfaceNr */ 0x02 /* baInterfaceNr */
View all questions in Keil forum