📄 usb_desc.h
字号:
/* Copyright (c) 2006 Nordic Semiconductor. All Rights Reserved.
*
* The information contained herein is confidential property of Nordic Semiconductor. The use,
* copying, transfer or disclosure of such information is prohibited except by express written
* agreement with Nordic Semiconductor.
*/
/** @file
* Definition of the USB configuration descriptor type
*/
/** @{
* @ingroup nordic_usb
*/
#ifndef USB_DESC_H__
#define USB_DESC_H__
#include <stdint.h>
#include <hal_usb_desc.h>
#include <hal_usb_hid_desc.h>
#define USB_DESC_TEMPLATE
//------------------------------------------
// Vendor ID and Product ID definitions
//------------------------------------------
#define VID 0x1915
#define PID 0x000C
//---------------------------------------------
// HID Configuration Descriptor Type Definition
//---------------------------------------------
// From "USB Device Class Definition for Human Interface Devices (HID)".
// Section 7.1:
// "When a Get_Descriptor(Configuration) request is issued,
// it returns the Configuration descriptor, all Interface descriptors,
// all Endpoint descriptors, and the HID descriptor for each interface."
#define USB_STRING_DESC_COUNT 3
typedef struct {
hal_usb_conf_desc_t conf;
hal_usb_if_desc_t if0; // Mouse
hal_usb_hid_desc_t hid1;
hal_usb_ep_desc_t ep1in;
hal_usb_if_desc_t if1; // Keyboard
hal_usb_hid_desc_t hid2;
hal_usb_ep_desc_t ep2in;
#if 0
hal_usb_if_desc_t if2; // RC
hal_usb_hid_desc_t hid3;
hal_usb_ep_desc_t ep3in;
#endif
} usb_conf_desc_templ_t;
typedef struct {
volatile uint8_t* idx[USB_STRING_DESC_COUNT];
} usb_string_desc_templ_t;
extern code usb_string_desc_templ_t g_usb_string_desc;
extern code usb_conf_desc_templ_t g_usb_conf_desc;
extern code hal_usb_dev_desc_t g_usb_dev_desc;
typedef struct {
hal_usb_dev_desc_t* dev;
usb_conf_desc_templ_t* conf;
usb_string_desc_templ_t* string;
uint8_t string_zero[4];
} usb_descs_templ_t;
#define HID_REPORT_DESCRIPTOR_SIZE_MOUSE 52 // WHEEL ADDED
#define HID_REPORT_DESCRIPTOR_SIZE_KEYB 0x002D
#if 0
#define HID_REPORT_DESCRIPTOR_SIZE_RC 0x0058
#endif
#define USB_HID_REPORT_1_SIZE 52 // Mouse
#if 1
#define USB_HID_REPORT_2_SIZE 65 // Keyboard
#endif
extern code const uint8_t g_usb_hid_report_1[HID_REPORT_DESCRIPTOR_SIZE_MOUSE];
extern code const uint8_t g_usb_hid_report_2[HID_REPORT_DESCRIPTOR_SIZE_KEYB];
#if 0
extern code uint8_t g_usb_hid_report_3[HID_REPORT_DESCRIPTOR_SIZE_RC];
#endif
#endif /* _USB_DESC_H_ */
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -