Further clean up identifier names and indentation.
This commit is contained in:
@@ -35,7 +35,7 @@ usb_device_class_config_struct_t g_CompositeClassConfig[USB_COMPOSITE_INTERFACE_
|
|||||||
{
|
{
|
||||||
USB_DeviceHidMouseCallback,
|
USB_DeviceHidMouseCallback,
|
||||||
(class_handle_t)NULL,
|
(class_handle_t)NULL,
|
||||||
&UsbDeviceMouseConfig,
|
&UsbDeviceMouseClass,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = {
|
|||||||
0x00U, // Country code of the localized hardware
|
0x00U, // Country code of the localized hardware
|
||||||
0x01U, // Number of class descriptors (at least one report descriptor)
|
0x01U, // Number of class descriptors (at least one report descriptor)
|
||||||
USB_DESCRIPTOR_TYPE_HID_REPORT,
|
USB_DESCRIPTOR_TYPE_HID_REPORT,
|
||||||
USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_MOUSE_REPORT),
|
USB_SHORT_GET_LOW(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),
|
||||||
USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_MOUSE_REPORT),
|
USB_SHORT_GET_HIGH(USB_MOUSE_REPORT_DESCRIPTOR_LENGTH),
|
||||||
|
|
||||||
// Mouse endpoint descriptor
|
// Mouse endpoint descriptor
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = {
|
|||||||
0x00U, // Country code of the localized hardware
|
0x00U, // Country code of the localized hardware
|
||||||
0x01U, // Number of class descriptors (at least one report descriptor)
|
0x01U, // Number of class descriptors (at least one report descriptor)
|
||||||
USB_DESCRIPTOR_TYPE_HID_REPORT,
|
USB_DESCRIPTOR_TYPE_HID_REPORT,
|
||||||
USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT),
|
USB_SHORT_GET_LOW(USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH),
|
||||||
USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT),
|
USB_SHORT_GET_HIGH(USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH),
|
||||||
|
|
||||||
// Keyboard endpoint descriptor
|
// Keyboard endpoint descriptor
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = {
|
|||||||
USB_SHORT_GET_LOW(USB_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),
|
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.
|
// Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected.
|
||||||
USB_KEYBOARD_INTERRUPT_IN_POLL_INTERVAL,
|
USB_KEYBOARD_INTERRUPT_IN_INTERVAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t g_UsbDeviceString0[USB_DESCRIPTOR_LENGTH_STRING0] = {
|
uint8_t g_UsbDeviceString0[USB_DESCRIPTOR_LENGTH_STRING0] = {
|
||||||
@@ -257,11 +257,11 @@ usb_status_t USB_DeviceGetHidReportDescriptor(
|
|||||||
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor)
|
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor)
|
||||||
{
|
{
|
||||||
if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||||
hidReportDescriptor->buffer = UsbDeviceMouseReportDescriptor;
|
hidReportDescriptor->buffer = UsbMouseReportDescriptor;
|
||||||
hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_MOUSE_REPORT;
|
hidReportDescriptor->length = USB_MOUSE_REPORT_DESCRIPTOR_LENGTH;
|
||||||
} else if (USB_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
} else if (USB_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||||
hidReportDescriptor->buffer = UsbKeyboardReportDescriptor;
|
hidReportDescriptor->buffer = UsbKeyboardReportDescriptor;
|
||||||
hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT;
|
hidReportDescriptor->length = USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH;
|
||||||
} else {
|
} else {
|
||||||
return kStatus_USB_InvalidRequest;
|
return kStatus_USB_InvalidRequest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,46 +6,31 @@
|
|||||||
#include "usb_device_descriptor.h"
|
#include "usb_device_descriptor.h"
|
||||||
#include "usb_keyboard_descriptors.h"
|
#include "usb_keyboard_descriptors.h"
|
||||||
|
|
||||||
static usb_device_endpoint_struct_t UsbKeyboardEndpoints[USB_KEYBOARD_ENDPOINT_COUNT] =
|
static usb_device_endpoint_struct_t UsbKeyboardEndpoints[USB_KEYBOARD_ENDPOINT_COUNT] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
|
USB_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
|
||||||
USB_ENDPOINT_INTERRUPT,
|
USB_ENDPOINT_INTERRUPT,
|
||||||
USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE,
|
USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE,
|
||||||
},
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
static usb_device_interface_struct_t UsbKeyboardInterface[] =
|
static usb_device_interface_struct_t UsbKeyboardInterface[] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING,
|
USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING,
|
||||||
{
|
{USB_KEYBOARD_ENDPOINT_COUNT, UsbKeyboardEndpoints},
|
||||||
USB_KEYBOARD_ENDPOINT_COUNT,
|
|
||||||
UsbKeyboardEndpoints,
|
|
||||||
},
|
|
||||||
NULL,
|
NULL,
|
||||||
}
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
static usb_device_interfaces_struct_t UsbKeyboardInterfaces[USB_KEYBOARD_INTERFACE_COUNT] =
|
static usb_device_interfaces_struct_t UsbKeyboardInterfaces[USB_KEYBOARD_INTERFACE_COUNT] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_KEYBOARD_CLASS,
|
USB_KEYBOARD_CLASS,
|
||||||
USB_KEYBOARD_SUBCLASS,
|
USB_KEYBOARD_SUBCLASS,
|
||||||
USB_KEYBOARD_PROTOCOL,
|
USB_KEYBOARD_PROTOCOL,
|
||||||
USB_KEYBOARD_INTERFACE_INDEX,
|
USB_KEYBOARD_INTERFACE_INDEX,
|
||||||
UsbKeyboardInterface,
|
UsbKeyboardInterface,
|
||||||
sizeof(UsbKeyboardInterface) / sizeof(usb_device_interfaces_struct_t),
|
sizeof(UsbKeyboardInterface) / sizeof(usb_device_interfaces_struct_t),
|
||||||
},
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
static usb_device_interface_list_t UsbKeyboardInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] =
|
static usb_device_interface_list_t UsbKeyboardInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_KEYBOARD_INTERFACE_COUNT,
|
USB_KEYBOARD_INTERFACE_COUNT,
|
||||||
UsbKeyboardInterfaces,
|
UsbKeyboardInterfaces,
|
||||||
},
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
usb_device_class_struct_t UsbKeyboardClass = {
|
usb_device_class_struct_t UsbKeyboardClass = {
|
||||||
UsbKeyboardInterfaceList,
|
UsbKeyboardInterfaceList,
|
||||||
@@ -53,7 +38,7 @@ usb_device_class_struct_t UsbKeyboardClass = {
|
|||||||
USB_DEVICE_CONFIGURATION_COUNT,
|
USB_DEVICE_CONFIGURATION_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT] = {
|
uint8_t UsbKeyboardReportDescriptor[USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH] = {
|
||||||
0x05U, 0x01U, // Usage Page (Generic Desktop)
|
0x05U, 0x01U, // Usage Page (Generic Desktop)
|
||||||
0x09U, 0x06U, // Usage (Keyboard)
|
0x09U, 0x06U, // Usage (Keyboard)
|
||||||
0xA1U, 0x01U, // Collection (Application)
|
0xA1U, 0x01U, // Collection (Application)
|
||||||
|
|||||||
@@ -3,25 +3,28 @@
|
|||||||
|
|
||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#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_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_CLASS (0x03U)
|
||||||
#define USB_KEYBOARD_SUBCLASS (0x01U)
|
#define USB_KEYBOARD_SUBCLASS (0x01U)
|
||||||
#define USB_KEYBOARD_PROTOCOL (0x01U)
|
#define USB_KEYBOARD_PROTOCOL (0x01U)
|
||||||
|
|
||||||
#define USB_KEYBOARD_INTERFACE_INDEX (1U)
|
#define USB_KEYBOARD_INTERFACE_INDEX (1U)
|
||||||
#define USB_KEYBOARD_IN_BUFFER_LENGTH (8U)
|
#define USB_KEYBOARD_INTERFACE_COUNT (1U)
|
||||||
#define USB_KEYBOARD_INTERRUPT_IN_POLL_INTERVAL (0x04U)
|
#define USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING (0U)
|
||||||
|
|
||||||
|
#define USB_KEYBOARD_ENDPOINT_IN (2U)
|
||||||
|
#define USB_KEYBOARD_ENDPOINT_COUNT (1U)
|
||||||
|
|
||||||
|
#define USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE (8U)
|
||||||
|
#define USB_KEYBOARD_INTERRUPT_IN_INTERVAL (0x04U)
|
||||||
|
|
||||||
#define USB_KEYBOARD_REPORT_LENGTH (0x08U)
|
#define USB_KEYBOARD_REPORT_LENGTH (0x08U)
|
||||||
|
#define USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH (63U)
|
||||||
|
#define USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH (40U)
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern uint8_t UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH];
|
|
||||||
extern usb_device_class_struct_t UsbKeyboardClass;
|
extern usb_device_class_struct_t UsbKeyboardClass;
|
||||||
extern uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT];
|
extern uint8_t UsbKeyboardReportDescriptor[USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH];
|
||||||
|
extern uint8_t UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,54 +8,39 @@
|
|||||||
#include "hid_mouse.h"
|
#include "hid_mouse.h"
|
||||||
#include "hid_keyboard.h"
|
#include "hid_keyboard.h"
|
||||||
|
|
||||||
static usb_device_endpoint_struct_t g_UsbDeviceHidMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] =
|
static usb_device_endpoint_struct_t UsbMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_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,
|
USB_ENDPOINT_INTERRUPT,
|
||||||
USB_MOUSE_INTERRUPT_IN_PACKET_SIZE,
|
USB_MOUSE_INTERRUPT_IN_PACKET_SIZE,
|
||||||
},
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
static usb_device_interface_struct_t g_UsbDeviceHidMouseInterface[] =
|
static usb_device_interface_struct_t UsbMouseInterface[] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_MOUSE_INTERFACE_ALTERNATE_SETTING,
|
USB_MOUSE_INTERFACE_ALTERNATE_SETTING,
|
||||||
{
|
{USB_MOUSE_ENDPOINT_COUNT, UsbMouseEndpoints},
|
||||||
USB_MOUSE_ENDPOINT_COUNT,
|
|
||||||
g_UsbDeviceHidMouseEndpoints,
|
|
||||||
},
|
|
||||||
NULL,
|
NULL,
|
||||||
}
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
static usb_device_interfaces_struct_t g_UsbDeviceHidMouseInterfaces[USB_MOUSE_INTERFACE_COUNT] =
|
static usb_device_interfaces_struct_t UsbMouseInterfaces[USB_MOUSE_INTERFACE_COUNT] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_MOUSE_CLASS,
|
USB_MOUSE_CLASS,
|
||||||
USB_MOUSE_SUBCLASS,
|
USB_MOUSE_SUBCLASS,
|
||||||
USB_MOUSE_PROTOCOL,
|
USB_MOUSE_PROTOCOL,
|
||||||
USB_MOUSE_INTERFACE_INDEX,
|
USB_MOUSE_INTERFACE_INDEX,
|
||||||
g_UsbDeviceHidMouseInterface,
|
UsbMouseInterface,
|
||||||
sizeof(g_UsbDeviceHidMouseInterface) / sizeof(usb_device_interfaces_struct_t),
|
sizeof(UsbMouseInterface) / sizeof(usb_device_interfaces_struct_t),
|
||||||
},
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
static usb_device_interface_list_t g_UsbDeviceHidMouseInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] =
|
static usb_device_interface_list_t UsbMouseInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] = {{
|
||||||
{
|
|
||||||
{
|
|
||||||
USB_MOUSE_INTERFACE_COUNT,
|
USB_MOUSE_INTERFACE_COUNT,
|
||||||
g_UsbDeviceHidMouseInterfaces,
|
UsbMouseInterfaces,
|
||||||
},
|
}};
|
||||||
};
|
|
||||||
|
|
||||||
usb_device_class_struct_t UsbDeviceMouseConfig = {
|
usb_device_class_struct_t UsbDeviceMouseClass = {
|
||||||
g_UsbDeviceHidMouseInterfaceList,
|
UsbMouseInterfaceList,
|
||||||
kUSB_DeviceClassTypeHid,
|
kUSB_DeviceClassTypeHid,
|
||||||
USB_DEVICE_CONFIGURATION_COUNT,
|
USB_DEVICE_CONFIGURATION_COUNT,
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t UsbDeviceMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_MOUSE_REPORT] = {
|
uint8_t UsbMouseReportDescriptor[USB_MOUSE_REPORT_DESCRIPTOR_LENGTH] = {
|
||||||
0x05U, 0x01U, // Usage Page (Generic Desktop)
|
0x05U, 0x01U, // Usage Page (Generic Desktop)
|
||||||
0x09U, 0x02U, // Usage (Mouse)
|
0x09U, 0x02U, // Usage (Mouse)
|
||||||
0xA1U, 0x01U, // Collection (Application)
|
0xA1U, 0x01U, // Collection (Application)
|
||||||
|
|||||||
@@ -3,29 +3,28 @@
|
|||||||
|
|
||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#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_MOUSE_REPORT_LENGTH (0x04U)
|
|
||||||
|
|
||||||
#define USB_MOUSE_CLASS (0x03U)
|
#define USB_MOUSE_CLASS (0x03U)
|
||||||
#define USB_MOUSE_SUBCLASS (0x01U)
|
#define USB_MOUSE_SUBCLASS (0x01U)
|
||||||
#define USB_MOUSE_PROTOCOL (0x02U)
|
#define USB_MOUSE_PROTOCOL (0x02U)
|
||||||
|
|
||||||
|
#define USB_MOUSE_INTERFACE_INDEX (0U)
|
||||||
|
#define USB_MOUSE_INTERFACE_COUNT (1U)
|
||||||
|
#define USB_MOUSE_INTERFACE_ALTERNATE_SETTING (0U)
|
||||||
|
|
||||||
|
#define USB_MOUSE_ENDPOINT_IN (1U)
|
||||||
|
#define USB_MOUSE_ENDPOINT_COUNT (1U)
|
||||||
|
|
||||||
#define USB_MOUSE_INTERRUPT_IN_PACKET_SIZE (8U)
|
#define USB_MOUSE_INTERRUPT_IN_PACKET_SIZE (8U)
|
||||||
#define USB_MOUSE_INTERRUPT_IN_INTERVAL (0x04U)
|
#define USB_MOUSE_INTERRUPT_IN_INTERVAL (0x04U)
|
||||||
|
|
||||||
#define USB_DESCRIPTOR_LENGTH_MOUSE_REPORT (52U)
|
#define USB_MOUSE_REPORT_LENGTH (0x04U)
|
||||||
|
#define USB_MOUSE_REPORT_DESCRIPTOR_LENGTH (52U)
|
||||||
#define USB_MOUSE_STRING_DESCRIPTOR_LENGTH (34U)
|
#define USB_MOUSE_STRING_DESCRIPTOR_LENGTH (34U)
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern usb_device_class_struct_t UsbDeviceMouseConfig;
|
extern usb_device_class_struct_t UsbDeviceMouseClass;
|
||||||
extern uint8_t UsbDeviceMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_MOUSE_REPORT];
|
extern uint8_t UsbMouseReportDescriptor[USB_MOUSE_REPORT_DESCRIPTOR_LENGTH];
|
||||||
extern uint8_t UsbMouseString[USB_MOUSE_STRING_DESCRIPTOR_LENGTH];
|
extern uint8_t UsbMouseString[USB_MOUSE_STRING_DESCRIPTOR_LENGTH];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user