Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
hid_device_ops Struct Reference

HID device user callbacks. More...

#include <usbd_hid.h>

Data Fields

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 interface is part of the active configuration and the device can e.g.
 
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, which is specified by the argument type.
 
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, which is specified by the argument type.
 
void(* set_idle )(const struct device *dev, const uint8_t id, const uint32_t duration)
 Notification to limit intput report frequency.
 
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 the duration for the specified report ID.
 
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 vice versa.
 
void(* input_report_done )(const struct device *dev)
 Notification that input report submitted with hid_device_submit_report() has been sent.
 
void(* output_report )(const struct device *dev, const uint16_t len, const uint8_t *const buf)
 New output report callback.
 
void(* sof )(const struct device *dev)
 Optional Start of Frame (SoF) event callback.
 

Detailed Description

HID device user callbacks.

Each device depends on a user part that handles feature, input, and output report processing according to the device functionality described by the report descriptor. Which callbacks must be implemented depends on the device functionality. The USB device part of the HID device, cannot interpret device specific report descriptor and only handles USB specific parts, transfers and validation of requests, all reports are opaque to it. Callbacks are called from the USB device stack thread and must not block.

Field Documentation

◆ get_idle

uint32_t(* hid_device_ops::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 the duration for the specified report ID.

Duration time resolution is in miliseconds.

◆ get_report

int(* hid_device_ops::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, which is specified by the argument type.

If there is no report ID in the report descriptor, the id argument is zero. The callback implementation must check the arguments, such as whether the report type is supported and the report length, and return a negative value to indicate an unsupported type or an error, or return the length of the report written to the buffer.

◆ iface_ready

void(* hid_device_ops::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 interface is part of the active configuration and the device can e.g.

begin submitting input reports, and with the argument set to false when the interface is no longer active. This callback is optional.

◆ input_report_done

void(* hid_device_ops::input_report_done) (const struct device *dev)

Notification that input report submitted with hid_device_submit_report() has been sent.

If the device does not use the callback, hid_device_submit_report() will be processed synchronously.

◆ output_report

void(* hid_device_ops::output_report) (const struct device *dev, const uint16_t len, const uint8_t *const buf)

New output report callback.

Callback will only be called for reports received through the optional interrupt OUT pipe. If there is no interrupt OUT pipe, output reports will be received using set_report(). If a report ID is used in the report descriptor, the host places the ID in the buffer first, followed by the report data.

◆ set_idle

void(* hid_device_ops::set_idle) (const struct device *dev, const uint8_t id, const uint32_t duration)

Notification to limit intput report frequency.

The device should mute an input report submission until a new event occurs or until the time specified by the duration value has elapsed. If a report ID is used in the report descriptor, the device must store the duration and handle the specified report accordingly. Duration time resolution is in miliseconds.

◆ set_protocol

void(* hid_device_ops::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 vice versa.

◆ set_report

int(* hid_device_ops::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, which is specified by the argument type.

If there is no report ID in the report descriptor, the id argument is zero. The callback implementation must check the arguments, such as whether the report type is supported, and return a nonzero value to indicate an unsupported type or an error.

◆ sof

void(* hid_device_ops::sof) (const struct device *dev)

Optional Start of Frame (SoF) event callback.

There will always be software and hardware dependent jitter and latency. This should be used very carefully, it should not block and the execution time should be quite short.


The documentation for this struct was generated from the following file: