initial usb
[rapper.git] / new_cmsis / usb / usbdesc.c
diff --git a/new_cmsis/usb/usbdesc.c b/new_cmsis/usb/usbdesc.c
new file mode 100755 (executable)
index 0000000..a2a75b0
--- /dev/null
@@ -0,0 +1,201 @@
+/*----------------------------------------------------------------------------\r
+ *      U S B  -  K e r n e l\r
+ *----------------------------------------------------------------------------\r
+ * Name:    usbdesc.c\r
+ * Purpose: USB Descriptors\r
+ * Version: V1.20\r
+ *----------------------------------------------------------------------------\r
+ *      This software is supplied "AS IS" without any warranties, express,\r
+ *      implied or statutory, including but not limited to the implied\r
+ *      warranties of fitness for purpose, satisfactory quality and\r
+ *      noninfringement. Keil extends you a royalty-free right to reproduce\r
+ *      and distribute executable files created using this software for use\r
+ *      on NXP Semiconductors LPC microcontroller devices only. Nothing else\r
+ *      gives you the right to use this software.\r
+ *\r
+ * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.\r
+ *----------------------------------------------------------------------------\r
+ * History:\r
+ *          V1.20 Changed string descriptor handling\r
+ *          V1.00 Initial Version\r
+ *---------------------------------------------------------------------------*/\r
+#include "lpc_types.h"\r
+#include "usb.h"\r
+#include "cdc.h"\r
+#include "usbcfg.h"\r
+#include "usbdesc.h"\r
+\r
+\r
+/* USB Standard Device Descriptor */\r
+const uint8_t USB_DeviceDescriptor[] = {\r
+  USB_DEVICE_DESC_SIZE,              /* bLength */\r
+  USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
+  WBVAL(0x0200), /* 2.0 */           /* bcdUSB */\r
+  USB_DEVICE_CLASS_COMMUNICATIONS,   /* bDeviceClass CDC*/\r
+  0x00,                              /* bDeviceSubClass */\r
+  0x00,                              /* bDeviceProtocol */\r
+  USB_MAX_PACKET0,                   /* bMaxPacketSize0 */\r
+  WBVAL(0x1FC9),                     /* idVendor */\r
+  WBVAL(0x2002),                     /* idProduct */\r
+  WBVAL(0x0100), /* 1.00 */          /* bcdDevice */\r
+  0x01,                              /* iManufacturer */\r
+  0x02,                              /* iProduct */\r
+  0x03,                              /* iSerialNumber */\r
+  0x01                               /* bNumConfigurations: one possible configuration*/\r
+};\r
+\r
+/* USB Configuration Descriptor */\r
+/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */\r
+const uint8_t USB_ConfigDescriptor[] = {\r
+/* Configuration 1 */\r
+  USB_CONFIGUARTION_DESC_SIZE,       /* bLength */\r
+  USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */\r
+  WBVAL(                             /* wTotalLength */\r
+    1*USB_CONFIGUARTION_DESC_SIZE +\r
+    1*USB_INTERFACE_DESC_SIZE     +  /* communication interface */\r
+    0x0013                        +  /* CDC functions */\r
+    1*USB_ENDPOINT_DESC_SIZE      +  /* interrupt endpoint */\r
+    1*USB_INTERFACE_DESC_SIZE     +  /* data interface */\r
+    2*USB_ENDPOINT_DESC_SIZE         /* bulk endpoints */\r
+      ),\r
+  0x02,                              /* bNumInterfaces */\r
+  0x01,                              /* bConfigurationValue: 0x01 is used to select this configuration */\r
+  0x00,                              /* iConfiguration: no string to describe this configuration */\r
+  USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */\r
+/*USB_CONFIG_REMOTE_WAKEUP*/,\r
+  USB_CONFIG_POWER_MA(100),          /* bMaxPower, device power consumption is 100 mA */\r
+/* Interface 0, Alternate Setting 0, Communication class interface descriptor */\r
+  USB_INTERFACE_DESC_SIZE,           /* bLength */\r
+  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */\r
+  USB_CDC_CIF_NUM,                   /* bInterfaceNumber: Number of Interface */\r
+  0x00,                              /* bAlternateSetting: Alternate setting */\r
+  0x01,                              /* bNumEndpoints: One endpoint used */\r
+  CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */\r
+  CDC_ABSTRACT_CONTROL_MODEL,        /* bInterfaceSubClass: Abstract Control Model */\r
+  0x00,                              /* bInterfaceProtocol: no protocol used */\r
+  0x5E,                              /* iInterface: */\r
+/*Header Functional Descriptor*/\r
+  0x05,                              /* bLength: Endpoint Descriptor size */\r
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
+  CDC_HEADER,                        /* bDescriptorSubtype: Header Func Desc */\r
+  WBVAL(CDC_V1_10), /* 1.10 */       /* bcdCDC */\r
+/*Call Management Functional Descriptor*/\r
+  0x05,                              /* bFunctionLength */\r
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
+  CDC_CALL_MANAGEMENT,               /* bDescriptorSubtype: Call Management Func Desc */\r
+  0x01,                              /* bmCapabilities: device handles call management */\r
+  0x01,                              /* bDataInterface: CDC data IF ID */\r
+/*Abstract Control Management Functional Descriptor*/\r
+  0x04,                              /* bFunctionLength */\r
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
+  CDC_ABSTRACT_CONTROL_MANAGEMENT,   /* bDescriptorSubtype: Abstract Control Management desc */\r
+  0x02,                              /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */\r
+/*Union Functional Descriptor*/\r
+  0x05,                              /* bFunctionLength */\r
+  CDC_CS_INTERFACE,                  /* bDescriptorType: CS_INTERFACE */\r
+  CDC_UNION,                         /* bDescriptorSubtype: Union func desc */\r
+  USB_CDC_CIF_NUM,                   /* bMasterInterface: Communication class interface is master */\r
+  USB_CDC_DIF_NUM,                   /* bSlaveInterface0: Data class interface is slave 0 */\r
+/*Endpoint 1 Descriptor*/            /* event notification (optional) */\r
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */\r
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */\r
+  USB_ENDPOINT_IN(1),                /* bEndpointAddress */\r
+  USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */\r
+  WBVAL(0x0010),                     /* wMaxPacketSize */\r
+  0x02,          /* 2ms */           /* bInterval */\r
+/* Interface 1, Alternate Setting 0, Data class interface descriptor*/\r
+  USB_INTERFACE_DESC_SIZE,           /* bLength */\r
+  USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */\r
+  USB_CDC_DIF_NUM,                   /* bInterfaceNumber: Number of Interface */\r
+  0x00,                              /* bAlternateSetting: no alternate setting */\r
+  0x02,                              /* bNumEndpoints: two endpoints used */\r
+  CDC_DATA_INTERFACE_CLASS,          /* bInterfaceClass: Data Interface Class */\r
+  0x00,                              /* bInterfaceSubClass: no subclass available */\r
+  0x00,                              /* bInterfaceProtocol: no protocol used */\r
+  0x5E,                              /* iInterface: */\r
+/* Endpoint, EP2 Bulk Out */\r
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */\r
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */\r
+  USB_ENDPOINT_OUT(2),               /* bEndpointAddress */\r
+  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */\r
+  WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */\r
+  0x00,                              /* bInterval: ignore for Bulk transfer */\r
+/* Endpoint, EP2 Bulk In */\r
+  USB_ENDPOINT_DESC_SIZE,            /* bLength */\r
+  USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */\r
+  USB_ENDPOINT_IN(2),                /* bEndpointAddress */\r
+  USB_ENDPOINT_TYPE_BULK,            /* bmAttributes */\r
+  WBVAL(USB_CDC_BUFSIZE),            /* wMaxPacketSize */\r
+  0x00,                              /* bInterval: ignore for Bulk transfer */\r
+/* Terminator */\r
+  0                                  /* bLength */\r
+};\r
+\r
+\r
+\r
+\r
+/* USB String Descriptor (optional) */\r
+const uint8_t USB_StringDescriptor[] = {\r
+/* Index 0x00: LANGID Codes */\r
+  0x04,                              /* bLength */\r
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
+  WBVAL(0x0409), /* US English */    /* wLANGID */\r
+/* Index 0x01: Manufacturer */\r
+  (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */\r
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
+  'N',0,\r
+  'X',0,\r
+  'P',0,\r
+  ' ',0,\r
+  'S',0,\r
+  'E',0,\r
+  'M',0,\r
+  'I',0,\r
+  'C',0,\r
+  'O',0,\r
+  'N',0,\r
+  'D',0,\r
+  ' ',0,\r
+/* Index 0x02: Product */\r
+  (17*2 + 2),                        /* bLength ( 17 Char + Type + lenght) */\r
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
+  'N',0,\r
+  'X',0,\r
+  'P',0,\r
+  ' ',0,\r
+  'L',0,\r
+  'P',0,\r
+  'C',0,\r
+  '1',0,\r
+  '7',0,\r
+  'x',0,\r
+  'x',0,\r
+  ' ',0,\r
+  'V',0,\r
+  'C',0,\r
+  'O',0,\r
+  'M',0,\r
+  ' ',0,\r
+/* Index 0x03: Serial Number */\r
+  (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */\r
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
+  'D',0,\r
+  'E',0,\r
+  'M',0,\r
+  'O',0,\r
+  '0',0,\r
+  '0',0,\r
+  '0',0,\r
+  '0',0,\r
+  '0',0,\r
+  '0',0,\r
+  '0',0,\r
+  '0',0,\r
+/* Index 0x04: Interface 0, Alternate Setting 0 */\r
+  ( 4*2 + 2),                        /* bLength (4 Char + Type + lenght) */\r
+  USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */\r
+  'V',0,\r
+  'C',0,\r
+  'O',0,\r
+  'M',0,\r
+};\r