Contiki 2.6
|
00001 #ifndef __USB_H__6PFTDPIMZM__ 00002 #define __USB_H__6PFTDPIMZM__ 00003 #include <stdint.h> 00004 00005 /* Adapted from usb_kbd_enum.h in c5131-usb-kbd-light-1_0_2 package from 00006 Atmel */ 00007 00008 /* These definitions assume a little endian architecture */ 00009 00010 #ifdef __GNUC__ 00011 #define BYTE_ALIGNED __attribute__ ((__packed__)) 00012 #else 00013 #define BYTE_ALIGNED 00014 #endif 00015 00016 #define LOW_BYTE(x) ((unsigned char)x) 00017 #define HIGH_BYTE(x) ((unsigned char)(x>>8)) 00018 00019 typedef uint8_t Uchar; 00020 typedef uint16_t Uint16; 00021 typedef uint32_t Uint32; 00022 00023 /*_____ S T A N D A R D R E Q U E S T S __________________________________*/ 00024 00025 #define GET_STATUS 0x00 00026 #define GET_DEVICE 0x01 00027 #define CLEAR_FEATURE 0x01 /* see FEATURES below */ 00028 #define GET_STRING 0x03 00029 #define SET_FEATURE 0x03 /* see FEATURES below */ 00030 #define SET_ADDRESS 0x05 00031 #define GET_DESCRIPTOR 0x06 00032 #define SET_DESCRIPTOR 0x07 00033 #define GET_CONFIGURATION 0x08 00034 #define SET_CONFIGURATION 0x09 00035 #define GET_INTERFACE 0x0A 00036 #define SET_INTERFACE 0x0B 00037 #define SYNCH_FRAME 0x0C 00038 00039 #define GET_DEVICE_DESCRIPTOR 1 00040 #define GET_CONFIGURATION_DESCRIPTOR 4 00041 00042 #define REQUEST_DEVICE_STATUS 0x80 00043 #define REQUEST_INTERFACE_STATUS 0x81 00044 #define REQUEST_ENDPOINT_STATUS 0x82 00045 #define ZERO_TYPE 0x00 00046 #define INTERFACE_TYPE 0x01 00047 #define ENDPOINT_TYPE 0x02 00048 00049 /*_____ D E S C R I P T O R T Y P E S ____________________________________*/ 00050 00051 #define DEVICE 0x01 00052 #define CONFIGURATION 0x02 00053 #define STRING 0x03 00054 #define INTERFACE 0x04 00055 #define ENDPOINT 0x05 00056 00057 /* HID specific */ 00058 #define HID 0x21 00059 #define REPORT 0x22 00060 /* *** */ 00061 00062 /*_____ S T A N D A R D F E A T U R E S __________________________________*/ 00063 00064 #define DEVICE_REMOTE_WAKEUP_FEATURE 0x01 00065 #define ENDPOINT_HALT_FEATURE 0x00 00066 00067 /*_____ D E V I C E S T A T U S ___________________________________________*/ 00068 00069 #define SELF_POWERED 1 00070 00071 /*_____ D E V I C E S T A T E _____________________________________________*/ 00072 00073 #define ATTACHED 0 00074 #define POWERED 1 00075 #define DEFAULT 2 00076 #define ADDRESSED 3 00077 #define CONFIGURED 4 00078 #define SUSPENDED 5 00079 00080 #define USB_CONFIG_BUSPOWERED 0x80 00081 #define USB_CONFIG_SELFPOWERED 0x40 00082 #define USB_CONFIG_REMOTEWAKEUP 0x20 00083 00084 /* Class specific */ 00085 #define CS_INTERFACE 0x24 00086 #define CS_ENDPOINT 0x25 00087 00088 /*_________________________________________________________ S T R U C T _____*/ 00089 /*_____ U S B D E V I C E R E Q U E S T _________________________________*/ 00090 00091 struct USB_request_st 00092 { 00093 Uchar bmRequestType; /* Characteristics of the request */ 00094 Uchar bRequest; /* Specific request */ 00095 Uint16 wValue; 00096 Uint16 wIndex; /* field that varies according to request */ 00097 Uint16 wLength; /* Number of bytes to transfer if Data */ 00098 }; 00099 00100 00101 /*_____ U S B D E V I C E D E S C R I P T O R ___________________________*/ 00102 00103 struct usb_st_device_descriptor 00104 { 00105 Uchar bLength; /* Size of this descriptor in bytes */ 00106 Uchar bDescriptorType; /* DEVICE descriptor type */ 00107 Uint16 bscUSB; /* Binay Coded Decimal Spec. release */ 00108 Uchar bDeviceClass; /* Class code assigned by the USB */ 00109 Uchar bDeviceSubClass; /* Sub-class code assigned by the USB */ 00110 Uchar bDeviceProtocol; /* Protocol code assigned by the USB */ 00111 Uchar bMaxPacketSize0; /* Max packet size for EP0 */ 00112 Uint16 idVendor; /* Vendor ID. ATMEL = 0x03EB */ 00113 Uint16 idProduct; /* Product ID assigned by the manufacturer */ 00114 Uint16 bcdDevice; /* Device release number */ 00115 Uchar iManufacturer; /* Index of manu. string descriptor */ 00116 Uchar iProduct; /* Index of prod. string descriptor */ 00117 Uchar iSerialNumber; /* Index of S.N. string descriptor */ 00118 Uchar bNumConfigurations; /* Number of possible configurations */ 00119 } BYTE_ALIGNED; 00120 00121 00122 /*_____ U S B C O N F I G U R A T I O N D E S C R I P T O R _____________*/ 00123 00124 struct usb_st_configuration_descriptor 00125 { 00126 Uchar bLength; /* size of this descriptor in bytes */ 00127 Uchar bDescriptorType; /* CONFIGURATION descriptor type */ 00128 Uint16 wTotalLength; /* total length of data returned */ 00129 Uchar bNumInterfaces; /* number of interfaces for this conf. */ 00130 Uchar bConfigurationValue; /* value for SetConfiguration resquest */ 00131 Uchar iConfiguration; /* index of string descriptor */ 00132 Uchar bmAttibutes; /* Configuration characteristics */ 00133 Uchar MaxPower; /* maximum power consumption */ 00134 } BYTE_ALIGNED; 00135 00136 00137 /*_____ U S B I N T E R F A C E D E S C R I P T O R _____________________*/ 00138 00139 struct usb_st_interface_descriptor 00140 { 00141 Uchar bLength; /* size of this descriptor in bytes */ 00142 Uchar bDescriptorType; /* INTERFACE descriptor type */ 00143 Uchar bInterfaceNumber; /* Number of interface */ 00144 Uchar bAlternateSetting; /* value to select alternate setting */ 00145 Uchar bNumEndpoints; /* Number of EP except EP 0 */ 00146 Uchar bInterfaceClass; /* Class code assigned by the USB */ 00147 Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ 00148 Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ 00149 Uchar iInterface; /* Index of string descriptor */ 00150 } BYTE_ALIGNED; 00151 00152 00153 /*_____ U S B E N D P O I N T D E S C R I P T O R _______________________*/ 00154 00155 struct usb_st_endpoint_descriptor 00156 { 00157 Uchar bLength; /* Size of this descriptor in bytes */ 00158 Uchar bDescriptorType; /* ENDPOINT descriptor type */ 00159 Uchar bEndpointAddress; /* Address of the endpoint */ 00160 Uchar bmAttributes; /* Endpoint's attributes */ 00161 Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ 00162 Uchar bInterval; /* Interval for polling EP in ms */ 00163 /* Uchar bRefresh; */ 00164 /* Uchar bSynchAddress; */ 00165 } BYTE_ALIGNED; 00166 00167 00168 /*_____ U S B S T R I N G D E S C R I P T O R _______________*/ 00169 00170 struct usb_st_string_descriptor 00171 { 00172 Uchar bLength; /* size of this descriptor in bytes */ 00173 Uchar bDescriptorType; /* STRING descriptor type */ 00174 Uint16 wstring[1];/* unicode characters */ 00175 } BYTE_ALIGNED; 00176 00177 00178 struct usb_st_language_descriptor 00179 { 00180 Uchar bLength; /* size of this descriptor in bytes */ 00181 Uchar bDescriptorType; /* STRING descriptor type */ 00182 Uint16 wlangid[1]; /* language id */ 00183 } BYTE_ALIGNED; 00184 00185 #endif /* __USB_H__6PFTDPIMZM__ */