LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
HIDParser.h
Go to the documentation of this file.
1
/*
2
* @brief USB Human Interface Device (HID) Class report descriptor parser
3
*
4
* @note
5
* Copyright(C) NXP Semiconductors, 2012
6
* Copyright(C) Dean Camera, 2011, 2012
7
* All rights reserved.
8
*
9
* @par
10
* Software that is described herein is for illustrative purposes only
11
* which provides customers with programming information regarding the
12
* LPC products. This software is supplied "AS IS" without any warranties of
13
* any kind, and NXP Semiconductors and its licensor disclaim any and
14
* all warranties, express or implied, including all implied warranties of
15
* merchantability, fitness for a particular purpose and non-infringement of
16
* intellectual property rights. NXP Semiconductors assumes no responsibility
17
* or liability for the use of the software, conveys no license or rights under any
18
* patent, copyright, mask work right, or any other intellectual property rights in
19
* or to any products. NXP Semiconductors reserves the right to make changes
20
* in the software without notification. NXP Semiconductors also makes no
21
* representation or warranty that such application will be suitable for the
22
* specified use without further testing or modification.
23
*
24
* @par
25
* Permission to use, copy, modify, and distribute this software and its
26
* documentation is hereby granted, under NXP Semiconductors' and its
27
* licensor's relevant copyrights in the software, without fee, provided that it
28
* is used in conjunction with NXP Semiconductors microcontrollers. This
29
* copyright, permission, and disclaimer notice must appear in all copies of
30
* this code.
31
*/
32
60
#ifndef __HIDPARSER_H__
61
#define __HIDPARSER_H__
62
63
/* Includes: */
64
#include "../../../../Common/Common.h"
65
66
#include "
HIDReportData.h
"
67
#include "
HIDClassCommon.h
"
68
69
/* Enable C linkage for C++ Compilers: */
70
#if defined(__cplusplus)
71
extern
"C"
{
72
#endif
73
74
/* Macros: */
75
#if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__)
76
82
#define HID_STATETABLE_STACK_DEPTH 2
83
#endif
84
85
#if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__)
86
93
#define HID_USAGE_STACK_DEPTH 8
94
#endif
95
96
#if !defined(HID_MAX_COLLECTIONS) || defined(__DOXYGEN__)
97
103
#define HID_MAX_COLLECTIONS 10
104
#endif
105
106
#if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__)
107
113
#define HID_MAX_REPORTITEMS 20
114
#endif
115
116
#if !defined(HID_MAX_REPORT_IDS) || defined(__DOXYGEN__)
117
124
#define HID_MAX_REPORT_IDS 10
125
#endif
126
136
#define HID_ALIGN_DATA(ReportItem, Type) ((Type)(ReportItem->Value << ((8 * sizeof(Type)) - ReportItem->Attributes.BitSize)))
137
138
/* Public Interface - May be used in end-application: */
139
/* Enums: */
141
enum
HID_Parse_ErrorCodes_t
142
{
143
HID_PARSE_Successful
= 0,
144
HID_PARSE_HIDStackOverflow
= 1,
145
HID_PARSE_HIDStackUnderflow
= 2,
146
HID_PARSE_InsufficientReportItems
= 3,
147
HID_PARSE_UnexpectedEndCollection
= 4,
148
HID_PARSE_InsufficientCollectionPaths
= 5,
149
HID_PARSE_UsageListOverflow
= 6,
150
HID_PARSE_InsufficientReportIDItems
= 7,
151
HID_PARSE_NoUnfilteredReportItems
= 8,
152
};
153
154
/* Type Defines: */
159
typedef
struct
160
{
161
uint32_t
Minimum
;
162
uint32_t
Maximum
;
163
}
HID_MinMax_t
;
164
169
typedef
struct
170
{
171
uint32_t
Type
;
172
uint8_t
Exponent
;
173
}
HID_Unit_t
;
174
179
typedef
struct
180
{
181
uint16_t
Page
;
182
uint16_t
Usage
;
183
}
HID_Usage_t
;
184
190
typedef
struct
HID_CollectionPath
191
{
192
uint8_t
Type
;
193
HID_Usage_t
Usage
;
194
struct
HID_CollectionPath*
Parent
;
195
}
HID_CollectionPath_t
;
196
201
typedef
struct
202
{
203
uint8_t
BitSize
;
205
HID_Usage_t
Usage
;
206
HID_Unit_t
Unit
;
207
HID_MinMax_t
Logical
;
208
HID_MinMax_t
Physical
;
209
}
HID_ReportItem_Attributes_t
;
210
215
typedef
struct
216
{
217
uint16_t
BitOffset
;
218
uint8_t
ItemType
;
219
uint16_t
ItemFlags
;
220
uint8_t
ReportID
;
221
HID_CollectionPath_t
*
CollectionPath
;
223
HID_ReportItem_Attributes_t
Attributes
;
225
uint32_t
Value;
228
uint32_t
PreviousValue
;
229
}
HID_ReportItem_t
;
230
235
typedef
struct
236
{
237
uint8_t
ReportID
;
238
uint16_t ReportSizeBits[3];
241
}
HID_ReportSizeInfo_t
;
242
247
typedef
struct
248
{
249
uint8_t
TotalReportItems
;
250
HID_ReportItem_t
ReportItems[
HID_MAX_REPORTITEMS
];
253
HID_CollectionPath_t
CollectionPaths[
HID_MAX_COLLECTIONS
];
256
uint8_t
TotalDeviceReports
;
257
HID_ReportSizeInfo_t
ReportIDSizes[
HID_MAX_REPORT_IDS
];
258
uint16_t
LargestReportSizeBits
;
259
bool
UsingReportIDs;
262
}
HID_ReportInfo_t
;
263
264
/* Function Prototypes: */
274
uint8_t
USB_ProcessHIDReport
(
const
uint8_t* ReportData,
275
uint16_t ReportSize,
276
HID_ReportInfo_t
*
const
ParserData)
ATTR_NON_NULL_PTR_ARG
(1)
ATTR_NON_NULL_PTR_ARG
(3);
277
291
bool
USB_GetHIDReportItemInfo
(const uint8_t* ReportData,
292
HID_ReportItem_t
* const ReportItem)
ATTR_NON_NULL_PTR_ARG
(1);
293
307
void
USB_SetHIDReportItemInfo
(uint8_t* ReportData,
308
HID_ReportItem_t
* const ReportItem) ATTR_NON_NULL_PTR_ARG(1);
309
319
uint16_t
USB_GetHIDReportSize
(
HID_ReportInfo_t
* const ParserData,
320
const uint8_t ReportID,
321
const uint8_t ReportType)
ATTR_CONST
ATTR_NON_NULL_PTR_ARG(1);
322
337
bool
CALLBACK_HIDParser_FilterHIDReportItem
(
HID_ReportItem_t
* const CurrentItem);
338
339
/* Private Interface - For use in library only: */
340
#if !defined(__DOXYGEN__)
341
/* Type Defines: */
342
typedef
struct
343
{
344
HID_ReportItem_Attributes_t
Attributes
;
345
uint8_t ReportCount;
346
uint8_t ReportID;
347
} HID_StateTable_t;
348
#endif
349
350
/* Disable C linkage for C++ Compilers: */
351
#if defined(__cplusplus)
352
}
353
#endif
354
355
#endif
356
software
LPCUSBLib
Drivers
USB
Class
Common
HIDParser.h
Generated on Fri Nov 16 2012 13:36:44 for LPCOpen Platform by
1.8.2