?? usbdrv.h
字號:
/* ------------------------------------------------------------------------- *//* ----------------- Definitions for Descriptor Properties ----------------- *//* ------------------------------------------------------------------------- *//* This is advanced stuff. See usbconfig-prototype.h for more information * about the various methods to define USB descriptors. If you do nothing, * the default descriptors will be used. */#define USB_PROP_IS_DYNAMIC (1 << 8)/* If this property is set for a descriptor, usbFunctionDescriptor() will be * used to obtain the particular descriptor. */#define USB_PROP_IS_RAM (1 << 9)/* If this property is set for a descriptor, the data is read from RAM * memory instead of Flash. The property is used for all methods to provide * external descriptors. */#define USB_PROP_LENGTH(len) ((len) & 0xff)/* If a static external descriptor is used, this is the total length of the * descriptor in bytes. *//* all descriptors which may have properties: */#ifndef USB_CFG_DESCR_PROPS_DEVICE#define USB_CFG_DESCR_PROPS_DEVICE 0#endif#ifndef USB_CFG_DESCR_PROPS_CONFIGURATION#define USB_CFG_DESCR_PROPS_CONFIGURATION 0#endif#ifndef USB_CFG_DESCR_PROPS_STRINGS#define USB_CFG_DESCR_PROPS_STRINGS 0#endif#ifndef USB_CFG_DESCR_PROPS_STRING_0#define USB_CFG_DESCR_PROPS_STRING_0 0#endif#ifndef USB_CFG_DESCR_PROPS_STRING_VENDOR#define USB_CFG_DESCR_PROPS_STRING_VENDOR 0#endif#ifndef USB_CFG_DESCR_PROPS_STRING_PRODUCT#define USB_CFG_DESCR_PROPS_STRING_PRODUCT 0#endif#ifndef USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER#define USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER 0#endif#ifndef USB_CFG_DESCR_PROPS_HID#define USB_CFG_DESCR_PROPS_HID 0#endif#if !(USB_CFG_DESCR_PROPS_HID_REPORT)# undef USB_CFG_DESCR_PROPS_HID_REPORT# if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH /* do some backward compatibility tricks */# define USB_CFG_DESCR_PROPS_HID_REPORT USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH# else# define USB_CFG_DESCR_PROPS_HID_REPORT 0# endif#endif#ifndef USB_CFG_DESCR_PROPS_UNKNOWN#define USB_CFG_DESCR_PROPS_UNKNOWN 0#endif/* ------------------ forward declaration of descriptors ------------------- *//* If you use external static descriptors, they must be stored in global * arrays as declared below: */#ifndef __ASSEMBLER__extern#if !(USB_CFG_DESCR_PROPS_DEVICE & USB_PROP_IS_RAM)PROGMEM#endifchar usbDescriptorDevice[];extern#if !(USB_CFG_DESCR_PROPS_CONFIGURATION & USB_PROP_IS_RAM)PROGMEM#endifchar usbDescriptorConfiguration[];extern#if !(USB_CFG_DESCR_PROPS_HID_REPORT & USB_PROP_IS_RAM)PROGMEM#endifchar usbDescriptorHidReport[];extern#if !(USB_CFG_DESCR_PROPS_STRING_0 & USB_PROP_IS_RAM)PROGMEM#endifchar usbDescriptorString0[];extern#if !(USB_CFG_DESCR_PROPS_STRING_VENDOR & USB_PROP_IS_RAM)PROGMEM#endifint usbDescriptorStringVendor[];extern#if !(USB_CFG_DESCR_PROPS_STRING_PRODUCT & USB_PROP_IS_RAM)PROGMEM#endifint usbDescriptorStringDevice[];extern#if !(USB_CFG_DESCR_PROPS_STRING_SERIAL_NUMBER & USB_PROP_IS_RAM)PROGMEM#endifint usbDescriptorStringSerialNumber[];#endif /* __ASSEMBLER__ *//* ------------------------------------------------------------------------- *//* ------------------------ General Purpose Macros ------------------------- *//* ------------------------------------------------------------------------- */#define USB_CONCAT(a, b) a ## b#define USB_CONCAT_EXPANDED(a, b) USB_CONCAT(a, b)#define USB_OUTPORT(name) USB_CONCAT(PORT, name)#define USB_INPORT(name) USB_CONCAT(PIN, name)#define USB_DDRPORT(name) USB_CONCAT(DDR, name)/* The double-define trick above lets us concatenate strings which are * defined by macros. *//* ------------------------------------------------------------------------- *//* ------------------------- Constant definitions -------------------------- *//* ------------------------------------------------------------------------- */#if !defined __ASSEMBLER__ && (!defined USB_CFG_VENDOR_ID || !defined USB_CFG_DEVICE_ID)#warning "You should define USB_CFG_VENDOR_ID and USB_CFG_DEVICE_ID in usbconfig.h"/* If the user has not defined IDs, we default to obdev's free IDs. * See USBID-License.txt for details. */#endif/* make sure we have a VID and PID defined, byte order is lowbyte, highbyte */#ifndef USB_CFG_VENDOR_ID# define USB_CFG_VENDOR_ID 0xc0, 0x16 /* 5824 in dec, stands for VOTI */#endif#ifndef USB_CFG_DEVICE_ID# if USB_CFG_HID_REPORT_DESCRIPTOR_LENGTH# define USB_CFG_DEVICE_ID 0xdf, 0x05 /* 1503 in dec, shared PID for HIDs */# elif USB_CFG_INTERFACE_CLASS == 2# define USB_CFG_DEVICE_ID 0xe1, 0x05 /* 1505 in dec, shared PID for CDC Modems */# else# define USB_CFG_DEVICE_ID 0xdc, 0x05 /* 1500 in dec, obdev's free PID */# endif#endif/* Derive Output, Input and DataDirection ports from port names */#ifndef USB_CFG_IOPORTNAME#error "You must define USB_CFG_IOPORTNAME in usbconfig.h, see usbconfig-prototype.h"#endif#define USBOUT USB_OUTPORT(USB_CFG_IOPORTNAME)#define USB_PULLUP_OUT USB_OUTPORT(USB_CFG_PULLUP_IOPORTNAME)#define USBIN USB_INPORT(USB_CFG_IOPORTNAME)#define USBDDR USB_DDRPORT(USB_CFG_IOPORTNAME)#define USB_PULLUP_DDR USB_DDRPORT(USB_CFG_PULLUP_IOPORTNAME)#define USBMINUS USB_CFG_DMINUS_BIT#define USBPLUS USB_CFG_DPLUS_BIT#define USBIDLE (1<<USB_CFG_DMINUS_BIT) /* value representing J state */#define USBMASK ((1<<USB_CFG_DPLUS_BIT) | (1<<USB_CFG_DMINUS_BIT)) /* mask for USB I/O bits *//* defines for backward compatibility with older driver versions: */#define USB_CFG_IOPORT USB_OUTPORT(USB_CFG_IOPORTNAME)#ifdef USB_CFG_PULLUP_IOPORTNAME#define USB_CFG_PULLUP_IOPORT USB_OUTPORT(USB_CFG_PULLUP_IOPORTNAME)#endif#define USB_BUFSIZE 11 /* PID, 8 bytes data, 2 bytes CRC *//* ----- Try to find registers and bits responsible for ext interrupt 0 ----- */#ifndef USB_INTR_CFG /* allow user to override our default */# if defined EICRA# define USB_INTR_CFG EICRA# else# define USB_INTR_CFG MCUCR# endif#endif#ifndef USB_INTR_CFG_SET /* allow user to override our default */# define USB_INTR_CFG_SET ((1 << ISC00) | (1 << ISC01)) /* cfg for rising edge */#endif#ifndef USB_INTR_CFG_CLR /* allow user to override our default */# define USB_INTR_CFG_CLR 0 /* no bits to clear */#endif#ifndef USB_INTR_ENABLE /* allow user to override our default */# if defined GIMSK# define USB_INTR_ENABLE GIMSK# elif defined EIMSK# define USB_INTR_ENABLE EIMSK# else# define USB_INTR_ENABLE GICR# endif#endif#ifndef USB_INTR_ENABLE_BIT /* allow user to override our default */# define USB_INTR_ENABLE_BIT INT0#endif#ifndef USB_INTR_PENDING /* allow user to override our default */# if defined EIFR# define USB_INTR_PENDING EIFR# else# define USB_INTR_PENDING GIFR# endif#endif#ifndef USB_INTR_PENDING_BIT /* allow user to override our default */# define USB_INTR_PENDING_BIT INTF0#endif/*The defines above don't work for the following chipsat90c8534: no ISC0?, no PORTB, can't find a data sheetat86rf401: no PORTB, no MCUCR etc, low clock rateatmega103: no ISC0? (maybe omission in header, can't find data sheet)atmega603: not defined in avr-libcat43usb320, at43usb355, at76c711: have USB anywayat94k: is different...at90s1200, attiny11, attiny12, attiny15, attiny28: these have no RAM*//* ------------------------------------------------------------------------- *//* ----------------- USB Specification Constants and Types ----------------- *//* ------------------------------------------------------------------------- *//* USB Token values */#define USBPID_SETUP 0x2d#define USBPID_OUT 0xe1#define USBPID_IN 0x69#define USBPID_DATA0 0xc3#define USBPID_DATA1 0x4b#define USBPID_ACK 0xd2#define USBPID_NAK 0x5a#define USBPID_STALL 0x1e#ifndef __ASSEMBLER__extern uchar usbTxBuf1[USB_BUFSIZE], usbTxBuf3[USB_BUFSIZE];typedef union usbWord{ unsigned word; uchar bytes[2];}usbWord_t;typedef struct usbRequest{ uchar bmRequestType; uchar bRequest; usbWord_t wValue; usbWord_t wIndex; usbWord_t wLength;}usbRequest_t;/* This structure matches the 8 byte setup request */#endif/* bmRequestType field in USB setup: * d t t r r r r r, where * d ..... direction: 0=host->device, 1=device->host * t ..... type: 0=standard, 1=class, 2=vendor, 3=reserved * r ..... recipient: 0=device, 1=interface, 2=endpoint, 3=other *//* USB setup recipient values */#define USBRQ_RCPT_MASK 0x1f#define USBRQ_RCPT_DEVICE 0#define USBRQ_RCPT_INTERFACE 1#define USBRQ_RCPT_ENDPOINT 2/* USB request type values */#define USBRQ_TYPE_MASK 0x60#define USBRQ_TYPE_STANDARD (0<<5)#define USBRQ_TYPE_CLASS (1<<5)#define USBRQ_TYPE_VENDOR (2<<5)/* USB direction values: */#define USBRQ_DIR_MASK 0x80#define USBRQ_DIR_HOST_TO_DEVICE (0<<7)#define USBRQ_DIR_DEVICE_TO_HOST (1<<7)/* USB Standard Requests */#define USBRQ_GET_STATUS 0#define USBRQ_CLEAR_FEATURE 1#define USBRQ_SET_FEATURE 3#define USBRQ_SET_ADDRESS 5#define USBRQ_GET_DESCRIPTOR 6#define USBRQ_SET_DESCRIPTOR 7#define USBRQ_GET_CONFIGURATION 8#define USBRQ_SET_CONFIGURATION 9#define USBRQ_GET_INTERFACE 10#define USBRQ_SET_INTERFACE 11#define USBRQ_SYNCH_FRAME 12/* USB descriptor constants */#define USBDESCR_DEVICE 1#define USBDESCR_CONFIG 2#define USBDESCR_STRING 3#define USBDESCR_INTERFACE 4#define USBDESCR_ENDPOINT 5#define USBDESCR_HID 0x21#define USBDESCR_HID_REPORT 0x22#define USBDESCR_HID_PHYS 0x23#define USBATTR_BUSPOWER 0x80#define USBATTR_SELFPOWER 0x40#define USBATTR_REMOTEWAKE 0x20/* USB HID Requests */#define USBRQ_HID_GET_REPORT 0x01#define USBRQ_HID_GET_IDLE 0x02#define USBRQ_HID_GET_PROTOCOL 0x03#define USBRQ_HID_SET_REPORT 0x09#define USBRQ_HID_SET_IDLE 0x0a#define USBRQ_HID_SET_PROTOCOL 0x0b/* ------------------------------------------------------------------------- */#endif /* __usbdrv_h_included__ */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -