Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usbd_hid.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12#ifndef ZEPHYR_INCLUDE_USBD_HID_CLASS_DEVICE_H_
13#define ZEPHYR_INCLUDE_USBD_HID_CLASS_DEVICE_H_
14
15#include <stdint.h>
16#include <zephyr/device.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
32/*
33 * HID Device overview:
34 *
35 * +---------------------+
36 * | |
37 * | |
38 * | HID Device |
39 * | User "top half" |
40 * | of the device that +-------+
41 * | deals with input | |
42 * | sampling | |
43 * | | |
44 * | | |
45 * | ------------------- | |
46 * | | |
47 * | HID Device user | |
48 * | callbacks | |
49 * | handlers | |
50 * +---------------------+ |
51 * ^ | HID Device Driver API:
52 * | |
53 * set_protocol() | | hid_device_register()
54 * get_report() | | hid_device_submit_report(
55 * .... | | ...
56 * v |
57 * +---------------------+ |
58 * | | |
59 * | HID Device | |
60 * | "bottom half" |<------+
61 * | USB HID class |
62 * | implementation |
63 * | |
64 * | |
65 * +---------------------+
66 * ^
67 * v
68 * +--------------------+
69 * | |
70 * | USB Device |
71 * | Support |
72 * | |
73 * +--------------------+
74 */
75
79enum {
83};
84
104 void (*iface_ready)(const struct device *dev, const bool ready);
105
116 int (*get_report)(const struct device *dev,
117 const uint8_t type, const uint8_t id,
118 const uint16_t len, uint8_t *const buf);
119
128 int (*set_report)(const struct device *dev,
129 const uint8_t type, const uint8_t id,
130 const uint16_t len, const uint8_t *const buf);
131
140 void (*set_idle)(const struct device *dev,
141 const uint8_t id, const uint32_t duration);
142
148 uint32_t (*get_idle)(const struct device *dev, const uint8_t id);
149
154 void (*set_protocol)(const struct device *dev, const uint8_t proto);
155
162 void (*input_report_done)(const struct device *dev);
163
171 void (*output_report)(const struct device *dev, const uint16_t len,
172 const uint8_t *const buf);
179 void (*sof)(const struct device *dev);
180};
181
193int hid_device_register(const struct device *dev,
194 const uint8_t *const rdesc, const uint16_t rsize,
195 const struct hid_device_ops *const ops);
196
211int hid_device_submit_report(const struct device *dev,
212 const uint16_t size, const uint8_t *const report);
213
218#ifdef __cplusplus
219}
220#endif
221
222#endif /* ZEPHYR_INCLUDE_USBD_HID_CLASS_DEVICE_H_ */
int hid_device_submit_report(const struct device *dev, const uint16_t size, const uint8_t *const report)
Submit new input report.
int hid_device_register(const struct device *dev, const uint8_t *const rdesc, const uint16_t rsize, const struct hid_device_ops *const ops)
Register HID device report descriptor and user callbacks.
@ HID_REPORT_TYPE_INPUT
Definition usbd_hid.h:80
@ HID_REPORT_TYPE_OUTPUT
Definition usbd_hid.h:81
@ HID_REPORT_TYPE_FEATURE
Definition usbd_hid.h:82
USB Human Interface Device (HID) common definitions header.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
HID device user callbacks.
Definition usbd_hid.h:96
void(* sof)(const struct device *dev)
Optional Start of Frame (SoF) event callback.
Definition usbd_hid.h:179
void(* set_idle)(const struct device *dev, const uint8_t id, const uint32_t duration)
Notification to limit input report frequency.
Definition usbd_hid.h:140
void(* iface_ready)(const struct device *dev, const bool ready)
The interface ready callback is called with the ready argument set to true when the corresponding int...
Definition usbd_hid.h:104
void(* output_report)(const struct device *dev, const uint16_t len, const uint8_t *const buf)
New output report callback.
Definition usbd_hid.h:171
int(* set_report)(const struct device *dev, const uint8_t type, const uint8_t id, const uint16_t len, const uint8_t *const buf)
This callback is called for the HID Set Report request to set a feature, input, or output report,...
Definition usbd_hid.h:128
void(* input_report_done)(const struct device *dev)
Notification that input report submitted with hid_device_submit_report() has been sent.
Definition usbd_hid.h:162
void(* set_protocol)(const struct device *dev, const uint8_t proto)
Notification that the host has changed the protocol from Boot Protocol(0) to Report Protocol(1) or vi...
Definition usbd_hid.h:154
uint32_t(* get_idle)(const struct device *dev, const uint8_t id)
If a report ID is used in the report descriptor, the device must implement this callback and return t...
Definition usbd_hid.h:148
int(* get_report)(const struct device *dev, const uint8_t type, const uint8_t id, const uint16_t len, uint8_t *const buf)
This callback is called for the HID Get Report request to get a feature, input, or output report,...
Definition usbd_hid.h:116