| NUC472_NUC442_BSP V3.04.000 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;
76 typedef void (HID_IR_FUNC)(struct usbhid_dev *hdev, uint8_t *rdata, int data_len);
77 typedef 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 */
91 typedef struct usbhid_dev
92{
93 USB_DEV_T *udev;
94 int ifnum;
95 uint8_t bSubClassCode;
96 uint8_t bProtocolCode;
97 URB_T *urbin;
98 URB_T *urbout;
99 uint8_t inbuf[HID_MAX_BUFFER_SIZE];
100 HID_IR_FUNC *read_func;
101 HID_IW_FUNC *write_func;
102 struct usbhid_dev *next;
103 uint8_t client[HID_CLIENT_SIZE];
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);
119 HID_DEV_T * USBH_HidGetDeviceList(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);
127int32_t USBH_HidStartIntReadPipe(HID_DEV_T *hdev, HID_IR_FUNC *func);
128int32_t USBH_HidStartIntWritePipe(HID_DEV_T *hdev, HID_IW_FUNC *func);
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
USB_DEV_T
HIDDEN_SYMBOLS struct usb_device USB_DEV_T
HID_MAX_BUFFER_SIZE
#define HID_MAX_BUFFER_SIZE
Definition: usbh_hid.h:36
HID_CLIENT_SIZE
#define HID_CLIENT_SIZE
Definition: usbh_hid.h:37
usbhid_dev::write_func
HID_IW_FUNC * write_func
Definition: usbh_hid.h:101
usbhid_dev::udev
USB_DEV_T * udev
Definition: usbh_hid.h:93
USBH_HidStartIntReadPipe
int32_t USBH_HidStartIntReadPipe(HID_DEV_T *hdev, HID_IR_FUNC *func)
Start purge the USB interrupt in transfer.
Definition: hid_core.c:378
usbhid_dev::urbin
URB_T * urbin
Definition: usbh_hid.h:97
HID_HidGetProtocol
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
usbhid_dev::read_func
HID_IR_FUNC * read_func
Definition: usbh_hid.h:100
HID_HidGetReportDescriptor
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
usbhid_dev::next
struct usbhid_dev * next
Definition: usbh_hid.h:102
usbhid_dev::urbout
URB_T * urbout
Definition: usbh_hid.h:98
HID_HidGetIdle
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
USBH_HidInit
void USBH_HidInit(void)
Init USB Host HID driver.
Definition: hid_driver.c:246
HID_HidSetIdle
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
usbhid_dev::inbuf
uint8_t inbuf[HID_MAX_BUFFER_SIZE]
Definition: usbh_hid.h:99
usbhid_dev::bProtocolCode
uint8_t bProtocolCode
Definition: usbh_hid.h:96
USBH_HidStartIntWritePipe
int32_t USBH_HidStartIntWritePipe(HID_DEV_T *hdev, HID_IW_FUNC *func)
Start purge the USB interrupt out transfer.
Definition: hid_core.c:439
HID_HidGetReport
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
usbhid_dev::client
uint8_t client[HID_CLIENT_SIZE]
Definition: usbh_hid.h:103
USBH_HidGetDeviceList
HID_DEV_T * USBH_HidGetDeviceList(void)
Get a list of currently connected USB Hid devices.
Definition: hid_driver.c:262
HID_HidSetReport
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
HID_HidSetProtocol
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
usbhid_dev::ifnum
int ifnum
Definition: usbh_hid.h:94
usbhid_dev::bSubClassCode
uint8_t bSubClassCode
Definition: usbh_hid.h:95
HID_DEV_T
struct usbhid_dev HID_DEV_T
HID_IR_FUNC
void() HID_IR_FUNC(struct usbhid_dev *hdev, uint8_t *rdata, int data_len)
Definition: usbh_hid.h:76
HID_IW_FUNC
void() HID_IW_FUNC(struct usbhid_dev *hdev, uint8_t **wbuff, int *buff_size)
Definition: usbh_hid.h:77
urb_t
Definition: usbh_core.h:537
usbhid_dev
Definition: usbh_hid.h:92
usbh_core.h
USB Host core driver header file.