NUC472_NUC442_BSP V3.03.005
The Board Support Package for NUC472/NUC442
usbh_hid.h
Go to the documentation of this file.
1#ifndef __INCLUDED_HID_H__
2#define __INCLUDED_HID_H__
3
4#include "usbh_core.h"
5
16// #define HID_DEBUG
17
18/*
19 * Debug message
20 */
21#ifdef HID_DEBUG
22#define HID_DBGMSG printf
23#else
24#define HID_DBGMSG(...)
25#endif
26
28
29
35#define CONFIG_HID_MAX_DEV 3
36#define HID_MAX_BUFFER_SIZE 64
37#define HID_CLIENT_SIZE 64
39/*
40 * Constants
41 */
42#define HID_RET_OK 0
43#define HID_RET_DEV_NOT_FOUND -9
44#define HID_RET_IO_ERR -11
45#define HID_RET_INVALID_PARAMETER -13
46#define HID_RET_OUT_OF_MEMORY -15
47#define HID_RET_NOT_SUPPORTED -17
50#define HID_REPORT_GET 0x01
51#define HID_GET_IDLE 0x02
52#define HID_GET_PROTOCOL 0x03
53#define HID_REPORT_SET 0x09
54#define HID_SET_IDLE 0x0A
55#define HID_SET_PROTOCOL 0x0B
58/*
59 * Report type
60 */
61#define RT_INPUT 1
62#define RT_OUTPUT 2
63#define RT_FEATURE 3 /* end of group NUC472_442_USBH_HID_EXPORTED_CONSTANTS */
67
68
69struct usbhid_dev;
76typedef void (HID_IR_FUNC)(struct usbhid_dev *hdev, uint8_t *rdata, int data_len);
77typedef void (HID_IW_FUNC)(struct usbhid_dev *hdev, uint8_t **wbuff, int *buff_size); /* end of group NUC472_442_USBH_HID_EXPORTED_TYPEDEFS */
81
82
87/*-----------------------------------------------------------------------------------
88 * HID device
89 */
91typedef struct usbhid_dev
92{
94 int ifnum;
95 uint8_t bSubClassCode;
96 uint8_t bProtocolCode;
102 struct usbhid_dev *next;
104} HID_DEV_T; /* end of group NUC472_442_USBH_HID_EXPORTED_STRUCTURES */
108
109
110#ifdef __cplusplus
111extern "C" {
112#endif
113
118void USBH_HidInit(void);
120int32_t HID_HidGetReportDescriptor(HID_DEV_T *hdev, uint8_t *desc_buf, int buf_max_len);
121int32_t HID_HidGetReport(HID_DEV_T *hdev, int rtp_typ, int rtp_id, uint8_t *data, int len);
122int32_t HID_HidSetReport(HID_DEV_T *hdev, int rtp_typ, int rtp_id, uint8_t *data, int len);
123int32_t HID_HidGetIdle(HID_DEV_T *hdev, int rtp_id, uint8_t *idle_rate);
124int32_t HID_HidSetIdle(HID_DEV_T *hdev, int rtp_id, uint8_t idle_rate);
125int32_t HID_HidGetProtocol(HID_DEV_T *hdev, uint8_t *protocol);
126int32_t HID_HidSetProtocol(HID_DEV_T *hdev, uint8_t protocol);
129
130 /* end of group NUC472_442_USBH_HID_EXPORTED_FUNCTIONS */
132 /* end of group NUC472_442_USBH_HID_Driver */
134 /* end of group NUC472_442_Device_Driver */
136
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif /* __INCLUDED_HID_H__ */
143
144/*** (C) COPYRIGHT 2014 Nuvoton Technology Corp. ***/
145
HIDDEN_SYMBOLS struct usb_device USB_DEV_T
#define HID_MAX_BUFFER_SIZE
Definition: usbh_hid.h:36
#define HID_CLIENT_SIZE
Definition: usbh_hid.h:37
HID_IW_FUNC * write_func
Definition: usbh_hid.h:101
USB_DEV_T * udev
Definition: usbh_hid.h:93
int32_t USBH_HidStartIntReadPipe(HID_DEV_T *hdev, HID_IR_FUNC *func)
Start purge the USB interrupt in transfer.
Definition: hid_core.c:378
URB_T * urbin
Definition: usbh_hid.h:97
int32_t HID_HidGetProtocol(HID_DEV_T *hdev, uint8_t *protocol)
HID class standard request Get_Protocol request. The Get_Protocol request reads which protocol is cur...
Definition: hid_core.c:268
HID_IR_FUNC * read_func
Definition: usbh_hid.h:100
int32_t HID_HidGetReportDescriptor(HID_DEV_T *hdev, uint8_t *desc_buf, int buf_max_len)
Get report descriptor request.
Definition: hid_core.c:76
struct usbhid_dev * next
Definition: usbh_hid.h:102
URB_T * urbout
Definition: usbh_hid.h:98
int32_t HID_HidGetIdle(HID_DEV_T *hdev, int rtp_id, uint8_t *idle_rate)
HID class standard request Get_Idle request. The Get_Idle request reads the current idle rate for a p...
Definition: hid_core.c:204
void USBH_HidInit(void)
Init USB Host HID driver.
Definition: hid_driver.c:246
int32_t HID_HidSetIdle(HID_DEV_T *hdev, int rtp_id, uint8_t idle_rate)
HID class standard request Set_Idle request. The Set_Idle request silences a particular report on the...
Definition: hid_core.c:236
uint8_t inbuf[HID_MAX_BUFFER_SIZE]
Definition: usbh_hid.h:99
uint8_t bProtocolCode
Definition: usbh_hid.h:96
int32_t USBH_HidStartIntWritePipe(HID_DEV_T *hdev, HID_IW_FUNC *func)
Start purge the USB interrupt out transfer.
Definition: hid_core.c:439
int32_t HID_HidGetReport(HID_DEV_T *hdev, int rtp_typ, int rtp_id, uint8_t *data, int len)
HID class standard request Get_Report request. The Get_Report request allows the host to receive a re...
Definition: hid_core.c:138
uint8_t client[HID_CLIENT_SIZE]
Definition: usbh_hid.h:103
HID_DEV_T * USBH_HidGetDeviceList(void)
Get a list of currently connected USB Hid devices.
Definition: hid_driver.c:262
int32_t HID_HidSetReport(HID_DEV_T *hdev, int rtp_typ, int rtp_id, uint8_t *data, int len)
HID class standard request Set_Report request. The Set_Report request allows the host to send a repor...
Definition: hid_core.c:174
int32_t HID_HidSetProtocol(HID_DEV_T *hdev, uint8_t protocol)
HID class standard request Set_Protocol request. The Set_Protocol switches between the boot protocol ...
Definition: hid_core.c:299
int ifnum
Definition: usbh_hid.h:94
uint8_t bSubClassCode
Definition: usbh_hid.h:95
struct usbhid_dev HID_DEV_T
void() HID_IR_FUNC(struct usbhid_dev *hdev, uint8_t *rdata, int data_len)
Definition: usbh_hid.h:76
void() HID_IW_FUNC(struct usbhid_dev *hdev, uint8_t **wbuff, int *buff_size)
Definition: usbh_hid.h:77
USB Host core driver header file.