Port of Keils USBCDC example, compiles ok. Gets stuck at init

Dependencies:   mbed

Committer:
tecnosys
Date:
Mon Jul 05 10:16:57 2010 +0000
Revision:
0:0b777ff85deb

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tecnosys 0:0b777ff85deb 1 /*----------------------------------------------------------------------------
tecnosys 0:0b777ff85deb 2 * U S B - K e r n e l
tecnosys 0:0b777ff85deb 3 *----------------------------------------------------------------------------
tecnosys 0:0b777ff85deb 4 * Name: usbdesc.c
tecnosys 0:0b777ff85deb 5 * Purpose: USB Descriptors
tecnosys 0:0b777ff85deb 6 * Version: V1.20
tecnosys 0:0b777ff85deb 7 *----------------------------------------------------------------------------
tecnosys 0:0b777ff85deb 8 * This software is supplied "AS IS" without any warranties, express,
tecnosys 0:0b777ff85deb 9 * implied or statutory, including but not limited to the implied
tecnosys 0:0b777ff85deb 10 * warranties of fitness for purpose, satisfactory quality and
tecnosys 0:0b777ff85deb 11 * noninfringement. Keil extends you a royalty-free right to reproduce
tecnosys 0:0b777ff85deb 12 * and distribute executable files created using this software for use
tecnosys 0:0b777ff85deb 13 * on NXP Semiconductors LPC microcontroller devices only. Nothing else
tecnosys 0:0b777ff85deb 14 * gives you the right to use this software.
tecnosys 0:0b777ff85deb 15 *
tecnosys 0:0b777ff85deb 16 * Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
tecnosys 0:0b777ff85deb 17 *----------------------------------------------------------------------------
tecnosys 0:0b777ff85deb 18 * History:
tecnosys 0:0b777ff85deb 19 * V1.20 Changed string descriptor handling
tecnosys 0:0b777ff85deb 20 * V1.00 Initial Version
tecnosys 0:0b777ff85deb 21 *---------------------------------------------------------------------------*/
tecnosys 0:0b777ff85deb 22 #include "type.h"
tecnosys 0:0b777ff85deb 23 #include "usb.h"
tecnosys 0:0b777ff85deb 24 #include "cdc.h"
tecnosys 0:0b777ff85deb 25 #include "usbcfg.h"
tecnosys 0:0b777ff85deb 26 #include "usbdesc.h"
tecnosys 0:0b777ff85deb 27
tecnosys 0:0b777ff85deb 28
tecnosys 0:0b777ff85deb 29 /* USB Standard Device Descriptor */
tecnosys 0:0b777ff85deb 30 const uint8_t USB_DeviceDescriptor[] = {
tecnosys 0:0b777ff85deb 31 USB_DEVICE_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 32 USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 33 WBVAL(0x0200), /* 2.0 */ /* bcdUSB */
tecnosys 0:0b777ff85deb 34 USB_DEVICE_CLASS_COMMUNICATIONS, /* bDeviceClass CDC*/
tecnosys 0:0b777ff85deb 35 0x00, /* bDeviceSubClass */
tecnosys 0:0b777ff85deb 36 0x00, /* bDeviceProtocol */
tecnosys 0:0b777ff85deb 37 USB_MAX_PACKET0, /* bMaxPacketSize0 */
tecnosys 0:0b777ff85deb 38 WBVAL(0x1FC9), /* idVendor */
tecnosys 0:0b777ff85deb 39 WBVAL(0x2002), /* idProduct */
tecnosys 0:0b777ff85deb 40 WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
tecnosys 0:0b777ff85deb 41 0x01, /* iManufacturer */
tecnosys 0:0b777ff85deb 42 0x02, /* iProduct */
tecnosys 0:0b777ff85deb 43 0x03, /* iSerialNumber */
tecnosys 0:0b777ff85deb 44 0x01 /* bNumConfigurations: one possible configuration*/
tecnosys 0:0b777ff85deb 45 };
tecnosys 0:0b777ff85deb 46
tecnosys 0:0b777ff85deb 47 /* USB Configuration Descriptor */
tecnosys 0:0b777ff85deb 48 /* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
tecnosys 0:0b777ff85deb 49 const uint8_t USB_ConfigDescriptor[] = {
tecnosys 0:0b777ff85deb 50 /* Configuration 1 */
tecnosys 0:0b777ff85deb 51 USB_CONFIGUARTION_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 52 USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 53 WBVAL( /* wTotalLength */
tecnosys 0:0b777ff85deb 54 1*USB_CONFIGUARTION_DESC_SIZE +
tecnosys 0:0b777ff85deb 55 1*USB_INTERFACE_DESC_SIZE + /* communication interface */
tecnosys 0:0b777ff85deb 56 0x0013 + /* CDC functions */
tecnosys 0:0b777ff85deb 57 1*USB_ENDPOINT_DESC_SIZE + /* interrupt endpoint */
tecnosys 0:0b777ff85deb 58 1*USB_INTERFACE_DESC_SIZE + /* data interface */
tecnosys 0:0b777ff85deb 59 2*USB_ENDPOINT_DESC_SIZE /* bulk endpoints */
tecnosys 0:0b777ff85deb 60 ),
tecnosys 0:0b777ff85deb 61 0x02, /* bNumInterfaces */
tecnosys 0:0b777ff85deb 62 0x01, /* bConfigurationValue: 0x01 is used to select this configuration */
tecnosys 0:0b777ff85deb 63 0x00, /* iConfiguration: no string to describe this configuration */
tecnosys 0:0b777ff85deb 64 USB_CONFIG_BUS_POWERED /*|*/ /* bmAttributes */
tecnosys 0:0b777ff85deb 65 /*USB_CONFIG_REMOTE_WAKEUP*/,
tecnosys 0:0b777ff85deb 66 USB_CONFIG_POWER_MA(100), /* bMaxPower, device power consumption is 100 mA */
tecnosys 0:0b777ff85deb 67 /* Interface 0, Alternate Setting 0, Communication class interface descriptor */
tecnosys 0:0b777ff85deb 68 USB_INTERFACE_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 69 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 70 USB_CDC_CIF_NUM, /* bInterfaceNumber: Number of Interface */
tecnosys 0:0b777ff85deb 71 0x00, /* bAlternateSetting: Alternate setting */
tecnosys 0:0b777ff85deb 72 0x01, /* bNumEndpoints: One endpoint used */
tecnosys 0:0b777ff85deb 73 CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
tecnosys 0:0b777ff85deb 74 CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass: Abstract Control Model */
tecnosys 0:0b777ff85deb 75 0x00, /* bInterfaceProtocol: no protocol used */
tecnosys 0:0b777ff85deb 76 0x5E, /* iInterface: */
tecnosys 0:0b777ff85deb 77 /*Header Functional Descriptor*/
tecnosys 0:0b777ff85deb 78 0x05, /* bLength: Endpoint Descriptor size */
tecnosys 0:0b777ff85deb 79 CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
tecnosys 0:0b777ff85deb 80 CDC_HEADER, /* bDescriptorSubtype: Header Func Desc */
tecnosys 0:0b777ff85deb 81 WBVAL(CDC_V1_10), /* 1.10 */ /* bcdCDC */
tecnosys 0:0b777ff85deb 82 /*Call Management Functional Descriptor*/
tecnosys 0:0b777ff85deb 83 0x05, /* bFunctionLength */
tecnosys 0:0b777ff85deb 84 CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
tecnosys 0:0b777ff85deb 85 CDC_CALL_MANAGEMENT, /* bDescriptorSubtype: Call Management Func Desc */
tecnosys 0:0b777ff85deb 86 0x01, /* bmCapabilities: device handles call management */
tecnosys 0:0b777ff85deb 87 0x01, /* bDataInterface: CDC data IF ID */
tecnosys 0:0b777ff85deb 88 /*Abstract Control Management Functional Descriptor*/
tecnosys 0:0b777ff85deb 89 0x04, /* bFunctionLength */
tecnosys 0:0b777ff85deb 90 CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
tecnosys 0:0b777ff85deb 91 CDC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype: Abstract Control Management desc */
tecnosys 0:0b777ff85deb 92 0x02, /* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
tecnosys 0:0b777ff85deb 93 /*Union Functional Descriptor*/
tecnosys 0:0b777ff85deb 94 0x05, /* bFunctionLength */
tecnosys 0:0b777ff85deb 95 CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
tecnosys 0:0b777ff85deb 96 CDC_UNION, /* bDescriptorSubtype: Union func desc */
tecnosys 0:0b777ff85deb 97 USB_CDC_CIF_NUM, /* bMasterInterface: Communication class interface is master */
tecnosys 0:0b777ff85deb 98 USB_CDC_DIF_NUM, /* bSlaveInterface0: Data class interface is slave 0 */
tecnosys 0:0b777ff85deb 99 /*Endpoint 1 Descriptor*/ /* event notification (optional) */
tecnosys 0:0b777ff85deb 100 USB_ENDPOINT_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 101 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 102 USB_ENDPOINT_IN(1), /* bEndpointAddress */
tecnosys 0:0b777ff85deb 103 USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
tecnosys 0:0b777ff85deb 104 WBVAL(0x0010), /* wMaxPacketSize */
tecnosys 0:0b777ff85deb 105 0x02, /* 2ms */ /* bInterval */
tecnosys 0:0b777ff85deb 106 /* Interface 1, Alternate Setting 0, Data class interface descriptor*/
tecnosys 0:0b777ff85deb 107 USB_INTERFACE_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 108 USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 109 USB_CDC_DIF_NUM, /* bInterfaceNumber: Number of Interface */
tecnosys 0:0b777ff85deb 110 0x00, /* bAlternateSetting: no alternate setting */
tecnosys 0:0b777ff85deb 111 0x02, /* bNumEndpoints: two endpoints used */
tecnosys 0:0b777ff85deb 112 CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass: Data Interface Class */
tecnosys 0:0b777ff85deb 113 0x00, /* bInterfaceSubClass: no subclass available */
tecnosys 0:0b777ff85deb 114 0x00, /* bInterfaceProtocol: no protocol used */
tecnosys 0:0b777ff85deb 115 0x5E, /* iInterface: */
tecnosys 0:0b777ff85deb 116 /* Endpoint, EP2 Bulk Out */
tecnosys 0:0b777ff85deb 117 USB_ENDPOINT_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 118 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 119 USB_ENDPOINT_OUT(2), /* bEndpointAddress */
tecnosys 0:0b777ff85deb 120 USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
tecnosys 0:0b777ff85deb 121 WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */
tecnosys 0:0b777ff85deb 122 0x00, /* bInterval: ignore for Bulk transfer */
tecnosys 0:0b777ff85deb 123 /* Endpoint, EP2 Bulk In */
tecnosys 0:0b777ff85deb 124 USB_ENDPOINT_DESC_SIZE, /* bLength */
tecnosys 0:0b777ff85deb 125 USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 126 USB_ENDPOINT_IN(2), /* bEndpointAddress */
tecnosys 0:0b777ff85deb 127 USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
tecnosys 0:0b777ff85deb 128 WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */
tecnosys 0:0b777ff85deb 129 0x00, /* bInterval: ignore for Bulk transfer */
tecnosys 0:0b777ff85deb 130 /* Terminator */
tecnosys 0:0b777ff85deb 131 0 /* bLength */
tecnosys 0:0b777ff85deb 132 };
tecnosys 0:0b777ff85deb 133
tecnosys 0:0b777ff85deb 134
tecnosys 0:0b777ff85deb 135
tecnosys 0:0b777ff85deb 136
tecnosys 0:0b777ff85deb 137 /* USB String Descriptor (optional) */
tecnosys 0:0b777ff85deb 138 const uint8_t USB_StringDescriptor[] = {
tecnosys 0:0b777ff85deb 139 /* Index 0x00: LANGID Codes */
tecnosys 0:0b777ff85deb 140 0x04, /* bLength */
tecnosys 0:0b777ff85deb 141 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 142 WBVAL(0x0409), /* US English */ /* wLANGID */
tecnosys 0:0b777ff85deb 143 /* Index 0x01: Manufacturer */
tecnosys 0:0b777ff85deb 144 (13*2 + 2), /* bLength (13 Char + Type + lenght) */
tecnosys 0:0b777ff85deb 145 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 146 'N',0,
tecnosys 0:0b777ff85deb 147 'X',0,
tecnosys 0:0b777ff85deb 148 'P',0,
tecnosys 0:0b777ff85deb 149 ' ',0,
tecnosys 0:0b777ff85deb 150 'S',0,
tecnosys 0:0b777ff85deb 151 'E',0,
tecnosys 0:0b777ff85deb 152 'M',0,
tecnosys 0:0b777ff85deb 153 'I',0,
tecnosys 0:0b777ff85deb 154 'C',0,
tecnosys 0:0b777ff85deb 155 'O',0,
tecnosys 0:0b777ff85deb 156 'N',0,
tecnosys 0:0b777ff85deb 157 'D',0,
tecnosys 0:0b777ff85deb 158 ' ',0,
tecnosys 0:0b777ff85deb 159 /* Index 0x02: Product */
tecnosys 0:0b777ff85deb 160 (17*2 + 2), /* bLength ( 17 Char + Type + lenght) */
tecnosys 0:0b777ff85deb 161 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 162 'N',0,
tecnosys 0:0b777ff85deb 163 'X',0,
tecnosys 0:0b777ff85deb 164 'P',0,
tecnosys 0:0b777ff85deb 165 ' ',0,
tecnosys 0:0b777ff85deb 166 'L',0,
tecnosys 0:0b777ff85deb 167 'P',0,
tecnosys 0:0b777ff85deb 168 'C',0,
tecnosys 0:0b777ff85deb 169 '1',0,
tecnosys 0:0b777ff85deb 170 '7',0,
tecnosys 0:0b777ff85deb 171 'x',0,
tecnosys 0:0b777ff85deb 172 'x',0,
tecnosys 0:0b777ff85deb 173 ' ',0,
tecnosys 0:0b777ff85deb 174 'V',0,
tecnosys 0:0b777ff85deb 175 'C',0,
tecnosys 0:0b777ff85deb 176 'O',0,
tecnosys 0:0b777ff85deb 177 'M',0,
tecnosys 0:0b777ff85deb 178 ' ',0,
tecnosys 0:0b777ff85deb 179 /* Index 0x03: Serial Number */
tecnosys 0:0b777ff85deb 180 (12*2 + 2), /* bLength (12 Char + Type + lenght) */
tecnosys 0:0b777ff85deb 181 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 182 'D',0,
tecnosys 0:0b777ff85deb 183 'E',0,
tecnosys 0:0b777ff85deb 184 'M',0,
tecnosys 0:0b777ff85deb 185 'O',0,
tecnosys 0:0b777ff85deb 186 '0',0,
tecnosys 0:0b777ff85deb 187 '0',0,
tecnosys 0:0b777ff85deb 188 '0',0,
tecnosys 0:0b777ff85deb 189 '0',0,
tecnosys 0:0b777ff85deb 190 '0',0,
tecnosys 0:0b777ff85deb 191 '0',0,
tecnosys 0:0b777ff85deb 192 '0',0,
tecnosys 0:0b777ff85deb 193 '0',0,
tecnosys 0:0b777ff85deb 194 /* Index 0x04: Interface 0, Alternate Setting 0 */
tecnosys 0:0b777ff85deb 195 ( 4*2 + 2), /* bLength (4 Char + Type + lenght) */
tecnosys 0:0b777ff85deb 196 USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
tecnosys 0:0b777ff85deb 197 'V',0,
tecnosys 0:0b777ff85deb 198 'C',0,
tecnosys 0:0b777ff85deb 199 'O',0,
tecnosys 0:0b777ff85deb 200 'M',0,
tecnosys 0:0b777ff85deb 201 };