![]() |
USB Component
Version 6.5
MDK-Professional Middleware for USB Device and Host
|
USB Host functions to support Human Interface Device (HID) USB Devices. More...
Content | |
Configuration | |
Configuration of the USB Host HID Class in µVision. | |
Functions | |
usbStatus | USBH_HID_GetDeviceStatus (uint8_t instance) |
Get status of Human Interface Device. | |
int32_t | USBH_HID_Read (uint8_t instance, uint8_t *buf, int32_t len) |
Read data received from Human Interface Device. | |
int32_t | USBH_HID_Write (uint8_t instance, const uint8_t *buf, int32_t len) |
Write data to Human Interface Device. | |
int | USBH_HID_GetKeyboardKey (uint8_t instance) |
Retrieve first pending pressed keyboard key on HID Keyboard. | |
usbStatus | USBH_HID_GetMouseState (uint8_t instance, usbHID_MouseState *state) |
Retrieve state change since last call of this function. | |
void | USBH_HID_ParseReportDescriptor (uint8_t instance, uint8_t *ptr_hid_report_desc) |
Callback function called for parsing of the Human Interface Device report descriptor. | |
void | USBH_HID_DataReceived (uint8_t instance, uint32_t len) |
Callback function called when data is received from the Human Interface Device. | |
USB Host functions to support Human Interface Device (HID) USB Devices.
The HID class in the USB Component is used for attaching input devices to your system.
Refer to:
Software Structure
The application starts the USB Host by calling USBH_Initialize. The USB Host Core will wait until an USB HID device is attached to the system. As soon as this happens it will enumerate the device and it will be ready to be used by the application. The handling of the HID class events is implemented in USBH_HID_Thread.
The transmit functions USBH_HID_Read and USBH_HID_Write will be called by the user thread directly to communicate with the HID device.
To create an USB Host with support for the HID class:
Code Example
void USBH_HID_DataReceived | ( | uint8_t | instance, |
uint32_t | len | ||
) |
Callback function called when data is received from the Human Interface Device.
[in] | instance | instance index. |
[in] | len | length of received data. |
The USBH_HID_DataReceived function enables programmers to analyse received data coming from an USB HID device. Implementing this function in user code overrides the library function that handles boot protocol device data reception. This is useful if the default HID functionality needs to be changed to support special HID devices.
usbStatus USBH_HID_GetDeviceStatus | ( | uint8_t | instance | ) |
Get status of Human Interface Device.
[in] | instance | instance of HID Device. |
The function USBH_HID_GetDeviceStatus checks whether the human interface device is connected and initialized.
The argument instance is specifying the device instance.
Code Example
int32_t USBH_HID_GetKeyboardKey | ( | uint8_t | instance | ) |
Retrieve first pending pressed keyboard key on HID Keyboard.
[in] | instance | instance of HID Device. |
The function USBH_HID_GetKeyboardKey enables programmers to handle signals from an USB keyboard.
The argument instance is specifying the device instance.
Code Example
bool USBH_HID_GetMouseState | ( | uint8_t | instance, |
usbHID_MouseState * | state | ||
) |
Retrieve state change since last call of this function.
[in] | instance | instance of HID Device. |
[out] | state | pointer to mouse state usbHID_MouseState structure. |
The function USBH_HID_GetMouseState enables programmers to handle signals from an USB mouse.
The argument instance is specifying the device instance.
The argument state is a pointer to the mouse state structure (usbHID_MouseState).
Code Example
void USBH_HID_ParseReportDescriptor | ( | uint8_t | instance, |
uint8_t * | ptr_hid_report_desc | ||
) |
Callback function called for parsing of the Human Interface Device report descriptor.
[in] | instance | instance index. |
[in] | ptr_hid_report_desc | pointer to HID report descriptor. |
The USBH_HID_ParseReportDescriptor function enables programmers to parse report descriptors of an USB HID device. Implementing this function in user code overrides the library function that handles boot protocol device report descriptor parsing. This is useful if the default HID functionality needs to be changed to support special HID devices.
int32_t USBH_HID_Read | ( | uint8_t | instance, |
uint8_t * | buf, | ||
int32_t | len | ||
) |
Read data received from Human Interface Device.
[in] | instance | instance of HID Device. |
[out] | buf | buffer that receives data. |
[in] | len | maximum number of bytes to read. |
The function USBH_HID_Read retrieves the data sent by an USB HID device and stores it in a buffer.
The argument instance is specifying the device instance.
The argument buf is pointing to the location where the data will be returned (stored).
The argument len specifies the number of bytes to be read.
Code Example
int32_t USBH_HID_Write | ( | uint8_t | instance, |
const uint8_t * | buf, | ||
int32_t | len | ||
) |
Write data to Human Interface Device.
[in] | instance | instance of HID Device. |
[in] | buf | data buffer containing data to write. |
[in] | len | number of data bytes to write. |
The function USBH_HID_Write writes data from a buffer to an USB HID device.
The argument instance is specifying the device instance.
The argument buf is pointing to the location where the data will be written.
The argument len specifies the number of data bytes to be written.
Code Example