#ifndef _USBDEFS_INC_
#define _USBDEFS_INC_
#define USBDRV_VERSION 20080513
#if USB_CFG_LONG_TRANSFERS
#define usbMsgLen_t 16
#else
#define usbMsgLen_t 8
#endif
#define USB_NO_MSG ((usbMsgLen_t)-1)
#ifdef USB_CFG_PULLUP_IOPORTNAME
usbDeviceConnect:
sbi USB_PULLUP_DDR,USB_CFG_PULLUP_BIT
sbi USB_PULLUP_OUT,USB_CFG_PULLUP_BIT
usbDeviceDisconnect:
cbi USB_PULLUP_DDR,USB_CFG_PULLUP_BIT
cbi USB_PULLUP_OUT,USB_CFG_PULLUP_BIT
#else
usbDeviceConnect:
cbi USBDDR,USBMINUS
usbDeviceDisconnect:
sbi USBDDR,USBMINUS
#endif
/*--- Definitions for Descriptor Properties ---*/
#define USB_PROP_IS_DYNAMIC (1 << 14)
#define USB_PROP_IS_RAM (1 << 15)
#define USB_PROP_LENGTH(len) ((len) & 0x3fff)
#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
/*--- General purpose macros ---*/
/*--- USB Specification Constants and Types ---*/
#define USB_BUFSIZE 0x0B
#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
/* Cia?aiey iieo?aoaey USB setup */
#define USBRQ_RCPT_MASK 0x1f
#define USBRQ_RCPT_DEVICE 0
#define USBRQ_RCPT_INTERFACE 1
#define USBRQ_RCPT_ENDPOINT 2
/* Cia?aiey oeia cai?ina USB */
#define USBRQ_TYPE_MASK 0x60
#define USBRQ_TYPE_STANDARD (0<<5)
#define USBRQ_TYPE_CLASS (1<<5)
#define USBRQ_TYPE_VENDOR (2<<5)
/* Cia?aiey iai?aaeaiey USB: */
#define USBRQ_DIR_MASK 0x80
#define USBRQ_DIR_HOST_TO_DEVICE (0<<7)
#define USBRQ_DIR_DEVICE_TO_HOST (1<<7)
/* Noaiaa?oiua cai?inu USB */
#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
/* Eiinoaiou aane?eioi?a USB */
#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
/* Cai?inu USB HID */
#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 /* _USBDEF_INC_ */