CN115168253A - USB working mode switching method and electronic equipment - Google Patents

USB working mode switching method and electronic equipment Download PDF

Info

Publication number
CN115168253A
CN115168253A CN202110368239.4A CN202110368239A CN115168253A CN 115168253 A CN115168253 A CN 115168253A CN 202110368239 A CN202110368239 A CN 202110368239A CN 115168253 A CN115168253 A CN 115168253A
Authority
CN
China
Prior art keywords
interface
usb
working mode
data packet
electronic equipment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110368239.4A
Other languages
Chinese (zh)
Inventor
陈响亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hefei Jiefa Technology Co ltd
Original Assignee
Hefei Jiefa Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hefei Jiefa Technology Co ltd filed Critical Hefei Jiefa Technology Co ltd
Priority to CN202110368239.4A priority Critical patent/CN115168253A/en
Publication of CN115168253A publication Critical patent/CN115168253A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/10Program control for peripheral devices
    • G06F13/12Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor
    • G06F13/124Program control for peripheral devices using hardware independent of the central processor, e.g. channel or peripheral processor where hardware is a sequential transfer control unit, e.g. microprocessor, peripheral processor or state-machine
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Microelectronics & Electronic Packaging (AREA)
  • Information Transfer Systems (AREA)

Abstract

The application discloses a switching method of a USB working mode and electronic equipment, wherein the method is applied to the electronic equipment, the electronic equipment comprises a control chip and a USB interface which are connected with each other, and the method comprises the following steps: after the USB equipment is inserted into the USB interface, the working mode of the electronic equipment defaults to be a first working mode; judging whether errors occur when the electronic equipment and the USB equipment transmit data packets; if the electronic equipment and the USB equipment generate errors during data packet transmission, the switch controlled by the control software is switched off so that the working mode of the electronic equipment is switched from the first working mode to the second working mode, wherein the switch is arranged in the control chip or is respectively connected with the control chip and the USB interface. Through the mode, the working modes can be automatically switched, and the working stability is improved.

Description

