📄 usbdesc.h
字号:
/***************************************************************************
* C Source Header File: USBDESC.H
*
* Copyright 2001 DeVaSys
* All rights are reserved.
* No part of this document may be reproduced, stored, or transmitted in any
* form or by any means without the prior written permission of DeVaSys
*
* Description:
*
* This header contains declarations and defines to support the USBDESC.C
* source module.
*
* ........................ Revision History ................................
*
* Creation date: 02/22/2001 - Michael A. DeVault, DeVaSys
*
* Revision History Summary:
*
* Rev 1.0 22 February 2001 12:00:00 mad
* Initial revision.
*
***************************************************************************/
/* following ifndef is for skipping double includes of this header file */
#if !defined(__USBDESC_H)
#define __USBDESC_H
#include "portable.h"
#include "usb100.h"
#define NUM_ENDPOINTS 1 // excluding default control endpoints
// endpoint maximum packet sizes
#define EP0_PACKET_SIZE 8
#define EP1_PACKET_SIZE 8
#define EP2_PACKET_SIZE 8
// class definitions
#define USB_CLASS_CODE_TEST_CLASS_DEVICE 0xDC
#define USB_SUBCLASS_CODE_TEST_CLASS_D12 0xA0
#define USB_PROTOCOL_CODE_TEST_CLASS_D12 0xB0
//typedef packed struct _USB_REQUEST {
typedef packed struct {
BYTE byReqType;
BYTE byRequest;
WORD wValue;
WORD wIndex;
WORD wLength;
} USB_REQUEST, *PUSB_REQUEST;
#define USB_HID_DESCRIPTOR_TYPE 0x21
//typedef packed struct _USB_HID_DESCRIPTOR {
typedef packed struct {
BYTE bLength;
BYTE bDescriptorType;
WORD wHIDClassSpecComp;
BYTE bCountry;
BYTE bNumDescriptors;
BYTE b1stDescType;
WORD w1stDescLength;
// BYTE b2ndDescType;
// WORD w2ndDescLength;
} USB_HID_DESCRIPTOR, *PUSB_HID_DESCRIPTOR;
// device descriptor external reference
extern code const USB_DEVICE_DESCRIPTOR DeviceDescr;
// special structure to combine config, interface, and endpoint
// descriptors into a sequential entity, individual descriptors
// can still be accessed with the form UsbCfgData.ConfigDescr,
// UsbCfgData.InterfaceDescr, etc.
//typedef packed struct _USB_CONFIG_DATA {
typedef packed struct {
USB_CONFIGURATION_DESCRIPTOR ConfigDescr;
USB_INTERFACE_DESCRIPTOR InterfaceDescr;
USB_HID_DESCRIPTOR HidDescr;
#if NUM_ENDPOINTS > 0
USB_ENDPOINT_DESCRIPTOR EndpointDescrs[NUM_ENDPOINTS];
#endif
} USB_CONFIG_DATA, *PUSB_CONFIG_DATA;
// combined descriptor for configuration(s), interface(s), and endpoint(s)
extern code const USB_CONFIG_DATA UsbCfgData;
#define HID_REPORT_DESC_SIZE 50 // size of the HID REPORT descriptor
// for the cypress mouse example
extern code const char ReportDescr[HID_REPORT_DESC_SIZE];
/*
#define MAXIMUM_USB_STRING_LENGTH 255
typedef packed struct _USB_STRING_DESCRIPTOR {
BYTE bLength;
BYTE bDescriptorType;
BYTE bString[MAXIMUM_USB_STRING_LENGTH];
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
The above structure definition for a string descriptor is from the
standard USB100.H file.
Unfortunately, if we use it, each string descriptor gets allocated 257
bytes of our limited code space. Very wasteful, so... we will use a
modified version of this structure for each string descriptor
*/
#define USB_STRING_DESCRIPTOR_LANGUAGE_LENGTH 4
//typedef packed struct _USB_STRING_DESCRIPTOR_LANGUAGE {
typedef packed struct {
BYTE bLength;
BYTE bDescriptorType;
BYTE bString[USB_STRING_DESCRIPTOR_LANGUAGE_LENGTH - 2];
} USB_STRING_DESCRIPTOR_LANGUAGE, *PUSB_STRING_DESCRIPTOR_LANGUAGE;
#define USB_STRING_DESCRIPTOR_MANUFACT_LENGTH 18
//typedef packed struct _USB_STRING_DESCRIPTOR_MANUFACT {
typedef packed struct {
BYTE bLength;
BYTE bDescriptorType;
BYTE bString[USB_STRING_DESCRIPTOR_MANUFACT_LENGTH - 2];
} USB_STRING_DESCRIPTOR_MANUFACT, *PUSB_STRING_DESCRIPTOR_MANUFACT;
#define USB_STRING_DESCRIPTOR_PRODUCT_LENGTH 30
//typedef packed struct _USB_STRING_DESCRIPTOR_PRODUCT {
typedef packed struct {
BYTE bLength;
BYTE bDescriptorType;
BYTE bString[USB_STRING_DESCRIPTOR_PRODUCT_LENGTH - 2];
} USB_STRING_DESCRIPTOR_PRODUCT, *PUSB_STRING_DESCRIPTOR_PRODUCT;
#define USB_STRING_DESCRIPTOR_CFG_LENGTH 38
//typedef packed struct _USB_STRING_DESCRIPTOR_CFG {
typedef packed struct {
BYTE bLength;
BYTE bDescriptorType;
BYTE bString[USB_STRING_DESCRIPTOR_CFG_LENGTH - 2];
} USB_STRING_DESCRIPTOR_CFG, *PUSB_STRING_DESCRIPTOR_CFG;
#define USB_STRING_DESCRIPTOR_INTERFACE_LENGTH 30
//typedef packed struct _USB_STRING_DESCRIPTOR_INTERFACE {
typedef packed struct {
BYTE bLength;
BYTE bDescriptorType;
BYTE bString[USB_STRING_DESCRIPTOR_INTERFACE_LENGTH - 2];
} USB_STRING_DESCRIPTOR_INTERFACE, *PUSB_STRING_DESCRIPTOR_INTERFACE;
extern code const USB_STRING_DESCRIPTOR_LANGUAGE StrDescLanguage;
extern code const USB_STRING_DESCRIPTOR_MANUFACT StrDescManufacturer;
extern code const USB_STRING_DESCRIPTOR_PRODUCT StrDescProduct;
extern code const USB_STRING_DESCRIPTOR_CFG StrDescConfiguration;
extern code const USB_STRING_DESCRIPTOR_INTERFACE StrDescInterface;
/* following endif is for skipping double includes of this header file */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -