mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
Working compliant VCP+HID descriptors for Windows.
This commit is contained in:
parent
e70f41eb29
commit
4968df183a
@ -37,9 +37,9 @@ static const struct usb_device_desc device_desc = {
|
|||||||
.bLength = sizeof(struct usb_device_desc),
|
.bLength = sizeof(struct usb_device_desc),
|
||||||
.bDescriptorType = USB_DESC_TYPE_DEVICE,
|
.bDescriptorType = USB_DESC_TYPE_DEVICE,
|
||||||
.bcdUSB = htousbs(0x0200),
|
.bcdUSB = htousbs(0x0200),
|
||||||
.bDeviceClass = 0x02,
|
.bDeviceClass = 0xef,
|
||||||
.bDeviceSubClass = 0x00,
|
.bDeviceSubClass = 0x02,
|
||||||
.bDeviceProtocol = 0x00,
|
.bDeviceProtocol = 0x01,
|
||||||
.bMaxPacketSize0 = 64, /* Must be 64 for high-speed devices */
|
.bMaxPacketSize0 = 64, /* Must be 64 for high-speed devices */
|
||||||
.idVendor = htousbs(USB_VENDOR_ID_OPENPILOT),
|
.idVendor = htousbs(USB_VENDOR_ID_OPENPILOT),
|
||||||
.idProduct = htousbs(PIOS_USB_BOARD_PRODUCT_ID),
|
.idProduct = htousbs(PIOS_USB_BOARD_PRODUCT_ID),
|
||||||
@ -97,10 +97,6 @@ static const uint8_t hid_report_desc[36] = {
|
|||||||
struct usb_config_hid_cdc {
|
struct usb_config_hid_cdc {
|
||||||
struct usb_configuration_desc config;
|
struct usb_configuration_desc config;
|
||||||
struct usb_interface_association_desc iad;
|
struct usb_interface_association_desc iad;
|
||||||
struct usb_interface_desc hid_if;
|
|
||||||
struct usb_hid_desc hid;
|
|
||||||
struct usb_endpoint_desc hid_in;
|
|
||||||
struct usb_endpoint_desc hid_out;
|
|
||||||
struct usb_interface_desc cdc_control_if;
|
struct usb_interface_desc cdc_control_if;
|
||||||
struct usb_cdc_header_func_desc cdc_header;
|
struct usb_cdc_header_func_desc cdc_header;
|
||||||
struct usb_cdc_callmgmt_func_desc cdc_callmgmt;
|
struct usb_cdc_callmgmt_func_desc cdc_callmgmt;
|
||||||
@ -110,6 +106,10 @@ struct usb_config_hid_cdc {
|
|||||||
struct usb_interface_desc cdc_data_if;
|
struct usb_interface_desc cdc_data_if;
|
||||||
struct usb_endpoint_desc cdc_in;
|
struct usb_endpoint_desc cdc_in;
|
||||||
struct usb_endpoint_desc cdc_out;
|
struct usb_endpoint_desc cdc_out;
|
||||||
|
struct usb_interface_desc hid_if;
|
||||||
|
struct usb_hid_desc hid;
|
||||||
|
struct usb_endpoint_desc hid_in;
|
||||||
|
struct usb_endpoint_desc hid_out;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
static const struct usb_config_hid_cdc config_hid_cdc = {
|
static const struct usb_config_hid_cdc config_hid_cdc = {
|
||||||
@ -128,15 +128,87 @@ static const struct usb_config_hid_cdc config_hid_cdc = {
|
|||||||
.bDescriptorType = USB_DESC_TYPE_IAD,
|
.bDescriptorType = USB_DESC_TYPE_IAD,
|
||||||
.bFirstInterface = 0,
|
.bFirstInterface = 0,
|
||||||
.bInterfaceCount = 2,
|
.bInterfaceCount = 2,
|
||||||
.bFunctionClass = 2, /* Communication */
|
.bFunctionClass = USB_INTERFACE_CLASS_CDC, /* Communication */
|
||||||
.bFunctionSubClass = 2, /* Abstract Control Model */
|
.bFunctionSubClass = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL, /* Abstract Control Model */
|
||||||
.bFunctionProtocol = 0, /* V.25ter, Common AT commands */
|
.bFunctionProtocol = 1, /* V.25ter, Common AT commands */
|
||||||
.iInterface = 0,
|
.iInterface = 0,
|
||||||
},
|
},
|
||||||
|
.cdc_control_if = {
|
||||||
|
.bLength = sizeof(struct usb_interface_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||||
|
.bInterfaceNumber = 0,
|
||||||
|
.bAlternateSetting = 0,
|
||||||
|
.bNumEndpoints = 1,
|
||||||
|
.bInterfaceClass = USB_INTERFACE_CLASS_CDC,
|
||||||
|
.bInterfaceSubClass = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL, /* Abstract Control Model */
|
||||||
|
.nInterfaceProtocol = 1, /* V.25ter, Common AT commands */
|
||||||
|
.iInterface = 0,
|
||||||
|
},
|
||||||
|
.cdc_header = {
|
||||||
|
.bLength = sizeof(struct usb_cdc_header_func_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||||
|
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_HEADER,
|
||||||
|
.bcdCDC = htousbs(0x0110),
|
||||||
|
},
|
||||||
|
.cdc_callmgmt = {
|
||||||
|
.bLength = sizeof(struct usb_cdc_callmgmt_func_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||||
|
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_CALLMGMT,
|
||||||
|
.bmCapabilities = 0x00, /* No call handling */
|
||||||
|
.bDataInterface = 1,
|
||||||
|
},
|
||||||
|
.cdc_acm = {
|
||||||
|
.bLength = sizeof(struct usb_cdc_acm_func_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||||
|
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL,
|
||||||
|
.bmCapabilities = 0x00,
|
||||||
|
},
|
||||||
|
.cdc_union = {
|
||||||
|
.bLength = sizeof(struct usb_cdc_union_func_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
||||||
|
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_UNION,
|
||||||
|
.bMasterInterface = 0,
|
||||||
|
.bSlaveInterface = 1,
|
||||||
|
},
|
||||||
|
.cdc_mgmt_in = {
|
||||||
|
.bLength = sizeof(struct usb_endpoint_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||||
|
.bEndpointAddress = USB_EP_IN(2),
|
||||||
|
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
|
||||||
|
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_MGMT_LENGTH),
|
||||||
|
.bInterval = 4, /* ms */
|
||||||
|
},
|
||||||
|
.cdc_data_if = {
|
||||||
|
.bLength = sizeof(struct usb_interface_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||||
|
.bInterfaceNumber = 1,
|
||||||
|
.bAlternateSetting = 0,
|
||||||
|
.bNumEndpoints = 2,
|
||||||
|
.bInterfaceClass = USB_INTERFACE_CLASS_DATA,
|
||||||
|
.bInterfaceSubClass = 0,
|
||||||
|
.nInterfaceProtocol = 0, /* No class specific protocol */
|
||||||
|
.iInterface = 0,
|
||||||
|
},
|
||||||
|
.cdc_in = {
|
||||||
|
.bLength = sizeof(struct usb_endpoint_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||||
|
.bEndpointAddress = USB_EP_IN(3),
|
||||||
|
.bmAttributes = USB_EP_ATTR_TT_BULK,
|
||||||
|
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
||||||
|
.bInterval = 0, /* ms */
|
||||||
|
},
|
||||||
|
.cdc_out = {
|
||||||
|
.bLength = sizeof(struct usb_endpoint_desc),
|
||||||
|
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
||||||
|
.bEndpointAddress = USB_EP_OUT(3),
|
||||||
|
.bmAttributes = USB_EP_ATTR_TT_BULK, /* Bulk */
|
||||||
|
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
||||||
|
.bInterval = 0, /* ms */
|
||||||
|
},
|
||||||
.hid_if = {
|
.hid_if = {
|
||||||
.bLength = sizeof(struct usb_interface_desc),
|
.bLength = sizeof(struct usb_interface_desc),
|
||||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
||||||
.bInterfaceNumber = 0,
|
.bInterfaceNumber = 2,
|
||||||
.bAlternateSetting = 0,
|
.bAlternateSetting = 0,
|
||||||
.bNumEndpoints = 2,
|
.bNumEndpoints = 2,
|
||||||
.bInterfaceClass = USB_INTERFACE_CLASS_HID,
|
.bInterfaceClass = USB_INTERFACE_CLASS_HID,
|
||||||
@ -169,78 +241,6 @@ static const struct usb_config_hid_cdc config_hid_cdc = {
|
|||||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
|
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_HID_DATA_LENGTH),
|
||||||
.bInterval = 4, /* ms */
|
.bInterval = 4, /* ms */
|
||||||
},
|
},
|
||||||
.cdc_control_if = {
|
|
||||||
.bLength = sizeof(struct usb_interface_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
|
||||||
.bInterfaceNumber = 1,
|
|
||||||
.bAlternateSetting = 0,
|
|
||||||
.bNumEndpoints = 1,
|
|
||||||
.bInterfaceClass = USB_INTERFACE_CLASS_CDC,
|
|
||||||
.bInterfaceSubClass = 2, /* Abstract Control Model */
|
|
||||||
.nInterfaceProtocol = 1, /* V.25ter, Common AT commands */
|
|
||||||
.iInterface = 0,
|
|
||||||
},
|
|
||||||
.cdc_header = {
|
|
||||||
.bLength = sizeof(struct usb_cdc_header_func_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
|
||||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_HEADER,
|
|
||||||
.bcdCDC = htousbs(0x0110),
|
|
||||||
},
|
|
||||||
.cdc_callmgmt = {
|
|
||||||
.bLength = sizeof(struct usb_cdc_callmgmt_func_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
|
||||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_CALLMGMT,
|
|
||||||
.bmCapabilities = 0x00, /* No call handling */
|
|
||||||
.bDataInterface = 2,
|
|
||||||
},
|
|
||||||
.cdc_acm = {
|
|
||||||
.bLength = sizeof(struct usb_cdc_acm_func_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
|
||||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_ABSTRACT_CTRL,
|
|
||||||
.bmCapabilities = 0,
|
|
||||||
},
|
|
||||||
.cdc_union = {
|
|
||||||
.bLength = sizeof(struct usb_cdc_union_func_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_CLASS_SPECIFIC,
|
|
||||||
.bDescriptorSubType = USB_CDC_DESC_SUBTYPE_UNION,
|
|
||||||
.bMasterInterface = 1,
|
|
||||||
.bSlaveInterface = 2,
|
|
||||||
},
|
|
||||||
.cdc_mgmt_in = {
|
|
||||||
.bLength = sizeof(struct usb_endpoint_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
|
||||||
.bEndpointAddress = USB_EP_IN(2),
|
|
||||||
.bmAttributes = USB_EP_ATTR_TT_INTERRUPT,
|
|
||||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_MGMT_LENGTH),
|
|
||||||
.bInterval = 4, /* ms */
|
|
||||||
},
|
|
||||||
.cdc_data_if = {
|
|
||||||
.bLength = sizeof(struct usb_interface_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_INTERFACE,
|
|
||||||
.bInterfaceNumber = 2,
|
|
||||||
.bAlternateSetting = 0,
|
|
||||||
.bNumEndpoints = 2,
|
|
||||||
.bInterfaceClass = USB_INTERFACE_CLASS_DATA,
|
|
||||||
.bInterfaceSubClass = 0,
|
|
||||||
.nInterfaceProtocol = 0, /* No class specific protocol */
|
|
||||||
.iInterface = 0,
|
|
||||||
},
|
|
||||||
.cdc_in = {
|
|
||||||
.bLength = sizeof(struct usb_endpoint_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
|
||||||
.bEndpointAddress = USB_EP_IN(3),
|
|
||||||
.bmAttributes = USB_EP_ATTR_TT_BULK,
|
|
||||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
|
||||||
.bInterval = 0, /* ms */
|
|
||||||
},
|
|
||||||
.cdc_out = {
|
|
||||||
.bLength = sizeof(struct usb_endpoint_desc),
|
|
||||||
.bDescriptorType = USB_DESC_TYPE_ENDPOINT,
|
|
||||||
.bEndpointAddress = USB_EP_OUT(3),
|
|
||||||
.bmAttributes = USB_EP_ATTR_TT_BULK, /* Bulk */
|
|
||||||
.wMaxPacketSize = htousbs(PIOS_USB_BOARD_CDC_DATA_LENGTH),
|
|
||||||
.bInterval = 0, /* ms */
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t PIOS_USB_DESC_HID_CDC_Init(void)
|
int32_t PIOS_USB_DESC_HID_CDC_Init(void)
|
||||||
|
@ -299,7 +299,7 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
|||||||
switch (Type_Recipient) {
|
switch (Type_Recipient) {
|
||||||
case (STANDARD_REQUEST | INTERFACE_RECIPIENT):
|
case (STANDARD_REQUEST | INTERFACE_RECIPIENT):
|
||||||
switch (pInformation->USBwIndex0) {
|
switch (pInformation->USBwIndex0) {
|
||||||
case 0: /* HID Interface */
|
case 2: /* HID Interface */
|
||||||
switch (RequestNo) {
|
switch (RequestNo) {
|
||||||
case GET_DESCRIPTOR:
|
case GET_DESCRIPTOR:
|
||||||
switch (pInformation->USBwValue1) {
|
switch (pInformation->USBwValue1) {
|
||||||
@ -316,7 +316,7 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
|||||||
|
|
||||||
case (CLASS_REQUEST | INTERFACE_RECIPIENT):
|
case (CLASS_REQUEST | INTERFACE_RECIPIENT):
|
||||||
switch (pInformation->USBwIndex0) {
|
switch (pInformation->USBwIndex0) {
|
||||||
case 0: /* HID Interface */
|
case 2: /* HID Interface */
|
||||||
switch (RequestNo) {
|
switch (RequestNo) {
|
||||||
case GET_PROTOCOL:
|
case GET_PROTOCOL:
|
||||||
CopyRoutine = PIOS_USBHOOK_GetProtocolValue;
|
CopyRoutine = PIOS_USBHOOK_GetProtocolValue;
|
||||||
@ -325,16 +325,16 @@ static RESULT PIOS_USBHOOK_Data_Setup(uint8_t RequestNo)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
#if defined(PIOS_INCLUDE_USB_CDC)
|
#if defined(PIOS_INCLUDE_USB_CDC)
|
||||||
case 1: /* CDC Call Control Interface */
|
case 0: /* CDC Call Control Interface */
|
||||||
switch (RequestNo) {
|
switch (RequestNo) {
|
||||||
case GET_LINE_CODING:
|
case GET_LINE_CODING:
|
||||||
CopyRoutine = PIOS_USB_CDC_GetLineCoding;
|
//CopyRoutine = PIOS_USB_CDC_GetLineCoding;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* CDC Data Interface */
|
case 1: /* CDC Data Interface */
|
||||||
switch (RequestNo) {
|
switch (RequestNo) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user