#include <stddef.h>
#include "compiler.h"
#include "conf_usb.h"
#include "usb_task.h"
#include "usb_host_task.h"
#include "usb_host_enum.h"
#include "hid.h"
#include "host_hid.h"
Functions | |
Standard Requests Applied to HID | |
Status_t | host_hid_get_descriptor (uint8_t descriptor_type, uint8_t descriptor_index, uint8_t s_interface) |
Gets a HID class descriptor. More... | |
Status_t | host_hid_set_descriptor (uint8_t descriptor_type, uint8_t descriptor_index, uint8_t s_interface, uint16_t length) |
Sets a HID class descriptor. More... | |
HID-Specific Requests | |
Status_t | host_hid_get_report (uint8_t report_type, uint8_t report_id, uint8_t s_interface) |
Gets a HID report. More... | |
Status_t | host_hid_set_report (uint8_t report_type, uint8_t report_id, uint8_t s_interface, uint16_t length) |
Sets a HID report. More... | |
uint8_t | host_hid_get_idle (uint8_t report_id, uint8_t s_interface) |
Reads the current idle rate for a particular Input report. More... | |
Status_t | host_hid_set_idle (uint8_t duration_4_ms, uint8_t report_id, uint8_t s_interface) |
Silences a particular report on the Interrupt In pipe until a new event occurs or the specified amount of time passes. More... | |
uint8_t | host_hid_get_protocol (uint8_t s_interface) |
Reads which protocol is currently active (either the boot protocol or the report protocol). More... | |
Status_t | host_hid_set_protocol (uint8_t protocol, uint8_t s_interface) |
Switches between the boot protocol and the report protocol (or vice versa). More... | |
HID Report Descriptor Parsing Functions | |
Status_bool_t | host_hid_get_item (host_hid_item_t *item) |
Gets the next HID report descriptor item. More... | |
Variables | |
struct { | |
const hid_item_t * item | |
size_t length | |
} | host_hid_report_descriptor_parser |
HID report descriptor parser control structure. More... | |
Status_t host_hid_get_descriptor | ( | uint8_t | descriptor_type, |
uint8_t | descriptor_index, | ||
uint8_t | s_interface | ||
) |
Gets a HID class descriptor.
descriptor_type | Type of the descriptor to get. |
descriptor_index | Index of the descriptor to get. |
s_interface | The supported interface number of which to get the descriptor. |
References S_usb_setup_data::bmRequestType, hid_descriptor_t::bNumDescriptors, S_usb_setup_data::bRequest, hid_descriptor_t::bType, data_stage, hid_descriptor_t::Descriptor, GET_DESCRIPTOR, Get_interface_number, HID_DESCRIPTOR, HID_REPORT_DESCRIPTOR, host_hid_report_descriptor_parser, host_transfer_control(), S_usb_setup_data::incomplete_read, SIZEOF_DATA_STAGE, usb_format_usb_to_mcu_data, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, hid_descriptor_t::wLength, and S_usb_setup_data::wValue.
uint8_t host_hid_get_idle | ( | uint8_t | report_id, |
uint8_t | s_interface | ||
) |
Reads the current idle rate for a particular Input report.
report_id | ID of the report of which to get the idle rate. |
s_interface | The supported interface number of which to get the idle rate. |
HID_IDLE_DURATION_INDEFINITE
. References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, HID_GET_IDLE, host_transfer_control(), S_usb_setup_data::incomplete_read, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
Status_bool_t host_hid_get_item | ( | host_hid_item_t * | item | ) |
Gets the next HID report descriptor item.
item | Pointer to the item structure to fill. |
HID_DESCRIPTOR
and HID_REPORT_DESCRIPTOR
. References hid_item_t::bDataSize, hid_item_t::bLongItemTag, hid_item_t::bSize, hid_item_t::bTag, hid_item_t::bType, hid_item_t::data, hid_item_t::header, HID_ITEM_TAG_LONG_ITEM, host_hid_report_descriptor_parser, host_hid_item_t::long_data, host_hid_item_t::long_format, hid_item_t::long_format, host_hid_item_t::short_data, hid_item_t::short_format, host_hid_item_t::tag, host_hid_item_t::type, usb_format_usb_to_mcu_data, and hid_short_item_data_t::value.
uint8_t host_hid_get_protocol | ( | uint8_t | s_interface | ) |
Reads which protocol is currently active (either the boot protocol or the report protocol).
s_interface | The supported interface number of which to get the protocol. |
HID_BOOT_PROTOCOL
or HID_REPORT_PROTOCOL
.References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, HID_GET_PROTOCOL, host_transfer_control(), S_usb_setup_data::incomplete_read, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
Status_t host_hid_get_report | ( | uint8_t | report_type, |
uint8_t | report_id, | ||
uint8_t | s_interface | ||
) |
Gets a HID report.
report_type | Type of the report to get. |
report_id | ID of the report to get. |
s_interface | The supported interface number of which to get the report. |
References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, HID_GET_REPORT, host_transfer_control(), S_usb_setup_data::incomplete_read, SIZEOF_DATA_STAGE, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
Referenced by host_mouse_hid_task().
Status_t host_hid_set_descriptor | ( | uint8_t | descriptor_type, |
uint8_t | descriptor_index, | ||
uint8_t | s_interface, | ||
uint16_t | length | ||
) |
Sets a HID class descriptor.
descriptor_type | Type of the descriptor to set. |
descriptor_index | Index of the descriptor to set. |
s_interface | The supported interface number of which to set the descriptor. |
length | Length of the descriptor to set. |
References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, host_transfer_control(), S_usb_setup_data::incomplete_read, length, SET_DESCRIPTOR, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
Status_t host_hid_set_idle | ( | uint8_t | duration_4_ms, |
uint8_t | report_id, | ||
uint8_t | s_interface | ||
) |
Silences a particular report on the Interrupt In pipe until a new event occurs or the specified amount of time passes.
duration_4_ms | Idle duration with a 4-ms resolution, or HID_IDLE_DURATION_INDEFINITE . |
report_id | ID of the report of which to set the idle rate (can be HID_REPORT_ID_ALL ). |
s_interface | The supported interface number of which to set the idle rate. |
References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, HID_SET_IDLE, host_transfer_control(), S_usb_setup_data::incomplete_read, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
Referenced by host_mouse_hid_task().
Status_t host_hid_set_protocol | ( | uint8_t | protocol, |
uint8_t | s_interface | ||
) |
Switches between the boot protocol and the report protocol (or vice versa).
protocol | Protocol: HID_BOOT_PROTOCOL or HID_REPORT_PROTOCOL . |
s_interface | The supported interface number of which to set the protocol. |
References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, HID_SET_PROTOCOL, host_transfer_control(), S_usb_setup_data::incomplete_read, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
Status_t host_hid_set_report | ( | uint8_t | report_type, |
uint8_t | report_id, | ||
uint8_t | s_interface, | ||
uint16_t | length | ||
) |
Sets a HID report.
report_type | Type of the report to set. |
report_id | ID of the report to set. |
s_interface | The supported interface number of which to set the report. |
length | Length of the report to set. |
References S_usb_setup_data::bmRequestType, S_usb_setup_data::bRequest, data_stage, Get_interface_number, HID_SET_REPORT, host_transfer_control(), S_usb_setup_data::incomplete_read, length, usb_request, S_usb_setup_data::wIndex, S_usb_setup_data::wLength, and S_usb_setup_data::wValue.
struct { ... } host_hid_report_descriptor_parser |
HID report descriptor parser control structure.
Referenced by host_hid_get_descriptor(), and host_hid_get_item().
const hid_item_t* item |
size_t length |
Referenced by host_hid_set_descriptor(), and host_hid_set_report().