Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
在你之后
rt-thread
提交
e365ff54
R
rt-thread
项目概览
在你之后
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e365ff54
编写于
11月 16, 2017
作者:
lymzzyh
提交者:
Bernard Xiong
11月 16, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Components][Drivers][USB][HID]Update to common hid
上级
40d0ff99
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
588 addition
and
186 deletion
+588
-186
components/drivers/KConfig
components/drivers/KConfig
+75
-23
components/drivers/include/drivers/usb_common.h
components/drivers/include/drivers/usb_common.h
+32
-0
components/drivers/usb/usbdevice/class/hid.c
components/drivers/usb/usbdevice/class/hid.c
+277
-161
components/drivers/usb/usbdevice/class/hid.h
components/drivers/usb/usbdevice/class/hid.h
+204
-2
未找到文件。
components/drivers/KConfig
浏览文件 @
e365ff54
...
...
@@ -97,30 +97,82 @@ config RT_USING_WDT
bool "Using Watch Dog device drivers"
default n
config RT_USING_USB_HOST
bool "Using USB host"
default n
if RT_USING_USB_HOST
config RT_USBH_ADK
bool "Enable connected with Android by ADK USB"
default n
endif
config RT_USING_USB_DEVICE
bool "Using USB device"
default n
menu "Using USB"
config RT_USING_USB_HOST
bool "Using USB host"
default n
if RT_USING_USB_DEVICE
config RT_USB_DEVICE_CDC
bool "Enable to use device as CDC device"
default n
if RT_USING_USB_HOST
config RT_USBH_ADK
bool "Enable connected with Android by ADK USB"
default n
endif
config RT_USING_USB_DEVICE
bool "Using USB device"
default n
config RT_USB_DEVICE_MSTORAGE
bool "Enable to use device as Mass Storage device"
default n
config RT_USB_DEVICE_HID
bool "Enable to use device as HID device"
default n
endif
if RT_USING_USB_DEVICE
config RT_USB_DEVICE_COMPOSITE
bool "Enable composite device"
default n
choice
prompt "Device type"
default _RT_USB_DEVICE_CDC
depends on !RT_USB_DEVICE_COMPOSITE
config _RT_USB_DEVICE_CDC
bool "Enable to use device as CDC device"
select RT_USB_DEVICE_CDC
config _RT_USB_DEVICE_MSTORAGE
bool "Enable to use device as Mass Storage device"
select RT_USB_DEVICE_MSTORAGE
config _RT_USB_DEVICE_HID
bool "Enable to use device as HID device"
select RT_USB_DEVICE_HID
endchoice
if RT_USB_DEVICE_COMPOSITE
config RT_USB_DEVICE_CDC
bool "Enable to use device as CDC device"
default y
config RT_USB_DEVICE_MSTORAGE
bool "Enable to use device as Mass Storage device"
default n
config RT_USB_DEVICE_HID
bool "Enable to use device as HID device"
default n
endif
if RT_USB_DEVICE_HID
config RT_USB_DEVICE_HID_KEYBOARD
bool "Use to HID device as Keyboard"
default n
if RT_USB_DEVICE_HID_KEYBOARD
config RT_USB_DEVICE_HID_KEYBOARD_NUMBER
int "Number of Keyboard(max 3)"
default 1
range 1 3
endif
config RT_USB_DEVICE_HID_MOUSE
bool "Use to HID device as Mouse"
default n
config RT_USB_DEVICE_HID_GENERAL
bool "Use to HID device as General HID device"
default y
if RT_USB_DEVICE_HID_GENERAL
config RT_USB_DEVICE_HID_GENERAL_OUT_REPORT_LENGTH
int "General HID device out report length"
default 63
range 0 63
config RT_USB_DEVICE_HID_GENERAL_IN_REPORT_LENGTH
int "General HID device in report length"
default 63
range 0 63
endif
config RT_USB_DEVICE_HID_MEDIA
bool "Use to HID device as media keyboard"
default y
endif
endif
endmenu
endmenu
components/drivers/include/drivers/usb_common.h
浏览文件 @
e365ff54
...
...
@@ -218,6 +218,27 @@ extern "C" {
#define USB_EP_DESC_NUM(addr) (addr & USB_EP_DESC_NUM_MASK)
#define USB_EP_DIR(addr) ((addr & USB_DIR_MASK)>>7)
#ifdef RT_USB_DEVICE_HID
#ifdef RT_USB_DEVICE_HID_KEYBOARD
#define HID_REPORT_ID_KEYBOARD1 1
#if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>1
#define HID_REPORT_ID_KEYBOARD2 2
#if RT_USB_DEVICE_HID_KEYBOARD_NUMBER>2
#define HID_REPORT_ID_KEYBOARD3 3
#endif
#endif
#endif
#ifdef RT_USB_DEVICE_HID_MEDIA
#define HID_REPORT_ID_MEDIA 4
#endif
#ifdef RT_USB_DEVICE_HID_GENERAL
#define HID_REPORT_ID_GENERAL 5
#endif
#ifdef RT_USB_DEVICE_HID_MOUSE
#define HID_REPORT_ID_MOUSE 6
#endif
#endif
#define uswap_32(x) \
((((x) & 0xff000000) >> 24) | \
(((x) & 0x00ff0000) >> 8) | \
...
...
@@ -372,6 +393,8 @@ struct usb_qualifier_descriptor
#ifndef HID_SUB_DESCRIPTOR_MAX
#define HID_SUB_DESCRIPTOR_MAX 1
#endif
#ifdef RT_USB_DEVICE_HID
struct
uhid_descriptor
{
rt_uint8_t
bLength
;
...
...
@@ -387,6 +410,15 @@ struct uhid_descriptor
};
typedef
struct
uhid_descriptor
*
uhid_desc_t
;
struct
hid_report
{
rt_uint8_t
report_id
;
rt_uint8_t
report
[
63
];
rt_uint8_t
size
;
};
typedef
struct
hid_report
*
hid_report_t
;
extern
void
HID_Report_Received
(
hid_report_t
report
);
#endif
struct
urequest
{
rt_uint8_t
request_type
;
...
...
components/drivers/usb/usbdevice/class/hid.c
浏览文件 @
e365ff54
此差异已折叠。
点击以展开。
components/drivers/usb/usbdevice/class/hid.h
浏览文件 @
e365ff54
...
...
@@ -4,7 +4,8 @@
*
* Change Logs:
* Date Author Notes
* 2017313 Urey the first version
* 2017-03-13 Urey the first version
* 2017-11-16 ZYH Update to common hid
*/
#ifndef _USBDEVICE_CLASS_HID_H_
#define _USBDEVICE_CLASS_HID_H_
...
...
@@ -32,9 +33,210 @@ extern "C" {
#define USB_HID_REQ_SET_IDLE 0x0a
#define USB_HID_REQ_SET_PROTOCOL 0x0b
#define MAX_REPORT_SIZE
8
#define MAX_REPORT_SIZE
64
#define HID_RX_BUFSIZE 64
/* HID Report Types */
#define HID_REPORT_INPUT 0x01
#define HID_REPORT_OUTPUT 0x02
#define HID_REPORT_FEATURE 0x03
/* Usage Pages */
#define USAGEPAGE_UNDEFINED 0x00
#define USAGEPAGE_GENERIC 0x01
#define USAGEPAGE_SIMULATION 0x02
#define USAGEPAGE_VR 0x03
#define USAGEPAGE_SPORT 0x04
#define USAGEPAGE_GAME 0x05
#define USAGEPAGE_DEV_CONTROLS 0x06
#define USAGEPAGE_KEYBOARD 0x07
#define USAGEPAGE_LED 0x08
#define USAGEPAGE_BUTTON 0x09
#define USAGEPAGE_ORDINAL 0x0A
#define USAGEPAGE_TELEPHONY 0x0B
#define USAGEPAGE_CONSUMER 0x0C
#define USAGEPAGE_DIGITIZER 0x0D
#define USAGEPAGE_PIDPAGE 0x0F
#define USAGEPAGE_UNICODE 0x10
#define USAGEPAGE_ALPHANUMERIC 0x14
#define USAGEPAGE_BARCODESCANNER 0x8C
/* Generic Desktop Page (0x01) */
#define USAGE_GENERIC_POINTER 0x01
#define USAGE_GENERIC_MOUSE 0x02
#define USAGE_GENERIC_JOYSTICK 0x04
#define USAGE_GENERIC_GAMEPAD 0x05
#define USAGE_GENERIC_KEYBOARD 0x06
#define USAGE_GENERIC_KEYPAD 0x07
#define USAGE_GENERIC_X 0x30
#define USAGE_GENERIC_Y 0x31
#define USAGE_GENERIC_Z 0x32
#define USAGE_GENERIC_RX 0x33
#define USAGE_GENERIC_RY 0x34
#define USAGE_GENERIC_RZ 0x35
#define USAGE_GENERIC_SLIDER 0x36
#define USAGE_GENERIC_DIAL 0x37
#define USAGE_GENERIC_WHEEL 0x38
#define USAGE_GENERIC_HATSWITCH 0x39
#define USAGE_GENERIC_COUNTED_BUFFER 0x3A
#define USAGE_GENERIC_BYTE_COUNT 0x3B
#define USAGE_GENERIC_MOTION_WAKEUP 0x3C
#define USAGE_GENERIC_VX 0x40
#define USAGE_GENERIC_VY 0x41
#define USAGE_GENERIC_VZ 0x42
#define USAGE_GENERIC_VBRX 0x43
#define USAGE_GENERIC_VBRY 0x44
#define USAGE_GENERIC_VBRZ 0x45
#define USAGE_GENERIC_VNO 0x46
#define USAGE_GENERIC_SYSTEM_CTL 0x80
#define USAGE_GENERIC_SYSCTL_POWER 0x81
#define USAGE_GENERIC_SYSCTL_SLEEP 0x82
#define USAGE_GENERIC_SYSCTL_WAKE 0x83
#define USAGE_GENERIC_SYSCTL_CONTEXT_MENU 0x84
#define USAGE_GENERIC_SYSCTL_MAIN_MENU 0x85
#define USAGE_GENERIC_SYSCTL_APP_MENU 0x86
#define USAGE_GENERIC_SYSCTL_HELP_MENU 0x87
#define USAGE_GENERIC_SYSCTL_MENU_EXIT 0x88
#define USAGE_GENERIC_SYSCTL_MENU_SELECT 0x89
#define USAGE_GENERIC_SYSCTL_MENU_RIGHT 0x8A
#define USAGE_GENERIC_SYSCTL_MENU_LEFT 0x8B
#define USAGE_GENERIC_SYSCTL_MENU_UP 0x8C
#define USAGE_GENERIC_SYSCTL_MENU_DOWN 0x8D
/* Simulation Controls Page(0x02) */
#define USAGE_SIMCTRL_THROTTLE 0xBB
/* HID Report Items */
/* Main Items */
#define HID_Input(x) 0x81,x
#define HID_Output(x) 0x91,x
#define HID_Feature(x) 0xB1,x
#define HID_Collection(x) 0xA1,x
#define HID_EndCollection() 0xC0
/* Local Items */
#define HID_Usage(x) 0x09,x
#define HID_UsageMin(x) 0x19,x
#define HID_UsageMax(x) 0x29,x
/* Global Items */
#define HID_UsagePage(x) 0x05,x
#define HID_UsagePageVendor(x) 0x06,x,0xFF
#define HID_LogicalMin(x) 0x15,x
#define HID_LogicalMinS(x) 0x16,(x&0xFF),((x>>8)&0xFF)
#define HID_LogicalMinL(x) 0x17,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_LogicalMax(x) 0x25,x
#define HID_LogicalMaxS(x) 0x26,(x&0xFF),((x>>8)&0xFF)
#define HID_LogicalMaxL(x) 0x27,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_PhysicalMin(x) 0x35,x
#define HID_PhysicalMinS(x) 0x36,(x&0xFF),((x>>8)&0xFF)
#define HID_PhysicalMinL(x) 0x37,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_PhysicalMax(x) 0x45,x
#define HID_PhysicalMaxS(x) 0x46,(x&0xFF),((x>>8)&0xFF)
#define HID_PhysicalMaxL(x) 0x47,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_UnitExponent(x) 0x55,x
#define HID_Unit(x) 0x65,x
#define HID_UnitS(x) 0x66,(x&0xFF),((x>>8)&0xFF)
#define HID_UnitL(x) 0x67,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_ReportSize(x) 0x75,x
#define HID_ReportSizeS(x) 0x76,(x&0xFF),((x>>8)&0xFF))
#define HID_ReportSizeL(x) 0x77,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_ReportID(x) 0x85,x
#define HID_ReportCount(x) 0x95,x
#define HID_ReportCountS(x) 0x96,(x&0xFF),((x>>8)&0xFF)
#define HID_ReportCountL(x) 0x97,(x&0xFF),((x>>8)&0xFF),((x>>16)&0xFF),((x>>24)&0xFF)
#define HID_Push() 0xA4
#define HID_Pop() 0xB4
/* Input, Output, Feature Data */
#define HID_DATA (0<<0)
#define HID_CONST (1<<0)
#define HID_ARRAY (0<<1)
#define HID_VAR (1<<1)
#define HID_ABS (0<<2)
#define HID_REL (1<<2)
#define HID_NOWRAP (0<<3)
#define HID_WRAP (1<<3)
#define HID_LINEAR (0<<4)
#define HID_NONLINEAR (1<<4)
#define HID_PREFERREDSTATE (0<<5)
#define HID_NOPREFERRED (1<<5)
#define HID_NONULLPOSITION (0<<6)
#define HID_NULLSTATE (1<<6)
#define HID_NONVOLATILE (0<<7)
#define HID_VOLATILE (1<<7)
/* Collection Data */
#define HID_PHYSICAL 0x00
#define HID_APPLICATION 0x01
#define HID_LOGICAL 0x02
#define HID_REPORT 0x03
#define HID_NAMEDARRAY 0x04
#define HID_USAGESWITCH 0x05
#define HID_USAGEMODIFIER 0x06
//HID_MBED_DEFINE
#define HID_VERSION_1_11 (0x0111)
/* HID Class */
#define HID_CLASS (3)
#define HID_SUBCLASS_NONE (0)
#define HID_SUBCLASS_BOOT (1)
#define HID_PROTOCOL_NONE (0)
#define HID_PROTOCOL_KEYBOARD (1)
#define HID_PROTOCOL_MOUSE (2)
/* Descriptors */
#define HID_DESCRIPTOR (33)
#define HID_DESCRIPTOR_LENGTH (0x09)
#define REPORT_DESCRIPTOR (34)
/* Class requests */
#define GET_REPORT (0x1)
#define GET_IDLE (0x2)
#define SET_REPORT (0x9)
#define SET_IDLE (0xa)
/* HID Class Report Descriptor */
/* Short items: size is 0, 1, 2 or 3 specifying 0, 1, 2 or 4 (four) bytes */
/* of data as per HID Class standard */
/* Main items */
#define INPUT(size) (0x80 | size)
#define OUTPUT(size) (0x90 | size)
#define FEATURE(size) (0xb0 | size)
#define COLLECTION(size) (0xa0 | size)
#define END_COLLECTION(size) (0xc0 | size)
/* Global items */
#define USAGE_PAGE(size) (0x04 | size)
#define LOGICAL_MINIMUM(size) (0x14 | size)
#define LOGICAL_MAXIMUM(size) (0x24 | size)
#define PHYSICAL_MINIMUM(size) (0x34 | size)
#define PHYSICAL_MAXIMUM(size) (0x44 | size)
#define UNIT_EXPONENT(size) (0x54 | size)
#define UNIT(size) (0x64 | size)
#define REPORT_SIZE(size) (0x74 | size)
#define REPORT_ID(size) (0x84 | size)
#define REPORT_COUNT(size) (0x94 | size)
#define PUSH(size) (0xa4 | size)
#define POP(size) (0xb4 | size)
/* Local items */
#define USAGE(size) (0x08 | size)
#define USAGE_MINIMUM(size) (0x18 | size)
#define USAGE_MAXIMUM(size) (0x28 | size)
#define DESIGNATOR_INDEX(size) (0x38 | size)
#define DESIGNATOR_MINIMUM(size) (0x48 | size)
#define DESIGNATOR_MAXIMUM(size) (0x58 | size)
#define STRING_INDEX(size) (0x78 | size)
#define STRING_MINIMUM(size) (0x88 | size)
#define STRING_MAXIMUM(size) (0x98 | size)
#define DELIMITER(size) (0xa8 | size)
#define LSB(n) ((n)&0xff)
#define MSB(n) (((n)&0xff00)>>8)
struct
uhid_comm_descriptor
{
#ifdef RT_USB_DEVICE_COMPOSITE
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录