⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _usb.h

📁 motorola jw32 usb 源码
💻 H
字号:
//============================================================================
// File: U08USB.H
// Func: Definitions for USB Data Types & Constants
//		 Header File for USB08 Demo Application
// Ver.: 1.01
// Auth: (C)2000,2001 by Oliver Thamm, MCT Elektronikladen GbR
//       http://hc08web.de/usb08
// Rem.: View/Edit this File with TAB-Size=4
// Jan 02 : Adapted for CodeWarrior by Isabelle GIRAUD, Metrowerks Europe
//============================================================================
//-- Data Type Definitions ---------------------------------------------------

typedef struct {				// Data Type "Intel Word"
	unsigned char lo;					// (High/Low unsigned char  swapped)
	unsigned char  hi;
	} iword;

//----------------------------------------------------------------------------

// Standard Device Descriptor
// according to USB1.1 spec page 197
//
typedef struct {
	unsigned char  bLength;				// Size of this Descriptor in Bytes
	unsigned char  bDescriptorType;		// Descriptor Type (=1)
	iword bcdUSB;				// USB Spec Release Number in BCD
	unsigned char  bDeviceClass;			// Device Class Code
	unsigned char  bDeviceSubClass;		// Device Subclass Code
	unsigned char  bDeviceProtocol;		// Device Protocol Code
	unsigned char  bMaxPacketSize0;		// Maximum Packet Size for EP0
	iword idVendor;				// Vendor ID
	iword idProduct;			// Product ID
	iword bcdDevice;			// Device Release Number in BCD
	unsigned char  iManufacturer;		// Index of String Desc for Manufacturer
	unsigned char  iProduct;				// Index of String Desc for Product
	unsigned char  iSerialNumber;		// Index of String Desc for SerNo
	unsigned char  bNumConfigurations;	// Number of possible Configurations
	} device_descriptor;

//----------------------------------------------------------------------------
// Standard HID Descriptor
// according to USB1.1 spec page 197
//
typedef struct {
	unsigned char  bLength;				// Size of this Descriptor in Bytes
	unsigned char  bDescriptorType;		// Descriptor Type (=0x21)
	iword bcdHID;				// HID Spec Release Number in BCD
	unsigned char  bCountryCode;			// Country Code
	unsigned char  bNumDescriptors;		// Number of possible Descriptors
	unsigned char  bHidDescriptorType;	// HidDescriptorType = Report(0x22)
	iword wDescriptorLength;	//
	} hid_descriptor;


//----------------------------------------------------------------------------

// Standard Configuration Descriptor
// according to USB1.1 spec page 199
//
typedef struct {
	unsigned char  bLength;				// Size of this Descriptor in Bytes
	unsigned char  bDescriptorType;		// Descriptor Type (=2)
	iword wTotalLength;			// Total Length of Data for this Conf
	unsigned char  bNumInterfaces;		// No of Interfaces supported by this Conf
	unsigned char  bConfigurationValue;	// Designator Value for *this* Configuration
	unsigned char  iConfiguration;		// Index of String Desc for this Conf
	unsigned char  bmAttributes;			// Configuration Characteristics (see below)
	unsigned char  bMaxPower;			// Max. Power Consumption in this Conf (*2mA)
	} configuration_descriptor;

//----------------------------------------------------------------------------

// Standard Interface Descriptor
// according to USB1.1 spec page 202
//
typedef struct {
	unsigned char  bLength;				// Size of this Descriptor in Bytes
	unsigned char  bDescriptorType;		// Descriptor Type (=4)
	unsigned char  bInterfaceNumber;		// Number of *this* Interface (0..)
	unsigned char  bAlternateSetting;	// Alternative for this Interface (if any)
	unsigned char  bNumEndpoints;		// No of EPs used by this IF (excl. EP0)
	unsigned char  bInterfaceClass;		// Interface Class Code
	unsigned char  bInterfaceSubClass;	// Interface Subclass Code
	unsigned char  bInterfaceProtocol;	// Interface Protocol Code
	unsigned char  iInterface;			// Index of String Desc for this Interface
	} interface_descriptor;

//----------------------------------------------------------------------------

// Standard Endpoint Descriptor
// according to USB1.1 spec page 203
//
typedef struct {
	unsigned char  bLength;				// Size of this Descriptor in Bytes
	unsigned char  bDescriptorType;		// Descriptor Type (=5)
	unsigned char  bEndpointAddress;		// Endpoint Address (Number + Direction)
	unsigned char  bmAttributes;			// Endpoint Attributes (Transfer Type)
	iword wMaxPacketSize;		// Max. Endpoint Packet Size
	unsigned char  bInterval;			// Polling Interval (Interrupt) in ms
	} endpoint_descriptor;

//----------------------------------------------------------------------------

// Structure of Setup Packet sent during
// SETUP Stage of Standard Device Requests
// according to USB1.1 spec page 183
//
typedef struct {
	unsigned char  bmRequestType;		// Characteristics (Direction,Type,Recipient)
	unsigned char  bRequest;				// Standard Request Code
	iword wValue;				// Value Field
	iword wIndex;				// Index or Offset Field
	iword wLength;				// Number of Bytes to transfer (Data Stage)
	} setup_buffer;

typedef struct {
	configuration_descriptor 	hid_configuration_descriptor;

	interface_descriptor 		mouse_hid_interface_descriptor;
	hid_descriptor 			    mouse_hid_descriptor;
	endpoint_descriptor         mouse_input_terminal_descriptor;

	interface_descriptor 		keyboard_hid_interface_descriptor;
	hid_descriptor 			    keyboard_hid_descriptor;
	endpoint_descriptor         keyboard_input_terminal_descriptor;

	interface_descriptor 		hid_hid_interface_descriptor;
	hid_descriptor 			    hid_hid_descriptor;
	endpoint_descriptor         hid_input_terminal_descriptor;
	endpoint_descriptor         hid_output_terminal_descriptor;
}hid_configuration_descriptor;



//----------------------------------------------------------------------------

// USB Status Codes
//
#define US_ATTACHED			0x00	// (not used here)
#define US_POWERED			0x01
#define US_DEFAULT			0x02
#define US_ADDRESSED		0x03
#define US_CONFIGURED		0x04
#define US_SUSPENDED		0x80

//----------------------------------------------------------------------------

// USB Standard Device Request Codes
// according to USB1.1 spec page 187
//
#define GET_STATUS			0x00
#define CLEAR_FEATURE		0x01
#define SET_FEATURE			0x03
#define SET_ADDRESS			0x05
#define GET_DESCRIPTOR		0x06
#define SET DESCRIPTOR		0x07	// optional
#define GET_CONFIGURATION	0x08
#define SET_CONFIGURATION	0x09
#define GET_INTERFACE		0x0a
#define SET_INTERFACE		0x0b
#define SYNCH_FRAME			0x0c	// optional

#define REQUEST_COMPLETE	0xff	// not part of the Standard - just
									// a Flag to indicate that the recent
									// Request has been finished
//----------------------------------------------------------------------------

// Descriptor Types
// according to USB1.1 spec page 187
//
#define DT_DEVICE			1
#define DT_CONFIGURATION	2
#define DT_STRING			3
#define DT_INTERFACE		4
#define DT_ENDPOINT			5

#define DT_HID              0x21
#define DT_REPORT           0x22

//============================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -