Human Interface Device (HID) Class APIs for Harmony v2

Files added to Human Interface Device (HID) projects:

  • device-hid.c
  • device-hid.h

APIs provided:


USB_DEVICE_HID_ReportSend

Description Inputs Returns
USB_DEVICE_HID_ReportSend
initiates the USB transmit function by requesting
the USB Library transfer application data to the
output endpoint.
USB Device HID Instance,
Transfer handle,
Pointer to the data buffer,
Length of transfer
Status of the transfer request

Example of sending a USB HID Report

USB_DEVICE_HID_TRANSFER_HANDLE hidTransferHandle;
USB_DEVICE_HID_RESULT result;



// Transmitting the contents of appReport

result = USB_DEVICE_HID_ReportSend( USB_DEVICE_HID_INDEX_0,
&hidTransferHandle ,
&appReport[0], sizeof(appReport));


if( result != USB_DEVICE_HID_RESULT_OK)
{
//Handle error.

}


USB_DEVICE_HID_ReportReceive

Description Inputs Returns
USB_DEVICE_HID_ReportRecieve
starts the receiving process by requesting the
USB library returns the contents of EP1 into
the specified data buffer.
USB Device HID Instance,
Transfer handle,
Pointer to the data buffer,
Length of transfer
Status of the transfer request

Example of receiving HID Report

USB_DEVICE_HID_TRANSFER_HANDLE hidTransferHandle;
USB_DEVICE_HID_RESULT result;


result = USB_DEVICE_HID_ReportSend( USB_DEVICE_HID_INDEX_0,
&hidTransferHandle ,
&appReport[0], sizeof(appReport));

if( result != USB_DEVICE_HID_RESULT_OK)
{
//Handle error.

}


USB_DEVICE_HID_TransferCancel

Description Inputs Returns
USB_DEVICE_HID_TransferCancel
cancels a pending transfer. Works for
both pending Transmit and Receive transfers.
USB Device HID Instance,
Transfer handle
Status of the request

Example of cancelling a Transfer

USB_DEVICE_HID_TRANSFER_HANDLE hidTransferHandle;
USB_DEVICE_HID_RESULT result;


result = USB_DEVICE_HID_TransferCancel( USB_DEVICE_HID_INDEX_0,
&hidTransferHandle );


if( result == USB_DEVICE_HID_RESULT_OK)
{
// The transfer cancellation was either completely or
// partially successful

}


USB_DEVICE_HID_EventHandlerSet

Description Inputs Returns
USB_DEVICE_HID_EventHandlerSet
registers an event handler for the specified
HID function driver instance
USB Device HID Instance,
EventHandler,
context
Status of the request

Example of Registering an Event Handler

USB_DEVICE_HID_RESULT result;


result = USB_DEVICE_HID_EventHandlerSet( USB_DEVICE_HID_INDEX_0,
&EventHandlerFunction ,
0 );


if( result != USB_DEVICE_HID_RESULT_OK)
{
//Handle error.
}

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.