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
35 #include "../../USB.h"
39 /* Enable C linkage for C++ Compilers: */
40 #if defined(__cplusplus)
45 /** HID Class Specific Request to get the current HID report from the device. */
46 #define REQ_GetReport 0x01
48 /** HID Class Specific Request to get the current device idle count. */
49 #define REQ_GetIdle 0x02
51 /** HID Class Specific Request to set the current HID report to the device. */
52 #define REQ_SetReport 0x09
54 /** HID Class Specific Request to set the device's idle count. */
55 #define REQ_SetIdle 0x0A
57 /** HID Class Specific Request to get the current HID report protocol mode. */
58 #define REQ_GetProtocol 0x03
60 /** HID Class Specific Request to set the current HID report protocol mode. */
61 #define REQ_SetProtocol 0x0B
63 /** Descriptor header type value, to indicate a HID class HID descriptor. */
64 #define DTYPE_HID 0x21
66 /** Descriptor header type value, to indicate a HID class HID report descriptor. */
67 #define DTYPE_Report 0x22
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.
75 USB_Descriptor_Header_t Header
;
80 uint8_t TotalReportDescriptors
;
82 uint8_t HIDReportType
;
83 uint16_t HIDReportLength
;
84 } USB_Descriptor_HID_t
;
86 /** Type define for the data type used to store HID report descriptor elements. */
87 typedef uint8_t USB_Descriptor_HIDReport_Datatype_t
;
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.
96 uint8_t InterfaceNumber
; /**< Interface number of the HID interface within the device */
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 */
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 */
104 uint8_t ReportINBufferSize
;
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
;
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
);
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
);
119 /* Disable C linkage for C++ Compilers: */
120 #if defined(__cplusplus)