Microchip® Advanced Software Framework

host_hid.h File Reference
#include "compiler.h"
#include "hid.h"

Data Structures

struct  host_hid_item_t
 HID report descriptor item. More...
 

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...
 

Status_t host_hid_get_descriptor ( uint8_t  descriptor_type,
uint8_t  descriptor_index,
uint8_t  s_interface 
)
uint8_t host_hid_get_idle ( uint8_t  report_id,
uint8_t  s_interface 
)

Reads the current idle rate for a particular Input report.

Parameters
report_idID of the report of which to get the idle rate.
s_interfaceThe supported interface number of which to get the idle rate.
Returns
Idle duration with a 4-ms resolution, or 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.

uint8_t host_hid_get_protocol ( uint8_t  s_interface)

Reads which protocol is currently active (either the boot protocol or the report protocol).

Parameters
s_interfaceThe supported interface number of which to get the protocol.
Returns
Protocol: HID_BOOT_PROTOCOL or HID_REPORT_PROTOCOL.
Note
This request is supported by devices in the Boot subclass.

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.

Parameters
report_typeType of the report to get.
report_idID of the report to get.
s_interfaceThe supported interface number of which to get the report.
Returns
Status.

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.

Parameters
descriptor_typeType of the descriptor to set.
descriptor_indexIndex of the descriptor to set.
s_interfaceThe supported interface number of which to set the descriptor.
lengthLength of the descriptor to set.
Returns
Status.

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.

Parameters
duration_4_msIdle duration with a 4-ms resolution, or HID_IDLE_DURATION_INDEFINITE.
report_idID of the report of which to set the idle rate (can be HID_REPORT_ID_ALL).
s_interfaceThe supported interface number of which to set the idle rate.
Returns
Status.

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).

Parameters
protocolProtocol: HID_BOOT_PROTOCOL or HID_REPORT_PROTOCOL.
s_interfaceThe supported interface number of which to set the protocol.
Returns
Status.
Note
This request is supported by devices in the Boot subclass.
When initialized, all devices default to the report protocol. However, the host should not make any assumptions about the device's state and should set the desired protocol whenever initializing a device.

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.

Parameters
report_typeType of the report to set.
report_idID of the report to set.
s_interfaceThe supported interface number of which to set the report.
lengthLength of the report to set.
Returns
Status.

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.