📄 usb_cfg.h
字号:
#define uint unsigned int
#define uchar unsigned char
#include "usb_def.h"
#define MS_MAX_LUN 0 /* number of logical unit - 1 */
/* USB Driver */
#define VENDOR_ID 0xEB03 /* Atmel vendor ID = 03EBh */
#define PRODUCT_ID 0x0220 /* Atmel Product ID: 2002h */
#define RELEASE_NUMBER 0x0001
/* USB Mass Storage ! unicode char */
#define USB_MANUFACTURER_NAME {'C'<<8,'h'<<8,'i'<<8,'n'<<8,'a'<<8,'C'<<8,'o'<<8,'r'<<8,'e'<<8}
#define USB_MN_LENGTH 9
#define USB_PRODUCT_NAME {'U'<<8,'S'<<8,'B'<<8,' '<<8,'D'<<8,'i'<<8,'s'<<8,\
'k'<<8,' '<<8,'a'<<8,'n'<<8,'d'<<8,' '<<8,'m'<<8,'p'<<8,'3'<<8}
#define USB_PN_LENGTH 16
#define USB_SERIAL_NUMBER {'4'<<8,'7'<<8,'1'<<8,'0'<<8,'7'<<8,'6'<<8,'5'<<8,\
'0'<<8,'6'<<8,'6'<<8,'4'<<8,'5'<<8,'1'<<8}
#define USB_SN_LENGTH 13
/* SCSI Mass Storage */
#define SBC_VENDOR_ID {'G','e','n','e','r','i','c',' '}
#define SBC_PRODUCT_ID {'S','N','D','1',' ','M','P','3',' ','P','l','a','y','e','r',' '}
#define SBC_REVISION_ID {'0','.','0','0'}
/*_____ U S B D E V I C E R E Q U E S T _________________________________*/
struct Endpoint_information_st
{
uint fifo_size ; /* size of the endpoint FIFO */
uint fifo_left ;
};
struct USB_request_st
{
uchar bmRequestType; /* Characteristics of the request */
uchar bRequest; /* Specific request */
uint wValue; /* field that varies according to request */
uint wIndex; /* field that varies according to request */
uint wLength; /* Number of uchars to transfer if Data */
};
/*_____ U S B D E V I C E D E S C R I P T O R ___________________________*/
struct usb_st_device_descriptor
{
uchar bLength; /* Size of this descriptor in uchars */
uchar bDescriptorType; /* DEVICE descriptor type */
uint bscUSB; /* Binay Coded Decimal Spec. release */
uchar bDeviceClass; /* Class code assigned by the USB */
uchar bDeviceSubClass; /* Sub-class code assigned by the USB */
uchar bDeviceProtocol; /* Protocol code assigned by the USB */
uchar bMaxPacketSize0; /* Max packet size for EP0 */
uint idVendor; /* Vendor ID. ATMEL = 0x03EB */
uint idProduct; /* Product ID assigned by the manufacturer */
uint bcdDevice; /* Device release number */
uchar iManufacturer; /* Index of manu. string descriptor */
uchar iProduct; /* Index of prod. string descriptor */
uchar iSerialNumber; /* Index of S.N. string descriptor */
uchar bNumConfigurations; /* Number of possible configurations */
};
/*_____ U S B C O N F I G U R A T I O N D E S C R I P T O R _____________*/
struct usb_st_configuration_descriptor
{
uchar bLength; /* size of this descriptor in uchars */
uchar bDescriptorType; /* CONFIGURATION descriptor type */
uint wTotalLength; /* total length of data returned */
uchar bNumInterfaces; /* number of interfaces for this conf. */
uchar bConfigurationValue; /* value for SetConfiguration resquest */
uchar iConfiguration; /* index of string descriptor */
uchar bmAttibutes; /* Configuration characteristics */
uchar MaxPower; /* maximum power consumption */
};
/*_____ U S B M A N U F A C T U R E R D E S C R I P T O R _______________*/
struct usb_st_manufacturer
{
uchar bLength; /* size of this descriptor in uchars */
uchar bDescriptorType; /* STRING descriptor type */
uint wstring[USB_MN_LENGTH];/* unicode characters */
};
/*_____ U S B P R O D U C T D E S C R I P T O R _________________________*/
struct usb_st_product
{
uchar bLength; /* size of this descriptor in uchars */
uchar bDescriptorType; /* STRING descriptor type */
uint wstring[USB_PN_LENGTH];/* unicode characters */
};
/*_____ U S B S E R I A L N U M B E R D E S C R I P T O R _____________*/
struct usb_st_serial_number
{
uchar bLength; /* size of this descriptor in uchars */
uchar bDescriptorType; /* STRING descriptor type */
uint wstring[USB_SN_LENGTH];/* unicode characters */
};
/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/
struct usb_st_language_descriptor
{
uchar bLength; /* size of this descriptor in uchars */
uchar bDescriptorType; /* STRING descriptor type */
uint wlangid; /* language id */
};
/*_____ U S B I N T E R F A C E D E S C R I P T O R _____________________*/
struct usb_st_interface_descriptor
{
uchar bLength; /* size of this descriptor in uchars */
uchar bDescriptorType; /* INTERFACE descriptor type */
uchar bInterfaceNumber; /* Number of interface */
uchar bAlternateSetting; /* value to select alternate setting */
uchar bNumEndpoints; /* Number of EP except EP 0 */
uchar bInterfaceClass; /* Class code assigned by the USB */
uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */
uchar bInterfaceProtocol; /* Protocol code assigned by the USB */
uchar iInterface; /* Index of string descriptor */
};
/*_____ U S B E N D P O I N T D E S C R I P T O R _______________________*/
struct usb_st_endpoint_descriptor
{
uchar bLength; /* Size of this descriptor in uchars */
uchar bDescriptorType; /* ENDPOINT descriptor type */
uchar bEndpointAddress; /* Address of the endpoint */
uchar bmAttributes; /* Endpoint's attributes */
uint wMaxPacketSize; /* Maximum packet size for this EP */
uchar bInterval; /* Interval for polling EP in ms */
};
/*_____ D E F I N I T I O N ________________________________________________*/
code struct usb_st_device_descriptor usb_device_descriptor =
{
sizeof(usb_device_descriptor), DEVICE, 0x1001, 0, 0, 0, EP_CONTROL_LENGTH,
VENDOR_ID, PRODUCT_ID, RELEASE_NUMBER, MAN_INDEX, PROD_INDEX, SN_INDEX, 1
};
code struct usb_st_manufacturer usb_manufacturer =
{
sizeof(usb_manufacturer), STRING,
USB_MANUFACTURER_NAME
};
code struct usb_st_product usb_product =
{
sizeof(usb_product), STRING,
USB_PRODUCT_NAME
};
code struct usb_st_serial_number usb_serial_number =
{
sizeof(usb_serial_number), STRING,
USB_SERIAL_NUMBER
};
code struct usb_st_language_descriptor usb_language =
{
sizeof(usb_language), STRING, 0x0904
};
code struct
{
struct usb_st_configuration_descriptor cfg;
struct usb_st_interface_descriptor ifc;
struct usb_st_endpoint_descriptor ep1;
struct usb_st_endpoint_descriptor ep2;
struct usb_st_endpoint_descriptor ep3;
struct usb_st_endpoint_descriptor ep4;
struct usb_st_endpoint_descriptor ep5;
struct usb_st_endpoint_descriptor ep6;
}
usb_configuration =
{
{ 9, CONFIGURATION, sizeof(usb_configuration) << 8, 1, 1, 0, USB_CONFIG_BUSPOWERED, 0x30},
{ 9, INTERFACE, 0, 0, 6, 0x08, 0x06, 0x50, 0 },
{ 7, ENDPOINT, 0x81, 0x02, EP_IN_LENGTH << 8, 0 },//IN
{ 7, ENDPOINT, 0x02, 0x02, EP_OUT_LENGTH << 8, 0 },//OUT
{ 7, ENDPOINT, 0x83, 0x02, EP_IN_LENGTH << 8, 0 },//IN
{ 7, ENDPOINT, 0x04, 0x02, EP_OUT_LENGTH << 8, 0 },//OUT
{ 7, ENDPOINT, 0x85, 0x02, EP_IN_LENGTH << 8, 0 },//IN
{ 7, ENDPOINT, 0x06, 0x02, EP_OUT_LENGTH << 8, 0 }//OUT
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -