LPCOpen Platform
LPCOpen Platform for NXP LPC Microcontrollers
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
usbd_hiduser.h
Go to the documentation of this file.
1 /*
2  * @brief Definition of functions exported by ROM based HID function driver
3  *
4  * @note
5  * Copyright(C) NXP Semiconductors, 2012
6  * All rights reserved.
7  *
8  * @par
9  * Software that is described herein is for illustrative purposes only
10  * which provides customers with programming information regarding the
11  * LPC products. This software is supplied "AS IS" without any warranties of
12  * any kind, and NXP Semiconductors and its licensor disclaim any and
13  * all warranties, express or implied, including all implied warranties of
14  * merchantability, fitness for a particular purpose and non-infringement of
15  * intellectual property rights. NXP Semiconductors assumes no responsibility
16  * or liability for the use of the software, conveys no license or rights under any
17  * patent, copyright, mask work right, or any other intellectual property rights in
18  * or to any products. NXP Semiconductors reserves the right to make changes
19  * in the software without notification. NXP Semiconductors also makes no
20  * representation or warranty that such application will be suitable for the
21  * specified use without further testing or modification.
22  *
23  * @par
24  * Permission to use, copy, modify, and distribute this software and its
25  * documentation is hereby granted, under NXP Semiconductors' and its
26  * licensor's relevant copyrights in the software, without fee, provided that it
27  * is used in conjunction with NXP Semiconductors microcontrollers. This
28  * copyright, permission, and disclaimer notice must appear in all copies of
29  * this code.
30  */
31 
32 #ifndef __HIDUSER_H__
33 #define __HIDUSER_H__
34 
35 #include "usbd.h"
36 #include "usbd_hid.h"
37 #include "usbd_core.h"
38 
39 
66 typedef struct _HID_REPORT_T {
67  uint16_t len;
68  uint8_t idle_time;
76  uint8_t __pad;
77  uint8_t* desc;
79 
91 typedef struct USBD_HID_INIT_PARAM
92 {
93  /* memory allocation params */
94  uint32_t mem_base;
99  uint32_t mem_size;
102  /* HID paramas */
103  uint8_t max_reports;
106  uint8_t* intf_desc;
110  USB_HID_REPORT_T* report_data;
118  /* user defined functions */
119  /* required functions */
144  ErrorCode_t (*HID_GetReport)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
145 
169  ErrorCode_t (*HID_SetReport)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
170 
171  /* optional functions */
172 
203  ErrorCode_t (*HID_GetPhysDesc)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuf, uint16_t* length);
204 
228  ErrorCode_t (*HID_SetIdle)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t idleTime);
229 
251  ErrorCode_t (*HID_SetProtocol)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t protocol);
252 
272  ErrorCode_t (*HID_EpIn_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
292  ErrorCode_t (*HID_EpOut_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
293 
294  /* user overridable function */
315  ErrorCode_t (*HID_GetReportDesc)(USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuf, uint16_t* length);
335  ErrorCode_t (*HID_Ep0_Hdlr) (USBD_HANDLE_T hUsb, void* data, uint32_t event);
336 
338 
345 typedef struct USBD_HID_API
346 {
358  uint32_t (*GetMemSize)(USBD_HID_INIT_PARAM_T* param);
359 
382 
384 
385 /*-----------------------------------------------------------------------------
386  * Private functions & structures prototypes
387  *-----------------------------------------------------------------------------*/
390 typedef struct _HID_CTRL_T {
391  /* pointer to controller */
392  USB_CORE_CTRL_T* pUsbCtrl;
393  /* descriptor pointers */
394  uint8_t* hid_desc;
395  USB_HID_REPORT_T* report_data;
396 
397  uint8_t protocol;
398  uint8_t if_num; /* interface number */
399  uint8_t epin_adr; /* IN interrupt endpoint */
400  uint8_t epout_adr; /* OUT interrupt endpoint */
401 
402  /* user defined functions */
403  ErrorCode_t (*HID_GetReport)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t* length);
404  ErrorCode_t (*HID_SetReport)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuffer, uint16_t length);
405  ErrorCode_t (*HID_GetPhysDesc)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuf, uint16_t* length);
406  ErrorCode_t (*HID_SetIdle)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t idleTime);
407  ErrorCode_t (*HID_SetProtocol)( USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t protocol);
408 
409  /* virtual overridable functions */
410  ErrorCode_t (*HID_GetReportDesc)(USBD_HANDLE_T hHid, USB_SETUP_PACKET* pSetup, uint8_t** pBuf, uint16_t* length);
411 
412 }USB_HID_CTRL_T;
413 
414 
417 #endif /* __HIDUSER_H__ */