USB working mode switching method and electronic equipment
Technical Field
The present application relates to the field of communications technologies, and in particular, to a method for switching USB operating modes and an electronic device.
Background
Universal Serial Bus (USB) is a fast, bi-directional, synchronous, inexpensive and easy-to-use hot-pluggable Serial interface, which makes devices with USB interfaces widely available. The USB3.0 interface introduces a super high speed (SuperSpeed) mode, so that the transmission speed can reach 5Gb/s. Since the signals of the USB3.0 interface are physically incompatible with the signals of the USB2.0 interface, in order to achieve compatibility, the USB developer Forum (USB Implementers Forum, USB-IF) proposes a design scheme of the USB3.0 interface: a set of USB3.0 signals is added on the basis of the USB2.0 signals to realize compatibility. With the increase of the transmission speed of the USB interface, the requirement on hardware is higher and higher, and besides the requirement on hardware wiring, the requirement on a transmission cable is also correspondingly higher. At present, the maximum supported cable length of the USB3.0 interface is 3 meters, and when the transmission cable exceeds 3 meters, the transmission rate will be reduced, and there is a possibility of transmission error. In addition, the non-standard wiring of the circuit board may cause unstable signal transmission using the USB3.0 interface, thereby causing transmission failure, and in order to solve these problems, the design hardware is usually modified again, which requires a large time cost.
Disclosure of Invention
The application provides a switching method of a USB working mode and electronic equipment, which can automatically switch the working mode and improve the working stability.
In order to solve the technical problem, the technical scheme adopted by the application is as follows: the method is applied to electronic equipment, the electronic equipment comprises a control chip and a USB interface which are connected with each other, and the method comprises the following steps: after the USB equipment is inserted into the USB interface, the working mode of the electronic equipment defaults to be a first working mode; judging whether errors occur when the electronic equipment and the USB equipment transmit data packets; if the electronic equipment and the USB equipment generate errors during data packet transmission, the switch controlled by the control software is switched off so that the working mode of the electronic equipment is switched from the first working mode to the second working mode, wherein the switch is arranged in the control chip or is respectively connected with the control chip and the USB interface.
In order to solve the above technical problem, another technical solution adopted by the present application is: the electronic equipment comprises a control chip, a USB interface, a setting module, a judging module and a processing module; the control chip is connected with the USB interface, the control chip comprises a controller, a first physical layer chip, a first interface, a second interface and a second physical layer chip, the controller is connected with the first physical layer chip through the first interface, and the controller is connected with the second physical layer chip through the second interface; the setting module is used for defaulting the working mode of the electronic equipment to be a first working mode after the USB equipment is inserted into the USB interface; the judging module is connected with the setting module and used for judging whether errors occur when the electronic equipment and the USB equipment transmit data packets; the processing module is used for controlling the switch controlled by the software to be switched off when the transmission data packet has an error, so that the working mode of the electronic equipment is switched from the first working mode to the second working mode, wherein the switch is arranged in the control chip or is respectively connected with the control chip and the USB interface.
Through the scheme, the beneficial effects of the application are that: the electronic equipment comprises a control chip and a USB interface, wherein the control chip can communicate with external USB equipment through the USB interface to realize data transmission between the electronic equipment and the USB equipment; after the USB device is inserted into the USB interface, the electronic device works in a first working mode, data packets are sent to the USB device or the data packets sent by the USB device are received, after at least one data packet is successfully transmitted, whether the transmitted data packet is correct or not can be detected, if the transmission of the data packet is detected to be wrong, the working mode is switched, the current working mode is switched from the first working mode to a second working mode, the first working mode can be used or forbidden in a self-adaptive mode, the problem of unstable transmission when the electronic device works in the first working mode in certain scenes is solved, the working stability is improved, signals related to the first working mode do not need to be added with extension lines or disconnected physically, the first working mode and the second working mode can be used normally, and the implementation is simple and convenient.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts. Wherein:
fig. 1 is a schematic flowchart illustrating an embodiment of a method for switching USB operating modes according to the present application;
FIG. 2 is a schematic structural diagram of an embodiment of an electronic device provided in the present application;
FIG. 3 is a schematic flowchart illustrating a method for switching USB operating modes according to another embodiment of the present disclosure;
FIG. 4 is a schematic diagram of the LMP, TP and ITP formats provided herein;
FIG. 5 is a diagram illustrating a format of a DP provided herein;
FIG. 6 is a schematic diagram of a packet format provided herein;
FIG. 7 is a schematic structural diagram of a control chip provided in the present application;
FIG. 8 is a schematic structural diagram of another embodiment of an electronic device provided in the present application;
fig. 9 is a schematic structural diagram of another embodiment of an electronic device provided in the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In order to solve the problem that the USB2.0 interface is incompatible with the USB3.0 interface, there are two main solutions:
1) Scheme 1: the hardware is modified to physically disconnect signals associated with the USB3.0 SuperSpeed mode on the circuit board, thereby physically disabling the USB3.0 mode.
2) Scheme 2: before connecting the USB device, an extension line of USB2.0 is used for switching.
For the first scheme, the device needs to be disassembled to modify the circuit board, which is time-consuming and labor-consuming, and the circuit board is irreversibly modified, so that the USB3.0 mode cannot be used any more after modification. For the second scheme, an additional extension cord is required, and the user side is generally unacceptable.
In order to solve the problems existing in the existing scheme, the application provides a scheme for switching the USB working mode of the electronic equipment, a switch is arranged on a control chip for switching on and off of a USB3.0 SuperSpeed mode (USB 3.0 mode for short), the switch is controlled by software, the USB3.0 mode can be enabled or disabled freely, the USB3.0 mode is automatically switched to a USB2.0 mode, an extension line is not required to be added, or a signal related to the USB3.0 mode is not required to be disconnected physically, the implementation is simple and convenient, irreversible damage is not caused, and the USB3.0 mode and the USB2.0 mode can be used normally.
Referring to fig. 1 and fig. 2, fig. 1 is a flowchart illustrating an embodiment of a method for switching a USB operating mode provided by the present application, and fig. 2 is a schematic structural diagram illustrating an embodiment of an electronic device provided by the present application, where the method is applied to the electronic device 21 shown in fig. 2, the electronic device 21 includes a control chip 211 and a USB interface 212 that are connected to each other, and the method includes:
step 11: after the USB device is plugged into the USB interface, the working mode of the electronic device defaults to the first working mode.
As shown in fig. 2, the USB interface 212 is connected to the control Chip 211 and the USB device 22, so that the control Chip 211 communicates with the USB device 22 through the USB interface 212, and the control Chip 211 may be a System on Chip (SoC), a Field Programmable Gate Array (FPGA), a Micro Control Unit (MCU), or the like; after the user inserts the USB device 22 into the USB interface 212, the electronic device 21 may interact with the USB device 22, and the working mode of the electronic device 21 defaults to a first working mode, which may be a USB3.0 mode.
Step 12: and judging whether errors occur when the electronic equipment and the USB equipment transmit the data packets.
After the electronic device 21 establishes a communication connection with the USB device 22, the electronic device 21 operates in a first operating mode to communicate with the USB device 22, and data packets can be transmitted between the electronic device 21 and the USB device 22; after the at least one data packet is successfully transmitted, the electronic device 21 may detect whether the data packet transmitted between the electronic device 21 and the USB device 22 has a problem to determine whether the data transmission using the first operation mode is currently proper.
Step 13: if errors occur when the electronic equipment and the USB equipment transmit the data packets, the switch controlled by the software is controlled to be switched off, so that the working mode of the electronic equipment is switched from the first working mode to the second working mode.
If the electronic device 21 detects that the received data packet is incorrect, it may be determined that there is a problem in data transmission currently using the first working mode, and at this time, the working mode may be switched from the first working mode to the second working mode; specifically, a switch (not shown in the figure) that can be controlled to open and close by software may be provided, and the switch is provided inside the control chip 211, or the switch is respectively connected to the control chip 211 and the USB interface 212; the transmission speed of the second working mode is lower than that of the first working mode, and the second working mode can be a USB2.0 mode, namely when transmission has a problem, the USB2.0 mode with the lower transmission speed is adopted to transmit data packets.
It is understood that the first operating mode and the second operating mode are not limited to the USB3.0 mode and the USB2.0 mode, respectively, but may be other modes, such as: USB3.1 mode, USB3.2 mode, or USB4.0 mode, etc.; the types of the operation modes are not limited to two, and may be set according to specific application requirements, for example, a third operation mode may be further set, and the transmission speed of the third operation mode is greater than that of the first operation mode or less than that of the second operation mode. In addition, the working mode of the electronic device 21 may be defaulted to the second working mode, whether the current working mode is adjusted is determined according to the transmission requirement, and if the current working mode is adjusted, the working mode is switched from the second working mode to the first working mode.
The embodiment provides a method for switching a USB working mode, which can be applied to electronic equipment, wherein the electronic equipment comprises a control chip and a USB interface which are connected with each other, and the control chip can communicate with external USB equipment through the USB interface to realize data transmission; after the USB device is inserted into the USB interface, the working mode of the electronic device defaults to a first working mode with higher transmission speed, a data packet is sent to the USB device or received from the USB device under the first working mode, after the transmission of the data packet is realized, whether the transmitted data packet is correct or not can be detected, if the received data packet is detected to be different from the sent data packet or the received data packet does not accord with the format requirement of the current data packet, the transmission error is indicated, the current working mode is converted from the first working mode to a second working mode, the first working mode can be used or forbidden to be used in a self-adaptive mode, the automatic switching of the working modes is realized, the problem of unstable transmission when the USB device works in the first working mode under certain scenes is solved, the stability of data transmission is improved, an extension line does not need to be added or a signal related to the first working mode is disconnected in a physical mode, and the realization is simple and convenient.
Referring to fig. 3, fig. 3 is a schematic flowchart illustrating another embodiment of a method for switching USB operating modes according to the present application, where the method includes:
step 31: after the USB equipment is inserted into the USB interface, the working mode of the electronic equipment defaults to be the first working mode.
This step is the same as step 11 in the above embodiment, and is not described again.
The electronic device and the USB device may be connected by a cable, and no matter how the USB application is implemented, the Data packets transmitted on the cable are different types of Data packets, and the purposes such as Link Management or Data transmission are finally achieved through the Data packets, that is, the Data packets are basic units of USB communication, four types of Data packets are specified in the USB3.0 protocol, and are respectively a Link Management Packet (LMP), a Transport Packet (TP), a Data Packet (DP), and an Timestamp Packet (Isochronous Timestamp Packet), the LMP is mainly used for Link Management, the TP is mainly used for controlling Packet flow and configuring devices, and the DP is used for Data transmission between the host and the device, and the ITP is used for providing host timing information to the device to achieve synchronization.
The format of the LMP, TP, and ITP is shown in FIG. 4, and includes 12 bits of packet content information DWORD0-DWORD2, 2 bits of CRC-16 (Cyclic Redundancy Check) information, and 2 bits of a Link Control Word (Link Control Word).
The DP format is shown in fig. 5, and is formed by seamlessly connecting a Data Packet Payload (DPP) to a Data Packet Header (DPH), the structure of the DPH is similar to LMP/TP/ITP, and the DPP includes communication Data DWORD0-Data DWORDn plus a 4-bit CRC-32 information.
As shown in fig. 6, the actual packet transmission format at the link layer includes, for each packet, a header including 3 Start Header Packet (SHP) symbols and 1 End Packet Frame (EPF) symbol, and a packet end including 2 bytes of link control word information (except DPP).
After describing the data packet, how to use the data packet to determine whether the operation mode needs to be switched will be described in detail below, specifically as shown in steps 32 to 39.
Step 32: and judging whether the data packet transmitted between the electronic equipment and the USB equipment is complete or not by using the error detection module.
The control chip comprises an error detection module, the error detection module is used for detecting whether errors occur when the electronic device and the USB device transmit data packets, the error detection module can be used for checking the data packets at a link layer, the integrity of the data packets is mainly checked, namely, whether the data packets start with 3 SHPs and 1 EPF and whether the packet tails carry link control words is checked, if the packet headers do not start with 3 SHPs and 1 EPF or the packet tails do not carry the link control words, the currently transmitted data packets are determined to be incomplete, the integrity check is determined to fail, and the step 33 is executed.
Step 33: if the data packet is incomplete, whether to retry the operation is judged.
If the error detection module identifies that the currently transmitted data packet is incomplete, the error recovery process is entered, that is, whether to perform a retry operation is determined according to a specific error type, where the error type that needs to perform the retry operation may be: a header error, an end of packet error, or a CRC data check error, for example, the header error may be that the data packet is not turned on with 3 SHPs and 1 EPF, and the end of packet error may be that there is no link control word information.
Step 34: if the retry operation is not carried out, the transmission failure is determined, and the switch controlled by the control software is turned off, so that the working mode of the electronic equipment is switched from the first working mode to the second working mode.
If the retry operation is determined not to be performed, the currently transmitted data packet is not complete, and the operation of judging the integrity of the data packet again is not performed, at this time, the transmission failure information can be directly returned, and the working mode is switched.
Further, if it is determined that the transmission of the current data packet fails, it indicates that the purpose of correctly transmitting the data packet cannot be achieved by using the current working mode, at this time, the working mode needs to be switched, the current working mode is switched from the first working mode to the second working mode, and how to switch the working modes is explained below.
In a specific embodiment, the switch is disposed inside the control chip 70, as shown in fig. 7, the control chip 70 includes a controller 71, a first phy chip 72, a first interface, a second interface, and a second phy chip 73, the controller 71 is connected to the first phy chip 72 through the first interface, and the controller 71 is connected to the second phy chip 73 through the second interface; specifically, the first Interface may be a PCI Express (Peripheral Component Interconnect-Express) and USB3.0 Physical layer Interface (Physical Interface for Peripheral Component Interconnect Express and USB3.0, pipe) Interface, and the second Interface may be a USB2.0transceiver macro Interface (USB 2.0transceiver macro Interface, UTMI).
When the transmission data packet has an error, the switch controlled by the control software disconnects the path between the controller 71 and the first interface, so that the controller 71 communicates with the USB device through the second interface, the second physical layer chip 73 and the USB interface, and the working mode of the electronic device is switched from the first working mode to the second working mode; for example, taking the control chip 70 as an SoC, the switching between the USB3.0 mode and the USB2.0 mode is accomplished by controlling the enabling and disabling of logic units inside the SoC.
Further, an invalid flag bit corresponding to the working mode may be preset, and after the USB device is inserted into the USB interface, the invalid flag bit defaults to a first preset value to control the software-controlled switch to turn on the path between the controller 71 and the first interface, thereby realizing default setting of the working mode to the first working mode; after the error detection module 711 detects that a data packet transmission error occurs, the working mode is switched, the invalid flag bit is set to the second preset value to control the software-controlled switch to disconnect the path between the controller 71 and the first interface, and then the transmission of the data packet is restarted, that is, the electronic device sends the data packet to the USB device again or receives the data packet sent by the USB device.
For example, taking the control chip 70 as the SoC, and the first operating mode and the second operating mode are the USB3.0 mode and the USB2.0 mode, respectively, as an example, the invalid flag bit is marked as disable _ USB30, and a switch capable of being controlled by software is added in the SoC, so that the USB3.0 mode can be automatically turned on and off, and the user hardly feels that a problem occurs in data transmission, and the specific flow is as follows:
1) When the USB device is plugged into the USB interface, the default disable _ USB30 is "0", and the electronic device will operate in the USB3.0 mode.
2) When a data transmission error occurs between the electronic device and the USB device, the error detection module 711 in the SoC detects the transmission error and notifies the software, and after the software determines that the transmission error occurs, the disable _ USB30 is set to "1", the USB3.0 mode is turned off, and the current operating mode is switched to the USB2.0 mode.
3) And the software reinitiates the data packet transmission so that the data transmission can be normally completed.
It can be understood that if the electronic device can normally operate in the USB3.0 mode, no transmission error occurs, and the electronic device will always operate in the USB3.0 mode without any influence. The specific values of the first preset value and the second preset value can be set according to specific application requirements, and are not limited to "0" and "1" above.
In this embodiment, a switch that can be controlled by software is added inside the SoC, and the switch is used to disconnect or connect the PIPE interface, so as to achieve the purpose of enabling/disabling the USB3.0 mode. And while the PIPE interface is disconnected to prohibit the USB3.0 mode, the SoC can close some hardware logic units of the USB3.0 mode, thereby further reducing the chip power consumption.
In another embodiment, the switch is controlled by software to switch the USB3.0 signal outside the control chip on and off, so as to achieve the purpose of automatically switching the USB3.0 mode to the USB2.0 mode, and the specific scheme is shown in fig. 8.
The electronic device 80 comprises a circuit board 81, a control chip 811, a USB interface 812 and a switch 813 are arranged on the circuit board 81, the control chip 811 is provided with a General purpose input/output (GPIO) and an error detection module 8111, the USB interface 812 comprises a General purpose interface (D + and D-) and a dedicated interface (SSRX +, SSRX-, SSTX + and SSTX-) corresponding to the first operating mode, and the switch 813 is connected with the General purpose input/output interface and the dedicated interface.
Further, when an error occurs in the transmission data packet, the control chip 811 is used to generate a control signal, which is input to the switch 813 through the general input/output interface to control the switch 813 to be closed, so that the path between the control chip 811 and the dedicated interface is closed; the communication connection between the control chip 811 and the general-purpose interface is established, so that the electronic device 80 operates in the second operating mode, and therefore, the on/off of the switch 813 is controlled by a GPIO, so as to allow the enabling or disabling of the USB3.0 signal related to the USB3.0 mode, and realize the normal use or prohibition of the USB3.0 mode.
In other embodiments, in order to reduce the power consumption of the electronic device 80 and achieve the purposes of saving energy and prolonging the standby time, the function corresponding to the first operating mode with higher power consumption may be turned off or partially turned off, that is, the invalid flag bit corresponding to the operating mode is set to the second preset value, so as to turn off at least part of the function related to the first operating mode in the electronic device 80.
Step 35: and if the retry operation is carried out, waiting for the arrival of the next data packet.
If it is determined that the retry operation is required, the error is ignored and the data packet is waited to be retransmitted, and then the check is performed again, that is, when the next data packet arrives, the information of the next data packet is obtained, and then the error detection module is used to detect whether the next data packet is complete, that is, step 32 is executed.
And step 36: and if the data packet is complete, checking the data packet to judge whether the check is passed or not.
After the integrity detection of the current data packet passes, the data packet can be checked; specifically, the data packet includes data information and cyclic check information, the data information is a 12-bit field in the data packet shown in fig. 6, and the cyclic check information is a 2-bit CRC-16 field; the data information can be calculated to obtain corresponding verification information, and then whether the verification information is the same as the cyclic verification information is judged; if the verification information is the same as the cyclic verification information, determining that the verification is passed; if the check information is different from the cyclic check information, it is determined that the check fails, and at this time, it may be determined whether to perform a retry operation, i.e., step 33 is executed.
Step 37: and if the verification is passed, judging whether the information in the data packet is legal or not based on the type of the data packet.
After checking and checking the current data packet, performing packet type checking, namely checking the validity of each field according to the type of the current data packet, and notably, performing CRC (cyclic redundancy check) of DPP (DPP) on DP; if some fields in the current data packet are judged to be illegal, an error recovery process is carried out, namely whether retry operation is carried out or not is judged.
Step 38: and if the data packet is legal, determining that no error occurs in the data packet transmission.
If the data packet to be transmitted currently is detected to be legal, the data packet is indicated to be transmitted correctly, the working mode does not need to be switched at this time, taking the first working mode as the USB3.0 mode as an example, and if the error does not occur when the USB3.0 mode is used for transmitting the data packet, the USB3.0 mode is still adopted when the next data packet is transmitted.
In the embodiment, the mode of forbidding the USB3.0 mode from the inside or the outside of the control chip is adopted, the working mode can be automatically switched, the problem that the USB3.0 mode is unstable in working under certain scenes can be solved, the normal use of the original USB3.0 function cannot be influenced, and the power consumption of the control chip can be further reduced when the USB3.0 mode is forbidden. In addition, because the working mode negotiated by the devices may not be normally used due to external factors, and the current USB specification can only avoid this situation at the design stage, this embodiment provides a flexible configuration mode at the application stage, and cooperates with software to switch the USB working mode in real time to solve such problems, thereby increasing the working stability of the USB interface.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an embodiment of an electronic device provided in the present application, where the electronic device 90 includes a control chip 91, a USB interface 92, a setting module 93, a determining module 94, and a processing module 95.
The controller chip 91 is connected to the USB interface 92, the controller chip 91 includes a controller 911, a first phy layer chip 912, a first interface 913, a second interface 914, and a second phy layer chip 915, the controller 911 is connected to the first phy layer chip 912 through the first interface 913, and the controller 911 is connected to the second phy layer chip 915 through the second interface 914.
The setting module 93 is configured to default the operating mode of the electronic device 90 to the first operating mode after the USB device is plugged into the USB interface 92.
The determining module 94 is connected to the setting module 93, and is configured to determine whether an error occurs in the transmission of the data packet between the electronic device 90 and the USB device.
The processing module 95 is configured to control the software-controlled switch to be turned off when an error occurs in the data packet transmission, so that the operating mode of the electronic device 90 is switched from the first operating mode to the second operating mode; specifically, the switch is disposed inside the control chip 91 or the switch is connected to the control chip 91 and the USB interface 92.
The scheme provided by the embodiment can solve the problem that the transmission failure cannot be recovered due to poor signals after the first working mode is adopted, and the first working mode is automatically switched to the second working mode in a mode of combining software and hardware, so that the communication recovery between the electronic equipment and the USB equipment is realized.
In the several embodiments provided in the present application, it should be understood that the disclosed method and apparatus may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a module or a unit is only one type of logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one position, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each of the units may exist alone physically, or two or more units may be integrated into one unit. The integrated unit may be implemented in the form of hardware, or may also be implemented in the form of a software functional unit.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings, or which are directly or indirectly applied to other related technical fields, are intended to be included within the scope of the present application.

