diff --git a/right/usb_composite_device.c b/right/usb_composite_device.c index 78a6040..7379ffb 100644 --- a/right/usb_composite_device.c +++ b/right/usb_composite_device.c @@ -7,7 +7,7 @@ static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event, void *param); usb_composite_device_t UsbCompositeDevice; -usb_device_class_config_struct_t UsbDeviceCompositeClassConfig[USB_COMPOSITE_INTERFACE_COUNT] = { +usb_device_class_config_struct_t UsbDeviceCompositeClassConfig[USB_DEVICE_CONFIG_HID] = { {UsbGenericHidCallback, (class_handle_t)NULL, &UsbGenericHidClass}, {UsbKeyboardCallback, (class_handle_t)NULL, &UsbKeyboardClass}, {UsbMouseCallback, (class_handle_t)NULL, &UsbMouseClass}, @@ -16,7 +16,7 @@ usb_device_class_config_struct_t UsbDeviceCompositeClassConfig[USB_COMPOSITE_INT usb_device_class_config_list_struct_t UsbDeviceCompositeConfigList = { UsbDeviceCompositeClassConfig, UsbDeviceCallback, - USB_COMPOSITE_INTERFACE_COUNT + USB_DEVICE_CONFIG_HID }; static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event, void *param) @@ -50,7 +50,7 @@ static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event, if (UsbCompositeDevice.attach) { uint8_t interface = (uint8_t)((*temp16 & 0xFF00U) >> 8); uint8_t alternateSetting = (uint8_t)(*temp16 & 0x00FF); - if (interface < USB_COMPOSITE_INTERFACE_COUNT) { + if (interface < USB_DEVICE_CONFIG_HID) { UsbCompositeDevice.currentInterfaceAlternateSetting[interface] = alternateSetting; UsbGenericHidSetInterface(UsbCompositeDevice.genericHidHandle, interface, alternateSetting); UsbKeyboardSetInterface(UsbCompositeDevice.keyboardHandle, interface, alternateSetting); @@ -61,7 +61,7 @@ static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event, break; case kUSB_DeviceEventGetInterface: ; uint8_t interface = (uint8_t)((*temp16 & 0xFF00) >> 8); - if (interface < USB_COMPOSITE_INTERFACE_COUNT) { + if (interface < USB_DEVICE_CONFIG_HID) { *temp16 = (*temp16 & 0xFF00) | UsbCompositeDevice.currentInterfaceAlternateSetting[interface]; error = kStatus_USB_Success; } else { diff --git a/right/usb_composite_device.h b/right/usb_composite_device.h index 0cbb865..069d1f5 100644 --- a/right/usb_composite_device.h +++ b/right/usb_composite_device.h @@ -19,7 +19,7 @@ class_handle_t genericHidHandle; uint8_t attach; uint8_t currentConfiguration; - uint8_t currentInterfaceAlternateSetting[USB_COMPOSITE_INTERFACE_COUNT]; + uint8_t currentInterfaceAlternateSetting[USB_DEVICE_CONFIG_HID]; } usb_composite_device_t; // Variables: diff --git a/right/usb_descriptor_configuration.c b/right/usb_descriptor_configuration.c index 919de6c..d9ac4ec 100644 --- a/right/usb_descriptor_configuration.c +++ b/right/usb_descriptor_configuration.c @@ -11,7 +11,7 @@ uint8_t UsbConfigurationDescriptor[USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH] = USB_DESCRIPTOR_TYPE_CONFIGURE, USB_SHORT_GET_LOW(USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH), USB_SHORT_GET_HIGH(USB_CONFIGURATION_DESCRIPTOR_TOTAL_LENGTH), - USB_COMPOSITE_INTERFACE_COUNT, + USB_DEVICE_CONFIG_HID, USB_COMPOSITE_CONFIGURATION_INDEX, USB_STRING_DESCRIPTOR_NONE, (USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_D7_MASK) | diff --git a/right/usb_descriptor_device.h b/right/usb_descriptor_device.h index 5e63f8f..97bcb6f 100644 --- a/right/usb_descriptor_device.h +++ b/right/usb_descriptor_device.h @@ -17,9 +17,6 @@ #define USB_DEVICE_CONFIGURATION_COUNT 1 #define USB_REPORT_DESCRIPTOR_COUNT_PER_HID_DEVICE 1 #define USB_DEVICE_MAX_POWER 50 // Expressed in 2mA units - #define USB_COMPOSITE_INTERFACE_COUNT (USB_KEYBOARD_INTERFACE_COUNT + \ - USB_MOUSE_INTERFACE_COUNT + \ - USB_GENERIC_HID_INTERFACE_COUNT) #define USB_CLASS_HID 0x03 #define USB_HID_COUNTRY_CODE_NOT_SUPPORTED 0x00 diff --git a/right/usb_device_config.h b/right/usb_device_config.h index bb80a76..723f98f 100644 --- a/right/usb_device_config.h +++ b/right/usb_device_config.h @@ -8,7 +8,11 @@ #define USB_DEVICE_CONFIG_NUM 1 // HID instance count -#define USB_DEVICE_CONFIG_HID 3 +#define USB_KEYBOARD_INTERFACE_COUNT 1 +#define USB_MOUSE_INTERFACE_COUNT 1 +#define USB_GENERIC_HID_INTERFACE_COUNT 1 +#define USB_DEVICE_CONFIG_HID \ + (USB_KEYBOARD_INTERFACE_COUNT + USB_MOUSE_INTERFACE_COUNT + USB_GENERIC_HID_INTERFACE_COUNT) // Whether the device is self-powered: 1 supported, 0 not supported #define USB_DEVICE_CONFIG_SELF_POWER 1 diff --git a/right/usb_interface_generic_hid.h b/right/usb_interface_generic_hid.h index e38aa7f..f7e6372 100644 --- a/right/usb_interface_generic_hid.h +++ b/right/usb_interface_generic_hid.h @@ -9,7 +9,6 @@ // Macros: #define USB_GENERIC_HID_INTERFACE_INDEX 0 - #define USB_GENERIC_HID_INTERFACE_COUNT 1 #define USB_GENERIC_HID_ENDPOINT_IN_INDEX 3 #define USB_GENERIC_HID_ENDPOINT_OUT_INDEX 4 diff --git a/right/usb_interface_keyboard.h b/right/usb_interface_keyboard.h index e12af4b..3b40e67 100644 --- a/right/usb_interface_keyboard.h +++ b/right/usb_interface_keyboard.h @@ -9,7 +9,6 @@ // Macros: #define USB_KEYBOARD_INTERFACE_INDEX 1 - #define USB_KEYBOARD_INTERFACE_COUNT 1 #define USB_KEYBOARD_ENDPOINT_INDEX 2 #define USB_KEYBOARD_ENDPOINT_COUNT 1 diff --git a/right/usb_interface_mouse.h b/right/usb_interface_mouse.h index ef3f4eb..256c767 100644 --- a/right/usb_interface_mouse.h +++ b/right/usb_interface_mouse.h @@ -4,7 +4,6 @@ // Macros: #define USB_MOUSE_INTERFACE_INDEX 2 - #define USB_MOUSE_INTERFACE_COUNT 1 #define USB_MOUSE_ENDPOINT_INDEX 1 #define USB_MOUSE_ENDPOINT_COUNT 1