Extract general HID descriptor related functions to descriptor_hid.[ch]
This commit is contained in:
@@ -176,6 +176,8 @@ add_executable(dev_composite_hid_mouse_hid_keyboard_bm.elf
|
||||
"${SrcDir}/usb_descriptor_device.h"
|
||||
"${SrcDir}/usb_descriptor_generic_hid_report.c"
|
||||
"${SrcDir}/usb_descriptor_generic_hid_report.h"
|
||||
"${SrcDir}/usb_descriptor_hid.c"
|
||||
"${SrcDir}/usb_descriptor_hid.h"
|
||||
"${SrcDir}/usb_descriptor_keyboard_report.c"
|
||||
"${SrcDir}/usb_descriptor_keyboard_report.h"
|
||||
"${SrcDir}/usb_descriptor_mouse_report.c"
|
||||
|
||||
@@ -225,6 +225,16 @@
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/usb_descriptor_generic_hid_report.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>sources/usb_descriptor_hid.c</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/usb_descriptor_hid.c</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>sources/usb_descriptor_hid.h</name>
|
||||
<type>1</type>
|
||||
<locationURI>PARENT-2-PROJECT_LOC/usb_descriptor_hid.h</locationURI>
|
||||
</link>
|
||||
<link>
|
||||
<name>sources/usb_descriptor_keyboard_report.c</name>
|
||||
<type>1</type>
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <stdlib.h>
|
||||
#include "fsl_common.h"
|
||||
#include "usb_descriptor_strings.h"
|
||||
#include "usb_descriptor_hid.h"
|
||||
|
||||
static usb_status_t UsbDeviceCallback(usb_device_handle handle, uint32_t event, void *param);
|
||||
usb_composite_device_t UsbCompositeDevice;
|
||||
|
||||
@@ -149,33 +149,3 @@ usb_status_t USB_DeviceGetConfigurationDescriptor(
|
||||
}
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceGetHidDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_descriptor_struct_t *hidDescriptor)
|
||||
{
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceGetHidReportDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor)
|
||||
{
|
||||
if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||
hidReportDescriptor->buffer = UsbMouseReportDescriptor;
|
||||
hidReportDescriptor->length = USB_MOUSE_REPORT_DESCRIPTOR_LENGTH;
|
||||
} else if (USB_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||
hidReportDescriptor->buffer = UsbKeyboardReportDescriptor;
|
||||
hidReportDescriptor->length = USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH;
|
||||
} else if (USB_GENERIC_HID_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||
hidReportDescriptor->buffer = UsbGenericHidReportDescriptor;
|
||||
hidReportDescriptor->length = USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH;
|
||||
} else {
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
return kStatus_USB_Success;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceGetHidPhysicalDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_physical_descriptor_struct_t *hidPhysicalDescriptor)
|
||||
{
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,4 @@
|
||||
extern usb_status_t USB_DeviceGetConfigurationDescriptor(
|
||||
usb_device_handle handle, usb_device_get_configuration_descriptor_struct_t *configurationDescriptor);
|
||||
|
||||
extern usb_status_t USB_DeviceGetHidDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_descriptor_struct_t *hidDescriptor);
|
||||
|
||||
extern usb_status_t USB_DeviceGetHidReportDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor);
|
||||
|
||||
extern usb_status_t USB_DeviceGetHidPhysicalDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_physical_descriptor_struct_t *hidPhysicalDescriptor);
|
||||
|
||||
#endif
|
||||
|
||||
38
right/usb_descriptor_hid.c
Normal file
38
right/usb_descriptor_hid.c
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "usb_device_config.h"
|
||||
#include "usb.h"
|
||||
#include "usb_device.h"
|
||||
#include "include/usb/usb_device_class.h"
|
||||
#include "include/usb/usb_device_hid.h"
|
||||
#include "usb_descriptor_hid.h"
|
||||
#include "usb_descriptor_mouse_report.h"
|
||||
#include "usb_descriptor_generic_hid_report.h"
|
||||
|
||||
usb_status_t USB_DeviceGetHidDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_descriptor_struct_t *hidDescriptor)
|
||||
{
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceGetHidReportDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor)
|
||||
{
|
||||
if (USB_MOUSE_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||
hidReportDescriptor->buffer = UsbMouseReportDescriptor;
|
||||
hidReportDescriptor->length = USB_MOUSE_REPORT_DESCRIPTOR_LENGTH;
|
||||
} else if (USB_KEYBOARD_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||
hidReportDescriptor->buffer = UsbKeyboardReportDescriptor;
|
||||
hidReportDescriptor->length = USB_KEYBOARD_REPORT_DESCRIPTOR_LENGTH;
|
||||
} else if (USB_GENERIC_HID_INTERFACE_INDEX == hidReportDescriptor->interfaceNumber) {
|
||||
hidReportDescriptor->buffer = UsbGenericHidReportDescriptor;
|
||||
hidReportDescriptor->length = USB_GENERIC_HID_REPORT_DESCRIPTOR_LENGTH;
|
||||
} else {
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
return kStatus_USB_Success;
|
||||
}
|
||||
|
||||
usb_status_t USB_DeviceGetHidPhysicalDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_physical_descriptor_struct_t *hidPhysicalDescriptor)
|
||||
{
|
||||
return kStatus_USB_InvalidRequest;
|
||||
}
|
||||
21
right/usb_descriptor_hid.h
Normal file
21
right/usb_descriptor_hid.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef __USB_DESCRIPTOR_HID_H__
|
||||
#define __USB_DESCRIPTOR_HID_H__
|
||||
|
||||
// Includes:
|
||||
|
||||
#include "usb_interface_keyboard.h"
|
||||
#include "usb_interface_mouse.h"
|
||||
#include "usb_interface_generic_hid.h"
|
||||
|
||||
// Functions:
|
||||
|
||||
extern usb_status_t USB_DeviceGetHidDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_descriptor_struct_t *hidDescriptor);
|
||||
|
||||
extern usb_status_t USB_DeviceGetHidReportDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_report_descriptor_struct_t *hidReportDescriptor);
|
||||
|
||||
extern usb_status_t USB_DeviceGetHidPhysicalDescriptor(
|
||||
usb_device_handle handle, usb_device_get_hid_physical_descriptor_struct_t *hidPhysicalDescriptor);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user