hid.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2021 Nils Ollrogge
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
26 #include <stdint.h>
27 
28 #include "usb/usbus.h"
29 #include "usb/hid.h"
30 #include "mutex.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 #ifndef CONFIG_USBUS_HID_INTERRUPT_EP_SIZE
40 #define CONFIG_USBUS_HID_INTERRUPT_EP_SIZE 0x40
41 #endif
42 
47 
57 typedef void (*usbus_hid_cb_t)(usbus_hid_device_t *hid, uint8_t *data,
58  size_t len);
59 
69  const uint8_t *report_desc;
72  size_t occupied;
81 
86 };
87 
98  usbus_hid_cb_t cb, const uint8_t *report_desc,
99  size_t report_desc_size);
100 
101 #ifdef __cplusplus
102 }
103 #endif
104 
#define usbdev_ep_buf_t
Instantiation type for usbdev endpoint buffers.
Definition: usbdev.h:126
void(* usbus_hid_cb_t)(usbus_hid_device_t *hid, uint8_t *data, size_t len)
HID data callback.
Definition: hid.h:57
#define CONFIG_USBUS_HID_INTERRUPT_EP_SIZE
USB HID interrupt endpoint size.
Definition: hid.h:40
void usbus_hid_init(usbus_t *usbus, usbus_hid_device_t *hid, usbus_hid_cb_t cb, const uint8_t *report_desc, size_t report_desc_size)
Initialize an USBUS HID interface.
Definition for USB HID interfaces.
Mutex for thread synchronization.
event structure
Definition: event.h:142
Mutex structure.
Definition: mutex.h:36
USBUS descriptor generator.
Definition: usbus.h:294
USBUS endpoint context.
Definition: usbus.h:304
USBUS handler struct.
Definition: usbus.h:432
USBUS HID context struct.
Definition: hid.h:63
usbus_descr_gen_t hid_descr
HID descriptor generator.
Definition: hid.h:68
event_t tx_ready
Transmit ready event.
Definition: hid.h:74
usbus_endpoint_t * ep_in
IN endpoint.
Definition: hid.h:67
size_t report_desc_size
report descriptor size
Definition: hid.h:70
usbus_hid_cb_t cb
Callback for data handlers.
Definition: hid.h:73
usbus_handler_t handler_ctrl
control handler
Definition: hid.h:64
usbus_interface_t iface
HID interface.
Definition: hid.h:65
usbus_t * usbus
USBUS reference.
Definition: hid.h:71
size_t occupied
Number of bytes for the host.
Definition: hid.h:72
const uint8_t * report_desc
report descriptor reference
Definition: hid.h:69
mutex_t in_lock
mutex used for locking hid send
Definition: hid.h:75
usbus_endpoint_t * ep_out
OUT endpoint.
Definition: hid.h:66
usbdev_ep_buf_t in_buf[CONFIG_USBUS_HID_INTERRUPT_EP_SIZE]
Device to host data buffer.
Definition: hid.h:85
usbdev_ep_buf_t out_buf[CONFIG_USBUS_HID_INTERRUPT_EP_SIZE]
Host to device data buffer.
Definition: hid.h:80
USBUS interface.
Definition: usbus.h:349
USBUS context struct.
Definition: usbus.h:444
USBUS basic interface.