1 /*! 2 \file usb_hid.h 3 \brief definitions for the USB HID class 4 5 \version 2020-08-04, V1.1.0, firmware for GD32VF103 6 */ 7 8 /* 9 Copyright (c) 2020, GigaDevice Semiconductor Inc. 10 11 Redistribution and use in source and binary forms, with or without modification, 12 are permitted provided that the following conditions are met: 13 14 1. Redistributions of source code must retain the above copyright notice, this 15 list of conditions and the following disclaimer. 16 2. Redistributions in binary form must reproduce the above copyright notice, 17 this list of conditions and the following disclaimer in the documentation 18 and/or other materials provided with the distribution. 19 3. Neither the name of the copyright holder nor the names of its contributors 20 may be used to endorse or promote products derived from this software without 21 specific prior written permission. 22 23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 25 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 29 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 30 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 32 OF SUCH DAMAGE. 33 */ 34 35 #ifndef __USB_HID_H 36 #define __USB_HID_H 37 38 #include "usb_ch9_std.h" 39 40 #define USB_HID_CLASS 0x03U 41 42 #define USB_DESCTYPE_HID 0x21U 43 #define USB_DESCTYPE_REPORT 0x22U 44 45 /* HID subclass code */ 46 #define USB_HID_SUBCLASS_BOOT_ITF 0x01U 47 48 /* HID protocol codes */ 49 #define USB_HID_PROTOCOL_KEYBOARD 0x01U 50 #define USB_HID_PROTOCOL_MOUSE 0x02U 51 52 #define GET_REPORT 0x01U 53 #define GET_IDLE 0x02U 54 #define GET_PROTOCOL 0x03U 55 #define SET_REPORT 0x09U 56 #define SET_IDLE 0x0AU 57 #define SET_PROTOCOL 0x0BU 58 59 #pragma pack(1) 60 61 typedef struct 62 { 63 usb_desc_header header; /*!< regular descriptor header containing the descriptor's type and length */ 64 65 uint16_t bcdHID; /*!< BCD encoded version that the HID descriptor and device complies to */ 66 uint8_t bCountryCode; /*!< country code of the localized device, or zero if universal */ 67 uint8_t bNumDescriptors; /*!< total number of HID report descriptors for the interface */ 68 uint8_t bDescriptorType; /*!< type of HID report */ 69 uint16_t wDescriptorLength; /*!< length of the associated HID report descriptor, in bytes */ 70 } usb_desc_hid; 71 72 #pragma pack() 73 74 typedef struct 75 { 76 usb_desc_config config; 77 usb_desc_itf hid_itf; 78 usb_desc_hid hid_vendor; 79 usb_desc_ep hid_epin; 80 usb_desc_ep hid_epout; 81 }usb_hid_desc_config_set; 82 83 #endif /* __USB_HID_H */ 84