Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
HID class USB specific definitions

Data Structures

struct  hid_ops
 USB HID device interface. More...
 

Typedefs

typedef int(* hid_cb_t) (const struct device *dev, struct usb_setup_packet *setup, int32_t *len, uint8_t **data)
 
typedef void(* hid_int_ready_callback) (const struct device *dev)
 
typedef void(* hid_protocol_cb_t) (const struct device *dev, uint8_t protocol)
 
typedef void(* hid_idle_cb_t) (const struct device *dev, uint16_t report_id)
 

Functions

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.
 
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_set_proto_code (const struct device *dev, uint8_t proto_code)
 Set USB HID class Protocol Code.
 
int usb_hid_init (const struct device *dev)
 Initialize USB HID class support.
 

Detailed Description

Typedef Documentation

◆ hid_cb_t

typedef int(* hid_cb_t) (const struct device *dev, struct usb_setup_packet *setup, int32_t *len, uint8_t **data)

◆ hid_idle_cb_t

typedef void(* hid_idle_cb_t) (const struct device *dev, uint16_t report_id)

◆ hid_int_ready_callback

typedef void(* hid_int_ready_callback) (const struct device *dev)

◆ hid_protocol_cb_t

typedef void(* hid_protocol_cb_t) (const struct device *dev, uint8_t protocol)

Function Documentation

◆ hid_int_ep_read()

int hid_int_ep_read ( const struct device * dev,
uint8_t * data,
uint32_t max_data_len,
uint32_t * ret_bytes )

#include <zephyr/usb/class/usb_hid.h>

Read from USB HID interrupt endpoint buffer.

Parameters
[in]devPointer to USB HID device
[in]dataPointer to data buffer
[in]max_data_lenMax length of data to copy
[out]ret_bytesNumber of bytes to copy. If data is NULL and max_data_len is 0 the number of bytes available in the buffer will be returned.
Returns
0 on success, negative errno code on fail.

◆ hid_int_ep_write()

int hid_int_ep_write ( const struct device * dev,
const uint8_t * data,
uint32_t data_len,
uint32_t * bytes_ret )

#include <zephyr/usb/class/usb_hid.h>

Write to USB HID interrupt endpoint buffer.

Parameters
[in]devPointer to USB HID device
[in]dataPointer to data buffer
[in]data_lenLength of data to copy
[out]bytes_retBytes written to the EP buffer.
Returns
0 on success, negative errno code on fail.

◆ usb_hid_init()

int usb_hid_init ( const struct device * dev)

#include <zephyr/usb/class/usb_hid.h>

Initialize USB HID class support.

Parameters
[in]devPointer to USB HID device
Returns
0 on success, negative errno code on fail.

◆ usb_hid_register_device()

void usb_hid_register_device ( const struct device * dev,
const uint8_t * desc,
size_t size,
const struct hid_ops * op )

#include <zephyr/usb/class/usb_hid.h>

Register HID device.

Parameters
[in]devPointer to USB HID device
[in]descPointer to HID report descriptor
[in]sizeSize of HID report descriptor
[in]opPointer to USB HID device interrupt struct

◆ usb_hid_set_proto_code()

int usb_hid_set_proto_code ( const struct device * dev,
uint8_t proto_code )

#include <zephyr/usb/class/usb_hid.h>

Set USB HID class Protocol Code.

Should be called before usb_hid_init().

Parameters
[in]devPointer to USB HID device
[in]proto_codeProtocol Code to be used for bInterfaceProtocol
Returns
0 on success, negative errno code on fail.