Claims (10)

1. A method for switching USB working mode is applied to electronic equipment, wherein the electronic equipment comprises a control chip and a USB interface which are connected with each other, and the method comprises the following steps:
after the USB equipment is inserted into the USB interface, the working mode of the electronic equipment is defaulted to be a first working mode;
judging whether the electronic equipment and the USB equipment have errors or not when transmitting data packets;
if yes, the switch controlled by the software is controlled to be disconnected, so that the working mode of the electronic equipment is switched from the first working mode to the second working mode, wherein the switch is arranged inside the control chip or is respectively connected with the control chip and the USB interface.
2. The method for switching USB operation modes according to claim 1,
the switch set up in inside the control chip, the control chip includes controller, first physical layer chip, first interface, second interface and second physical layer chip, the controller passes through first interface with first physical layer chip is connected, the controller passes through the second interface with second physical layer chip is connected, the step of the switch disconnection of control software control includes:
when the data packet is transmitted in error, the software-controlled switch is controlled to open a path between the controller and the first interface, so that the electronic equipment works in the second working mode.
3. The method according to claim 2, wherein the invalid flag bit corresponding to the operating mode is default to a first preset value to control the software-controlled switch to turn on a path between the controller and the first interface;
the step of controlling the software-controlled switch to open the path between the controller and the first interface comprises:
and setting the invalid flag bit to be a second preset value so as to control the switch controlled by the software to break a path between the controller and the first interface.
4. The switching method of USB operation mode according to claim 1,
the control chip is provided with a universal input/output interface, the USB interface comprises a universal interface and a special interface corresponding to the first working mode, and the switch is connected with the universal input/output interface and the special interface.
5. The method for switching the USB operating mode according to claim 4, further comprising:
when the data packet is transmitted in error, the control chip is used for generating a control signal to control the switch to be closed so as to close a passage between the control chip and the special interface;
and establishing a communication connection between the control chip and the general interface so as to enable the electronic equipment to work in the second working mode.
6. The switching method of USB operation mode according to claim 2 or 4,
and setting an invalid flag bit corresponding to the working mode to be a second preset value so as to close at least part of functions related to the first working mode in the electronic equipment.
7. The method according to claim 1, wherein the control chip comprises an error detection module, the method further comprising:
judging whether a data packet transmitted between the electronic equipment and the USB equipment is complete or not by using the error detection module;
if the data packet is incomplete, judging whether to perform retry operation;
if the retry operation is not carried out, determining that the transmission fails;
and if the retry operation is carried out, waiting for the arrival of the next data packet, and returning to the step of judging whether the data packet transmitted between the electronic equipment and the USB equipment is complete by using the error detection module.
8. The method for switching the USB operation mode according to claim 7, further comprising:
when the data packet is complete, checking the data packet to judge whether the check is passed;
if the verification is not passed, executing the step of judging whether to perform retry operation;
if the verification is passed, judging whether the information in the data packet is legal or not based on the type of the data packet; if the data packet is legal, determining that no error occurs during the transmission of the data packet; and if the operation is illegal, executing the step of judging whether to perform retry operation.
9. The method for switching the USB operation mode according to claim 8, wherein the data packet includes data information and cyclic check information, and the step of checking the data packet to determine whether the check is passed includes:
calculating the data information to obtain corresponding verification information;
judging whether the checking information is the same as the cyclic checking information or not;
if yes, determining that the verification is passed;
if not, determining that the verification fails.
10. An electronic device is characterized by comprising a control chip, a USB interface, a setting module, a judging module and a processing module; the control chip is connected with the USB interface, the control chip comprises a controller, a first physical layer chip, a first interface, a second interface and a second physical layer chip, the controller is connected with the first physical layer chip through the first interface, and the controller is connected with the second physical layer chip through the second interface; the setting module is used for defaulting the working mode of the electronic equipment to be a first working mode after the USB equipment is inserted into the USB interface; the judging module is connected with the setting module and is used for judging whether errors occur when the electronic equipment and the USB equipment transmit data packets; the processing module is used for controlling the switch controlled by the software to be switched off when the data packet is transmitted to be in error, so that the working mode of the electronic equipment is switched from the first working mode to the second working mode, wherein the switch is arranged in the control chip or is respectively connected with the control chip and the USB interface.
CN202110368239.4A 2021-04-06 2021-04-06 USB working mode switching method and electronic equipment Pending CN115168253A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110368239.4A CN115168253A (en) 2021-04-06 2021-04-06 USB working mode switching method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110368239.4A CN115168253A (en) 2021-04-06 2021-04-06 USB working mode switching method and electronic equipment

