CN-122019436-A - High-speed mode detection method and device of USB device, electronic device and storage medium
Abstract
The present disclosure provides a method, an apparatus, an electronic device, and a storage medium for detecting a high-speed mode of a USB device, where parallel detection, serial state machine, and comprehensive decision logic are matched, and SE0 state detection, J state detection, signal edge quality detection, dual time window constraint, and adaptive threshold adjustment mechanism are combined, so that accuracy in identifying a high-speed handshake signal can be improved, misjudgment and missed judgment caused by ringing, reflection, and noise can be reduced, and reliability, anti-interference capability, and environmental adaptability of high-speed mode detection of the USB device are improved.
Inventors
- YANG HONGLIANG
- CHEN GUOYIN
Assignees
- 此芯科技集团有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260414
Claims (10)
- 1. A high-speed mode detection method of a USB device, comprising: Collecting differential signals of a USB bus, and carrying out parallel detection on the differential signals to obtain SE0 state detection results, J state detection results and signal quality detection results; when the SE0 state is detected, a first time window is started, and the duration time of the SE0 state is verified to judge whether the SE0 state meets a preset reset judging condition or not; under the condition that the SE0 state meets the preset reset judging condition, detecting whether the USB bus enters a J state, starting a second time window when the J state is detected, and verifying the duration time of the J state; Detecting the signal edge quality corresponding to the J state to judge whether the J state is an effective handshake signal or not; Based on the duration verification result of the SE0 state, the duration verification result of the J state and the quality detection result of the signal edge, judging whether the current host supports a high-speed mode according to preset state judgment logic, and outputting a high-speed mode detection result.
- 2. The method according to claim 1, characterized in that the parallel detection of the differential signals comprises in particular: Receiving the USB bus signal through a differential receiver; Detecting whether the USB bus is in an SE0 state or not through an independent SE0 state detection channel; Detecting whether the USB bus is in a J state or not through an independent J state detection channel, wherein hysteresis is set when the J state detection channel detects the J state so as to weaken the influence of ringing signals on J state judgment; and detecting the edge rate information of the corresponding edge of the USB bus through an independent signal quality monitoring channel.
- 3. The method according to claim 1, characterized in that verifying the duration of the J-state, in particular comprises: when the J state is detected in the first time window, starting the second time window; Judging whether the duration time of the J state is in a second preset time range or not; and when the duration time of the J state is within the second preset time range, determining that the time sequence detection result of the J state is valid.
- 4. The method according to claim 1, wherein detecting the signal edge quality corresponding to the J state specifically comprises: starting high-speed sampling when a signal edge is detected; waveform data in a preset time range before and after the signal edge is collected; calculating edge time based on the waveform data, wherein the edge time is the time corresponding to the change of the signal amplitude from 10% to 90%; Comparing the edge time with a preset edge threshold value to output a signal quality detection result, wherein when the edge time is not greater than the preset edge threshold value, the corresponding signal is determined to be a valid signal, and when the edge time is greater than the preset edge threshold value, the corresponding signal is determined to be a false signal.
- 5. The method of claim 1, wherein the preset state determination logic comprises: only when the SE0 state satisfies a reset determination condition, the J state satisfies a duration determination condition, and the signal edge quality satisfies a validity determination condition, determining that the current host supports a high-speed mode; and when any one of the conditions is not met, judging that the current host does not support the high-speed mode or the detection is invalid.
- 6. The method according to claim 1, wherein the method further comprises: counting J state pulse times during the SE0 state detection; judging whether the current environment is a high-noise environment or not according to the J state pulse times; and when the current environment is judged to be a high noise environment, adjusting the lower threshold of the second time window.
- 7. The method of claim 6, wherein the method further comprises: when the J state pulse frequency is larger than a preset frequency threshold, judging that the current environment is a high-noise environment; when the current environment is judged to be a high noise environment, the lower threshold of the second time window is adjusted from a first lower threshold to a second lower threshold, wherein the first lower threshold is smaller than the second lower threshold; when the continuous multiple detection periods meet the low noise condition, the adjusted lower limit threshold value of the second time window is restored to the initial threshold value; and when the continuous multiple detection periods are all low in noise, the second time window lower limit threshold value is restored to the first lower limit threshold value.
- 8. A high-speed mode detection apparatus for a USB device, comprising: the detection module is used for collecting differential signals of the USB bus and carrying out parallel detection on the differential signals to obtain SE0 state detection results, J state detection results and signal quality detection results; The first judging module is used for starting a first time window when the SE0 state is detected, and verifying the duration time of the SE0 state to judge whether the SE0 state meets a preset reset judging condition or not; The second judging module is used for detecting whether the USB bus enters a J state or not under the condition that the SE0 state meets the preset reset judging condition, starting a second time window when the J state is detected, and verifying the duration time of the J state; the third judging module is used for detecting the signal edge quality corresponding to the J state so as to judge whether the J state is an effective handshake signal or not; And the result output module is used for judging whether the current host supports the high-speed mode according to preset state judgment logic based on the duration verification result of the SE0 state, the duration verification result of the J state and the quality detection result of the signal edge, and outputting a high-speed mode detection result.
- 9. An electronic device comprising a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, the processor and the memory in communication over the bus when the electronic device is in operation, the machine-readable instructions when executed by the processor performing the steps of the method of high speed mode detection of a USB device as claimed in any one of claims 1 to 7.
- 10. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the high-speed mode detection method of a USB device according to any one of claims 1 to 7.
Description
High-speed mode detection method and device of USB device, electronic device and storage medium Technical Field The disclosure relates to the technical field of detection of USB communication interfaces, and in particular, to a method and device for detecting a high-speed mode of a USB device, an electronic device, and a storage medium. Background Along with the wide application of the USB interface in various electronic devices, the connection establishment, speed identification and mode switching reliability between the USB device and a host directly influence the data transmission performance and system compatibility of the device. For USB devices, after the device accesses the host, it is often necessary to detect the bus state to identify the communication mode supported by the currently connected host, and to complete subsequent data link initialization and transmission parameter configuration accordingly. The high-speed mode detection is an important precondition for the USB device to enter the high-speed communication state normally, so how to accurately identify whether the host has the high-speed communication capability has become one of the key problems in the design of the interface circuit of the USB device. The existing high-speed handshake detection scheme generally starts a timeout counter with fixed duration after detecting a bus reset state, and judges whether the bus enters a J state within preset time so as to infer whether a host supports a high-speed mode. Still other schemes employ level comparators to directly compare the levels of d+ and D-, and determine the J state when a preset high-low level relationship is satisfied. The scheme is relatively simple in circuit structure, but mostly depends on a single judgment condition, and lacks the capability of dynamic adjustment according to an actual noise environment, so that the detection accuracy and stability are poor in a high-noise environment, an impedance mismatch environment or a power supply fluctuation environment, and the requirement of high-speed USB equipment on the host mode recognition reliability is difficult to meet. Disclosure of Invention The embodiment of the disclosure provides at least a method, a device, an electronic device and a storage medium for detecting a high-speed mode of a USB device, which are matched with each other through parallel detection, serial state machine and comprehensive judgment logic and are combined with SE0 state detection, J state detection, signal edge quality detection, double time window constraint and self-adaptive threshold adjustment mechanism, so that the accuracy of identifying a high-speed handshake signal can be improved, misjudgment and missed judgment caused by ringing, reflection and noise can be reduced, and the reliability, anti-interference capability and environment adaptability of the high-speed mode detection of the USB device are improved. The embodiment of the disclosure provides a high-speed mode detection method of a USB device, comprising the following steps: Collecting differential signals of a USB bus, and carrying out parallel detection on the differential signals to obtain SE0 state detection results, J state detection results and signal quality detection results; when the SE0 state is detected, a first time window is started, and the duration time of the SE0 state is verified to judge whether the SE0 state meets a preset reset judging condition or not; under the condition that the SE0 state meets the preset reset judging condition, detecting whether the USB bus enters a J state, starting a second time window when the J state is detected, and verifying the duration time of the J state; Detecting the signal edge quality corresponding to the J state to judge whether the J state is an effective handshake signal or not; Based on the duration verification result of the SE0 state, the duration verification result of the J state and the quality detection result of the signal edge, judging whether the current host supports a high-speed mode according to preset state judgment logic, and outputting a high-speed mode detection result. In an alternative embodiment, the parallel detection of the differential signal specifically includes: Receiving the USB bus signal through a differential receiver; Detecting whether the USB bus is in an SE0 state or not through an independent SE0 state detection channel; Detecting whether the USB bus is in a J state or not through an independent J state detection channel, wherein hysteresis is set when the J state detection channel detects the J state so as to weaken the influence of ringing signals on J state judgment; and detecting the edge rate information of the corresponding edge of the USB bus through an independent signal quality monitoring channel. In an alternative embodiment, verifying the duration of the J-state specifically includes: when the J state is detected in the first time window, starting the second time window; Judging