Remove USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token, split out standard descri...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Host / HID.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
20
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
28 this software.
29 */
30
31 /** \ingroup Group_USBClassHID
32 * @defgroup Group_USBClassHIDHost HID Class Host Mode Driver
33 *
34 * \section Sec_Dependencies Module Source Dependencies
35 * The following files must be built with any user project that uses this module:
36 * - LUFA/Drivers/USB/Class/Host/HID.c
37 *
38 * \section Module Description
39 * Host Mode USB Class driver framework interface, for the HID USB Class driver.
40 *
41 * @{
42 */
43
44 #ifndef __HID_CLASS_HOST_H__
45 #define __HID_CLASS_HOST_H__
46
47 /* Includes: */
48 #include "../../USB.h"
49 #include "../Common/HID.h"
50 #include "HIDParser.h"
51
52 /* Enable C linkage for C++ Compilers: */
53 #if defined(__cplusplus)
54 extern "C" {
55 #endif
56
57 /* Public Interface - May be used in end-application: */
58 /* Macros: */
59 /** Error code for some HID Host functions, indicating a logical (and not hardware) error */
60 #define MS_ERROR_UNSUPPORTED 0xC0
61
62 /* Type Defines: */
63 /** Class state structure. An instance of this structure should be made within the user application,
64 * and passed to each of the HID class driver functions as the HIDInterfaceInfo parameter. This
65 * stores each HID interface's configuration and state information.
66 */
67 typedef struct
68 {
69 const struct
70 {
71 uint8_t DataINPipeNumber; /**< Pipe number of the HID interface's IN data pipe */
72 uint8_t DataOUTPipeNumber; /**< Pipe number of the HID interface's OUT data pipe */
73
74 uint8_t HIDInterfaceProtocol; /**< HID interface protocol value to match against if a specific
75 * boot subclass protocol is required (e.g. keyboard, mouse), or
76 * leave as 0 to match against the first HID interface found
77 */
78 HID_ReportInfo_t* HIDParserData; /**< HID parser data to store the parsed HID report data, when boot protocol
79 * is not used */
80 } Config; /**< Config data for the USB class interface within the device. All elements in this section
81 * <b>must</b> be set or the interface will fail to enumerate and operate correctly.
82 */
83 struct
84 {
85 bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid
86 * after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the
87 * Configured state
88 */
89 uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device */
90
91 uint16_t DataINPipeSize; /**< Size in bytes of the HID interface's IN data pipe */
92 uint16_t DataOUTPipeSize; /**< Size in bytes of the HID interface's OUT data pipe */
93
94 bool SupportsBootSubClass; /**< Indicates if the current interface instance supports the HID Boot
95 * Protocol when enabled via \ref USB_HID_Host_SetProtocol()
96 */
97 uint16_t HIDReportSize; /**< Size in bytes of the HID report descriptor in the device */
98 } State; /**< State data for the USB class interface within the device. All elements in this section
99 * <b>may</b> be set to initial values, but may also be ignored to default to sane values when
100 * the interface is enumerated.
101 */
102 } USB_ClassInfo_HID_Host_t;
103
104 /* Enums: */
105 enum HIDHost_EnumerationFailure_ErrorCodes_t
106 {
107 HID_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully */
108 HID_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor */
109 HID_ENUMERROR_NoHIDInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor */
110 HID_ENUMERROR_NoHIDDescriptorFound = 3, /**< The HID descriptor was not found in the device's HID interface */
111 HID_ENUMERROR_EndpointsNotFound = 4, /**< Compatible HID endpoints were not found in the device's HID interface */
112 };
113
114 /* Function Prototypes: */
115 void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
116 uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, uint16_t ConfigDescriptorLength,
117 uint8_t* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1, 3);
118
119 bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
120
121 uint8_t USB_HID_Host_SetProtocol(USB_ClassInfo_HID_Host_t* HIDInterfaceInfo, bool UseReportProtocol) ATTR_NON_NULL_PTR_ARG(1);
122
123 /* Private Interface - For use in library only: */
124 #if !defined(__DOXYGEN__)
125 /* Macros: */
126 #define HID_INTERFACE_CLASS 0x03
127
128 #define HID_FOUND_DATAPIPE_IN (1 << 0)
129 #define HID_FOUND_DATAPIPE_OUT (1 << 1)
130
131 /* Function Prototypes: */
132 #if defined(INCLUDE_FROM_HID_CLASS_HOST_C)
133 static uint8_t DComp_HID_Host_NextHIDInterface(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
134 static uint8_t DComp_NextHID(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
135 static uint8_t DComp_HID_Host_NextHIDInterfaceEndpoint(void* CurrentDescriptor) ATTR_NON_NULL_PTR_ARG(1);
136 #endif
137 #endif
138
139 /* Disable C linkage for C++ Compilers: */
140 #if defined(__cplusplus)
141 }
142 #endif
143
144 #endif
145
146 /** @} */