Zephyr API 3.6.99
Loading...
Searching...
No Matches
usb_hid.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation
3 * Copyright (c) 2018,2021 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13#ifndef ZEPHYR_INCLUDE_USB_HID_CLASS_DEVICE_H_
14#define ZEPHYR_INCLUDE_USB_HID_CLASS_DEVICE_H_
15
17#include <zephyr/usb/usb_ch9.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
35typedef int (*hid_cb_t)(const struct device *dev,
36 struct usb_setup_packet *setup, int32_t *len,
37 uint8_t **data);
38typedef void (*hid_int_ready_callback)(const struct device *dev);
39typedef void (*hid_protocol_cb_t)(const struct device *dev, uint8_t protocol);
40typedef void (*hid_idle_cb_t)(const struct device *dev, uint16_t report_id);
41
45struct hid_ops {
50 /*
51 * int_in_ready is an optional callback that is called when
52 * the current interrupt IN transfer has completed. This can
53 * be used to wait for the endpoint to go idle or to trigger
54 * the next transfer.
55 */
58};
59
68void usb_hid_register_device(const struct device *dev,
69 const uint8_t *desc,
70 size_t size,
71 const struct hid_ops *op);
72
83int hid_int_ep_write(const struct device *dev,
84 const uint8_t *data,
85 uint32_t data_len,
86 uint32_t *bytes_ret);
87
100int hid_int_ep_read(const struct device *dev,
101 uint8_t *data,
102 uint32_t max_data_len,
103 uint32_t *ret_bytes);
104
115int usb_hid_set_proto_code(const struct device *dev, uint8_t proto_code);
116
124int usb_hid_init(const struct device *dev);
125
134#ifdef __cplusplus
135}
136#endif
137
138#endif /* ZEPHYR_INCLUDE_USB_HID_CLASS_DEVICE_H_ */
int(* hid_cb_t)(const struct device *dev, struct usb_setup_packet *setup, int32_t *len, uint8_t **data)
Definition usb_hid.h:35
void(* hid_idle_cb_t)(const struct device *dev, uint16_t report_id)
Definition usb_hid.h:40
int hid_int_ep_read(const struct device *dev, uint8_t *data, uint32_t max_data_len, uint32_t *ret_bytes)
Read from USB HID interrupt endpoint buffer.
int usb_hid_init(const struct device *dev)
Initialize USB HID class support.
void usb_hid_register_device(const struct device *dev, const uint8_t *desc, size_t size, const struct hid_ops *op)
Register HID device.
int hid_int_ep_write(const struct device *dev, const uint8_t *data, uint32_t data_len, uint32_t *bytes_ret)
Write to USB HID interrupt endpoint buffer.
void(* hid_protocol_cb_t)(const struct device *dev, uint8_t protocol)
Definition usb_hid.h:39
void(* hid_int_ready_callback)(const struct device *dev)
Definition usb_hid.h:38
int usb_hid_set_proto_code(const struct device *dev, uint8_t proto_code)
Set USB HID class Protocol Code.
USB Human Interface Device (HID) common definitions header.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__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:403
USB HID device interface.
Definition usb_hid.h:45
hid_idle_cb_t on_idle
Definition usb_hid.h:49
hid_int_ready_callback int_out_ready
Definition usb_hid.h:57
hid_cb_t get_report
Definition usb_hid.h:46
hid_cb_t set_report
Definition usb_hid.h:47
hid_protocol_cb_t protocol_change
Definition usb_hid.h:48
hid_int_ready_callback int_in_ready
Definition usb_hid.h:56
USB Setup Data packet defined in spec.
Definition usb_ch9.h:40
USB Chapter 9 structures and definitions.