Obtains max packet size for the connected HID device. The max packet size is set to the area. Set the direction (USB_HID_IN/USB_HID_OUT). More...
Detailed Description
This module provides a USB Host Human Interface Device Class Driver (HHID). It implements the USB HHID Interface.
Overview
The r_usb_hhid module combines with the r_usb_basic module to provide a USB Host Human Interface Device Class (HHID) driver. The HHID driver conforms to the USB Human Interface Device class specifications and implements communication with a HID device.
Features
The r_usb_hhid module has the following key features:
Data communication with a connected HID device (USB mouse, keyboard etc.)
Issuing of HID class requests to a connected HID device
Supports Interrupt OUT transfer
Configuration
Build Time Configurations for r_usb_hhid
The following build time configurations are defined in fsp_cfg/r_usb_hhid_cfg.h:
Configuration
Options
Default
Description
Interrupt In Pipe
USB PIPE6
USB PIPE7
USB PIPE8
USB PIPE9
USB PIPE6
Select the pipe number to use for input interrupt events.
Interrupt Out Pipe
USB PIPE6
USB PIPE7
USB PIPE8
USB PIPE9
USB PIPE9
Select the pipe number to use for output interrupt events.
Configurations for Connectivity > USB HHID (r_usb_hhid)
This module can be added to the Stacks tab via New Stack > Connectivity > USB HHID (r_usb_hhid). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.
This driver is not guaranteed to provide USB HID operation in all scenarios. The developer must verify correct operation when connected to the targeted USB peripherals.
Class Requests
The class requests supported by this driver are shown below:
Request
Code
Description
USB_GET_REPORT
0x01
Receives a report from the HID device.
USB_SET_REPORT
0x09
Sends a report to the HID device.
USB_GET_IDLE
0x02
Receives a duration (time) from the HID device.
USB_SET_IDLE
0x0A
Sends a duration (time) to the HID device.
USB_GET_PROTOCOL
0x03
Reads a protocol from the HID device.
USB_SET_PROTOCOL
0x0B
Sends a protocol to the HID device.
USB_GET_REPORT_DESCRIPTOR
0x06
Requests a report descriptor.
USB_GET_HID_DESCRIPTOR
0x06
Requests a HID descriptor.
Data Format
The boot protocol data format of data received from the keyboard or mouse through interrupt-IN transfers is shown below:
The HID driver does not analyze the report descriptor. This driver determines the report format from the interface protocol.
This driver does not support DMA transfers.
This driver does not support High-speed.
The transfer rates of Full-speed and Low-speed are the same when the max packet sizes of Full-speed and Low-speed are the same.
This driver does not support simultaneous operation with the other device class.
Examples
USB HHID Example
The main functions of the application are as follows:
Performs enumeration and initialization of HID devices.
Transfers data to and from a connected HID device (mouse or keyboard). Data received from the device is read and discarded.
When an RTOS is used, the USB driver calls the callback (usb_apl_callback) in order to pass events to the main loop through a queue.
Example Operating Environment
Application Processing (for RTOS)
The main loop performs processing to receive data from the HID device as part of the main routine. An overview of the processing performed by the loop is shown below.
When a USB-related event has completed, the USB driver calls the callback function (usb_apl_callback). In the callback function (usb_apl_callback), the application task (APL) is notified of the USB completion event using the real-time OS functionality.
In APL, information regarding the USB completion event was notified from the callback function is retrieved using the real-time OS functionality.
If the USB completion event (the event member of the usb_ctrl_t structure) retrieved in step 2 above is USB_STATUS_CONFIGURED, APL sends the class request (SET_PROTOCOL) to the HID device.
If the USB completion event (the event member of the usb_ctrl_t structure) retrieved in step 2 above is USB_STATUS_REQUEST_COMPLETE, APL performs a data reception request to receive data transmitted from the HID device by calling the R_USB_Read function.
The above processing is repeated.
Main Loop (Normal mode)
Application Processing (for Non-OS)
The main loop performs processing to receive data from the HID device as part of the main routine. An overview of the processing of the main loop is presented below.
When the R_USB_GetEvent function is called after an HID device attaches to the USB host and enumeration completes, USB_STATUS_CONFIGURED is set as the return value. When the APL confirms USB_STATUS_CONFIGURED, it calls the R_USB_Write function to request transmission of data to the HID device.
When the R_USB_GetEvent function is called after sending of class request SET_PROTOCOL to the HID device has completed, USB_STATUS_REQUEST_COMPLETE is set as the return value. When the APL confirms USB_STATUS_REQUEST_COMPLETE, it calls the R_USB_Read function to make a data receive request for data sent by the HID device.
When the R_USB_GetEvent function is called after reception of data from the HID device has completed, USB_STATUS_READ_COMPLETE is set as the return value. When the APL confirms USB_STATUS_READ_COMPLETE, it calls the R_USB_Read function to make a data receive request for data sent by the HID device.