3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
31 /** \ingroup Group_USBClassHID
32 * @defgroup Group_USBClassHIDHost HID Class Host Mode Driver
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
38 * \section Module Description
39 * Host Mode USB Class driver framework interface, for the HID USB Class driver.
44 #ifndef __HID_CLASS_HOST_H__
45 #define __HID_CLASS_HOST_H__
48 #include "../../USB.h"
49 #include "../Common/HID.h"
50 #include "HIDParser.h"
52 /* Enable C linkage for C++ Compilers: */
53 #if defined(__cplusplus)
57 /* Public Interface - May be used in end-application: */
59 /** Class state structure. An instance of this structure should be made within the user application,
60 * and passed to each of the HID class driver functions as the HIDInterfaceInfo parameter. This
61 * stores each HID interface's configuration and state information.
67 uint8_t DataINPipeNumber
; /**< Pipe number of the HID interface's IN data pipe */
68 uint8_t DataOUTPipeNumber
; /**< Pipe number of the HID interface's OUT data pipe */
70 bool MatchInterfaceProtocol
; /**< Indicates whether the driver should match the device's
71 * HID interface protocol's value to the \ref HIDInterfaceProtocol
72 * suppled (otherwise just accept all HID class devices)
74 uint8_t HIDInterfaceProtocol
; /**< HID interface protocol value to match against if the
75 * \ref MatchInterfaceProtocol is set to true (ignored otherwise)
77 } Config
; /**< Config data for the USB class interface within the device. All elements in this section
78 * <b>must</b> be set or the interface will fail to enumerate and operate correctly.
82 bool Active
; /**< Indicates if the current interface instance is connected to an attached device */
84 uint16_t DataINPipeSize
; /**< Size in bytes of the HID interface's IN data pipe */
85 uint16_t DataOUTPipeSize
; /**< Size in bytes of the HID interface's OUT data pipe */
86 } State
; /**< State data for the USB class interface within the device. All elements in this section
87 * <b>may</b> be set to initial values, but may also be ignored to default to sane values when
88 * the interface is enumerated.
90 } USB_ClassInfo_HID_Host_t
;
95 HID_ENUMERROR_NoError
= 0, /**< Configuration Descriptor was processed successfully */
96 HID_ENUMERROR_InvalidConfigDescriptor
= 1, /**< The device returned an invalid Configuration Descriptor */
97 HID_ENUMERROR_NoHIDInterfaceFound
= 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor */
98 HID_ENUMERROR_EndpointsNotFound
= 3, /**< Compatible HID endpoints were not found in the device's CDC interface */
99 } HIDHost_EnumerationFailure_ErrorCodes_t
;
101 /* Function Prototypes: */
102 void HID_Host_USBTask(USB_ClassInfo_HID_Host_t
* HIDInterfaceInfo
);
103 uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t
* HIDInterfaceInfo
, uint16_t ConfigDescriptorLength
,
104 uint8_t* DeviceConfigDescriptor
);
106 bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t
* HIDInterfaceInfo
);
108 /* Private Interface - For use in library only: */
109 #if !defined(__DOXYGEN__)
111 #define HID_INTERFACE_CLASS 0x03
113 #define HID_FOUND_DATAPIPE_IN (1 << 0)
114 #define HID_FOUND_DATAPIPE_OUT (1 << 1)
116 /* Function Prototypes: */
117 #if defined(INCLUDE_FROM_HID_CLASS_HOST_C)
118 static uint8_t DComp_HID_Host_NextHIDInterface(void* CurrentDescriptor
);
119 static uint8_t DComp_HID_Host_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor
);
123 /* Disable C linkage for C++ Compilers: */
124 #if defined(__cplusplus)