VSF Documented
vsf_usbd_HID_desc.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_USBD_HID_DESC_H__
19#define __VSF_USBD_HID_DESC_H__
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25/*============================ INCLUDES ======================================*/
26/*============================ MACROS ========================================*/
27
28#define USB_HID_SUBCLASS_NONE 0
29#define USB_HID_SUBCLASS_BOOT 1
30
31#define USB_HID_PROTOCOL_NONE 0
32#define USB_HID_PROTOCOL_KEYBOARD 1
33#define USB_HID_PROTOCOL_MOUSE 2
34
35#define USB_DT_HID_SIZE 9
36#define USB_DESC_HID(__IFS, __I_FUNC, __SUBCLASS, __PROTOCOL, \
37 __VERSION_BCD, __COUNTRY_CODE, __REPORT_DESC_LEN, \
38 __EP_IN, __EP_IN_SIZE, __EP_IN_INTERVAL, \
39 __EP_OUT, __EP_OUT_SIZE, __EP_OUT_INTERVAL) \
40 USB_DESC_IFS((__IFS), 0, 2, USB_CLASS_HID, (__SUBCLASS), (__PROTOCOL), (__I_FUNC))\
41 USB_DT_HID_SIZE, \
42 USB_DT_HID, \
43 USB_DESC_WORD(__VERSION_BCD), /* bcdHID: HID Class Specification release in BCD */\
44 (__COUNTRY_CODE), /* bCountryCode */ \
45 (1), /* bNumDescriptor: number of class descriptors */\
46 USB_DT_REPORT, /* bDescriptorType */ \
47 USB_DESC_WORD(__REPORT_DESC_LEN), /* wDescriptorLen */ \
48 USB_DESC_EP(USB_DIR_IN | (__EP_IN), USB_ENDPOINT_XFER_INT, __EP_IN_SIZE, __EP_IN_INTERVAL)\
49 USB_DESC_EP(USB_DIR_OUT | (__EP_OUT), USB_ENDPOINT_XFER_INT, __EP_OUT_SIZE, __EP_OUT_INTERVAL)
50#define USB_DESC_HID_LEN (USB_DESC_IFS_LEN + USB_DT_HID_SIZE + 2 * USB_DESC_EP_LEN)
51
52#define USB_DESC_HID_IAD(__IFS, __I_FUNC, __SUBCLASS, __PROTOCOL, __VERSION_BCD, __COUNTRY_CODE, __REPORT_DESC_LEN,\
53 __EP_IN, __EP_IN_SIZE, __EP_IN_INTERVAL, \
54 __EP_OUT, __EP_OUT_SIZE, __EP_OUT_INTERVAL) \
55 USB_DESC_IAD((__IFS), 1, USB_CLASS_HID, (__SUBCLASS), (__PROTOCOL), (__I_FUNC))\
56 USB_DESC_HID((__IFS), (__I_FUNC), (__SUBCLASS), (__PROTOCOL), (__VERSION_BCD), (__COUNTRY_CODE), (__REPORT_DESC_LEN),\
57 (__EP_IN), (__EP_IN_SIZE), (__EP_IN_INTERVAL), \
58 (__EP_OUT), (__EP_OUT_SIZE), (__EP_OUT_INTERVAL))
59#define USB_DESC_HID_IAD_LEN (USB_DESC_IAD_LEN + USB_DESC_HID_LEN)
60
61/*============================ MACROFIED FUNCTIONS ===========================*/
62/*============================ TYPES =========================================*/
63/*============================ GLOBAL VARIABLES ==============================*/
64/*============================ PROTOTYPES ====================================*/
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif // __VSF_USBD_HID_DESC_H__