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