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

📄 usb.h

📁 This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY without ev
💻 H
字号:
/*************************************** * usb.h based on sunkbd_hid.h * http://sourceforge.net/projects/ezhid * maintainer: * Arnim Laeuger * arnim@users.sourceforge.net ***************************************//* USB descriptor type *//* Supported: */ #define USB_DT_DEVICE            0x01#define USB_DT_CONFIG            0x02#define USB_DT_STRING            0x03/* Not Supported: */#define USB_DT_INTERFACE         0x04#define USB_DT_ENDPOINT          0x05/* fundamental data type */typedef unsigned char byte;typedef unsigned short word;#include "vendor.id" /* device descriptor */static code byte dev_desc[] = {  0x12, // bLength            : Length of Descriptor  0x01, // bDescriptorType    : Descriptor Type = Device  0x00, // bcdUSB (L)         : USB Sepcification 2.0 (L)  0x02, // bcdUSB (H)         : USB Specification 2.0 (H)  0xFF, // bDeviceClass       : Device Class   0xFF, // bDeviceSubClass    : Device Subclass  0xFF, // bDeviceProtocol    : Device Protocol  0x40, // bMaxPacketSize0    : Maximum packet size for EP0  VENDORID & 0xFF,         // idVendor (L)       : Vendor ID (L)  (VENDORID >> 8) & 0xFF,  // idVendor (H)       : Vendor ID (H)  PRODUCTID & 0xFF,        // idProduct(L)       : Product ID (L)  (PRODUCTID >> 8) & 0xFF, // idProduct(H)       : Product ID (H)  0x01, // bcdDevice(L)       : Device Release Number (BCD,L)  0x00, // bcdDevice(H)       : Device Release Number (BCD,H)  0x01, // iManufacturer      : Manufacturer Index String  0x00, // iProduct           : Product Index String  0x00, // iSerialNumber      : Serial Number Index String  0x01 // bNumConfigurations : Number of Configurations in this Device};/* configuration descriptor */static code byte conf_desc[] = {  0x09, // bLength            : Legth of the Descriptor  0x02, // bDecriptorType     : Descriptor Type = Configuration  0x27, // wTotalLength (L)   : Total Length (L) including interface and endpoint  0x00, // wTotalLength (H)   : Total Length (H) including interface and endpoint  0x01, // bNumIterfaces      : Number of interfaces  0x01, // bConfigurationVal  : Configuration value used by set configuration request  0x00, // iConfiguration     : Index of String Describing this Configuartion  0x80, // bmAttributes       : Attributes  0x32, // MaxPower           : Maximum Power  /* Interface Descriptor, Interface 0, Alternate Setting 0 */  0x09, // bLength            : Length  0x04, // bDescriptorType    : Interface descriptor  0x00, // bInterfaceNumber   : Zero-based index of this interface  0x00, // bAlternateSetting  : This alternate setting  0x03, // bNumEndpoints      : Number of endpoints used for this descriptor  0xFF, // bInterfaceClass    : Vendor specific  0x00, // bInterfaceSubClass :   0xFF, // bInterfaceProtocol : Vendor specific  0x00, // iInterface         : Index to sring describing this interface  /* Bulk Out Endpoint Descriptor, Interface 0, Alternate Setting 0 */  0x07, // bLength            : Length of Descriptor  0x05, // bDescriptorType    : Endpoint  0x01, // bEndpointAddress   : OUT endpoint 1  0x02, // bmAttributes       : Bulk endpoint  0x40, // wMaxPacketSize (L) : Maximum data transfer size (L)  0x00, // wMaxPacketSize (H) : Maximum data transfer size (H)  0x00, // bInterval          : Polling interval  /* Bulk In Endpoint Descriptor, Interface 0, Alternate Setting 0 */  0x07, // bLength            : Length of Descriptor  0x05, // bDescriptorType    : Endpoint  0x82, // bEndpointAddress   : IN endpoint 2  0x02, // bmAttributes       : Bulk endpoint  0x40, // wMaxPacketSize (L) : Maximum data transfer size (L)  0x00, // wMaxPacketSize (H) : Maximum data transfer size (H)  0x00, // bInterval          : Polling interval  /* Bulk In Endpoint Descriptor, Interface 0, Alternate Setting 0 */  0x07, // bLength            : Length of Descriptor  0x05, // bDescriptorType    : Endpoint  0x84, // bEndpointAddress   : IN endpoint 4  0x03, // bmAttributes       : Interrupt endpoint  0x01, // wMaxPacketSize (L) : Maximum data transfer size (L)  0x00, // wMaxPacketSize (H) : Maximum data transfer size (H)  0x01  // bInterval          : Polling interval (Every frame)  };/* language ID string descriptor */static code byte string_langid[] = {0x04, 0x03, 0x00, 0x00};/* manufacturer ID string */static code byte string_mfg[] = {  0x0C, 0x03,  /* standard requests */  'H',0,'e',0,'l',0,'l',0,'o',0};static data unsigned int string_index[2] = {  (unsigned int) string_langid,  (unsigned int) string_mfg};/* setup packet structure */typedef struct {  byte bmRequestType;  byte bRequest;  byte wValueL;  byte wValueH;  byte wIndexL;  byte wIndexH;  byte wLengthL;  byte wLengthH;} setup_data;static xdata setup_data * data sdata = (xdata setup_data *)&SETUPDAT;static xdata byte * data in0buf = (xdata byte *)&IN0BUF;static xdata byte * data out1buf = (xdata byte *)&OUT1BUF;static xdata byte * data in2buf = (xdata byte *)&IN2BUF;static xdata byte * data in4buf = (xdata byte *)&IN4BUF;

⌨️ 快捷键说明

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