diff --git a/right/composite.c b/right/composite.c index b927cd6..16b4247 100644 --- a/right/composite.c +++ b/right/composite.c @@ -35,7 +35,7 @@ usb_device_class_config_struct_t g_CompositeClassConfig[USB_COMPOSITE_INTERFACE_ { USB_DeviceHidMouseCallback, (class_handle_t)NULL, - &g_UsbDeviceHidMouseConfig, + &UsbDeviceMouseConfig, } }; diff --git a/right/hid_keyboard.c b/right/hid_keyboard.c index 3468fb6..ca81450 100644 --- a/right/hid_keyboard.c +++ b/right/hid_keyboard.c @@ -41,8 +41,8 @@ static usb_status_t USB_DeviceHidKeyboardAction(void) default: break; } - return USB_DeviceHidSend(s_UsbDeviceComposite->hidKeyboardHandle, USB_HID_KEYBOARD_ENDPOINT_IN, - s_UsbDeviceHidKeyboard.buffer, USB_HID_KEYBOARD_REPORT_LENGTH); + return USB_DeviceHidSend(s_UsbDeviceComposite->hidKeyboardHandle, USB_KEYBOARD_ENDPOINT_IN, + s_UsbDeviceHidKeyboard.buffer, USB_KEYBOARD_REPORT_LENGTH); } usb_status_t USB_DeviceHidKeyboardCallback(class_handle_t handle, uint32_t event, void *param) @@ -82,7 +82,7 @@ usb_status_t USB_DeviceHidKeyboardSetConfigure(class_handle_t handle, uint8_t co usb_status_t USB_DeviceHidKeyboardSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting) { - if (USB_HID_KEYBOARD_INTERFACE_INDEX == interface) { + if (USB_KEYBOARD_INTERFACE_INDEX == interface) { return USB_DeviceHidKeyboardAction(); } return kStatus_USB_Error; diff --git a/right/hid_keyboard.h b/right/hid_keyboard.h index c7797c4..1f2e362 100644 --- a/right/hid_keyboard.h +++ b/right/hid_keyboard.h @@ -234,7 +234,7 @@ /* Type defines: */ typedef struct _usb_device_hid_keyboard_struct { - uint8_t buffer[USB_HID_KEYBOARD_REPORT_LENGTH]; + uint8_t buffer[USB_KEYBOARD_REPORT_LENGTH]; uint8_t idleRate; } usb_device_hid_keyboard_struct_t; diff --git a/right/hid_mouse.c b/right/hid_mouse.c index b6b1e43..0de7574 100644 --- a/right/hid_mouse.c +++ b/right/hid_mouse.c @@ -67,8 +67,8 @@ static usb_status_t USB_DeviceHidMouseAction(void) break; } - return USB_DeviceHidSend(s_UsbDeviceComposite->hidMouseHandle, USB_HID_MOUSE_ENDPOINT_IN, - s_UsbDeviceHidMouse.buffer, USB_HID_MOUSE_REPORT_LENGTH); + return USB_DeviceHidSend(s_UsbDeviceComposite->hidMouseHandle, USB_MOUSE_ENDPOINT_IN, + s_UsbDeviceHidMouse.buffer, USB_MOUSE_REPORT_LENGTH); } usb_status_t USB_DeviceHidMouseCallback(class_handle_t handle, uint32_t event, void *param) @@ -109,7 +109,7 @@ usb_status_t USB_DeviceHidMouseSetConfigure(class_handle_t handle, uint8_t confi usb_status_t USB_DeviceHidMouseSetInterface(class_handle_t handle, uint8_t interface, uint8_t alternateSetting) { - if (USB_HID_KEYBOARD_INTERFACE_INDEX == interface) { + if (USB_KEYBOARD_INTERFACE_INDEX == interface) { return USB_DeviceHidMouseAction(); } return kStatus_USB_Error; diff --git a/right/hid_mouse.h b/right/hid_mouse.h index 0bb77b8..dfa7b19 100644 --- a/right/hid_mouse.h +++ b/right/hid_mouse.h @@ -4,7 +4,7 @@ /* Type defines: */ typedef struct usb_device_hid_mouse_struct { - uint8_t buffer[USB_HID_MOUSE_REPORT_LENGTH]; + uint8_t buffer[USB_MOUSE_REPORT_LENGTH]; uint8_t idleRate; } usb_device_hid_mouse_struct_t; diff --git a/right/usb_device_descriptor.c b/right/usb_device_descriptor.c index 4991e27..6650d88 100644 --- a/right/usb_device_descriptor.c +++ b/right/usb_device_descriptor.c @@ -59,12 +59,12 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = { USB_DESCRIPTOR_LENGTH_INTERFACE, USB_DESCRIPTOR_TYPE_INTERFACE, - USB_HID_MOUSE_INTERFACE_INDEX, + USB_MOUSE_INTERFACE_INDEX, 0x00U, // Value used to select this alternate setting for the interface identified in the prior field - USB_HID_MOUSE_ENDPOINT_COUNT, - USB_HID_MOUSE_CLASS, - USB_HID_MOUSE_SUBCLASS, - USB_HID_MOUSE_PROTOCOL, + USB_MOUSE_ENDPOINT_COUNT, + USB_MOUSE_CLASS, + USB_MOUSE_SUBCLASS, + USB_MOUSE_PROTOCOL, USB_STRING_DESCRIPTOR_ID_MOUSE, // Mouse HID descriptor @@ -75,30 +75,30 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = { 0x00U, // Country code of the localized hardware 0x01U, // Number of class descriptors (at least one report descriptor) USB_DESCRIPTOR_TYPE_HID_REPORT, - USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT), - USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT), + USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_MOUSE_REPORT), + USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_MOUSE_REPORT), // Mouse endpoint descriptor USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, // The address of the endpoint on the USB device described by this descriptor. - USB_HID_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), + USB_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), USB_ENDPOINT_INTERRUPT, // This field describes the endpoint's attributes // Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. - USB_SHORT_GET_LOW(FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE), USB_SHORT_GET_HIGH(FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE), - FS_HID_MOUSE_INTERRUPT_IN_INTERVAL, // Interval for polling endpoint for data transfers. + 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, // Interval for polling endpoint for data transfers. // Keyboard interface descriptor USB_DESCRIPTOR_LENGTH_INTERFACE, USB_DESCRIPTOR_TYPE_INTERFACE, - USB_HID_KEYBOARD_INTERFACE_INDEX, + USB_KEYBOARD_INTERFACE_INDEX, 0x00U, // Value used to select this alternate setting for the interface identified in the prior field - USB_HID_KEYBOARD_ENDPOINT_COUNT, - USB_HID_KEYBOARD_CLASS, - USB_HID_KEYBOARD_SUBCLASS, - USB_HID_KEYBOARD_PROTOCOL, + USB_KEYBOARD_ENDPOINT_COUNT, + USB_KEYBOARD_CLASS, + USB_KEYBOARD_SUBCLASS, + USB_KEYBOARD_PROTOCOL, USB_STRING_DESCRIPTOR_ID_KEYBOARD, // Keyboard HID descriptor @@ -109,20 +109,20 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = { 0x00U, // Country code of the localized hardware 0x01U, // Number of class descriptors (at least one report descriptor) USB_DESCRIPTOR_TYPE_HID_REPORT, - USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT), - USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT), + USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT), + USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT), // Keyboard endpoint descriptor USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, - USB_HID_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), + USB_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), // The address of the endpoint on the USB device described by this descriptor. USB_ENDPOINT_INTERRUPT, // This field describes the endpoint's attributes - USB_SHORT_GET_LOW(FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE), - USB_SHORT_GET_HIGH(FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE), + USB_SHORT_GET_LOW(USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE), + USB_SHORT_GET_HIGH(USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE), // Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. - FS_HID_KEYBOARD_INTERRUPT_IN_INTERVAL, // Interval for polling endpoint for data transfers. + USB_KEYBOARD_INTERRUPT_IN_POLL_INTERVAL, }; uint8_t g_UsbDeviceString0[USB_DESCRIPTOR_LENGTH_STRING0] = { @@ -185,11 +185,11 @@ uint8_t g_UsbDeviceString2[USB_DESCRIPTOR_LENGTH_STRING2] = { uint32_t g_UsbDeviceStringDescriptorLength[USB_DEVICE_STRING_COUNT] = { sizeof(g_UsbDeviceString0), sizeof(g_UsbDeviceString1), sizeof(g_UsbDeviceString2), - sizeof(g_UsbDeviceString3), sizeof(g_UsbKeyboardString), + sizeof(UsbMouseString), sizeof(UsbKeyboardString), }; uint8_t *g_UsbDeviceStringDescriptorArray[USB_DEVICE_STRING_COUNT] = { - g_UsbDeviceString0, g_UsbDeviceString1, g_UsbDeviceString2, g_UsbDeviceString3, g_UsbKeyboardString, + g_UsbDeviceString0, g_UsbDeviceString1, g_UsbDeviceString2, UsbMouseString, UsbKeyboardString, }; usb_language_t g_UsbDeviceLanguage[USB_DEVICE_LANGUAGE_COUNT] = {{ @@ -256,12 +256,12 @@ usb_status_t USB_DeviceGetHidDescriptor( usb_status_t USB_DeviceGetHidReportDescriptor( usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor) { - if (USB_HID_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) { - hidReportDescriptor->buffer = g_UsbDeviceHidMouseReportDescriptor; - hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT; - } else if (USB_HID_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) { + if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) { + hidReportDescriptor->buffer = UsbDeviceMouseReportDescriptor; + hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_MOUSE_REPORT; + } else if (USB_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) { hidReportDescriptor->buffer = UsbKeyboardReportDescriptor; - hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT; + hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT; } else { return kStatus_USB_InvalidRequest; } diff --git a/right/usb_device_descriptor.h b/right/usb_device_descriptor.h index 5841474..2c0f65b 100644 --- a/right/usb_device_descriptor.h +++ b/right/usb_device_descriptor.h @@ -38,7 +38,7 @@ #define USB_COMPOSITE_CONFIGURE_INDEX (1U) - #define USB_COMPOSITE_INTERFACE_COUNT (USB_HID_KEYBOARD_INTERFACE_COUNT + USB_HID_MOUSE_INTERFACE_COUNT) + #define USB_COMPOSITE_INTERFACE_COUNT (USB_KEYBOARD_INTERFACE_COUNT + USB_MOUSE_INTERFACE_COUNT) // Function prototypes: diff --git a/right/usb_keyboard_descriptors.c b/right/usb_keyboard_descriptors.c index 7aef0fe..f38787b 100644 --- a/right/usb_keyboard_descriptors.c +++ b/right/usb_keyboard_descriptors.c @@ -6,11 +6,12 @@ #include "usb_device_descriptor.h" #include "usb_keyboard_descriptors.h" -static usb_device_endpoint_struct_t UsbKeyboardEndpoints[USB_HID_KEYBOARD_ENDPOINT_COUNT] = +static usb_device_endpoint_struct_t UsbKeyboardEndpoints[USB_KEYBOARD_ENDPOINT_COUNT] = { { - USB_HID_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), - USB_ENDPOINT_INTERRUPT, FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE, + USB_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), + USB_ENDPOINT_INTERRUPT, + USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE, }, }; @@ -19,20 +20,20 @@ static usb_device_interface_struct_t UsbKeyboardInterface[] = { USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING, { - USB_HID_KEYBOARD_ENDPOINT_COUNT, + USB_KEYBOARD_ENDPOINT_COUNT, UsbKeyboardEndpoints, }, NULL, } }; -static usb_device_interfaces_struct_t UsbKeyboardInterfaces[USB_HID_KEYBOARD_INTERFACE_COUNT] = +static usb_device_interfaces_struct_t UsbKeyboardInterfaces[USB_KEYBOARD_INTERFACE_COUNT] = { { - USB_HID_KEYBOARD_CLASS, - USB_HID_KEYBOARD_SUBCLASS, - USB_HID_KEYBOARD_PROTOCOL, - USB_HID_KEYBOARD_INTERFACE_INDEX, + USB_KEYBOARD_CLASS, + USB_KEYBOARD_SUBCLASS, + USB_KEYBOARD_PROTOCOL, + USB_KEYBOARD_INTERFACE_INDEX, UsbKeyboardInterface, sizeof(UsbKeyboardInterface) / sizeof(usb_device_interfaces_struct_t), }, @@ -41,7 +42,7 @@ static usb_device_interfaces_struct_t UsbKeyboardInterfaces[USB_HID_KEYBOARD_INT static usb_device_interface_list_t UsbKeyboardInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = { { - USB_HID_KEYBOARD_INTERFACE_COUNT, + USB_KEYBOARD_INTERFACE_COUNT, UsbKeyboardInterfaces, }, }; @@ -52,7 +53,7 @@ usb_device_class_struct_t UsbKeyboardClass = { USB_DEVICE_CONFIGURATION_COUNT, }; -uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT] = { +uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT] = { 0x05U, 0x01U, // Usage Page (Generic Desktop) 0x09U, 0x06U, // Usage (Keyboard) 0xA1U, 0x01U, // Collection (Application) @@ -92,8 +93,8 @@ uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT] = 0xC0U, // End collection }; -uint8_t g_UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH] = { - sizeof(g_UsbKeyboardString), +uint8_t UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH] = { + sizeof(UsbKeyboardString), USB_DESCRIPTOR_TYPE_STRING, 'H', 0x00U, 'I', 0x00U, diff --git a/right/usb_keyboard_descriptors.h b/right/usb_keyboard_descriptors.h index 75f5319..ad65829 100644 --- a/right/usb_keyboard_descriptors.h +++ b/right/usb_keyboard_descriptors.h @@ -3,25 +3,25 @@ // Macros: - #define USB_HID_KEYBOARD_INTERFACE_COUNT (1U) - #define USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT (63U) + #define USB_KEYBOARD_INTERFACE_COUNT (1U) + #define USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT (63U) #define USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH (40U) #define USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING (0U) - #define USB_HID_KEYBOARD_ENDPOINT_IN (2U) - #define FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE (8U) - #define USB_HID_KEYBOARD_ENDPOINT_COUNT (1U) - #define USB_HID_KEYBOARD_CLASS (0x03U) - #define USB_HID_KEYBOARD_SUBCLASS (0x01U) - #define USB_HID_KEYBOARD_PROTOCOL (0x01U) - #define USB_HID_KEYBOARD_INTERFACE_INDEX (1U) - #define USB_HID_KEYBOARD_IN_BUFFER_LENGTH (8U) - #define FS_HID_KEYBOARD_INTERRUPT_IN_INTERVAL (0x04U) - #define USB_HID_KEYBOARD_REPORT_LENGTH (0x08U) + #define USB_KEYBOARD_ENDPOINT_IN (2U) + #define USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE (8U) + #define USB_KEYBOARD_ENDPOINT_COUNT (1U) + #define USB_KEYBOARD_CLASS (0x03U) + #define USB_KEYBOARD_SUBCLASS (0x01U) + #define USB_KEYBOARD_PROTOCOL (0x01U) + #define USB_KEYBOARD_INTERFACE_INDEX (1U) + #define USB_KEYBOARD_IN_BUFFER_LENGTH (8U) + #define USB_KEYBOARD_INTERRUPT_IN_POLL_INTERVAL (0x04U) + #define USB_KEYBOARD_REPORT_LENGTH (0x08U) // Variables: - extern uint8_t g_UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH]; + extern uint8_t UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH]; extern usb_device_class_struct_t UsbKeyboardClass; - extern uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT]; + extern uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT]; #endif diff --git a/right/usb_mouse_descriptors.c b/right/usb_mouse_descriptors.c index 09e5654..3b30d9b 100644 --- a/right/usb_mouse_descriptors.c +++ b/right/usb_mouse_descriptors.c @@ -8,50 +8,54 @@ #include "hid_mouse.h" #include "hid_keyboard.h" -// HID mouse endpoint -static usb_device_endpoint_struct_t g_UsbDeviceHidMouseEndpoints[USB_HID_MOUSE_ENDPOINT_COUNT] = { - // HID mouse interrupt IN pipe +static usb_device_endpoint_struct_t g_UsbDeviceHidMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] = +{ { - USB_HID_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), USB_ENDPOINT_INTERRUPT, - FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE, + USB_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), + USB_ENDPOINT_INTERRUPT, + USB_MOUSE_INTERRUPT_IN_PACKET_SIZE, }, }; -// HID mouse interface information -static usb_device_interface_struct_t g_UsbDeviceHidMouseInterface[] = {{ - 0U, // The alternate setting of the interface +static usb_device_interface_struct_t g_UsbDeviceHidMouseInterface[] = +{ { - USB_HID_MOUSE_ENDPOINT_COUNT, - g_UsbDeviceHidMouseEndpoints, - }, - NULL, -}}; + USB_MOUSE_INTERFACE_ALTERNATE_SETTING, + { + USB_MOUSE_ENDPOINT_COUNT, + g_UsbDeviceHidMouseEndpoints, + }, + NULL, + } +}; -static usb_device_interfaces_struct_t g_UsbDeviceHidMouseInterfaces[USB_HID_MOUSE_INTERFACE_COUNT] = { +static usb_device_interfaces_struct_t g_UsbDeviceHidMouseInterfaces[USB_MOUSE_INTERFACE_COUNT] = +{ { - USB_HID_MOUSE_CLASS, - USB_HID_MOUSE_SUBCLASS, - USB_HID_MOUSE_PROTOCOL, - USB_HID_MOUSE_INTERFACE_INDEX, + USB_MOUSE_CLASS, + USB_MOUSE_SUBCLASS, + USB_MOUSE_PROTOCOL, + USB_MOUSE_INTERFACE_INDEX, g_UsbDeviceHidMouseInterface, sizeof(g_UsbDeviceHidMouseInterface) / sizeof(usb_device_interfaces_struct_t), }, }; -static usb_device_interface_list_t g_UsbDeviceHidMouseInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = { +static usb_device_interface_list_t g_UsbDeviceHidMouseInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = +{ { - USB_HID_MOUSE_INTERFACE_COUNT, + USB_MOUSE_INTERFACE_COUNT, g_UsbDeviceHidMouseInterfaces, }, }; -usb_device_class_struct_t g_UsbDeviceHidMouseConfig = { +usb_device_class_struct_t UsbDeviceMouseConfig = { g_UsbDeviceHidMouseInterfaceList, kUSB_DeviceClassTypeHid, USB_DEVICE_CONFIGURATION_COUNT, }; -uint8_t g_UsbDeviceHidMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT] = { +uint8_t UsbDeviceMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_MOUSE_REPORT] = { 0x05U, 0x01U, // Usage Page (Generic Desktop) 0x09U, 0x02U, // Usage (Mouse) 0xA1U, 0x01U, // Collection (Application) @@ -82,13 +86,13 @@ uint8_t g_UsbDeviceHidMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPO 0x75U, 0x08U, // Report Size (8U) 0x95U, 0x03U, // Report Count (3U) - 0x81U, 0x06U, // Input(Data, Variable, Relative), three position bytes (X & Y & Z) + 0x81U, 0x06U, // Input(Data, Variable, Relative), 3 position bytes (X & Y & Z) 0xC0U, // End collection, Close Pointer collection 0xC0U // End collection, Close Mouse collection }; -uint8_t g_UsbDeviceString3[USB_DESCRIPTOR_LENGTH_STRING3] = { - sizeof(g_UsbDeviceString3), +uint8_t UsbMouseString[USB_MOUSE_STRING_DESCRIPTOR_LENGTH] = { + sizeof(UsbMouseString), USB_DESCRIPTOR_TYPE_STRING, 'H', 0x00U, 'I', 0x00U, diff --git a/right/usb_mouse_descriptors.h b/right/usb_mouse_descriptors.h index f0de7a2..dc6e1e3 100644 --- a/right/usb_mouse_descriptors.h +++ b/right/usb_mouse_descriptors.h @@ -3,28 +3,29 @@ // Macros: - #define USB_HID_MOUSE_INTERFACE_COUNT (1U) - #define USB_HID_MOUSE_INTERFACE_INDEX (0U) - #define USB_HID_MOUSE_IN_BUFFER_LENGTH (8U) - #define USB_HID_MOUSE_ENDPOINT_COUNT (1U) - #define USB_HID_MOUSE_ENDPOINT_IN (1U) + #define USB_MOUSE_INTERFACE_COUNT (1U) + #define USB_MOUSE_INTERFACE_INDEX (0U) + #define USB_MOUSE_IN_BUFFER_LENGTH (8U) + #define USB_MOUSE_ENDPOINT_COUNT (1U) + #define USB_MOUSE_ENDPOINT_IN (1U) + #define USB_MOUSE_INTERFACE_ALTERNATE_SETTING (0U) - #define USB_HID_MOUSE_REPORT_LENGTH (0x04U) + #define USB_MOUSE_REPORT_LENGTH (0x04U) - #define USB_HID_MOUSE_CLASS (0x03U) - #define USB_HID_MOUSE_SUBCLASS (0x01U) - #define USB_HID_MOUSE_PROTOCOL (0x02U) + #define USB_MOUSE_CLASS (0x03U) + #define USB_MOUSE_SUBCLASS (0x01U) + #define USB_MOUSE_PROTOCOL (0x02U) - #define FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE (8U) - #define FS_HID_MOUSE_INTERRUPT_IN_INTERVAL (0x04U) + #define USB_MOUSE_INTERRUPT_IN_PACKET_SIZE (8U) + #define USB_MOUSE_INTERRUPT_IN_INTERVAL (0x04U) - #define USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT (52U) - #define USB_DESCRIPTOR_LENGTH_STRING3 (34U) + #define USB_DESCRIPTOR_LENGTH_MOUSE_REPORT (52U) + #define USB_MOUSE_STRING_DESCRIPTOR_LENGTH (34U) // Variables: -extern usb_device_class_struct_t g_UsbDeviceHidMouseConfig; -extern uint8_t g_UsbDeviceHidMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT]; -extern uint8_t g_UsbDeviceString3[USB_DESCRIPTOR_LENGTH_STRING3]; + extern usb_device_class_struct_t UsbDeviceMouseConfig; + extern uint8_t UsbDeviceMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_MOUSE_REPORT]; + extern uint8_t UsbMouseString[USB_MOUSE_STRING_DESCRIPTOR_LENGTH]; #endif