Skip to content

Commit

Permalink
Merge pull request #738 from kareltucek/rebased_interface_reorder
Browse files Browse the repository at this point in the history
Fixes #287 Reorder USB Interfaces
  • Loading branch information
mondalaci authored Feb 26, 2024
2 parents 4e34a1d + ea43582 commit f794a56
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 123 deletions.
85 changes: 43 additions & 42 deletions right/src/usb_composite_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,61 +20,54 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
.count = USB_DEVICE_CONFIG_HID,
.config = (usb_device_class_config_struct_t[USB_DEVICE_CONFIG_HID]) {
{
.classCallback = UsbGenericHidCallback,
.classCallback = UsbBasicKeyboardCallback,
.classInfomation = (usb_device_class_struct_t[]) {{
.type = kUSB_DeviceClassTypeHid,
.configurations = USB_DEVICE_CONFIGURATION_COUNT,
.interfaceList = (usb_device_interface_list_t[USB_DEVICE_CONFIGURATION_COUNT]) {{
.count = USB_GENERIC_HID_INTERFACE_COUNT,
.interfaces = (usb_device_interfaces_struct_t[USB_GENERIC_HID_INTERFACE_COUNT]) {{
.count = USB_BASIC_KEYBOARD_INTERFACE_COUNT,
.interfaces = (usb_device_interfaces_struct_t[USB_BASIC_KEYBOARD_INTERFACE_COUNT]) {{
.classCode = USB_CLASS_HID,
.subclassCode = USB_HID_SUBCLASS_NONE,
.protocolCode = USB_HID_PROTOCOL_NONE,
.interfaceNumber = USB_GENERIC_HID_INTERFACE_INDEX,
.subclassCode = USB_HID_SUBCLASS_BOOT,
.protocolCode = USB_HID_PROTOCOL_KEYBOARD,
.interfaceNumber = USB_BASIC_KEYBOARD_INTERFACE_INDEX,
.count = 1,
.interface = (usb_device_interface_struct_t[]) {{
.alternateSetting = USB_INTERFACE_ALTERNATE_SETTING_NONE,
.endpointList = {
.count = USB_GENERIC_HID_ENDPOINT_COUNT,
.endpoint = (usb_device_endpoint_struct_t[USB_GENERIC_HID_ENDPOINT_COUNT]) {
{
.endpointAddress = USB_GENERIC_HID_ENDPOINT_IN_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE,
},
{
.endpointAddress = USB_GENERIC_HID_ENDPOINT_OUT_INDEX | (USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE,
}
}
USB_BASIC_KEYBOARD_ENDPOINT_COUNT,
(usb_device_endpoint_struct_t[USB_BASIC_KEYBOARD_ENDPOINT_COUNT]) {{
.endpointAddress = USB_BASIC_KEYBOARD_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE,
}}
}
}}
}}
}}
}}
},
{
.classCallback = UsbBasicKeyboardCallback,
.classCallback = UsbMouseCallback,
.classInfomation = (usb_device_class_struct_t[]) {{
.type = kUSB_DeviceClassTypeHid,
.configurations = USB_DEVICE_CONFIGURATION_COUNT,
.interfaceList = (usb_device_interface_list_t[USB_DEVICE_CONFIGURATION_COUNT]) {{
.count = USB_BASIC_KEYBOARD_INTERFACE_COUNT,
.interfaces = (usb_device_interfaces_struct_t[USB_BASIC_KEYBOARD_INTERFACE_COUNT]) {{
.count = USB_MOUSE_INTERFACE_COUNT,
.interfaces = (usb_device_interfaces_struct_t[USB_MOUSE_INTERFACE_COUNT]) {{
.classCode = USB_CLASS_HID,
.subclassCode = USB_HID_SUBCLASS_BOOT,
.protocolCode = USB_HID_PROTOCOL_KEYBOARD,
.interfaceNumber = USB_BASIC_KEYBOARD_INTERFACE_INDEX,
.protocolCode = USB_HID_PROTOCOL_MOUSE,
.interfaceNumber = USB_MOUSE_INTERFACE_INDEX,
.count = 1,
.interface = (usb_device_interface_struct_t[]) {{
.alternateSetting = USB_INTERFACE_ALTERNATE_SETTING_NONE,
.endpointList = {
USB_BASIC_KEYBOARD_ENDPOINT_COUNT,
(usb_device_endpoint_struct_t[USB_BASIC_KEYBOARD_ENDPOINT_COUNT]) {{
.endpointAddress = USB_BASIC_KEYBOARD_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
USB_MOUSE_ENDPOINT_COUNT,
(usb_device_endpoint_struct_t[USB_MOUSE_ENDPOINT_COUNT]) {{
.endpointAddress = USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE,
.maxPacketSize = USB_MOUSE_INTERRUPT_IN_PACKET_SIZE,
}}
}
}}
Expand Down Expand Up @@ -139,27 +132,34 @@ static usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = {
}}
},
{
.classCallback = UsbMouseCallback,
.classCallback = UsbGenericHidCallback,
.classInfomation = (usb_device_class_struct_t[]) {{
.type = kUSB_DeviceClassTypeHid,
.configurations = USB_DEVICE_CONFIGURATION_COUNT,
.interfaceList = (usb_device_interface_list_t[USB_DEVICE_CONFIGURATION_COUNT]) {{
.count = USB_MOUSE_INTERFACE_COUNT,
.interfaces = (usb_device_interfaces_struct_t[USB_MOUSE_INTERFACE_COUNT]) {{
.count = USB_GENERIC_HID_INTERFACE_COUNT,
.interfaces = (usb_device_interfaces_struct_t[USB_GENERIC_HID_INTERFACE_COUNT]) {{
.classCode = USB_CLASS_HID,
.subclassCode = USB_HID_SUBCLASS_BOOT,
.protocolCode = USB_HID_PROTOCOL_MOUSE,
.interfaceNumber = USB_MOUSE_INTERFACE_INDEX,
.subclassCode = USB_HID_SUBCLASS_NONE,
.protocolCode = USB_HID_PROTOCOL_NONE,
.interfaceNumber = USB_GENERIC_HID_INTERFACE_INDEX,
.count = 1,
.interface = (usb_device_interface_struct_t[]) {{
.alternateSetting = USB_INTERFACE_ALTERNATE_SETTING_NONE,
.endpointList = {
USB_MOUSE_ENDPOINT_COUNT,
(usb_device_endpoint_struct_t[USB_MOUSE_ENDPOINT_COUNT]) {{
.endpointAddress = USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_MOUSE_INTERRUPT_IN_PACKET_SIZE,
}}
.count = USB_GENERIC_HID_ENDPOINT_COUNT,
.endpoint = (usb_device_endpoint_struct_t[USB_GENERIC_HID_ENDPOINT_COUNT]) {
{
.endpointAddress = USB_GENERIC_HID_ENDPOINT_IN_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE,
},
{
.endpointAddress = USB_GENERIC_HID_ENDPOINT_OUT_INDEX | (USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
.transferType = USB_ENDPOINT_INTERRUPT,
.maxPacketSize = USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE,
}
}
}
}}
}}
Expand Down Expand Up @@ -319,11 +319,11 @@ void InitUsb(void)

UsbCompositeDevice.attach = 0;
USB_DeviceClassInit(CONTROLLER_ID, &UsbDeviceCompositeConfigList, &UsbCompositeDevice.deviceHandle);
UsbCompositeDevice.genericHidHandle = UsbDeviceCompositeConfigList.config[USB_GENERIC_HID_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.basicKeyboardHandle = UsbDeviceCompositeConfigList.config[USB_BASIC_KEYBOARD_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.mouseHandle = UsbDeviceCompositeConfigList.config[USB_MOUSE_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.mediaKeyboardHandle = UsbDeviceCompositeConfigList.config[USB_MEDIA_KEYBOARD_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.systemKeyboardHandle = UsbDeviceCompositeConfigList.config[USB_SYSTEM_KEYBOARD_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.mouseHandle = UsbDeviceCompositeConfigList.config[USB_MOUSE_INTERFACE_INDEX].classHandle;
UsbCompositeDevice.genericHidHandle = UsbDeviceCompositeConfigList.config[USB_GENERIC_HID_INTERFACE_INDEX].classHandle;

uint8_t usbDeviceKhciIrq[] = USB_IRQS;
uint8_t irqNumber = usbDeviceKhciIrq[CONTROLLER_ID - kUSB_ControllerKhci0];
Expand All @@ -332,3 +332,4 @@ void InitUsb(void)
FMC->PFAPR |= (1 << FMC_PFAPR_M3AP_SHIFT) | (1 << FMC_PFAPR_M4AP_SHIFT); // allow USB controller to read from Flash
USB_DeviceRun(UsbCompositeDevice.deviceHandle);
}

4 changes: 2 additions & 2 deletions right/src/usb_composite_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

typedef struct {
usb_device_handle deviceHandle;
class_handle_t mouseHandle;
class_handle_t basicKeyboardHandle;
class_handle_t genericHidHandle;
class_handle_t mouseHandle;
class_handle_t mediaKeyboardHandle;
class_handle_t systemKeyboardHandle;
class_handle_t gamepadHandle;
class_handle_t genericHidHandle;
uint8_t attach;
uint8_t currentConfiguration;
uint8_t currentInterfaceAlternateSetting[USB_DEVICE_CONFIG_HID];
Expand Down
112 changes: 57 additions & 55 deletions right/src/usb_descriptors/usb_descriptor_configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,29 @@
1 * (USB_DESCRIPTOR_LENGTH_INTERFACE + USB_DESCRIPTOR_LENGTH_HID + (2 * USB_DESCRIPTOR_LENGTH_ENDPOINT)) + \
4 * (USB_DESCRIPTOR_LENGTH_INTERFACE + USB_DESCRIPTOR_LENGTH_HID + USB_DESCRIPTOR_LENGTH_ENDPOINT))

#define USB_GENERIC_HID_DESCRIPTOR_INDEX \
#define USB_BASIC_KEYBOARD_HID_DESCRIPTOR_INDEX \
(USB_DESCRIPTOR_LENGTH_CONFIGURE + USB_DESCRIPTOR_LENGTH_INTERFACE)

#define USB_BASIC_KEYBOARD_HID_DESCRIPTOR_INDEX \
(USB_GENERIC_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
2 * USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)
#define USB_MOUSE_HID_DESCRIPTOR_INDEX \
(USB_BASIC_KEYBOARD_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)

#define USB_MEDIA_KEYBOARD_HID_DESCRIPTOR_INDEX \
(USB_BASIC_KEYBOARD_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
(USB_MOUSE_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)

#define USB_SYSTEM_KEYBOARD_HID_DESCRIPTOR_INDEX \
(USB_MEDIA_KEYBOARD_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)

#define USB_MOUSE_HID_DESCRIPTOR_INDEX \
#define USB_GENERIC_HID_DESCRIPTOR_INDEX \
(USB_SYSTEM_KEYBOARD_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)

#define USB_GAMEPAD_HID_DESCRIPTOR_INDEX \
(USB_MOUSE_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)
(USB_GENERIC_HID_DESCRIPTOR_INDEX + USB_DESCRIPTOR_LENGTH_HID + \
2 * USB_DESCRIPTOR_LENGTH_ENDPOINT + USB_DESCRIPTOR_LENGTH_INTERFACE)


#define BASE_CONFIGURATION_DESCRIPTOR(TOTAL_LENGTH) \
/* Configuration descriptor */ \
Expand All @@ -45,76 +46,67 @@
(USB_DEVICE_CONFIG_REMOTE_WAKEUP << USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_REMOTE_WAKEUP_SHIFT),\
USB_DEVICE_MAX_POWER,\
\
/* Generic HID interface descriptor */\
/* Basic keyboard interface descriptor */\
USB_DESCRIPTOR_LENGTH_INTERFACE,\
USB_DESCRIPTOR_TYPE_INTERFACE,\
USB_GENERIC_HID_INTERFACE_INDEX,\
USB_BASIC_KEYBOARD_INTERFACE_INDEX,\
USB_INTERFACE_ALTERNATE_SETTING_NONE,\
USB_GENERIC_HID_ENDPOINT_COUNT,\
USB_BASIC_KEYBOARD_ENDPOINT_COUNT,\
USB_CLASS_HID,\
USB_HID_SUBCLASS_NONE,\
USB_HID_PROTOCOL_NONE,\
USB_HID_SUBCLASS_BOOT,\
USB_HID_PROTOCOL_KEYBOARD,\
USB_STRING_DESCRIPTOR_NONE,\
\
/* Generic HID descriptor */\
/* Basic keyboard HID descriptor */\
USB_DESCRIPTOR_LENGTH_HID,\
USB_DESCRIPTOR_TYPE_HID,\
USB_SHORT_GET_LOW(USB_HID_VERSION),\
USB_SHORT_GET_HIGH(USB_HID_VERSION),\
USB_HID_COUNTRY_CODE_NOT_SUPPORTED,\
USB_REPORT_DESCRIPTOR_COUNT_PER_HID_DEVICE,\
USB_DESCRIPTOR_TYPE_HID_REPORT,\
USB_SHORT_GET_LOW(USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_HIGH(USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH),\
\
/* Generic HID IN endpoint descriptor */\
USB_DESCRIPTOR_LENGTH_ENDPOINT,\
USB_DESCRIPTOR_TYPE_ENDPOINT,\
USB_GENERIC_HID_ENDPOINT_IN_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_ENDPOINT_INTERRUPT,\
USB_SHORT_GET_LOW(USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE),\
USB_GENERIC_HID_INTERRUPT_IN_INTERVAL,\
USB_SHORT_GET_LOW(USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_HIGH(USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH),\
\
/* Generic HID OUT endpoint descriptor */\
/* Basic keyboard endpoint descriptor */\
USB_DESCRIPTOR_LENGTH_ENDPOINT,\
USB_DESCRIPTOR_TYPE_ENDPOINT,\
USB_GENERIC_HID_ENDPOINT_OUT_INDEX | (USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_BASIC_KEYBOARD_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_ENDPOINT_INTERRUPT,\
USB_SHORT_GET_LOW(USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE),\
USB_GENERIC_HID_INTERRUPT_IN_INTERVAL,\
USB_SHORT_GET_LOW(USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),\
USB_BASIC_KEYBOARD_INTERRUPT_IN_INTERVAL,\
\
/* Basic keyboard interface descriptor */\
/* Mouse interface descriptor */\
USB_DESCRIPTOR_LENGTH_INTERFACE,\
USB_DESCRIPTOR_TYPE_INTERFACE,\
USB_BASIC_KEYBOARD_INTERFACE_INDEX,\
USB_MOUSE_INTERFACE_INDEX,\
USB_INTERFACE_ALTERNATE_SETTING_NONE,\
USB_BASIC_KEYBOARD_ENDPOINT_COUNT,\
USB_MOUSE_ENDPOINT_COUNT,\
USB_CLASS_HID,\
USB_HID_SUBCLASS_BOOT,\
USB_HID_PROTOCOL_KEYBOARD,\
USB_HID_PROTOCOL_MOUSE,\
USB_STRING_DESCRIPTOR_NONE,\
\
/* Basic keyboard HID descriptor */\
/* Mouse HID descriptor */\
USB_DESCRIPTOR_LENGTH_HID,\
USB_DESCRIPTOR_TYPE_HID,\
USB_SHORT_GET_LOW(USB_HID_VERSION),\
USB_SHORT_GET_HIGH(USB_HID_VERSION),\
USB_HID_COUNTRY_CODE_NOT_SUPPORTED,\
USB_REPORT_DESCRIPTOR_COUNT_PER_HID_DEVICE,\
USB_DESCRIPTOR_TYPE_HID_REPORT,\
USB_SHORT_GET_LOW(USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_HIGH(USB_BASIC_KEYBOARD_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_LOW(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_HIGH(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),\
\
/* Basic keyboard endpoint descriptor */\
/* Mouse endpoint descriptor */\
USB_DESCRIPTOR_LENGTH_ENDPOINT,\
USB_DESCRIPTOR_TYPE_ENDPOINT,\
USB_BASIC_KEYBOARD_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_ENDPOINT_INTERRUPT,\
USB_SHORT_GET_LOW(USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_BASIC_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),\
USB_BASIC_KEYBOARD_INTERRUPT_IN_INTERVAL,\
USB_SHORT_GET_LOW(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),\
USB_MOUSE_INTERRUPT_IN_INTERVAL, \
\
/* Media keyboard interface descriptor */\
USB_DESCRIPTOR_LENGTH_INTERFACE,\
Expand Down Expand Up @@ -178,36 +170,45 @@
USB_SHORT_GET_HIGH(USB_SYSTEM_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),\
USB_SYSTEM_KEYBOARD_INTERRUPT_IN_INTERVAL,\
\
/* Mouse interface descriptor */\
/* Generic HID interface descriptor */\
USB_DESCRIPTOR_LENGTH_INTERFACE,\
USB_DESCRIPTOR_TYPE_INTERFACE,\
USB_MOUSE_INTERFACE_INDEX,\
USB_GENERIC_HID_INTERFACE_INDEX,\
USB_INTERFACE_ALTERNATE_SETTING_NONE,\
USB_MOUSE_ENDPOINT_COUNT,\
USB_GENERIC_HID_ENDPOINT_COUNT,\
USB_CLASS_HID,\
USB_HID_SUBCLASS_BOOT,\
USB_HID_PROTOCOL_MOUSE,\
USB_HID_SUBCLASS_NONE,\
USB_HID_PROTOCOL_NONE,\
USB_STRING_DESCRIPTOR_NONE,\
\
/* Mouse HID descriptor */\
/* Generic HID descriptor */\
USB_DESCRIPTOR_LENGTH_HID,\
USB_DESCRIPTOR_TYPE_HID,\
USB_SHORT_GET_LOW(USB_HID_VERSION),\
USB_SHORT_GET_HIGH(USB_HID_VERSION),\
USB_HID_COUNTRY_CODE_NOT_SUPPORTED,\
USB_REPORT_DESCRIPTOR_COUNT_PER_HID_DEVICE,\
USB_DESCRIPTOR_TYPE_HID_REPORT,\
USB_SHORT_GET_LOW(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_HIGH(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_LOW(USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH),\
USB_SHORT_GET_HIGH(USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH),\
\
/* Mouse endpoint descriptor */\
/* Generic HID IN endpoint descriptor */\
USB_DESCRIPTOR_LENGTH_ENDPOINT,\
USB_DESCRIPTOR_TYPE_ENDPOINT,\
USB_MOUSE_ENDPOINT_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_GENERIC_HID_ENDPOINT_IN_INDEX | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_ENDPOINT_INTERRUPT,\
USB_SHORT_GET_LOW(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),\
USB_MOUSE_INTERRUPT_IN_INTERVAL
USB_SHORT_GET_LOW(USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_GENERIC_HID_INTERRUPT_IN_PACKET_SIZE),\
USB_GENERIC_HID_INTERRUPT_IN_INTERVAL,\
\
/* Generic HID OUT endpoint descriptor */\
USB_DESCRIPTOR_LENGTH_ENDPOINT,\
USB_DESCRIPTOR_TYPE_ENDPOINT,\
USB_GENERIC_HID_ENDPOINT_OUT_INDEX | (USB_OUT << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),\
USB_ENDPOINT_INTERRUPT,\
USB_SHORT_GET_LOW(USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE),\
USB_SHORT_GET_HIGH(USB_GENERIC_HID_INTERRUPT_OUT_PACKET_SIZE),\
USB_GENERIC_HID_INTERRUPT_IN_INTERVAL\


#define GAMEPAD_HID_CONFIGURATION_DESCRIPTOR \
Expand Down Expand Up @@ -346,3 +347,4 @@ usb_status_t USB_DeviceGetConfigurationDescriptor(
}
return kStatus_USB_InvalidRequest;
}

Loading

0 comments on commit f794a56

Please sign in to comment.