User API reference of the Human Interface Device Class. More...
Functions | |
void | USBD_HIDn_Initialize (void) |
Callback function called during USBD_Initialize to initialize the USB HID class instance. | |
void | USBD_HIDn_Uninitialize (void) |
Callback function called during USBD_Uninitialize to de-initialize the USB HID class instance. | |
int32_t | USBD_HIDn_GetReport (uint8_t rtype, uint8_t req, uint8_t rid, uint8_t *buf) |
Callback function called to prepare HID Report data to send. | |
bool | USBD_HIDn_SetReport (uint8_t rtype, uint8_t req, uint8_t rid, const uint8_t *buf, int32_t len) |
Callback function called to process received HID Report data. | |
usbStatus | USBD_HID_GetReportTrigger (uint8_t instance, uint8_t rid, const uint8_t *buf, uint32_t len) |
Asynchronously prepare HID Report data to send. | |
User API reference of the Human Interface Device Class.
usbStatus USBD_HID_GetReportTrigger | ( | uint8_t | instance, |
uint8_t | rid, | ||
const uint8_t * | buf, | ||
uint32_t | len | ||
) |
Asynchronously prepare HID Report data to send.
[in] | instance | instance of HID class. |
[in] | rid | report ID. |
[in] | buf | buffer containing report data to send. |
[in] | len | number of report data bytes to send. |
The function USBD_HID_GetReportTrigger asynchronously prepares data that will be returned to the USB Host upon request. It enables the USB Device to send HID report data only when the data has changed. Usually, the USB Host sets idle time to infinity upon HID Device enumeration. This means, the USB Host expects data from a device only when it has changed. If idle time is not set to infinity, the USBD_HIDn_GetReport function is called whenever the idle time period is expired.
Use the function only for reports of type HID_REPORT_INPUT and for events that needs to update report data. The function should only be used for reports with the rtype = HID_REPORT_INPUT to signal that an updated HID report is available.
The argument instance specifies the instance of the HID device that is to be used.
The argument rid specifies the report ID and should be 0 if there's only one report in the system.
The argument buf is pointing to the buffer with the data to be sent.
The argument len specifies the number of bytes to be sent.
Code Example
int32_t USBD_HIDn_GetReport | ( | uint8_t | rtype, |
uint8_t | req, | ||
uint8_t | rid, | ||
uint8_t * | buf | ||
) |
Callback function called to prepare HID Report data to send.
[in] | rtype | report type :
|
[in] | req | request type :
|
[in] | rid | report ID (0 if only one report exists). |
[out] | buf | buffer containing report data to send. |
The function USBD_HIDn_GetReport prepares data that will be returned to the USB Host. You may modify the function to the application's needs. The function is called on any of the following events:
The argument rtype specifies the report type:
Value | Description |
---|---|
HID_REPORT_INPUT | Input report requested |
HID_REPORT_FEATURE | Feature report requested |
The argument req specifies the request type:
Value | Description |
---|---|
USBD_HID_REQ_EP_CTRL | Request came from control endpoint |
USBD_HID_REQ_PERIOD_UPDATE | Request came from idle period expiration |
USBD_HID_REQ_EP_INT | Request came from previously sent report on interrupt endpoint |
The argument rid specifies the report ID and should be 0 if there's only one report in the system.
The argument buf is pointing to the buffer to report data.
Code Example
void USBD_HIDn_Initialize | ( | void | ) |
Callback function called during USBD_Initialize to initialize the USB HID class instance.
The function USBD_HIDn_Initialize is called automatically upon initialization of a Human Interface Device Class Device and needs no invocation in the user code.
Modify this function to the application needs to allocate resources and initialize additional peripherals.
Code Example
bool USBD_HIDn_SetReport | ( | uint8_t | rtype, |
uint8_t | req, | ||
uint8_t | rid, | ||
const uint8_t * | buf, | ||
int32_t | len | ||
) |
Callback function called to process received HID Report data.
[in] | rtype | report type :
|
[in] | req | request type :
|
[in] | rid | report ID (0 if only one report exists). |
[in] | buf | buffer that receives report data. |
[in] | len | length of received report data. |
The function USBD_HIDn_SetReport handles HID report data that is received from the USB Host. The function is called when a HID report was received. You may modify the function to the application's needs.
The argument rtype specifies the report type:
Value | Description |
---|---|
HID_REPORT_OUTPUT | Output report received |
HID_REPORT_FEATURE | Feature report received |
The argument req specifies the request type:
Value | Description |
---|---|
USBD_HID_REQ_EP_CTRL | Request came through control endpoint |
USBD_HID_REQ_EP_INT | Request came through interrupt endpoint |
The argument rid specifies the report ID and should be 0 if there's only one report in the system.
The argument buf is pointing to the buffer to report data.
The argument len specifies the length of the received report data.
Code Example
void USBD_HIDn_Uninitialize | ( | void | ) |
Callback function called during USBD_Uninitialize to de-initialize the USB HID class instance.
The function USBD_HIDn_Uninitialize is called automatically upon un-initialization of a Human Interface Device Class Device and needs no invocation in the user code. If USBD_HIDn_Initialize has been adapted to the application, USBD_HIDn_Uninitialize should release resources and should de-initialize peripherals.
Code Example