These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers usbdesc.c Source File

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 microcontroller devices only. Nothing else
00014  *      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 #include "usb.h"
00024 #include "cdc.h"
00025 #include "usbcfg.h"
00026 #include "usbdesc.h"
00027 
00028 
00029 /* USB Standard Device Descriptor */
00030 const uint8_t USB_DeviceDescriptor[] = {
00031   USB_DEVICE_DESC_SIZE,              /* bLength */
00032   USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
00033   WBVAL(0x0200), /* 2.0 */           /* bcdUSB */
00034   USB_DEVICE_CLASS_COMMUNICATIONS,   /* bDeviceClass CDC*/
00035   0x00,                              /* bDeviceSubClass */
00036   0x00,                              /* bDeviceProtocol */
00037   USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
00038   WBVAL(0x1FC9),                     /* idVendor */
00039   WBVAL(0x2002),                     /* idProduct */
00040   WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
00041   0x01,                              /* iManufacturer */
00042   0x02,                              /* iProduct */
00043   0x03,                              /* iSerialNumber */
00044   0x01                               /* bNumConfigurations: one possible configuration*/
00045 };
00046 
00047 /* USB Configuration Descriptor */
00048 /*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
00049 const uint8_t USB_ConfigDescriptor[] = {
00050 /* Configuration 1 */
00051   USB_CONFIGUARTION_DESC_SIZE,       /* bLength */
00052   USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
00053   WBVAL(                             /* wTotalLength */
00054     1*USB_CONFIGUARTION_DESC_SIZE +
00055     1*USB_INTERFACE_DESC_SIZE     +  /* communication interface */
00056     0x0013                        +  /* CDC functions */
00057     1*USB_ENDPOINT_DESC_SIZE      +  /* interrupt endpoint */
00058     1*USB_INTERFACE_DESC_SIZE     +  /* data interface */
00059     2*USB_ENDPOINT_DESC_SIZE         /* bulk endpoints */
00060       ),
00061   0x02,                              /* bNumInterfaces */
00062   0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */
00063   0x00,                              /* iConfiguration: no string to describe this configuration */
00064   USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
00065 /*USB_CONFIG_REMOTE_WAKEUP*/,
00066   USB_CONFIG_POWER_MA(100),          /* bMaxPower, device power consumption is 100 mA */
00067 /* Interface 0, Alternate Setting 0, Communication class interface descriptor */
00068   USB_INTERFACE_DESC_SIZE,           /* bLength */
00069   USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
00070   USB_CDC_CIF_NUM,                   /* bInterfaceNumber: Number of Interface */
00071   0x00,                              /* bAlternateSetting: Alternate setting */
00072   0x01,                              /* bNumEndpoints: One endpoint used */
00073   CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
00074   CDC_ABSTRACT_CONTROL_MODEL,        /* bInterfaceSubClass: Abstract Control Model */
00075   0x00,                              /* bInterfaceProtocol: no protocol used */
00076   0x5E,                              /* iInterface: */
00077 /*Header Functional Descriptor*/
00078   0x05,                              /* bLength: Endpoint Descriptor size */
00079   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
00080   CDC_HEADER,                        /* bDescriptorSubtype: Header Func Desc */
00081   WBVAL(CDC_V1_10), /* 1.10 */       /* bcdCDC */
00082 /*Call Management Functional Descriptor*/
00083   0x05,                              /* bFunctionLength */
00084   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
00085   CDC_CALL_MANAGEMENT,               /* bDescriptorSubtype: Call Management Func Desc */
00086   0x01,                              /* bmCapabilities: device handles call management */
00087   0x01,                              /* bDataInterface: CDC data IF ID */
00088 /*Abstract Control Management Functional Descriptor*/
00089   0x04,                              /* bFunctionLength */
00090   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
00091   CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */
00092   0x02,                              /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
00093 /*Union Functional Descriptor*/
00094   0x05,                              /* bFunctionLength */
00095   CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */
00096   CDC_UNION,                         /* bDescriptorSubtype: Union func desc */
00097   USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */
00098   USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */
00099 /*Endpoint 1 Descriptor*/            /* event notification (optional) */
00100   USB_ENDPOINT_DESC_SIZE,            /* bLength */
00101   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
00102   USB_ENDPOINT_IN(1),                /* bEndpointAddress */
00103   USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
00104   WBVAL(0x0010),                     /* wMaxPacketSize */
00105   0x02,          /* 2ms */           /* bInterval */
00106 /* Interface 1, Alternate Setting 0, Data class interface descriptor*/
00107   USB_INTERFACE_DESC_SIZE,           /* bLength */
00108   USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
00109   USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */
00110   0x00,                              /* bAlternateSetting: no alternate setting */
00111   0x02,                              /* bNumEndpoints: two endpoints used */
00112   CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */
00113   0x00,                              /* bInterfaceSubClass: no subclass available */
00114   0x00,                              /* bInterfaceProtocol: no protocol used */
00115   0x5E,                              /* iInterface: */
00116 /* Endpoint, EP2 Bulk Out */
00117   USB_ENDPOINT_DESC_SIZE,            /* bLength */
00118   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
00119   USB_ENDPOINT_OUT(2),               /* bEndpointAddress */
00120   USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
00121   WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */
00122   0x00,                              /* bInterval: ignore for Bulk transfer */
00123 /* Endpoint, EP2 Bulk In */
00124   USB_ENDPOINT_DESC_SIZE,            /* bLength */
00125   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
00126   USB_ENDPOINT_IN(2),                /* bEndpointAddress */
00127   USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */
00128   WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */
00129   0x00,                              /* bInterval: ignore for Bulk transfer */
00130 /* Terminator */
00131   0                                  /* bLength */
00132 };
00133 
00134 
00135 
00136 
00137 /* USB String Descriptor (optional) */
00138 const uint8_t USB_StringDescriptor[] = {
00139 /* Index 0x00: LANGID Codes */
00140   0x04,                              /* bLength */
00141   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00142   WBVAL(0x0409), /* US English */    /* wLANGID */
00143 /* Index 0x01: Manufacturer */
00144   (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */
00145   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00146   'N',0,
00147   'X',0,
00148   'P',0,
00149   ' ',0,
00150   'S',0,
00151   'E',0,
00152   'M',0,
00153   'I',0,
00154   'C',0,
00155   'O',0,
00156   'N',0,
00157   'D',0,
00158   ' ',0,
00159 /* Index 0x02: Product */
00160   (17*2 + 2),                        /* bLength ( 17 Char + Type + lenght) */
00161   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00162   'N',0,
00163   'X',0,
00164   'P',0,
00165   ' ',0,
00166   'L',0,
00167   'P',0,
00168   'C',0,
00169   '1',0,
00170   '7',0,
00171   'x',0,
00172   'x',0,
00173   ' ',0,
00174   'V',0,
00175   'C',0,
00176   'O',0,
00177   'M',0,
00178   ' ',0,
00179 /* Index 0x03: Serial Number */
00180   (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */
00181   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00182   'D',0,
00183   'E',0,
00184   'M',0,
00185   'O',0,
00186   '0',0,
00187   '0',0,
00188   '0',0,
00189   '0',0,
00190   '0',0,
00191   '0',0,
00192   '0',0,
00193   '0',0,
00194 /* Index 0x04: Interface 0, Alternate Setting 0 */
00195   ( 4*2 + 2),                        /* bLength (4 Char + Type + lenght) */
00196   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00197   'V',0,
00198   'C',0,
00199   'O',0,
00200   'M',0,
00201 };