Further clean up macro and variable naming.
This commit is contained in:
+1
-1
@@ -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,
|
||||||
&g_UsbDeviceHidMouseConfig,
|
&UsbDeviceMouseConfig,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ static usb_status_t USB_DeviceHidKeyboardAction(void)
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return USB_DeviceHidSend(s_UsbDeviceComposite->hidKeyboardHandle, USB_HID_KEYBOARD_ENDPOINT_IN,
|
return USB_DeviceHidSend(s_UsbDeviceComposite->hidKeyboardHandle, USB_KEYBOARD_ENDPOINT_IN,
|
||||||
s_UsbDeviceHidKeyboard.buffer, USB_HID_KEYBOARD_REPORT_LENGTH);
|
s_UsbDeviceHidKeyboard.buffer, USB_KEYBOARD_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_status_t USB_DeviceHidKeyboardCallback(class_handle_t handle, uint32_t event, void *param)
|
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)
|
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 USB_DeviceHidKeyboardAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
|
|||||||
@@ -234,7 +234,7 @@
|
|||||||
/* Type defines: */
|
/* Type defines: */
|
||||||
|
|
||||||
typedef struct _usb_device_hid_keyboard_struct {
|
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;
|
uint8_t idleRate;
|
||||||
} usb_device_hid_keyboard_struct_t;
|
} usb_device_hid_keyboard_struct_t;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -67,8 +67,8 @@ static usb_status_t USB_DeviceHidMouseAction(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return USB_DeviceHidSend(s_UsbDeviceComposite->hidMouseHandle, USB_HID_MOUSE_ENDPOINT_IN,
|
return USB_DeviceHidSend(s_UsbDeviceComposite->hidMouseHandle, USB_MOUSE_ENDPOINT_IN,
|
||||||
s_UsbDeviceHidMouse.buffer, USB_HID_MOUSE_REPORT_LENGTH);
|
s_UsbDeviceHidMouse.buffer, USB_MOUSE_REPORT_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_status_t USB_DeviceHidMouseCallback(class_handle_t handle, uint32_t event, void *param)
|
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)
|
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 USB_DeviceHidMouseAction();
|
||||||
}
|
}
|
||||||
return kStatus_USB_Error;
|
return kStatus_USB_Error;
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
/* Type defines: */
|
/* Type defines: */
|
||||||
|
|
||||||
typedef struct usb_device_hid_mouse_struct {
|
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;
|
uint8_t idleRate;
|
||||||
} usb_device_hid_mouse_struct_t;
|
} usb_device_hid_mouse_struct_t;
|
||||||
|
|
||||||
|
|||||||
@@ -59,12 +59,12 @@ uint8_t UsbConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = {
|
|||||||
|
|
||||||
USB_DESCRIPTOR_LENGTH_INTERFACE,
|
USB_DESCRIPTOR_LENGTH_INTERFACE,
|
||||||
USB_DESCRIPTOR_TYPE_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
|
0x00U, // Value used to select this alternate setting for the interface identified in the prior field
|
||||||
USB_HID_MOUSE_ENDPOINT_COUNT,
|
USB_MOUSE_ENDPOINT_COUNT,
|
||||||
USB_HID_MOUSE_CLASS,
|
USB_MOUSE_CLASS,
|
||||||
USB_HID_MOUSE_SUBCLASS,
|
USB_MOUSE_SUBCLASS,
|
||||||
USB_HID_MOUSE_PROTOCOL,
|
USB_MOUSE_PROTOCOL,
|
||||||
USB_STRING_DESCRIPTOR_ID_MOUSE,
|
USB_STRING_DESCRIPTOR_ID_MOUSE,
|
||||||
|
|
||||||
// Mouse HID descriptor
|
// Mouse HID descriptor
|
||||||
@@ -75,30 +75,30 @@ 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_HID_MOUSE_REPORT),
|
USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_MOUSE_REPORT),
|
||||||
USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT),
|
USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_MOUSE_REPORT),
|
||||||
|
|
||||||
// Mouse endpoint descriptor
|
// Mouse endpoint descriptor
|
||||||
|
|
||||||
USB_DESCRIPTOR_LENGTH_ENDPOINT,
|
USB_DESCRIPTOR_LENGTH_ENDPOINT,
|
||||||
USB_DESCRIPTOR_TYPE_ENDPOINT,
|
USB_DESCRIPTOR_TYPE_ENDPOINT,
|
||||||
// The address of the endpoint on the USB device described by this descriptor.
|
// 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
|
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.
|
// 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),
|
USB_SHORT_GET_LOW(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE), USB_SHORT_GET_HIGH(USB_MOUSE_INTERRUPT_IN_PACKET_SIZE),
|
||||||
FS_HID_MOUSE_INTERRUPT_IN_INTERVAL, // Interval for polling endpoint for data transfers.
|
USB_MOUSE_INTERRUPT_IN_INTERVAL, // Interval for polling endpoint for data transfers.
|
||||||
|
|
||||||
// Keyboard interface descriptor
|
// Keyboard interface descriptor
|
||||||
|
|
||||||
USB_DESCRIPTOR_LENGTH_INTERFACE,
|
USB_DESCRIPTOR_LENGTH_INTERFACE,
|
||||||
USB_DESCRIPTOR_TYPE_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
|
0x00U, // Value used to select this alternate setting for the interface identified in the prior field
|
||||||
USB_HID_KEYBOARD_ENDPOINT_COUNT,
|
USB_KEYBOARD_ENDPOINT_COUNT,
|
||||||
USB_HID_KEYBOARD_CLASS,
|
USB_KEYBOARD_CLASS,
|
||||||
USB_HID_KEYBOARD_SUBCLASS,
|
USB_KEYBOARD_SUBCLASS,
|
||||||
USB_HID_KEYBOARD_PROTOCOL,
|
USB_KEYBOARD_PROTOCOL,
|
||||||
USB_STRING_DESCRIPTOR_ID_KEYBOARD,
|
USB_STRING_DESCRIPTOR_ID_KEYBOARD,
|
||||||
|
|
||||||
// Keyboard HID descriptor
|
// Keyboard HID descriptor
|
||||||
@@ -109,20 +109,20 @@ 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_HID_KEYBOARD_REPORT),
|
USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT),
|
||||||
USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT),
|
USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT),
|
||||||
|
|
||||||
// Keyboard endpoint descriptor
|
// Keyboard endpoint descriptor
|
||||||
|
|
||||||
USB_DESCRIPTOR_LENGTH_ENDPOINT,
|
USB_DESCRIPTOR_LENGTH_ENDPOINT,
|
||||||
USB_DESCRIPTOR_TYPE_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.
|
// The address of the endpoint on the USB device described by this descriptor.
|
||||||
USB_ENDPOINT_INTERRUPT, // This field describes the endpoint's attributes
|
USB_ENDPOINT_INTERRUPT, // This field describes the endpoint's attributes
|
||||||
USB_SHORT_GET_LOW(FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),
|
USB_SHORT_GET_LOW(USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE),
|
||||||
USB_SHORT_GET_HIGH(FS_HID_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.
|
||||||
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] = {
|
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] = {
|
uint32_t g_UsbDeviceStringDescriptorLength[USB_DEVICE_STRING_COUNT] = {
|
||||||
sizeof(g_UsbDeviceString0), sizeof(g_UsbDeviceString1), sizeof(g_UsbDeviceString2),
|
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] = {
|
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] = {{
|
usb_language_t g_UsbDeviceLanguage[USB_DEVICE_LANGUAGE_COUNT] = {{
|
||||||
@@ -256,12 +256,12 @@ usb_status_t USB_DeviceGetHidDescriptor(
|
|||||||
usb_status_t USB_DeviceGetHidReportDescriptor(
|
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_HID_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||||
hidReportDescriptor->buffer = g_UsbDeviceHidMouseReportDescriptor;
|
hidReportDescriptor->buffer = UsbDeviceMouseReportDescriptor;
|
||||||
hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT;
|
hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_MOUSE_REPORT;
|
||||||
} else if (USB_HID_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
} else if (USB_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||||
hidReportDescriptor->buffer = UsbKeyboardReportDescriptor;
|
hidReportDescriptor->buffer = UsbKeyboardReportDescriptor;
|
||||||
hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT;
|
hidReportDescriptor->length = USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT;
|
||||||
} else {
|
} else {
|
||||||
return kStatus_USB_InvalidRequest;
|
return kStatus_USB_InvalidRequest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#define USB_COMPOSITE_CONFIGURE_INDEX (1U)
|
#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:
|
// Function prototypes:
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
#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_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_KEYBOARD_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
|
||||||
USB_ENDPOINT_INTERRUPT, FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE,
|
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_KEYBOARD_INTERFACE_ALTERNATE_SETTING,
|
||||||
{
|
{
|
||||||
USB_HID_KEYBOARD_ENDPOINT_COUNT,
|
USB_KEYBOARD_ENDPOINT_COUNT,
|
||||||
UsbKeyboardEndpoints,
|
UsbKeyboardEndpoints,
|
||||||
},
|
},
|
||||||
NULL,
|
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_KEYBOARD_CLASS,
|
||||||
USB_HID_KEYBOARD_SUBCLASS,
|
USB_KEYBOARD_SUBCLASS,
|
||||||
USB_HID_KEYBOARD_PROTOCOL,
|
USB_KEYBOARD_PROTOCOL,
|
||||||
USB_HID_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),
|
||||||
},
|
},
|
||||||
@@ -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] =
|
static usb_device_interface_list_t UsbKeyboardInterfaceList[USB_DEVICE_CONFIGURATION_COUNT] =
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
USB_HID_KEYBOARD_INTERFACE_COUNT,
|
USB_KEYBOARD_INTERFACE_COUNT,
|
||||||
UsbKeyboardInterfaces,
|
UsbKeyboardInterfaces,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -52,7 +53,7 @@ usb_device_class_struct_t UsbKeyboardClass = {
|
|||||||
USB_DEVICE_CONFIGURATION_COUNT,
|
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)
|
0x05U, 0x01U, // Usage Page (Generic Desktop)
|
||||||
0x09U, 0x06U, // Usage (Keyboard)
|
0x09U, 0x06U, // Usage (Keyboard)
|
||||||
0xA1U, 0x01U, // Collection (Application)
|
0xA1U, 0x01U, // Collection (Application)
|
||||||
@@ -92,8 +93,8 @@ uint8_t UsbKeyboardReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT] =
|
|||||||
0xC0U, // End collection
|
0xC0U, // End collection
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t g_UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH] = {
|
uint8_t UsbKeyboardString[USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH] = {
|
||||||
sizeof(g_UsbKeyboardString),
|
sizeof(UsbKeyboardString),
|
||||||
USB_DESCRIPTOR_TYPE_STRING,
|
USB_DESCRIPTOR_TYPE_STRING,
|
||||||
'H', 0x00U,
|
'H', 0x00U,
|
||||||
'I', 0x00U,
|
'I', 0x00U,
|
||||||
|
|||||||
@@ -3,25 +3,25 @@
|
|||||||
|
|
||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#define USB_HID_KEYBOARD_INTERFACE_COUNT (1U)
|
#define USB_KEYBOARD_INTERFACE_COUNT (1U)
|
||||||
#define USB_DESCRIPTOR_LENGTH_HID_KEYBOARD_REPORT (63U)
|
#define USB_DESCRIPTOR_LENGTH_KEYBOARD_REPORT (63U)
|
||||||
#define USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH (40U)
|
#define USB_KEYBOARD_STRING_DESCRIPTOR_LENGTH (40U)
|
||||||
#define USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING (0U)
|
#define USB_KEYBOARD_INTERFACE_ALTERNATE_SETTING (0U)
|
||||||
#define USB_HID_KEYBOARD_ENDPOINT_IN (2U)
|
#define USB_KEYBOARD_ENDPOINT_IN (2U)
|
||||||
#define FS_HID_KEYBOARD_INTERRUPT_IN_PACKET_SIZE (8U)
|
#define USB_KEYBOARD_INTERRUPT_IN_PACKET_SIZE (8U)
|
||||||
#define USB_HID_KEYBOARD_ENDPOINT_COUNT (1U)
|
#define USB_KEYBOARD_ENDPOINT_COUNT (1U)
|
||||||
#define USB_HID_KEYBOARD_CLASS (0x03U)
|
#define USB_KEYBOARD_CLASS (0x03U)
|
||||||
#define USB_HID_KEYBOARD_SUBCLASS (0x01U)
|
#define USB_KEYBOARD_SUBCLASS (0x01U)
|
||||||
#define USB_HID_KEYBOARD_PROTOCOL (0x01U)
|
#define USB_KEYBOARD_PROTOCOL (0x01U)
|
||||||
#define USB_HID_KEYBOARD_INTERFACE_INDEX (1U)
|
#define USB_KEYBOARD_INTERFACE_INDEX (1U)
|
||||||
#define USB_HID_KEYBOARD_IN_BUFFER_LENGTH (8U)
|
#define USB_KEYBOARD_IN_BUFFER_LENGTH (8U)
|
||||||
#define FS_HID_KEYBOARD_INTERRUPT_IN_INTERVAL (0x04U)
|
#define USB_KEYBOARD_INTERRUPT_IN_POLL_INTERVAL (0x04U)
|
||||||
#define USB_HID_KEYBOARD_REPORT_LENGTH (0x08U)
|
#define USB_KEYBOARD_REPORT_LENGTH (0x08U)
|
||||||
|
|
||||||
// Variables:
|
// 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 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
|
#endif
|
||||||
|
|||||||
@@ -8,50 +8,54 @@
|
|||||||
#include "hid_mouse.h"
|
#include "hid_mouse.h"
|
||||||
#include "hid_keyboard.h"
|
#include "hid_keyboard.h"
|
||||||
|
|
||||||
// HID mouse endpoint
|
static usb_device_endpoint_struct_t g_UsbDeviceHidMouseEndpoints[USB_MOUSE_ENDPOINT_COUNT] =
|
||||||
static usb_device_endpoint_struct_t g_UsbDeviceHidMouseEndpoints[USB_HID_MOUSE_ENDPOINT_COUNT] = {
|
{
|
||||||
// HID mouse interrupt IN pipe
|
|
||||||
{
|
{
|
||||||
USB_HID_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT), USB_ENDPOINT_INTERRUPT,
|
USB_MOUSE_ENDPOINT_IN | (USB_IN << USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_SHIFT),
|
||||||
FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE,
|
USB_ENDPOINT_INTERRUPT,
|
||||||
|
USB_MOUSE_INTERRUPT_IN_PACKET_SIZE,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// HID mouse interface information
|
static usb_device_interface_struct_t g_UsbDeviceHidMouseInterface[] =
|
||||||
static usb_device_interface_struct_t g_UsbDeviceHidMouseInterface[] = {{
|
{
|
||||||
0U, // The alternate setting of the interface
|
|
||||||
{
|
{
|
||||||
USB_HID_MOUSE_ENDPOINT_COUNT,
|
USB_MOUSE_INTERFACE_ALTERNATE_SETTING,
|
||||||
g_UsbDeviceHidMouseEndpoints,
|
{
|
||||||
},
|
USB_MOUSE_ENDPOINT_COUNT,
|
||||||
NULL,
|
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_MOUSE_CLASS,
|
||||||
USB_HID_MOUSE_SUBCLASS,
|
USB_MOUSE_SUBCLASS,
|
||||||
USB_HID_MOUSE_PROTOCOL,
|
USB_MOUSE_PROTOCOL,
|
||||||
USB_HID_MOUSE_INTERFACE_INDEX,
|
USB_MOUSE_INTERFACE_INDEX,
|
||||||
g_UsbDeviceHidMouseInterface,
|
g_UsbDeviceHidMouseInterface,
|
||||||
sizeof(g_UsbDeviceHidMouseInterface) / sizeof(usb_device_interfaces_struct_t),
|
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,
|
g_UsbDeviceHidMouseInterfaces,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
usb_device_class_struct_t g_UsbDeviceHidMouseConfig = {
|
usb_device_class_struct_t UsbDeviceMouseConfig = {
|
||||||
g_UsbDeviceHidMouseInterfaceList,
|
g_UsbDeviceHidMouseInterfaceList,
|
||||||
kUSB_DeviceClassTypeHid,
|
kUSB_DeviceClassTypeHid,
|
||||||
USB_DEVICE_CONFIGURATION_COUNT,
|
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)
|
0x05U, 0x01U, // Usage Page (Generic Desktop)
|
||||||
0x09U, 0x02U, // Usage (Mouse)
|
0x09U, 0x02U, // Usage (Mouse)
|
||||||
0xA1U, 0x01U, // Collection (Application)
|
0xA1U, 0x01U, // Collection (Application)
|
||||||
@@ -82,13 +86,13 @@ uint8_t g_UsbDeviceHidMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPO
|
|||||||
0x75U, 0x08U, // Report Size (8U)
|
0x75U, 0x08U, // Report Size (8U)
|
||||||
0x95U, 0x03U, // Report Count (3U)
|
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 Pointer collection
|
||||||
0xC0U // End collection, Close Mouse collection
|
0xC0U // End collection, Close Mouse collection
|
||||||
};
|
};
|
||||||
|
|
||||||
uint8_t g_UsbDeviceString3[USB_DESCRIPTOR_LENGTH_STRING3] = {
|
uint8_t UsbMouseString[USB_MOUSE_STRING_DESCRIPTOR_LENGTH] = {
|
||||||
sizeof(g_UsbDeviceString3),
|
sizeof(UsbMouseString),
|
||||||
USB_DESCRIPTOR_TYPE_STRING,
|
USB_DESCRIPTOR_TYPE_STRING,
|
||||||
'H', 0x00U,
|
'H', 0x00U,
|
||||||
'I', 0x00U,
|
'I', 0x00U,
|
||||||
|
|||||||
@@ -3,28 +3,29 @@
|
|||||||
|
|
||||||
// Macros:
|
// Macros:
|
||||||
|
|
||||||
#define USB_HID_MOUSE_INTERFACE_COUNT (1U)
|
#define USB_MOUSE_INTERFACE_COUNT (1U)
|
||||||
#define USB_HID_MOUSE_INTERFACE_INDEX (0U)
|
#define USB_MOUSE_INTERFACE_INDEX (0U)
|
||||||
#define USB_HID_MOUSE_IN_BUFFER_LENGTH (8U)
|
#define USB_MOUSE_IN_BUFFER_LENGTH (8U)
|
||||||
#define USB_HID_MOUSE_ENDPOINT_COUNT (1U)
|
#define USB_MOUSE_ENDPOINT_COUNT (1U)
|
||||||
#define USB_HID_MOUSE_ENDPOINT_IN (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_MOUSE_CLASS (0x03U)
|
||||||
#define USB_HID_MOUSE_SUBCLASS (0x01U)
|
#define USB_MOUSE_SUBCLASS (0x01U)
|
||||||
#define USB_HID_MOUSE_PROTOCOL (0x02U)
|
#define USB_MOUSE_PROTOCOL (0x02U)
|
||||||
|
|
||||||
#define FS_HID_MOUSE_INTERRUPT_IN_PACKET_SIZE (8U)
|
#define USB_MOUSE_INTERRUPT_IN_PACKET_SIZE (8U)
|
||||||
#define FS_HID_MOUSE_INTERRUPT_IN_INTERVAL (0x04U)
|
#define USB_MOUSE_INTERRUPT_IN_INTERVAL (0x04U)
|
||||||
|
|
||||||
#define USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT (52U)
|
#define USB_DESCRIPTOR_LENGTH_MOUSE_REPORT (52U)
|
||||||
#define USB_DESCRIPTOR_LENGTH_STRING3 (34U)
|
#define USB_MOUSE_STRING_DESCRIPTOR_LENGTH (34U)
|
||||||
|
|
||||||
// Variables:
|
// Variables:
|
||||||
|
|
||||||
extern usb_device_class_struct_t g_UsbDeviceHidMouseConfig;
|
extern usb_device_class_struct_t UsbDeviceMouseConfig;
|
||||||
extern uint8_t g_UsbDeviceHidMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_HID_MOUSE_REPORT];
|
extern uint8_t UsbDeviceMouseReportDescriptor[USB_DESCRIPTOR_LENGTH_MOUSE_REPORT];
|
||||||
extern uint8_t g_UsbDeviceString3[USB_DESCRIPTOR_LENGTH_STRING3];
|
extern uint8_t UsbMouseString[USB_MOUSE_STRING_DESCRIPTOR_LENGTH];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user