Zephyr API Documentation  3.6.99
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
30/*
31 * HID Device overview:
32 *
33 * +---------------------+
34 * | |
35 * | |
36 * | HID Device |
37 * | User "top half" |
38 * | of the device that +-------+
39 * | deals with input | |
40 * | sampling | |
41 * | | |
42 * | | |
43 * | ------------------- | |
44 * | | |
45 * | HID Device user | |
46 * | callbacks | |
47 * | handlers | |
48 * +---------------------+ |
49 * ^ | HID Device Driver API:
50 * | |
51 * set_protocol() | | hid_device_register()
52 * get_report() | | hid_device_submit_report(
53 * .... | | ...
54 * v |
55 * +---------------------+ |
56 * | | |
57 * | HID Device | |
58 * | "bottom half" |<------+
59 * | USB HID class |
60 * | implementation |
61 * | |
62 * | |
63 * +---------------------+
64 * ^
65 * v
66 * +--------------------+
67 * | |
68 * | USB Device |
69 * | Support |
70 * | |
71 * +--------------------+
72 */
73
77enum {
81};
82
102 void (*iface_ready)(const struct device *dev, const bool ready);
103
114 int (*get_report)(const struct device *dev,
115 const uint8_t type, const uint8_t id,
116 const uint16_t len, uint8_t *const buf);
117
126 int (*set_report)(const struct device *dev,
127 const uint8_t type, const uint8_t id,
128 const uint16_t len, const uint8_t *const buf);
129
138 void (*set_idle)(const struct device *dev,
139 const uint8_t id, const uint32_t duration);
140
146 uint32_t (*get_idle)(const struct device *dev, const uint8_t id);
147
152 void (*set_protocol)(const struct device *dev, const uint8_t proto);
153
160 void (*input_report_done)(const struct device *dev);
161
169 void (*output_report)(const struct device *dev, const uint16_t len,
170 const uint8_t *const buf);
177 void (*sof)(const struct device *dev);
178};
179
191int hid_device_register(const struct device *dev,
192 const uint8_t *const rdesc, const uint16_t rsize,
193 const struct hid_device_ops *const ops);
194
209int hid_device_submit_report(const struct device *dev,
210 const uint16_t size, const uint8_t *const report);
211
216#ifdef __cplusplus
217}
218#endif
219
220#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:78
@ HID_REPORT_TYPE_OUTPUT
Definition: usbd_hid.h:79
@ HID_REPORT_TYPE_FEATURE
Definition: usbd_hid.h:80
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:399
HID device user callbacks.
Definition: usbd_hid.h:94
void(* sof)(const struct device *dev)
Optional Start of Frame (SoF) event callback.
Definition: usbd_hid.h:177
void(* set_idle)(const struct device *dev, const uint8_t id, const uint32_t duration)
Notification to limit intput report frequency.
Definition: usbd_hid.h:138
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:102
void(* output_report)(const struct device *dev, const uint16_t len, const uint8_t *const buf)
New output report callback.
Definition: usbd_hid.h:169
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:126
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:160
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:152
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:146
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:114