These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
usbdesc.c
00001 /*---------------------------------------------------------------------------- 00002 * U S B - K e r n e l 00003 *---------------------------------------------------------------------------- 00004 * Name: usbdesc.c 00005 * Purpose: USB Descriptors 00006 * Version: V1.20 00007 *---------------------------------------------------------------------------- 00008 * This software is supplied "AS IS" without any warranties, express, 00009 * implied or statutory, including but not limited to the implied 00010 * warranties of fitness for purpose, satisfactory quality and 00011 * noninfringement. Keil extends you a royalty-free right to reproduce 00012 * and distribute executable files created using this software for use 00013 * on NXP Semiconductors LPC family microcontroller devices only. Nothing 00014 * else gives you the right to use this software. 00015 * 00016 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved. 00017 *---------------------------------------------------------------------------- 00018 * History: 00019 * V1.20 Changed string descriptor handling 00020 * V1.00 Initial Version 00021 *----------------------------------------------------------------------------*/ 00022 #include "lpc_types.h" 00023 00024 #include "usb.h" 00025 #include "audio.h" 00026 #include "usbcfg.h" 00027 #include "usbdesc.h" 00028 00029 00030 /* USB Standard Device Descriptor */ 00031 const uint8_t USB_DeviceDescriptor[] = { 00032 USB_DEVICE_DESC_SIZE, /* bLength */ 00033 USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00034 WBVAL(0x0200), /* 2.00 */ /* bcdUSB */ 00035 0x00, /* bDeviceClass */ 00036 0x00, /* bDeviceSubClass */ 00037 0x00, /* bDeviceProtocol */ 00038 USB_MAX_PACKET0, /* bMaxPacketSize0 */ 00039 WBVAL(0x1FC9), /* idVendor */ 00040 WBVAL(0x4002), /* idProduct */ 00041 WBVAL(0x0100), /* 1.00 */ /* bcdDevice */ 00042 0x01, /* iManufacturer */ 00043 0x02, /* iProduct */ 00044 0x03, /* iSerialNumber */ 00045 0x01 /* bNumConfigurations: one possible configuration*/ 00046 }; 00047 00048 /* USB Configuration Descriptor */ 00049 /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */ 00050 const uint8_t USB_ConfigDescriptor[] = { 00051 /* Configuration 1 */ 00052 USB_CONFIGUARTION_DESC_SIZE, /* bLength */ 00053 USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */ 00054 WBVAL( /* wTotalLength */ 00055 USB_CONFIGUARTION_DESC_SIZE + 00056 USB_INTERFACE_DESC_SIZE + 00057 AUDIO_CONTROL_INTERFACE_DESC_SZ(1) + 00058 AUDIO_INPUT_TERMINAL_DESC_SIZE + 00059 AUDIO_FEATURE_UNIT_DESC_SZ(1,1) + 00060 AUDIO_OUTPUT_TERMINAL_DESC_SIZE + 00061 USB_INTERFACE_DESC_SIZE + 00062 USB_INTERFACE_DESC_SIZE + 00063 AUDIO_STREAMING_INTERFACE_DESC_SIZE + 00064 AUDIO_FORMAT_TYPE_I_DESC_SZ(1) + 00065 AUDIO_STANDARD_ENDPOINT_DESC_SIZE + 00066 AUDIO_STREAMING_ENDPOINT_DESC_SIZE 00067 ), 00068 0x02, /* bNumInterfaces */ 00069 0x01, /* bConfigurationValue */ 00070 0x00, /* iConfiguration */ 00071 USB_CONFIG_BUS_POWERED, /* bmAttributes */ 00072 USB_CONFIG_POWER_MA(100), /* bMaxPower */ 00073 /* Interface 0, Alternate Setting 0, Audio Control */ 00074 USB_INTERFACE_DESC_SIZE, /* bLength */ 00075 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00076 0x00, /* bInterfaceNumber */ 00077 0x00, /* bAlternateSetting */ 00078 0x00, /* bNumEndpoints */ 00079 USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ 00080 AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass */ 00081 AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 00082 0x00, /* iInterface */ 00083 /* Audio Control Interface */ 00084 AUDIO_CONTROL_INTERFACE_DESC_SZ(1), /* bLength */ 00085 AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00086 AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */ 00087 WBVAL(0x0100), /* 1.00 */ /* bcdADC */ 00088 WBVAL( /* wTotalLength */ 00089 AUDIO_CONTROL_INTERFACE_DESC_SZ(1) + 00090 AUDIO_INPUT_TERMINAL_DESC_SIZE + 00091 AUDIO_FEATURE_UNIT_DESC_SZ(1,1) + 00092 AUDIO_OUTPUT_TERMINAL_DESC_SIZE 00093 ), 00094 0x01, /* bInCollection */ 00095 0x01, /* baInterfaceNr */ 00096 /* Audio Input Terminal */ 00097 AUDIO_INPUT_TERMINAL_DESC_SIZE, /* bLength */ 00098 AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00099 AUDIO_CONTROL_INPUT_TERMINAL, /* bDescriptorSubtype */ 00100 0x01, /* bTerminalID */ 00101 WBVAL(AUDIO_TERMINAL_USB_STREAMING), /* wTerminalType */ 00102 0x00, /* bAssocTerminal */ 00103 0x01, /* bNrChannels */ 00104 WBVAL(AUDIO_CHANNEL_M), /* wChannelConfig */ 00105 0x00, /* iChannelNames */ 00106 0x00, /* iTerminal */ 00107 /* Audio Feature Unit */ 00108 AUDIO_FEATURE_UNIT_DESC_SZ(1,1), /* bLength */ 00109 AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00110 AUDIO_CONTROL_FEATURE_UNIT, /* bDescriptorSubtype */ 00111 0x02, /* bUnitID */ 00112 0x01, /* bSourceID */ 00113 0x01, /* bControlSize */ 00114 AUDIO_CONTROL_MUTE | 00115 AUDIO_CONTROL_VOLUME, /* bmaControls(0) */ 00116 0x00, /* bmaControls(1) */ 00117 0x00, /* iTerminal */ 00118 /* Audio Output Terminal */ 00119 AUDIO_OUTPUT_TERMINAL_DESC_SIZE, /* bLength */ 00120 AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00121 AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */ 00122 0x03, /* bTerminalID */ 00123 WBVAL(AUDIO_TERMINAL_SPEAKER), /* wTerminalType */ 00124 0x00, /* bAssocTerminal */ 00125 0x02, /* bSourceID */ 00126 0x00, /* iTerminal */ 00127 /* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */ 00128 USB_INTERFACE_DESC_SIZE, /* bLength */ 00129 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00130 0x01, /* bInterfaceNumber */ 00131 0x00, /* bAlternateSetting */ 00132 0x00, /* bNumEndpoints */ 00133 USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ 00134 AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */ 00135 AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 00136 0x00, /* iInterface */ 00137 /* Interface 1, Alternate Setting 1, Audio Streaming - Operational */ 00138 USB_INTERFACE_DESC_SIZE, /* bLength */ 00139 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00140 0x01, /* bInterfaceNumber */ 00141 0x01, /* bAlternateSetting */ 00142 0x01, /* bNumEndpoints */ 00143 USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */ 00144 AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */ 00145 AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */ 00146 0x00, /* iInterface */ 00147 /* Audio Streaming Interface */ 00148 AUDIO_STREAMING_INTERFACE_DESC_SIZE, /* bLength */ 00149 AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00150 AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */ 00151 0x01, /* bTerminalLink */ 00152 0x01, /* bDelay */ 00153 WBVAL(AUDIO_FORMAT_PCM), /* wFormatTag */ 00154 /* Audio Type I Format */ 00155 AUDIO_FORMAT_TYPE_I_DESC_SZ(1), /* bLength */ 00156 AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */ 00157 AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */ 00158 AUDIO_FORMAT_TYPE_I, /* bFormatType */ 00159 0x01, /* bNrChannels */ 00160 0x02, /* bSubFrameSize */ 00161 16, /* bBitResolution */ 00162 0x01, /* bSamFreqType */ 00163 B3VAL(32000), /* tSamFreq */ 00164 /* Endpoint - Standard Descriptor */ 00165 AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */ 00166 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ 00167 USB_ENDPOINT_OUT(3), /* bEndpointAddress */ 00168 USB_ENDPOINT_TYPE_ISOCHRONOUS, /* bmAttributes */ 00169 WBVAL(64), /* wMaxPacketSize */ 00170 0x01, /* bInterval */ 00171 0x00, /* bRefresh */ 00172 0x00, /* bSynchAddress */ 00173 /* Endpoint - Audio Streaming */ 00174 AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */ 00175 AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ 00176 AUDIO_ENDPOINT_GENERAL, /* bDescriptor */ 00177 0x00, /* bmAttributes */ 00178 0x00, /* bLockDelayUnits */ 00179 WBVAL(0x0000), /* wLockDelay */ 00180 /* Terminator */ 00181 0 /* bLength */ 00182 }; 00183 00184 /* USB String Descriptor (optional) */ 00185 const uint8_t USB_StringDescriptor[] = { 00186 /* Index 0x00: LANGID Codes */ 00187 0x04, /* bLength */ 00188 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 00189 WBVAL(0x0409), /* US English */ /* wLANGID */ 00190 /* Index 0x01: Manufacturer */ 00191 (13*2 + 2), /* bLength (13 Char + Type + lenght) */ 00192 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 00193 'N',0, 00194 'X',0, 00195 'P',0, 00196 ' ',0, 00197 'S',0, 00198 'e',0, 00199 'm',0, 00200 'i',0, 00201 'c',0, 00202 'o',0, 00203 'n',0, 00204 'd',0, 00205 ' ',0, 00206 /* Index 0x02: Product */ 00207 (20*2 + 2), /* bLength ( 20 Char + Type + lenght) */ 00208 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 00209 'N',0, 00210 'X',0, 00211 'P',0, 00212 ' ',0, 00213 'L',0, 00214 'P',0, 00215 'C',0, 00216 '1',0, 00217 '7',0, 00218 'x',0, 00219 'x',0, 00220 ' ',0, 00221 'S',0, 00222 'p',0, 00223 'e',0, 00224 'a',0, 00225 'k',0, 00226 'e',0, 00227 'r',0, 00228 ' ',0, 00229 /* Index 0x03: Serial Number */ 00230 (12*2 + 2), /* bLength (12 Char + Type + lenght) */ 00231 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */ 00232 'D',0, 00233 'E',0, 00234 'M',0, 00235 'O',0, 00236 '0',0, 00237 '0',0, 00238 '0',0, 00239 '0',0, 00240 '0',0, 00241 '0',0, 00242 '0',0, 00243 '0',0, 00244 };
Generated on Tue Jul 12 2022 17:28:10 by 1.7.2