📄 usb_descriptor.h
字号:
/*********************************************************************
(c) copyright Freescale Semiconductor Hong Kong Ltd
ALL RIGHTS RESERVED
*********************************************************************
USB Driver Module for S12 MCUs
*********************************************************************
File: usb_descriptor.h
Description: Global Data allocation for USB Driver
Date: Mar. 2003
Author: Vincent Ko
********************************************************************/
//
// All the global variables are allocated in this module. Please
// note that once a new variable is allocated here. The same
// prototype should be claimed in specific header file.
//
// If it's required by USB module internally, put the prototype
// in the file <usb_includes.h>.
//
// If it's required by the other modules in the system, put the
// prototypes in the file <usb_extern.h>. So other modules can
// include it to know how to refer it.
//
#ifndef _H_USB_DESCRIPTOR_
#define _H_USB_DESCRIPTOR_
//
#pragma CODE_SEG DEFAULT
// ======================================================
//
// Device Descriptor USB 2.0
//
// ======================================================
const muint8 Device_Descriptor[18] = {
0x12, //blength
0x01, //bDescriptor
0x00,0x02, //bcdUSB ver 2.0
0x00, //bDeviceClass Mass Storage class
0x00, //bDeviceSubClass
0x00, //bDeviceProtocol
0x40, //bMaxPacketSize0 must be 64 for High speed
0x25,0x04, //idVendor - Freescale 0x0425
0x00,0x05, //idProduct - Mass storage start @ 0x500
0x01,0x00, //bcdDevice - Version 1
0x01, //iManufacturer - Index to string descriptor
0x02, //iProduct - Index to string descriptor
0x03, //iSerialNumber - Index to string descriptor
0x01 //bNumConfigurations - # of config. at current speed,
// not total # for all speed.
};
// ======================================================
//
// Device Qualifier
//
// ======================================================
const muint8 Device_Qualifier[10] = {
0x0a, //blength
0x06, //bDescriptor
0x00,0x02, //bcdUSB
0x00, //bDeviceClass Mass Storage class
0x00, //bDeviceSubClass
0x00, //bDeviceProtocol
0x40, //bMaxPacketSize0 must be 64 for High speed
0x01, //bNumConfigurations - # of config. at current speed,
// not total # for all speed.
0x00 //bReserved
};
// ======================================================
//
// Other Speed Configuration Descriptor
//
// ======================================================
const muint8 Other_Speed_Descriptor[] = {
0x09, //blength
0x07, //bDescriptor
0x27,0x00, //wTotalLengt - # of bytes including interface and endpoint descpt.
// 0x01, //bNumInterfaces - at least 1 data interface
// 0x01, //bConfigurationValue
// 0x00, //iConfiguration - index to string descriptor
// 0x80, //bmAttributes - 0x?0 bit 7-bus powered
// bit 6-self powered
// bit 5-remote wakeup
// bit 4-0-reserved
// 0x32 //bMaxPower - 50mA, expressed in 2mA units
};
// ======================================================
//
// Standard Configuration Descriptor High Speed
// BULK only Transport
//
// ======================================================
const muint8 Configuration_DescriptorHS[32] = {
0x09, //blength
0x02, //bDescriptor
0x20,0x00, //wTotalLength - # of bytes including interface and endpoint descpt.
0x01, //bNumInterfaces - at least 1 data interface
0x01, //bConfigurationValue -
0x00, //iConfiguration - index to string descriptor
0x80, //bmAttributes - 0x?0 bit 7-bus powered
// bit 6-self powered
// bit 5-remote wakeup
// bit 4-0-reserved
0x32, //bMaxPower - 50mA, expressed in 2mA units
// ======================================================
//
// Standard Interface Descriptor
// Data Interface for Mass Storage
// 3 endpoints including default Control endpt.,
// Bulk In and Bulk Out Endpt.
//
// ======================================================
// const muint8 interface_descriptor[9] = {
0x09, //blength
0x04, //bDescriptorType - Interface descriptor
0x00, //bInterfaceNumber - Zero based value identifying the index of the config.
0x00, //bAlternateSetting;
0x02, //bNumEndpoints - 2 endpoints
0x08, //bInterfaceClass - Mass storage device
0x06, //bInterfaceSubClass - SCSI Transparent command Set (refer USB MASS STORAGE overview)
0x50, //bInterfaceProtocol - Bulk-Only transport (refer USB MASS STORAGE overview)
0x00, //iInterface - Index to String descriptor
// ======================================================
//
// Standard Endpoint Descriptor
// Bulk IN Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor1[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
// 0x81, //bEndpointAddress - bit 3..0 endpoint number
0x81, // bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x02, //bmAttributes - BULK endpoint
0x00,0x02, //wMaxPacketSize -512 byte packat size
0x00, //bInterval - do not apply to BULK endpoint
// ======================================================
//
// Standard Endpoint Descriptor
// Bulk OUT Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor2[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
// 0x02, //bEndpointAddress - bit 3..0 endpoint number
0x01, // bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x02, //bmAttributes - BULK endpoint
0x00,0x02, //wMaxPacketSize - 512 byte packat size
0x00, //bInterval - do not apply to BULK endpoint
};
// ======================================================
//
// Standard Configuration Descriptor Full Speed
// BULK only Transport
//
// ======================================================
const muint8 Configuration_DescriptorFS[32] = {
0x09, //blength
0x02, //bDescriptor
0x20,0x00, //wTotalLength - # of bytes including interface and endpoint descpt.
0x01, //bNumInterfaces - at least 1 data interface
0x01, //bConfigurationValue -
0x00, //iConfiguration - index to string descriptor
0x80, //bmAttributes - 0x?0 bit 7-bus powered
// bit 6-self powered
// bit 5-remote wakeup
// bit 4-0-reserved
0x32, //bMaxPower - 50mA, expressed in 2mA units
// ======================================================
//
// Standard Interface Descriptor
// Data Interface for Mass Storage
// 3 endpoints including default Control endpt.,
// Bulk In and Bulk Out Endpt.
//
// ======================================================
// const muint8 interface_descriptor[9] = {
0x09, //blength
0x04, //bDescriptorType - Interface descriptor
0x00, //bInterfaceNumber - Zero based value identifying the index of the config.
0x00, //bAlternateSetting;
0x02, //bNumEndpoints - 2 endpoints
0x08, //bInterfaceClass - Mass storage device
0x06, //bInterfaceSubClass - SCSI Transparent command Set (refer USB MASS STORAGE overview)
0x50, //bInterfaceProtocol - Bulk-Only transport (refer USB MASS STORAGE overview)
0x00, //iInterface - Index to String descriptor
// ======================================================
//
// Standard Endpoint Descriptor
// Bulk IN Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor1[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
// 0x81, //bEndpointAddress - bit 3..0 endpoint number
0x81, // bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x02, //bmAttributes - BULK endpoint
0x40,0x00, //wMaxPacketSize - 64 byte packat size
0x00, //bInterval - do not apply to BULK endpoint
// ======================================================
//
// Standard Endpoint Descriptor
// Bulk OUT Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor2[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
// 0x02, //bEndpointAddress - bit 3..0 endpoint number
0x01, // bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x02, //bmAttributes - BULK endpoint
0x40,0x00, //wMaxPacketSize - 64 byte packat size
0x01, //bInterval - maximum NAK rate
};
// ======================================================
//
// String Descriptor Zero
//
// ======================================================
const muint8 string_descriptor0[4] = {
0x04, //bLength;
0x03, //bDescriptorType - STRING descriptor
0x09,0x04, //wLANDID0 - English (American)
};
// ======================================================
//
// String Descriptor one
//
// ======================================================
const muint8 string_descriptor1[] = {
10, //bLength;
0x03, //bDescriptorType - STRING descriptor
'M',0x00, // "M"
'o',0x00, // "o"
't',0x00, // "t"
'o',0x00, // "o"
'r',0x00, // "r"
'o',0x00, // "o"
'l',0x00, // "l"
'a',0x00 // "a"
};
// ======================================================
//
// String Descriptor two
//
// ======================================================
const muint8 string_descriptor2[] = {
10, //bLength;
0x03, //bDescriptorType - STRING descriptor
'U',0x00, // UF32
'F',0x00,
'3',0x00,
'2',0x00,
};
const muint8 string_descriptor3[] =
{
6,
0x03,
'3',0x00,
'2',0x00
};
// ======================================================
//
// Tables
//
// ======================================================
const muint8* Configuration_Table[][2] = {
{Configuration_DescriptorHS,Configuration_DescriptorHS},
{Configuration_DescriptorFS,Configuration_DescriptorFS}
};
const muint8* Interface_Table[1] = {
&Configuration_DescriptorHS[9] // Interface #1
};
const muint8* Endpoint_Table[][2] = {
{&Configuration_DescriptorHS[18],&Configuration_DescriptorHS[25]},
{&Configuration_DescriptorFS[18],&Configuration_DescriptorFS[25]} // Endpoint #1
, // Endpoint #2
};
const muint8* String_Table[4] = {
string_descriptor0, // String #0
string_descriptor1, // String #1
string_descriptor2, // String #2
string_descriptor3 // String #3
};
/*
// ======================================================
//
// Standard Configuration Descriptor 2.0
// CBI Transport
//
// ======================================================
const muint8 Configuration_Descriptor_CBI[39] = {
0x09, //blength
0x02, //bDescriptor
0x27,0x00, //wTotalLength - # of bytes including interface and endpoint descpt.
0x01, //bNumInterfaces - at least 1 data interface
0x01, //bConfigurationValue -
0x00, //iConfiguration - index to string descriptor
0x80, //bmAttributes - 0x?0 bit 7-bus powered
// bit 6-self powered
// bit 5-remote wakeup
// bit 4-0-reserved
0x32, //bMaxPower - 50mA, expressed in 2mA units
// ======================================================
//
// Standard Interface Descriptor
// Data Interface for Mass Storage
// 4 endpoints including default Control endpt.,
// Bulk In, Bulk Out and Interrupt Endpt.
//
// ======================================================
// const muint8 interface_descriptor[9] = {
0x09, //blength
0x04, //bDescriptorType - Interface descriptor
0x00, //bInterfaceNumber - Zero based value identifying the index of the config.
0x00, //bAlternateSetting;
0x03, //bNumEndpoints - 3 endpoints
0x08, //bInterfaceClass - Mass storage device
0x06, //bInterfaceSubClass - SCSI Transparent command Set (refer USB MASS STORAGE overview)
0x00, //bInterfaceProtocol - CBI transport (refer USB MASS STORAGE overview)
0x00, //iInterface - Index to String descriptor
// ======================================================
//
// Standard Endpoint Descriptor
// Bulk IN Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor1[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
0x81, //bEndpointAddress - bit 3..0 endpoint number
// bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x02, //bmAttributes - BULK endpoint
0x00,0x02, //wMaxPacketSize - 512 byte packat size
0x00, //bInterval - do not apply to BULK endpoint
// ======================================================
//
// Standard Endpoint Descriptor
// Bulk OUT Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor2[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
0x02, //bEndpointAddress - bit 3..0 endpoint number
// bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x02, //bmAttributes - BULK endpoint
0x00,0x02, //wMaxPacketSize - 512 byte packat size
0x00, //bInterval - do not apply to BULK endpoint
// ======================================================
//
// Standard Endpoint Descriptor
// Interrupt Endpoint
//
// ======================================================
// const muint8 endpoint_descriptor3[7] = {
0x07, //bLength;
0x05, //bDescriptorType - Endpoint descriptor
0x83, //bEndpointAddress - bit 3..0 endpoint number
// bit 6..4 Reserved reset to zero
// bit 7 0-OUT, 1-IN
0x03, //bmAttributes - INTERRUPT endpoint
0x02,0x00, //wMaxPacketSize - 2 byte packat size
0x0A //bInterval - Status sent every 10 Frame
};
*/
#endif _H_USB_DESCRIPTOR_
/* End Of File Name : usb_descriptor.c */
// ********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -