28 #ifndef PIOS_USB_DEFS_H
29 #define PIOS_USB_DEFS_H
31 #include "board_usb_ids.h"
68 #define htousbs(v) ((uint16_t)(\
69 ((((v) >> 0) & 0xFF) << 8) | \
70 ((((v) >> 8) & 0xFF) << 0)))
71 #define htousbl(v) ((uint32_t)(\
72 ((((v) >> 0) & 0xFF) << 24) | \
73 ((((v) >> 8) & 0xFF) << 16) | \
74 ((((v) >> 16) & 0xFF) << 8) | \
75 ((((v) >> 24) & 0xFF) << 0)))
77 #define htousbs(v) (v)
78 #define htousbl(v) (v)
81 #define USB_EP_IN(ep) ((uint8_t) (0x80 | ((ep) & 0xF)))
82 #define USB_EP_OUT(ep) ((uint8_t) (0x00 | ((ep) & 0xF)))
84 #define HID_ITEM_TYPE_MAIN 0x0
85 #define HID_ITEM_TYPE_GLOBAL 0x1
86 #define HID_ITEM_TYPE_LOCAL 0x2
87 #define HID_ITEM_TYPE_RSVD 0x3
89 #define HID_TAG_GLOBAL_USAGE_PAGE 0x0
90 #define HID_TAG_GLOBAL_LOGICAL_MIN 0x1
91 #define HID_TAG_GLOBAL_LOGICAL_MAX 0x2
92 #define HID_TAG_GLOBAL_PHYS_MIN 0x3
93 #define HID_TAG_GLOBAL_PHYS_MAX 0x4
94 #define HID_TAG_GLOBAL_UNIT_EXP 0x5
95 #define HID_TAG_GLOBAL_UNIT 0x6
96 #define HID_TAG_GLOBAL_REPORT_SIZE 0x7
97 #define HID_TAG_GLOBAL_REPORT_ID 0x8
98 #define HID_TAG_GLOBAL_REPORT_CNT 0x9
99 #define HID_TAG_GLOBAL_PUSH 0xA
100 #define HID_TAG_GLOBAL_POP 0xB
102 #define HID_TAG_MAIN_INPUT 0x8
103 #define HID_TAG_MAIN_OUTPUT 0x9
104 #define HID_TAG_MAIN_COLLECTION 0xA
105 #define HID_TAG_MAIN_FEATURE 0xB
106 #define HID_TAG_MAIN_ENDCOLLECTION 0xC
108 #define HID_TAG_LOCAL_USAGE 0x0
109 #define HID_TAG_LOCAL_USAGE_MIN 0x1
110 #define HID_TAG_LOCAL_USAGE_MAX 0x2
111 #define HID_TAG_LOCAL_DESIG_INDEX 0x3
112 #define HID_TAG_LOCAL_DESIG_MIN 0x4
113 #define HID_TAG_LOCAL_DESIG_MAX 0x5
115 #define HID_TAG_LOCAL_STRING_INDEX 0x7
116 #define HID_TAG_LOCAL_STRING_MIN 0x8
117 #define HID_TAG_LOCAL_STRING_MAX 0x9
118 #define HID_TAG_LOCAL_DELIMITER 0xA
120 #define HID_TAG_RSVD 0xF
122 #define HID_ITEM_SIZE_0 0
123 #define HID_ITEM_SIZE_1 1
124 #define HID_ITEM_SIZE_2 2
125 #define HID_ITEM_SIZE_4 3
127 #define HID_SHORT_ITEM(tag,type,size) (\
128 (((tag) & 0xF) << 4) | \
129 (((type) & 0x3) << 2) | \
130 (((size) & 0x3) << 0))
133 #define HID_LONG_ITEM HID_SHORT_ITEM(HID_TAG_RSVD, HID_ITEM_TYPE_RSVD, HID_ITEM_SIZE_2)
135 #define HID_MAIN_ITEM_0(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_MAIN, HID_ITEM_SIZE_0)
136 #define HID_MAIN_ITEM_1(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_MAIN, HID_ITEM_SIZE_1)
137 #define HID_MAIN_ITEM_2(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_MAIN, HID_ITEM_SIZE_2)
138 #define HID_MAIN_ITEM_4(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_MAIN, HID_ITEM_SIZE_4)
140 #define HID_GLOBAL_ITEM_0(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_GLOBAL, HID_ITEM_SIZE_0)
141 #define HID_GLOBAL_ITEM_1(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_GLOBAL, HID_ITEM_SIZE_1)
142 #define HID_GLOBAL_ITEM_2(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_GLOBAL, HID_ITEM_SIZE_2)
143 #define HID_GLOBAL_ITEM_4(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_GLOBAL, HID_ITEM_SIZE_4)
145 #define HID_LOCAL_ITEM_0(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_LOCAL, HID_ITEM_SIZE_0)
146 #define HID_LOCAL_ITEM_1(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_LOCAL, HID_ITEM_SIZE_1)
147 #define HID_LOCAL_ITEM_2(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_LOCAL, HID_ITEM_SIZE_2)
148 #define HID_LOCAL_ITEM_4(tag) HID_SHORT_ITEM((tag), HID_ITEM_TYPE_LOCAL, HID_ITEM_SIZE_4)
228 #define USB_REQ_TYPE_STANDARD 0x00
229 #define USB_REQ_TYPE_CLASS 0x20
230 #define USB_REQ_TYPE_VENDOR 0x40
231 #define USB_REQ_TYPE_MASK 0x60
233 #define USB_REQ_RECIPIENT_DEVICE 0x00
234 #define USB_REQ_RECIPIENT_INTERFACE 0x01
235 #define USB_REQ_RECIPIENT_ENDPOINT 0x02
236 #define USB_REQ_RECIPIENT_MASK 0x03
301 #define USB_LANGID_ENGLISH_US 0x0409
359 #define USB_OP_DEVICE_VER(board_id, board_mode) (\
360 ((board_id & 0xFF) << 8) | \
361 ((board_mode & 0xFF) << 0))
USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL
USB_CDC_LINE_CODING_STOP_1
USB_DESC_TYPE_CLASS_SPECIFIC
USB_CDC_NOTIFICATION_SERIAL_STATE
uint8_t bDescriptorSubType
USB_CDC_LINE_CODING_PARITY_SPACE
USB_CDC_LINE_CODING_STOP_1_5
uint8_t bNumConfigurations
USB_EP_ATTR_TT_ISOCHRONOUS
USB_CDC_DESC_SUBTYPE_HEADER
USB_OP_BOARD_ID_OPENPILOT_MAIN
USB_OP_BOARD_ID_PIPXTREME
USB_CDC_LINE_CODING_PARITY_ODD
USB_CDC_LINE_CODING_PARITY_MARK
uint8_t bFunctionSubClass
uint8_t bFunctionProtocol
enum usb_standard_requests __attribute__
USB_OP_BOARD_ID_REVOLUTION
USB_OP_BOARD_ID_COPTERCONTROL
USB_CDC_DESC_SUBTYPE_CALLMGMT
USB_DESC_TYPE_CONFIGURATION
uint8_t bInterfaceSubClass
USB_CDC_DESC_SUBTYPE_UNION
uint8_t nInterfaceProtocol
usb_cdc_line_coding_parity
USB_CDC_LINE_CODING_PARITY_EVEN
uint8_t bConfigurationValue
uint8_t bClassDescriptorType
uint8_t bDescriptorSubType
uint8_t bDescriptorSubType
USB_CDC_LINE_CODING_STOP_2
uint8_t bDescriptorSubType
USB_CDC_LINE_CODING_PARITY_NONE
uint8_t bAlternateSetting