You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
257 lines
10 KiB
257 lines
10 KiB
/*----------------------------------------------------------------------------
|
|
* U S B - K e r n e l
|
|
*----------------------------------------------------------------------------
|
|
* Name: usbdesc.c
|
|
* Purpose: USB Descriptors
|
|
* Version: V1.20
|
|
*----------------------------------------------------------------------------
|
|
* This software is supplied "AS IS" without any warranties, express,
|
|
* implied or statutory, including but not limited to the implied
|
|
* warranties of fitness for purpose, satisfactory quality and
|
|
* noninfringement. Keil extends you a royalty-free right to reproduce
|
|
* and distribute executable files created using this software for use
|
|
* on NXP Semiconductors LPC microcontroller devices only. Nothing else
|
|
* gives you the right to use this software.
|
|
*
|
|
* Copyright (c) 2009 Keil - An ARM Company. All rights reserved.
|
|
*----------------------------------------------------------------------------
|
|
* History:
|
|
* V1.20 Changed string descriptor handling
|
|
* V1.00 Initial Version
|
|
*---------------------------------------------------------------------------*/
|
|
extern "C" {
|
|
#include "lpc_types.h"
|
|
}
|
|
|
|
#include "usb.h"
|
|
#include "cdc.h"
|
|
#include "msc.h"
|
|
#include "usbcfg.h"
|
|
#include "usbdesc.h"
|
|
|
|
|
|
/* USB Standard Device Descriptor */
|
|
const uint8_t USB_DeviceDescriptor[] = {
|
|
USB_DEVICE_DESC_SIZE, /* bLength */
|
|
USB_DEVICE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(0x0200), /* 2.0 */ /* bcdUSB */
|
|
USB_DEVICE_CLASS_MISCELLANEOUS, /* bDeviceClass Composite*/
|
|
0x02, /* bDeviceSubClass */
|
|
0x01, /* bDeviceProtocol */
|
|
USB_MAX_PACKET0, /* bMaxPacketSize0 */
|
|
WBVAL(0x1d50), /* idVendor */
|
|
WBVAL(0x6029), /* idProduct */
|
|
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
|
|
0x01, /* iManufacturer */
|
|
0x02, /* iProduct */
|
|
0x03, /* iSerialNumber */
|
|
0x01 /* bNumConfigurations: one possible configuration*/
|
|
};
|
|
|
|
/* USB Configuration Descriptor */
|
|
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
|
|
const uint8_t USB_ConfigDescriptor[] = {
|
|
/* Configuration 1 */
|
|
USB_CONFIGUARTION_DESC_SIZE, /* bLength */
|
|
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL( /* wTotalLength */
|
|
1*USB_CONFIGUARTION_DESC_SIZE +
|
|
// Interface Association Descriptor
|
|
8 +
|
|
//CDC Control Interface
|
|
1*USB_INTERFACE_DESC_SIZE + /* communication interface */
|
|
0x0013 + /* CDC functions */
|
|
1*USB_ENDPOINT_DESC_SIZE + /* interrupt endpoint */
|
|
//CDC Data Interface
|
|
1*USB_INTERFACE_DESC_SIZE + /* data interface */
|
|
2*USB_ENDPOINT_DESC_SIZE + /* bulk endpoints */
|
|
//MSC Interface
|
|
1*USB_INTERFACE_DESC_SIZE +
|
|
2*USB_ENDPOINT_DESC_SIZE
|
|
),
|
|
0x03, /* bNumInterfaces */
|
|
0x01, /* bConfigurationValue: 0x01 is used to select this configuration */
|
|
0x00, /* iConfiguration: no string to describe this configuration */
|
|
USB_CONFIG_BUS_POWERED, /* bmAttributes */
|
|
USB_CONFIG_POWER_MA(500), /* bMaxPower, device power consumption is 500 mA */
|
|
|
|
|
|
/* Interface Association Descriptor */
|
|
0x08,
|
|
0x0B, //DescriptorType : Interface Association
|
|
0x00, //FirstInterface
|
|
0x02, //InterfaceCount
|
|
0x02, //FunctionClass
|
|
0x02, //FunctionSubClass
|
|
0x01, //FunctionProtocol
|
|
0x00, //Function
|
|
|
|
/* Interface 0, Alternate Setting 0, Communication class interface descriptor */
|
|
USB_INTERFACE_DESC_SIZE, /* bLength */
|
|
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_CDC_CIF_NUM, /* bInterfaceNumber: Number of Interface */
|
|
0x00, /* bAlternateSetting: Alternate setting */
|
|
0x01, /* bNumEndpoints: One endpoint used */
|
|
CDC_COMMUNICATION_INTERFACE_CLASS, /* bInterfaceClass: Communication Interface Class */
|
|
CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass: Abstract Control Model */
|
|
0x00, /* bInterfaceProtocol: no protocol used */
|
|
0x00, /* iInterface: */
|
|
|
|
/*Header Functional Descriptor*/
|
|
0x05, /* bLength: Endpoint Descriptor size */
|
|
CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
|
|
CDC_HEADER, /* bDescriptorSubtype: Header Func Desc */
|
|
WBVAL(CDC_V1_10), /* 1.10 */ /* bcdCDC */
|
|
|
|
/*Call Management Functional Descriptor*/
|
|
0x05, /* bFunctionLength */
|
|
CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
|
|
CDC_CALL_MANAGEMENT, /* bDescriptorSubtype: Call Management Func Desc */
|
|
CDC_CALLMGMT_CAP_CALLMGMT | CDC_CALLMGMT_CAP_DATAINTF, /* bmCapabilities: device handles call management */
|
|
0x01, /* bDataInterface: CDC data IF ID */
|
|
|
|
/*Abstract Control Management Functional Descriptor*/
|
|
0x04, /* bFunctionLength */
|
|
CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
|
|
CDC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype: Abstract Control Management desc */
|
|
CDC_ACM_CAP_LINE | CDC_ACM_CAP_BRK,/* bmCapabilities: SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported */
|
|
|
|
/*Union Functional Descriptor*/
|
|
0x05, /* bFunctionLength */
|
|
CDC_CS_INTERFACE, /* bDescriptorType: CS_INTERFACE */
|
|
CDC_UNION, /* bDescriptorSubtype: Union func desc */
|
|
USB_CDC_CIF_NUM, /* bMasterInterface: Communication class interface is master */
|
|
USB_CDC_DIF_NUM, /* bSlaveInterface0: Data class interface is slave 0 */
|
|
|
|
/*Endpoint 1 Descriptor*/ /* event notification (optional) */
|
|
USB_ENDPOINT_DESC_SIZE, /* bLength */
|
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_ENDPOINT_IN(1), /* bEndpointAddress */
|
|
USB_ENDPOINT_TYPE_INTERRUPT, /* bmAttributes */
|
|
WBVAL(0x0010), /* wMaxPacketSize */
|
|
0x10, /* bInterval */
|
|
|
|
|
|
/* Interface 1, Alternate Setting 0, Data class interface descriptor*/
|
|
USB_INTERFACE_DESC_SIZE, /* bLength */
|
|
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_CDC_DIF_NUM, /* bInterfaceNumber: Number of Interface */
|
|
0x00, /* bAlternateSetting: no alternate setting */
|
|
0x02, /* bNumEndpoints: two endpoints used */
|
|
CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass: Data Interface Class */
|
|
0x00, /* bInterfaceSubClass: no subclass available */
|
|
0x00, /* bInterfaceProtocol: no protocol used */
|
|
0x00, /* iInterface: */
|
|
/* Endpoint, EP2 Bulk Out */
|
|
USB_ENDPOINT_DESC_SIZE, /* bLength */
|
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_ENDPOINT_OUT(2), /* bEndpointAddress */
|
|
USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
|
|
WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */
|
|
0x00, /* bInterval: ignore for Bulk transfer */
|
|
/* Endpoint, EP2 Bulk In */
|
|
USB_ENDPOINT_DESC_SIZE, /* bLength */
|
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_ENDPOINT_IN(2), /* bEndpointAddress */
|
|
USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
|
|
WBVAL(USB_CDC_BUFSIZE), /* wMaxPacketSize */
|
|
0x00, /* bInterval: ignore for Bulk transfer */
|
|
|
|
|
|
/* MSC Interface */
|
|
/* Interface 2, Alternate Setting 0, Data class interface descriptor*/
|
|
USB_INTERFACE_DESC_SIZE, /* bLength */
|
|
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
0x02, /* bInterfaceNumber */
|
|
0x00, /* bAlternateSetting */
|
|
0x02, /* bNumEndpoints */
|
|
USB_DEVICE_CLASS_STORAGE, /* bInterfaceClass */
|
|
MSC_SUBCLASS_SCSI, /* bInterfaceSubClass */
|
|
MSC_PROTOCOL_BULK_ONLY, /* bInterfaceProtocol */
|
|
0x00, /* iInterface */
|
|
/* Bulk In Endpoint */
|
|
USB_ENDPOINT_DESC_SIZE, /* bLength */
|
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_ENDPOINT_IN(5), /* bEndpointAddress */
|
|
USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
|
|
WBVAL(0x0040), /* wMaxPacketSize */
|
|
0x00, /* bInterval */
|
|
/* Bulk Out Endpoint */
|
|
USB_ENDPOINT_DESC_SIZE, /* bLength */
|
|
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
USB_ENDPOINT_OUT(5), /* bEndpointAddress */
|
|
USB_ENDPOINT_TYPE_BULK, /* bmAttributes */
|
|
WBVAL(0x0040), /* wMaxPacketSize */
|
|
0,
|
|
/* Terminator */
|
|
0 /* bLength */
|
|
};
|
|
|
|
|
|
|
|
|
|
/* USB String Descriptor (optional) */
|
|
const uint8_t USB_StringDescriptor[] = {
|
|
/* Index 0x00: LANGID Codes */
|
|
0x04, /* bLength */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
WBVAL(0x0409), /* US English */ /* wLANGID */
|
|
/* Index 0x01: Manufacturer */
|
|
(13*2 + 2), /* bLength (13 Char + Type + length) */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'm',0,
|
|
'a',0,
|
|
'r',0,
|
|
'l',0,
|
|
'i',0,
|
|
'n',0,
|
|
'f',0,
|
|
'w',0,
|
|
'.',0,
|
|
'o',0,
|
|
'r',0,
|
|
'g',0,
|
|
' ',0,
|
|
/* Index 0x02: Product */
|
|
(17*2 + 2), /* bLength ( 17 Char + Type + length) */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'M',0,
|
|
'a',0,
|
|
'r',0,
|
|
'l',0,
|
|
'i',0,
|
|
'n',0,
|
|
' ',0,
|
|
'U',0,
|
|
'S',0,
|
|
'B',0,
|
|
' ',0,
|
|
'D',0,
|
|
'e',0,
|
|
'v',0,
|
|
'i',0,
|
|
'c',0,
|
|
'e',0,
|
|
/* Index 0x03: Serial Number */
|
|
(12*2 + 2), /* bLength (12 Char + Type + length) */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'1',0,
|
|
'.',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
'0',0,
|
|
/* Index 0x04: Interface 0, Alternate Setting 0 */
|
|
( 4*2 + 2), /* bLength (4 Char + Type + length) */
|
|
USB_STRING_DESCRIPTOR_TYPE, /* bDescriptorType */
|
|
'V',0,
|
|
'C',0,
|
|
'O',0,
|
|
'M',0,
|
|
};
|
|
|