00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00035 #ifndef LIBUSB_USB_H_
00036 #define LIBUSB_USB_H_
00037
00038 #include <sys/types.h>
00039 #include <byteorder.h>
00040
00042 #define uint16_host2usb(n) host2uint16_t_le((n))
00043
00045 #define uint32_host2usb(n) host2uint32_t_le((n))
00046
00048 #define uint16_usb2host(n) uint16_t_le2host((n))
00049
00051 #define uint32_usb2host(n) uint32_t_le2host((n))
00052
00053
00055 typedef enum {
00056 USB_TRANSFER_CONTROL = 0,
00057 USB_TRANSFER_ISOCHRONOUS = 1,
00058 USB_TRANSFER_BULK = 2,
00059 USB_TRANSFER_INTERRUPT = 3
00060 } usb_transfer_type_t;
00061
00062 const char * usb_str_transfer_type(usb_transfer_type_t t);
00063 const char * usb_str_transfer_type_short(usb_transfer_type_t t);
00064
00066 typedef enum {
00067 USB_DIRECTION_IN,
00068 USB_DIRECTION_OUT,
00069 USB_DIRECTION_BOTH
00070 } usb_direction_t;
00071
00073 typedef enum {
00075 USB_SPEED_LOW,
00077 USB_SPEED_FULL,
00079 USB_SPEED_HIGH,
00081 USB_SPEED_MAX
00082 } usb_speed_t;
00083
00084 const char *usb_str_speed(usb_speed_t);
00085
00086
00088 typedef enum {
00089 USB_REQUEST_TYPE_STANDARD = 0,
00090 USB_REQUEST_TYPE_CLASS = 1,
00091 USB_REQUEST_TYPE_VENDOR = 2
00092 } usb_request_type_t;
00093
00095 typedef enum {
00096 USB_REQUEST_RECIPIENT_DEVICE = 0,
00097 USB_REQUEST_RECIPIENT_INTERFACE = 1,
00098 USB_REQUEST_RECIPIENT_ENDPOINT = 2,
00099 USB_REQUEST_RECIPIENT_OTHER = 3
00100 } usb_request_recipient_t;
00101
00105 typedef int usb_address_t;
00106
00108 #define USB_ADDRESS_DEFAULT 0
00109
00110 #define USB11_ADDRESS_MAX 128
00111
00115 typedef int usb_endpoint_t;
00116
00119 #define USB11_ENDPOINT_MAX 16
00120
00121
00125 typedef struct {
00126 usb_address_t address;
00127 usb_endpoint_t endpoint;
00128 } usb_target_t;
00129
00136 static inline int usb_target_same(usb_target_t a, usb_target_t b)
00137 {
00138 return (a.address == b.address)
00139 && (a.endpoint == b.endpoint);
00140 }
00141
00145 typedef sysarg_t usb_handle_t;
00146
00148 typedef enum {
00149 #define _MAKE_PID_NIBBLE(tag, type) \
00150 ((uint8_t)(((tag) << 2) | (type)))
00151 #define _MAKE_PID(tag, type) \
00152 ( \
00153 _MAKE_PID_NIBBLE(tag, type) \
00154 | ((~_MAKE_PID_NIBBLE(tag, type)) << 4) \
00155 )
00156 USB_PID_OUT = _MAKE_PID(0, 1),
00157 USB_PID_IN = _MAKE_PID(2, 1),
00158 USB_PID_SOF = _MAKE_PID(1, 1),
00159 USB_PID_SETUP = _MAKE_PID(3, 1),
00160
00161 USB_PID_DATA0 = _MAKE_PID(0 ,3),
00162 USB_PID_DATA1 = _MAKE_PID(2 ,3),
00163
00164 USB_PID_ACK = _MAKE_PID(0 ,2),
00165 USB_PID_NAK = _MAKE_PID(2 ,2),
00166 USB_PID_STALL = _MAKE_PID(3 ,2),
00167
00168 USB_PID_PRE = _MAKE_PID(3 ,0),
00169
00170 #undef _MAKE_PID
00171 #undef _MAKE_PID_NIBBLE
00172 } usb_packet_id;
00173
00175 #define USB_HC_DDF_CLASS_NAME "usbhc"
00176
00177 #endif
00178