Fixed EVENT_USB_CDC_ControLineStateChanged() event not taking the CDC interface struc...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Device / 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_USBDeviceClassDrivers
32 * @defgroup Group_USBClassHIDDevice HID Device Class Driver - LUFA/Drivers/Class/Device/HID.h
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/Device/HID.c
37 *
38 * \section Module Description
39 * Functions, macros, variables, enums and types related to the management of USB HID Class interfaces
40 * within a USB device.
41 *
42 * @{
43 */
44
45 #ifndef _HID_CLASS_H_
46 #define _HID_CLASS_H_
47
48 /* Includes: */
49 #include "../../USB.h"
50
51 #include <string.h>
52
53 /* Enable C linkage for C++ Compilers: */
54 #if defined(__cplusplus)
55 extern "C" {
56 #endif
57
58 /* Macros: */
59 /** HID Class Specific Request to get the current HID report from the device. */
60 #define REQ_GetReport 0x01
61
62 /** HID Class Specific Request to get the current device idle count. */
63 #define REQ_GetIdle 0x02
64
65 /** HID Class Specific Request to set the current HID report to the device. */
66 #define REQ_SetReport 0x09
67
68 /** HID Class Specific Request to set the device's idle count. */
69 #define REQ_SetIdle 0x0A
70
71 /** HID Class Specific Request to get the current HID report protocol mode. */
72 #define REQ_GetProtocol 0x03
73
74 /** HID Class Specific Request to set the current HID report protocol mode. */
75 #define REQ_SetProtocol 0x0B
76
77 /** Descriptor header type value, to indicate a HID class HID descriptor. */
78 #define DTYPE_HID 0x21
79
80 /** Descriptor header type value, to indicate a HID class HID report descriptor. */
81 #define DTYPE_Report 0x22
82
83 /* Type Defines: */
84 /** Type define for the HID class specific HID descriptor, to describe the HID device's specifications. Refer to the HID
85 * specification for details on the structure elements.
86 */
87 typedef struct
88 {
89 USB_Descriptor_Header_t Header;
90
91 uint16_t HIDSpec;
92 uint8_t CountryCode;
93
94 uint8_t TotalReportDescriptors;
95
96 uint8_t HIDReportType;
97 uint16_t HIDReportLength;
98 } USB_Descriptor_HID_t;
99
100 /** Type define for the data type used to store HID report descriptor elements. */
101 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;
102
103 /** Class state structure. An instance of this structure should be made for each HID interface
104 * within the user application, and passed to each of the HID class driver functions as the
105 * HIDInterfaceInfo parameter. The contents of this structure should be set to their correct
106 * values when used, or ommitted to force the library to use default values.
107 */
108 typedef struct
109 {
110 uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device */
111
112 uint8_t ReportINEndpointNumber; /**< Endpoint number of the HID interface's IN report endpoint */
113 uint16_t ReportINEndpointSize; /**< Size in bytes of the HID interface's IN report endpoint */
114
115 uint8_t ReportOUTEndpointNumber; /**< Endpoint number of the HID interface's OUT report endpoint, if used */
116 uint16_t ReportOUTEndpointSize; /**< Size in bytes of the HID interface's OUT report endpoint, if used */
117
118 uint8_t ReportINBufferSize;
119
120 bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode */
121 uint16_t IdleCount; /**< Report idle period, in ms, set by the host */
122 uint16_t IdleMSRemaining; /**< Total number of ms remaining before the idle period elapses */
123 } USB_ClassInfo_HID_t;
124
125 /* Function Prototypes: */
126 bool USB_HID_ConfigureEndpoints(USB_ClassInfo_HID_t* HIDInterfaceInfo);
127 void USB_HID_ProcessControlPacket(USB_ClassInfo_HID_t* HIDInterfaceInfo);
128 void USB_HID_USBTask(USB_ClassInfo_HID_t* HIDInterfaceInfo);
129
130 uint16_t CALLBACK_USB_HID_CreateNextHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData);
131 void CALLBACK_USB_HID_ProcessReceivedHIDReport(USB_ClassInfo_HID_t* HIDInterfaceInfo, void* ReportData, uint16_t ReportSize);
132
133 /* Disable C linkage for C++ Compilers: */
134 #if defined(__cplusplus)
135 }
136 #endif
137
138 #endif
139
140 /** @} */