Design of intelligent remote control based on HID specification 2

Publisher:梦想学院Latest update time:2012-09-09 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

2.2 Software System Design

The somatosensory game controller designed and implemented in this system has input and output functions, that is, it has input and output HID data packets. Unlike keyboards and mice, it is a standard HID device and needs to customize its data packet format according to the HID specification. According to the format of the data packet, write its report descriptor to ensure that the somatosensory game controller device is correctly identified during the enumeration process. The Dongle end analyzes and organizes the data obtained from the remote control end, identifies the somatosensory game controller data according to the device's report descriptor, and organizes the data into data that conforms to its input data packet format. Then the Dongle end transmits the organized data to the TV set in the communication mode of the USB protocol. At the same time, the Dongle end receives the data information fed back by the TV set, organizes it into data that conforms to its output data packet format, and then feeds the information back to the remote control end, which then responds accordingly.

Like all HID devices, the application design of the smart remote control Dongle with somatosensory game controller function also mainly includes the following four aspects: 1) Find all HID devices; 2) Determine which HID device the user needs and connect the device; 3) Get the information of the HID device; 4) Read the HID input report or write the HID output report according to user needs.

Multiple HID devices may be defined in the smart remote control, and two interfaces are required. Interface 0 is used to implement the functions of other HID devices, and interface 1 is used to implement the functions of the somatosensory game controller. Therefore, two non-zero endpoints are required, because different interfaces under the same configuration must use different endpoints. Data is transmitted through non-zero endpoints, and the interface of the somatosensory game controller uses endpoint 2 to return or send report data. The dongle end returns the data of the somatosensory game controller to the TV through endpoint 2 input, and the TV sends the information fed back to the remote control through endpoint 2 output interrupt.

After the dongle is inserted, how can the TV recognize the USB somatosensory game controller? The function of device enumeration is to realize the process of TV recognizing the device. Only when the enumeration is successful can the TV recognize the device and establish communication between the TV and the device. The device enumeration process is implemented through endpoint 0. The TV sends various requests through endpoint 0 output interrupt, and the data is stored in the output buffer of endpoint 0. The dongle end reads and analyzes the data in the output buffer of endpoint 0, and then responds accordingly through endpoint 0 input interrupt. The data is stored in the input buffer of endpoint 0. After the TV sends the IN token packet next time, the MCU will automatically return the data in the input buffer of endpoint 0 to the TV. When there are multiple report descriptors on the dongle end, how does the program know which one the TV is requesting? When the TV wants to obtain the report descriptor, the request is sent to the interface. When the TV sends a report descriptor request sent to interface 1, the dongle end will return the report descriptor data of the somatosensory game controller to the TV, thereby successfully completing the enumeration process. The TV recognizes the somatosensory game controller and establishes communication between them.

In this system, by adding a USB module in the integrated development environment of the chip, making corresponding settings and compiling according to the functional characteristics of the device, the function of the device enumeration process and the required code are realized, and then the corresponding modifications are made according to the actual needs of the device. The USB module is initialized in the main function of the Dongle end program, so that the TV can recognize the Dongle and then recognize the somatosensory game controller device. The main flow chart of the Dongle end program is shown in Figure 4. Entering the main function, the MCU first completes a series of initializations, including interrupt configuration and USB module initialization (starting the enumeration process). Then the program is in an infinite loop to realize real-time communication between the TV and the device.

Figure 4 Main process of Dongle end program

The TV and the device cannot communicate at any time. Data can only be transmitted after a non-zero configuration is set. In the infinite loop, first determine whether the communication between the TV and the Dongle is ready, that is, whether the enumeration process of the device is successfully completed. This requires obtaining the configuration value and making a judgment. If the configuration value is non-zero, it means that the communication between the TV and the Dongle has been established. The Dongle end continuously obtains the data sent from the remote control end, analyzes and organizes it according to the device descriptor and configuration descriptor set (including breakpoint descriptors, interface descriptors, etc.) of the device, and stores it in the HID package of the corresponding HID device, and then passes it to the TV through the USB bus.

If the somatosensory switch key is pressed, the remote control selects the somatosensory game controller function; otherwise, the remote control selects the function of other devices. When the somatosensory switch key is pressed, the TV first sends feedback information through the endpoint 2 output interrupt, so that the somatosensory switch indicator light on the remote control end is on, the somatosensory game controller function is turned on, and then the remote control can send the somatosensory game controller data to the TV. Before the dongle end sends the somatosensory game controller data to endpoint 2, it needs to check whether endpoint 2 is in an idle state, that is, whether there is any data that has not been sent out. Endpoint 2 can be made idle through endpoint 2 input interrupt and bus reset interrupt. If endpoint 2 input is in an idle state, the somatosensory game controller data can be returned to the TV through endpoint 2 input. The TV will send feedback information according to the progress of the game, call the sensor module, vibration module and audio module of the remote control, and realize the interaction between the remote control and the TV.

3 Conclusion

This system is the design and implementation of a six-axis somatosensory game controller based on the HID specification applied to the smart remote control. First, the working principle of this somatosensory game controller is analyzed, and then the design and implementation scheme of the somatosensory game controller is proposed from the hardware system and software system. In the case that there may be multiple HID device functions in the smart remote control, the function of the somatosensory game controller is realized by sharing a USB interface. After repeated debugging and verification, it is shown that the smart remote control with this six-axis somatosensory game controller function has good working performance and can completely replace the ordinary somatosensory game controller to experience somatosensory games. In addition, based on this hardware system and software system, the remote control end can process the sensor data accordingly and transmit it to the Dongle end. The Dongle end can simulate and realize other functions, such as further realizing the function of the air mouse.

Reference address:Design of intelligent remote control based on HID specification 2

Previous article:Design of intelligent remote control based on HID specification 1
Next article:Implementation of IC card meter based on 68HC908GP32

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号