Files added to Human Interface Device (HID) projects:
- device-hid.c
- device-hid.h
APIs provided:
- USB_DEVICE_HID_ReportSend
- USB_DEVICE_HID_ReportReceive
- USB_DEVICE_HID_TransferCancel
- USB_DEVICE_HID_EventHandlerSet
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.
}