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.10
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) 2005-2009 Keil Software.
00017  *---------------------------------------------------------------------------*/
00018 
00019 #include "lpc_types.h"
00020 
00021 #include "usb.h"
00022 #include "usbcfg.h"
00023 #include "usbdesc.h"
00024 
00025 #include "hid.h"
00026 
00027 /* HID Report Descriptor */
00028 const uint8_t HID_ReportDescriptor[] = {
00029   HID_UsagePageVendor(0x00),
00030   HID_Usage(0x01),
00031   HID_Collection(HID_Application),
00032     HID_UsagePage(HID_USAGE_PAGE_BUTTON),
00033     HID_UsageMin(1),
00034     HID_UsageMax(3),
00035     HID_LogicalMin(0),
00036     HID_LogicalMax(1),
00037     HID_ReportCount(3),
00038     HID_ReportSize(1),
00039     HID_Input(HID_Data | HID_Variable | HID_Absolute),
00040     HID_ReportCount(1),
00041     HID_ReportSize(5),
00042     HID_Input(HID_Constant),
00043     HID_UsagePage(HID_USAGE_PAGE_LED),
00044     HID_Usage(HID_USAGE_LED_GENERIC_INDICATOR),
00045     HID_LogicalMin(0),
00046     HID_LogicalMax(1),
00047     HID_ReportCount(8),
00048     HID_ReportSize(1),
00049     HID_Output(HID_Data | HID_Variable | HID_Absolute),
00050   HID_EndCollection,
00051 };
00052 
00053 const uint16_t HID_ReportDescSize = sizeof(HID_ReportDescriptor);
00054 
00055 
00056 /* USB Standard Device Descriptor */
00057 const uint8_t USB_DeviceDescriptor[] = {
00058   USB_DEVICE_DESC_SIZE,              /* bLength */
00059   USB_DEVICE_DESCRIPTOR_TYPE,        /* bDescriptorType */
00060   WBVAL(0x0200), /* 2.00 */          /* bcdUSB */
00061   0x00,                              /* bDeviceClass */
00062   0x00,                              /* bDeviceSubClass */
00063   0x00,                              /* bDeviceProtocol */
00064   USB_MAX_PACKET0,                   /* bMaxPacketSize0 */
00065   WBVAL(0xC251),                     /* idVendor */
00066   WBVAL(0x2201),                     /* idProduct */
00067   WBVAL(0x0100), /* 1.00 */          /* bcdDevice */
00068   0x04,                              /* iManufacturer */
00069   0x20,                              /* iProduct */
00070   0x42,                              /* iSerialNumber */
00071   0x01                               /* bNumConfigurations */
00072 };
00073 
00074 /* USB Configuration Descriptor */
00075 /*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
00076 const uint8_t USB_ConfigDescriptor[] = {
00077 /* Configuration 1 */
00078   USB_CONFIGUARTION_DESC_SIZE,       /* bDescriptorType */
00079   USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
00080   WBVAL(                             /* wTotalLength */
00081     USB_CONFIGUARTION_DESC_SIZE +
00082     USB_INTERFACE_DESC_SIZE     +
00083     HID_DESC_SIZE               +
00084     USB_ENDPOINT_DESC_SIZE
00085   ),
00086   0x01,                              /* bNumInterfaces */
00087   0x01,                              /* bConfigurationValue */
00088   0x00,                              /* iConfiguration */
00089   USB_CONFIG_BUS_POWERED /*|*/       /* bmAttributes */
00090 /*USB_CONFIG_REMOTE_WAKEUP*/,
00091   USB_CONFIG_POWER_MA(100),          /* bMaxPower */
00092 /* Interface 0, Alternate Setting 0, HID Class */
00093   USB_INTERFACE_DESC_SIZE,           /* bLength */
00094   USB_INTERFACE_DESCRIPTOR_TYPE,     /* bDescriptorType */
00095   0x00,                              /* bInterfaceNumber */
00096   0x00,                              /* bAlternateSetting */
00097   0x01,                              /* bNumEndpoints */
00098   USB_DEVICE_CLASS_HUMAN_INTERFACE,  /* bInterfaceClass */
00099   HID_SUBCLASS_NONE,                 /* bInterfaceSubClass */
00100   HID_PROTOCOL_NONE,                 /* bInterfaceProtocol */
00101   0x5C,                              /* iInterface */
00102 /* HID Class Descriptor */
00103 /* HID_DESC_OFFSET = 0x0012 */
00104   HID_DESC_SIZE,                     /* bLength */
00105   HID_HID_DESCRIPTOR_TYPE,           /* bDescriptorType */
00106   WBVAL(0x0100), /* 1.00 */          /* bcdHID */
00107   0x00,                              /* bCountryCode */
00108   0x01,                              /* bNumDescriptors */
00109   HID_REPORT_DESCRIPTOR_TYPE,        /* bDescriptorType */
00110   WBVAL(HID_REPORT_DESC_SIZE),       /* wDescriptorLength */
00111 /* Endpoint, HID Interrupt In */
00112   USB_ENDPOINT_DESC_SIZE,            /* bLength */
00113   USB_ENDPOINT_DESCRIPTOR_TYPE,      /* bDescriptorType */
00114   USB_ENDPOINT_IN(1),                /* bEndpointAddress */
00115   USB_ENDPOINT_TYPE_INTERRUPT,       /* bmAttributes */
00116   WBVAL(0x0004),                     /* wMaxPacketSize */
00117   0x20,          /* 32ms */          /* bInterval */
00118 /* Terminator */
00119   0                                  /* bLength */
00120 };
00121 
00122 /* USB String Descriptor (optional) */
00123 const uint8_t USB_StringDescriptor[] = {
00124 /* Index 0x00: LANGID Codes */
00125   0x04,                              /* bLength */
00126   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00127   WBVAL(0x0409), /* US English */    /* wLANGID */
00128 /* Index 0x04: Manufacturer */
00129   0x1C,                              /* bLength */
00130   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00131   'N',0,
00132   'X',0,
00133   'P',0,
00134   ' ',0,
00135   'S',0,
00136   'E',0,
00137   'M',0,
00138   'I',0,
00139   'C',0,
00140   'O',0,
00141   'N',0,
00142   'D',0,
00143   ' ',0,
00144 /* Index 0x20: Product */
00145   0x22,                              /* bLength */
00146   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00147   'L',0,
00148   'P',0,
00149   'C',0,
00150   '1',0,
00151   '7',0,
00152   'x',0,
00153   'x',0,
00154   ' ',0,
00155   'H',0,
00156   'I',0,
00157   'D',0,
00158   ' ',0,
00159   ' ',0,
00160   ' ',0,
00161   ' ',0,
00162   ' ',0,
00163 /* Index 0x42: Serial Number */
00164   0x1A,                              /* bLength */
00165   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00166   'D',0,
00167   'E',0,
00168   'M',0,
00169   'O',0,
00170   '0',0,
00171   '0',0,
00172   '0',0,
00173   '0',0,
00174   '0',0,
00175   '0',0,
00176   '0',0,
00177   '0',0,
00178 /* Index 0x5C: Interface 0, Alternate Setting 0 */
00179   0x08,                              /* bLength */
00180   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
00181   'H',0,
00182   'I',0,
00183   'D',0,
00184 };