Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
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
37typedef int (*hid_cb_t)(const struct device *dev,
38 struct usb_setup_packet *setup, int32_t *len,
39 uint8_t **data);
40typedef void (*hid_int_ready_callback)(const struct device *dev);
41typedef void (*hid_protocol_cb_t)(const struct device *dev, uint8_t protocol);
42typedef void (*hid_idle_cb_t)(const struct device *dev, uint16_t report_id);
43
47struct hid_ops {
52 /*
53 * int_in_ready is an optional callback that is called when
54 * the current interrupt IN transfer has completed. This can
55 * be used to wait for the endpoint to go idle or to trigger
56 * the next transfer.
57 */
60};
61
70void usb_hid_register_device(const struct device *dev,
71 const uint8_t *desc,
72 size_t size,
73 const struct hid_ops *op);
74
85int hid_int_ep_write(const struct device *dev,
86 const uint8_t *data,
87 uint32_t data_len,
88 uint32_t *bytes_ret);
89
102int hid_int_ep_read(const struct device *dev,
103 uint8_t *data,
104 uint32_t max_data_len,
105 uint32_t *ret_bytes);
106
117int usb_hid_set_proto_code(const struct device *dev, uint8_t proto_code);
118
126int usb_hid_init(const struct device *dev);
127
136#ifdef __cplusplus
137}
138#endif
139
140#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:37
void(* hid_idle_cb_t)(const struct device *dev, uint16_t report_id)
Definition usb_hid.h:42
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:41
void(* hid_int_ready_callback)(const struct device *dev)
Definition usb_hid.h:40
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:412
USB HID device interface.
Definition usb_hid.h:47
hid_idle_cb_t on_idle
Definition usb_hid.h:51
hid_int_ready_callback int_out_ready
Definition usb_hid.h:59
hid_cb_t get_report
Definition usb_hid.h:48
hid_cb_t set_report
Definition usb_hid.h:49
hid_protocol_cb_t protocol_change
Definition usb_hid.h:50
hid_int_ready_callback int_in_ready
Definition usb_hid.h:58
USB Setup Data packet defined in spec.
Definition usb_ch9.h:40
USB Chapter 9 structures and definitions.