📄 u08usb.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 ---------------------------------------------------
#ifndef _U08USB__
#define _U08USB__
typedef struct { // Data Type "Intel Word"
uchar lo; // (High/Low Byte swapped)
uchar hi;
} iword;
//----------------------------------------------------------------------------
// Standard Device Descriptor
// according to USB1.1 spec page 197
//
typedef struct {
uchar bLength; // Size of this Descriptor in Bytes
uchar bDescriptorType; // Descriptor Type (=1)
iword bcdUSB; // USB Spec Release Number in BCD
uchar bDeviceClass; // Device Class Code
uchar bDeviceSubClass; // Device Subclass Code
uchar bDeviceProtocol; // Device Protocol Code
uchar bMaxPacketSize0; // Maximum Packet Size for EP0
iword idVendor; // Vendor ID
iword idProduct; // Product ID
iword bcdDevice; // Device Release Number in BCD
uchar iManufacturer; // Index of String Desc for Manufacturer
uchar iProduct; // Index of String Desc for Product
uchar iSerialNumber; // Index of String Desc for SerNo
uchar bNumConfigurations; // Number of possible Configurations
} device_descriptor;
//----------------------------------------------------------------------------
// Standard Configuration Descriptor
// according to USB1.1 spec page 199
//
typedef struct {
uchar bLength; // Size of this Descriptor in Bytes
uchar bDescriptorType; // Descriptor Type (=2)
iword wTotalLength; // Total Length of Data for this Conf
uchar bNumInterfaces; // No of Interfaces supported by this Conf
uchar bConfigurationValue; // Designator Value for *this* Configuration
uchar iConfiguration; // Index of String Desc for this Conf
uchar bmAttributes; // Configuration Characteristics (see below)
uchar bMaxPower; // Max. Power Consumption in this Conf (*2mA)
} configuration_descriptor;
//----------------------------------------------------------------------------
// Standard Interface Descriptor
// according to USB1.1 spec page 202
//
typedef struct {
uchar bLength; // Size of this Descriptor in Bytes
uchar bDescriptorType; // Descriptor Type (=4)
uchar bInterfaceNumber; // Number of *this* Interface (0..)
uchar bAlternateSetting; // Alternative for this Interface (if any)
uchar bNumEndpoints; // No of EPs used by this IF (excl. EP0)
uchar bInterfaceClass; // Interface Class Code
uchar bInterfaceSubClass; // Interface Subclass Code
uchar bInterfaceProtocol; // Interface Protocol Code
uchar iInterface; // Index of String Desc for this Interface
} interface_descriptor;
//----------------------------------------------------------------------------
// Standard Endpoint Descriptor
// according to USB1.1 spec page 203
//
typedef struct {
uchar bLength; // Size of this Descriptor in Bytes
uchar bDescriptorType; // Descriptor Type (=5)
uchar bEndpointAddress; // Endpoint Address (Number + Direction)
uchar bmAttributes; // Endpoint Attributes (Transfer Type)
iword wMaxPacketSize; // Max. Endpoint Packet Size
uchar 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 {
uchar bmRequestType; // Characteristics (Direction,Type,Recipient)
uchar 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;
//----------------------------------------------------------------------------
// 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
//----------------------------------------------------------------------------
// Function Prototypes
//
void initUSB(void);
uchar getUSB(void);
void putUSB(uchar c);
void isrUSB(void);
//============================================================================
#endif /* _U08USB__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -