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.
Previous article:Design of intelligent remote control based on HID specification 1
Next article:Implementation of IC card meter based on 68HC908GP32
- Popular Resources
- Popular amplifiers
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- F28335 PWM trigger ADC sampling code + comments
- 【TouchGFX Design】Installation and simple experience
- How is the output V0 of this op amp derived?
- How to configure AFE940? Does anyone have the documentation?
- The LCD screen uses the ILI9325 screen controller, and the 32-bit board is STM32F103ZET6. After burning the program, only the background is lit,...
- About Negative Feedback Amplifier Circuit
- GD32E230C development platform is finally built
- Proteus MSP430 MCU simulation example 16 - timer timing 1 second
- Building ESP32-C3 development environment based on window Visual Studio Code: ESP-IDF
- [AT-START-F403A Review] + Unsuccessful W25Q128 Read and Write