Publications (1)

Publication Number Publication Date
CN115168253A true CN115168253A (en) 2022-10-11

Family

ID=83476119

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110368239.4A Pending CN115168253A (en) 2021-04-06 2021-04-06 USB working mode switching method and electronic equipment

Country Status (1)

Country Link
CN (1) CN115168253A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115914327A (en) * 2022-11-07 2023-04-04 中国第一汽车股份有限公司 Control method, device, equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115914327A (en) * 2022-11-07 2023-04-04 中国第一汽车股份有限公司 Control method, device, equipment and storage medium
CN115914327B (en) * 2022-11-07 2024-03-26 中国第一汽车股份有限公司 Control method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN110687993B (en) Controlling power delivery by tunneling messages over USB
US8176227B2 (en) Method and system for high-speed detection handshake in universal serial bus based data communication system
US11210255B2 (en) Detection of displayport alternate mode communication and connector plug orientation without use of a power distribution controller
CN106462528A (en) Power-saving mode for USB power delivery sourcing device
CN108008980B (en) Method and apparatus for initiating re-enumeration of USB3.0 compatible devices
US20130254440A1 (en) Devices and methods for transmitting usb termination signals over extension media
US7353300B2 (en) Apparatus to improve the firmware efficiency for a multiframe serial interface
CN115168253A (en) USB working mode switching method and electronic equipment
JPS62161236A (en) Series data communication method
CN100476780C (en) Automatic method for identifying signal interfaces of electronic equipment
CN114297134A (en) Chip architecture and signal integrity test method
CN212112457U (en) Bus controller
CN112783817A (en) Device access detection apparatus, PCIe routing card, system, control method and medium
CN113986600B (en) Test method and device for chip serial interface and chip
CN111886585B (en) Terminal device, debugging card and debugging method
CN113992471B (en) Communication system and method for multiple hosts and multiple slaves
JP2024508592A (en) USB interface multiplexing method, circuit, electronic equipment and storage medium
CN108631130B (en) Concentrator
CN107770017A (en) The processing unit and method that a kind of CAN reversal connection can not communicate
CN112821156A (en) Electronic tags chip and TYPE-C data line
CN107704403B (en) Device and method for optimizing signal transmission of main back plate
EP2936760B1 (en) Devices and methods for transmitting usb termination signals over extension media
CN217718676U (en) GPIO communication circuit, board card and electronic equipment
CN112667548B (en) Communication interface, device and method for supporting bidirectional two-wire system synchronous serial bus
CN111384939B (en) ESD protection method for high-speed interface

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination