A USB interface multiplexing circuit and a control method thereof

By using a USB interface multiplexing circuit and its control method, the communication problem of the USB interface is solved, and the multiplexing of firmware burning for the main control module, firmware burning for the chip, and USB connection for external devices is realized. This reduces the cost of the USB-HUB chip and improves the functionality and flexibility of the USB interface.

CN115437979BActive Publication Date: 2026-06-02GUANGDONG TELEPOWER TELECOM TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG TELEPOWER TELECOM TECH
Filing Date
2022-08-04
Publication Date
2026-06-02

AI Technical Summary

Technical Problem

In existing technologies, the use of USB interfaces is expensive and the PCB board space is limited, resulting in chip designs that cannot achieve communication between the main control module and external devices. In existing technologies, USB interfaces cannot achieve data transmission between the main control module and external devices.

Method used

A USB interface multiplexing circuit and its control method are provided, which realizes communication between the host control module and external devices through the USB interface, thus solving the communication problem of the USB interface.

Benefits of technology

It enables the reuse of USB interfaces, reduces the cost of USB-HUB chips, and improves the functionality and flexibility of USB interfaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115437979B_ABST
    Figure CN115437979B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of circuits, in particular to a USB interface multiplexing circuit and a control method thereof, which comprises a start-up circuit, a power-off circuit, a reset holding circuit, a self-locking circuit, a key, a power module, a main control module and a MOS tube; when the key is pressed in a transient state, the start-up circuit turns on the self-locking circuit, and triggers the power module to supply power to the main control module; when the key is pressed in a steady state, the power-off circuit disconnects the self-locking circuit to cut off the power supply path of the power module, and triggers the main control module to forcibly power off; after the main control module is powered on, the main control module outputs a self-locking signal to the self-locking circuit, so that the self-locking circuit is self-locked after the key is released; after the key is released, the self-locking circuit is self-locked in response to the self-locking signal output by the main control module, so that the power module keeps supplying power; after the main control module is reset and the self-locking signal disappears, the reset holding circuit keeps the self-locking circuit on; and the application can realize multiplexing of the USB interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of circuit technology, specifically to a USB interface multiplexing circuit and its control method. Background Technology

[0002] In related technologies, many chips use USB interfaces for offline firmware burning. However, since USB-HUB chips are expensive and PCB board space is limited, adding a USB-HUB chip or a USB interface just for firmware burning would incur unnecessary additional costs.

[0003] Therefore, it is necessary to provide a solution that can reuse the firmware burning of the main control module, the firmware burning of the chip, and the USB connection (OTG) of external devices through the USB interface. Summary of the Invention

[0004] To address the aforementioned problems, this invention provides a USB interface multiplexing circuit and its control method to solve one or more technical problems existing in the prior art, and at least provide a beneficial option or create conditions.

[0005] To achieve the above objectives, the present invention provides the following technical solution:

[0006] A USB interface multiplexing circuit includes: a USB interface, a data channel switching switch, a main control module, a chip, a mode switching circuit, a data channel control circuit, and a power supply circuit;

[0007] The USB interface is connected to the data channel switching switch, which is connected to the main control module and the chip respectively. The main control module is also connected to the mode switching circuit. One end of the data channel control circuit is connected to the mode switching circuit and the power supply circuit respectively, and the other end of the data channel control circuit is connected to the data channel switching switch. The power supply circuit is connected to the USB interface, the main control module, and the chip respectively.

[0008] The power supply circuit is used to supply power to the chip when firmware is burned to the chip; to supply power to the main control module when firmware is burned to the main control module or the OTG function is used; and to supply power to external devices when the main control module is using the OTG function and the main control module is in HOST mode.

[0009] The mode switching circuit is used to switch the operating mode of the main control module when the main control module uses the OTG function; wherein, the operating mode of the main control module includes DEVICE mode and HOST mode;

[0010] The data channel control circuit is used to trigger a switching signal to select the data channel of the main control module when the power supply circuit supplies power to the main control module; and to trigger a switching signal to select the data channel of the chip when the power supply circuit supplies power to the chip.

[0011] The data channel switching switch is used to respond to the switching signal triggered by the data channel control circuit. When the power supply circuit supplies power to the main control module, it selects the data channel of the main control module to connect with the data channel of the USB interface; when the power supply circuit supplies power to the chip, it selects the data channel of the chip to connect with the data channel of the USB interface.

[0012] Furthermore, the power supply circuit includes: a power supply, a power switch, a voltage regulator, a single-pole double-throw switch, and a thirteenth resistor;

[0013] The power supply is connected to the VCC pin of the main control module, the enable pin of the power switch is connected to the GPIO pin of the main control module, one end of the thirteenth resistor is connected to the VBUS pin of the main control module, the other end of the thirteenth resistor, the output terminal of the power switch, and one end of the data channel control circuit are all connected to the mode switching circuit, the other end of the thirteenth resistor is also connected to the first stationary terminal of the single-pole double-throw switch, the second stationary terminal of the single-pole double-throw switch is connected to the VCC pin of the chip, and the moving terminal of the single-pole double-throw switch is connected to the VBUS pin of the USB interface through the VBUS line.

[0014] Furthermore, a voltage regulator is provided between the second stationary terminal of the single-pole double-throw switch and the VCC pin of the chip.

[0015] Furthermore, when the main control module uses the OTG function, it responds to a user-triggered switching action. If the switching action is to switch the main control module's operating mode to DEVICE mode via a mode switching circuit, the ID pin of the main control module is triggered to a high level, putting the main control module in DEVICE mode, and the GPIO pin of the main control module is pulled low, turning off the power switch. If the switching action is to switch the main control module's operating mode to HOST mode via a mode switching circuit, the ID pin of the main control module is triggered to a low level, putting the main control module in DEVICE mode, and the GPIO pin of the main control module is pulled high, turning off the power switch.

[0016] Furthermore, the mode switching circuit includes: a first resistor, a second resistor, a fifth resistor, a sixth resistor, a seventh resistor, an eighth resistor, a ninth resistor, a tenth resistor, an eleventh resistor, a twelfth resistor, a first capacitor, a second capacitor, a transistor, a MOSFET, and a tactile switch;

[0017] One end of the first resistor and one end of the second resistor are connected to the ID pin of the main control module. The other end of the first resistor is grounded. The other end of the second resistor is connected to the drain of the MOSFET and one end of the sixth resistor. The two ends of the eighth resistor are connected to the gate and source of the MOSFET. The gate of the MOSFET is connected to one end of the twelfth resistor. The other end of the twelfth resistor is connected to the collector of the transistor. The other end of the sixth resistor is connected to one end of the tactile switch, one end of the ninth resistor, one end of the second capacitor, and the base of the transistor. The other end of the tactile switch is connected to one end of the fifth resistor, one end of the first capacitor, and one end of the tenth resistor. The other end of the fifth resistor is connected to one end of the data channel control circuit, the output terminal of the power switch, the other end of the thirteenth resistor, and the first stationary terminal of the single-pole double-throw switch. The other ends of the first capacitor, the ninth resistor, the first capacitor, and the emitter of the transistor are connected to one end of the eleventh resistor. The other ends of the tenth resistor and the eleventh resistor are grounded.

[0018] Furthermore, the mode switching circuit also includes a seventh resistor and a light-emitting diode, one end of the seventh resistor being connected to the other end of the second resistor, the drain of the MOS transistor, and one end of the sixth resistor; the other end of the seventh resistor being connected to the anode of the light-emitting diode, and the cathode of the light-emitting diode being grounded.

[0019] Furthermore, the data channel control circuit includes a third resistor and a fourth resistor. One end of the fourth resistor is connected to the source of the MOS transistor, one end of the eighth resistor, the other end of the fifth resistor, the first stationary terminal of the single-pole double-throw switch, the other end of the thirteenth resistor, and the output terminal of the power switch. The other end of the fourth resistor is connected to one end of the third resistor and the S-pin of the data channel switching switch. The other end of the third resistor is grounded.

[0020] A control method for a USB interface multiplexing circuit, applied to any of the USB interface multiplexing circuits described above, the method comprising the following steps:

[0021] Step S100: Determine the operating mode of the USB interface multiplexing circuit; the operating modes of the USB interface multiplexing circuit include: firmware flashing of the chip, firmware flashing of the main control module, and the main control module using the OTG function;

[0022] Step S200: Determine the power supply target of the power supply circuit based on the working mode of the USB interface multiplexing circuit, and control the power supply circuit to supply power to the power supply target; wherein, the power supply target includes a chip and a main control module. When firmware is burned to the chip, the power supply circuit supplies power to the chip; when firmware is burned to the main control module or the OTG function is used, the power supply circuit supplies power to the main control module.

[0023] Step S300: When the power supply circuit supplies power to the main control module, the data channel control circuit triggers a switching signal to select the data channel of the main control module to the data channel switching switch; when the power supply circuit supplies power to the chip, the data channel control circuit triggers a switching signal to select the data channel of the chip to the data channel switching switch.

[0024] Step S400: In response to the switching signal triggered by the data channel control circuit, when the power supply circuit supplies power to the main control module, the data channel switching switch selects the data channel of the main control module to connect with the data channel of the USB interface; when the power supply circuit supplies power to the chip, the data channel switching switch selects the data channel of the chip to connect with the data channel of the USB interface.

[0025] Step S500: When the main control module uses the OTG function, it responds to the user-triggered switching action and switches the working mode of the main control module through the mode switching circuit; wherein, the working mode of the main control module includes DEVICE mode and HOST mode.

[0026] The beneficial effects of this invention are as follows: This invention provides a USB interface multiplexing circuit and its control method. The power supply target of the power supply circuit is determined according to the operating mode of the USB interface multiplexing circuit, and the power supply circuit is controlled to supply power to the target. When the main control module uses the OTG function, the operating mode of the main control module is switched between DEVICE mode and HOST mode through a mode switching circuit. The data channel connected to the data channel of the USB interface is selected through a data channel switching switch. This enables one USB port to program the software firmware of one main control module and one chip, and also enables the OTG function of connecting external USB devices to the main control module. This invention can realize the multiplexing of main control module firmware programming, chip firmware programming, and external device USB connection (OTG) through the USB interface. Attached Figure Description

[0027] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0028] Figure 1 This is a circuit block diagram of a USB interface multiplexing circuit according to an embodiment of the present invention;

[0029] Figure 2 This is a circuit schematic diagram of a USB interface multiplexing circuit according to an embodiment of the present invention;

[0030] Figure 3 This is a simulation diagram of a USB interface multiplexing circuit according to an embodiment of the present invention. Detailed Implementation

[0031] This section will describe in detail specific embodiments of the present invention. Preferred embodiments of the present invention are shown in the accompanying drawings. The purpose of the drawings is to supplement the textual description with graphics, so that people can intuitively and vividly understand each technical feature and overall technical solution of the present invention, but they should not be construed as limiting the scope of protection of the present invention.

[0032] In the description of this invention, it should be understood that the orientation descriptions, such as up, down, front, back, left, right, etc., are based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting this invention.

[0033] In the description of this invention, if there are words such as "several", they mean one or more, "multiple" means two or more, "greater than", "less than", "exceeding" etc. are understood to exclude the number itself, and "above", "below", "within" etc. are understood to include the number itself.

[0034] In the description of this invention, unless otherwise explicitly defined, terms such as "set up," "install," and "connect" should be interpreted broadly, and those skilled in the art can reasonably determine the specific meaning of the above terms in this invention in conjunction with the specific content of the technical solution.

[0035] refer to Figure 1 This invention provides a USB interface multiplexing circuit, including: a USB interface J1, a data channel switching switch U2, a main control module U1, a chip U3, a mode switching circuit 100, a data channel control circuit 200, and a power supply circuit 300.

[0036] The USB interface J1 is connected to the data channel switching switch U2, which is connected to the main control module U1 and the chip U3. The main control module U1 is also connected to the mode switching circuit 100. One end of the data channel control circuit 200 is connected to the mode switching circuit 100 and the power supply circuit 300, and the other end is connected to the data channel switching switch U2. The power supply circuit 300 is connected to the USB interface J1, the main control module U1, and the chip U3.

[0037] The power supply circuit 300 is used to supply power to the chip U3 when firmware is burned to the chip U3; to supply power to the main control module U1 when firmware is burned to the main control module U1 or OTG function is used; and to supply power to the external device when the main control module U1 is using OTG function and the main control module U1 is in HOST mode.

[0038] Specifically, since the HOST mode end supplies power to the DEVICE mode end, when the main control module U1 or chip U3 is in DEVICE mode and the USB interface J1 is used for firmware burning, the external device connected to the USB interface J1 supplies power to the main control module U1 or chip U3 through the power supply circuit 300; when the USB interface J1 is used to implement the OTG function, it supplies power to the external device through the power supply circuit 300; the functions of the USB interface J1 include firmware burning and OTG.

[0039] The mode switching circuit 100 is used to switch the working mode of the main control module U1 when the main control module U1 uses the OTG function; wherein, the working mode of the main control module U1 includes DEVICE mode and HOST mode;

[0040] Specifically, the mode switching circuit 100 controls the main control module U1 to switch between DEVICE mode and HOST mode; by controlling whether the main control module U1 is in DEVICE mode (firmware burning) or HOST mode (OTG), the mode switching circuit 100 enables the HOST mode / DEVICE mode switching of the USB interface J1.

[0041] It should be noted that the main control module U1 is the core of the USB interface multiplexing circuit. The main control module U1 supports HOST / DEVICE mode switching, meaning it supports connecting external USB devices. The chip U3 is a functional IC that supports firmware burning for the USB interface J1, such as a video conversion chip, audio / video conversion chip, or DP1.4 to HDMI2.0b converter chip (e.g., the Capstone CS5263 chip). When the chip U3 is working, for example, when firmware burning is required, the chip is in DEVICE mode.

[0042] The data channel control circuit 200 is used to trigger a switching signal to select the data channel of the main control module U1 to the data channel switching switch U2 when the power supply circuit 300 supplies power to the main control module U1; and to trigger a switching signal to select the data channel of the chip U3 to the data channel switching switch U2 when the power supply circuit 300 supplies power to the chip U3.

[0043] Specifically, when firmware flashing is required for chip U3, power supply circuit 300 determines that the power supply object is chip U3 and triggers a switching signal to connect the data channel of chip U3 with the data channel of USB interface J1; when OTG is required for main control module U1, power supply circuit 300 determines that the power supply object is main control module U1 and triggers a switching signal to connect the data channel of main control module U1 with the data channel of USB interface J1.

[0044] The data channel switching switch U2 is used to respond to the switching signal triggered by the data channel control circuit 200. When the power supply circuit 300 supplies power to the main control module U1, it selects the data channel of the main control module U1 to connect with the data channel of the USB interface J1; when the power supply circuit 300 supplies power to the chip U3, it selects the data channel of the chip U3 to connect with the data channel of the USB interface J1.

[0045] In other words, the data channel switching switch U2 determines whether the data channel of the USB interface J1 is connected to the data channel of the main control module U1 or the data channel of the chip U3.

[0046] It should be noted that the USB interface J1 comes in various forms, such as USB-A and Micro-USB, which have different shapes. USB 2.0 communication mainly uses the VBUS pin, DM pin, DP pin, and GND pin. Because Micro-USB has an additional ID pin compared to USB-A and other interfaces, this ID pin is left floating in the circuit for compatibility.

[0047] In the embodiments provided by this invention, when firmware is burned to chip U3, power is supplied to chip U3 through power supply circuit 300; when firmware is burned to main control module U1 or OTG function is used, power is supplied to main control module U1 through power supply circuit 300; when main control module U1 uses OTG function, if main control module U1 is in HOST mode, power is supplied to external devices through power supply circuit 300; when main control module U1 uses OTG function, mode switching circuit 100 switches the working mode of main control module U1 between DEVICE mode and HOST mode. The system switches between different modes. When the power supply circuit 300 supplies power to the main control module U1, the data channel switching switch U2 selects the data channel of the main control module U1 to connect with the data channel of the USB interface J1. When the power supply circuit 300 supplies power to the chip U3, the data channel switching switch U2 selects the data channel of the chip U3 to connect with the data channel of the USB interface J1. This enables software firmware burning for one main control module U1 and one chip U3 via a USB port, and enables the OTG function of connecting external USB devices to the main control module U1. In some embodiments, the data channel switching switch U2 is a SGM7227YMS10G / TR from Saint-Gobain Microelectronics, and the main control module U1 is a SIM8070 module from SIMCOM. Since the USB signal is a high-speed signal, the data channel switching switch U2 uses a dedicated chip U3 to switch channels, enabling the data channel of the USB interface J1 to connect with the data channel of the main control module U1 or the data channel of the chip U3. The S pin of the data channel switching switch U2 receives the switching signal from the data channel control circuit 200: when the S pin is high, H_DM, H_DP and DM, DP are connected; when the S pin is low, L_DM, L_DP and DM, DP are connected. OE is the enable pin, pulled low to enable.

[0048] refer to Figure 2 In some embodiments, the power supply circuit 300 includes: a power supply VCC_SOC, a power switch U4, a voltage regulator U5, a single-pole double-throw switch SWITCH, and a thirteenth resistor R3;

[0049] The power supply VCC_SOC is connected to the VCC pin of the main control module U1. The enable pin EN of the power switch U4 is connected to the GPIO pin of the main control module U1. One end of the thirteenth resistor R3 is connected to the VBUS pin of the main control module U1. The other end of the thirteenth resistor R3, the output pin OUT of the power switch U4, and one end of the data channel control circuit 200 are all connected to the mode switching circuit 100. The other end of the thirteenth resistor R3 is also connected to the first stationary pin 31 of the single-pole double-throw switch SWITCH. The second stationary pin 21 of the single-pole double-throw switch SWITCH is connected to the VCC pin of the chip U3. The moving pin 1 of the single-pole double-throw switch SWITCH is connected to the VBUS pin of the USB interface J1 through the VBUS line.

[0050] In this embodiment, the single-pole double-throw switch (SWITCH) is used to switch the path of the VBUS line. When it is necessary to flash the firmware of the chip U3, the SWITCH is switched to the second stationary terminal 21, so that the moving terminal 1 and the second stationary terminal 21 are connected. When it is necessary to flash the firmware of the main control module U1 or use the OTG function, the SWITCH is switched to the first stationary terminal 31, so that the moving terminal 1 and the first stationary terminal 31 are connected.

[0051] In some embodiments, a voltage regulator U5 is provided between the second stationary terminal 21 of the single-pole double-throw switch and the VCC pin of the chip U3.

[0052] In one embodiment, the input terminal IN of the power switch U4 is connected to a voltage of 5V, and the power supply VCC_SOC provides power to the main control module U1 at a voltage of 5V; the power supply VCC_SOC and the power switch U4 are always present. When the VCC pin of the chip U3 requires 5V power, it can be directly connected to the second stationary terminal 21 of the single-pole double-throw switch SWITCH; when the VCC of the chip U3 requires 3.3V or other voltages, a voltage regulator U5 needs to be added to step down the voltage. The second stationary terminal 21 of the single-pole double-throw switch SWITCH is connected to the input terminal IN of the voltage regulator U5, and the VCC of the chip U3 is connected to the output terminal OUT of the voltage regulator U5. The voltage regulator U5 can be a ME6211C33M5G / 500mA from Microlink, or an SGM2028-3.3 from Saint-Gobain, etc.

[0053] In some embodiments, when the main control module U1 uses the OTG function, it responds to a user-triggered switching action. If the switching action is to switch the operating mode of the main control module U1 to DEVICE mode through the mode switching circuit 100, then the ID pin of the main control module U1 is triggered to a high level, so that the main control module U1 is in DEVICE mode, and the GPIO pin of the main control module U1 is triggered to be pulled low, so that the power switch U4 is turned off. If the switching action is to switch the operating mode of the main control module U1 to HOST mode through the mode switching circuit 100, then the ID pin of the main control module U1 is triggered to a low level, so that the main control module U1 is in DEVICE mode, and the GPIO pin of the main control module U1 is triggered to be pulled high, so that the power switch U4 is turned off.

[0054] In this embodiment, power switch U4 is used by the main control module U1 to supply power to external devices via the USB interface multiplexing circuit when the OTG function is used. The main control module U1 controls whether power switch U4 outputs power. When the main control module U1 is in DEVICE mode, power switch U4 is off with no output, effectively preventing backflow voltage from external devices into the USB interface multiplexing circuit via the VBUS line. When the main control module U1 is in HOST mode, power switch U4 is on, supplying power to external devices.

[0055] When the ID pin of the main control module U1 is high, it is in DEVICE mode; when the ID pin is low, it is in HOST mode. In DEVICE mode, it also checks if the VBUS pin is high; if it is, it pulls the DP pin high. The GPIO pins of the main control module U1 are initially low upon power-up (before the USB interface multiplexing circuit starts operating): when the main control module U1 is in HOST mode, the GPIO pins are pulled high; when the main control module U1 is in DEVICE mode, the GPIO pins are pulled low. When the main control module U1 is in HOST mode, the current flowing into the VBUS pin of the main control module U1 is limited by the thirteenth resistor R3, thereby controlling the power switch U4 to supply power to external devices via the GPIO pin.

[0056] In some embodiments, the mode switching circuit 100 includes: a first resistor R1, a second resistor R2, a fifth resistor R5, a sixth resistor R6, a seventh resistor R7, an eighth resistor R8, a ninth resistor R9, a tenth resistor R10, an eleventh resistor R11, a twelfth resistor R12, a first capacitor C1, a second capacitor C2, a transistor Q2, a MOSFET Q1, and a tactile switch SW1.

[0057] One end of the first resistor R1 and one end of the second resistor R2 are connected to the ID pin of the main control module U1. The other end of the first resistor R1 is grounded. The other end of the second resistor R2 is connected to the drain of the MOSFET Q1 and one end of the sixth resistor R6. The two ends of the eighth resistor R8 are connected to the gate and source of the MOSFET Q1, respectively. The gate of the MOSFET Q1 is connected to one end of the twelfth resistor R12. The other end of the twelfth resistor R12 is connected to the collector of the transistor Q2. The other end of the sixth resistor R6 is connected to one end of the tactile switch SW1, one end of the ninth resistor R9, one end of the second capacitor C2, and the base of the transistor Q2. The other end of the tactile switch SW1 is connected to one end of the fifth resistor R5, one end of the first capacitor C1, and one end of the tenth resistor R10. The other end of the fifth resistor R5 is connected to one end of the data channel control circuit 200, the output terminal OUT of the power switch U4, the other end of the thirteenth resistor R3, and the first stationary terminal 31 of the single-pole double-throw switch SWITCH. The other end of the first capacitor C1, the other end of the ninth resistor R9, the other end of the first capacitor C1, and the emitter of the transistor Q2 are all connected to one end of the eleventh resistor R11. The other ends of the tenth resistor R10 and the other ends of the eleventh resistor R11 are all grounded.

[0058] In one embodiment, the MOS transistor Q1 is a P-channel MOS transistor, with the source of the MOS transistor Q1 connected to the power input and the drain serving as the output terminal OUT connected to the load.

[0059] The working principle of the mode switching circuit 100 is as follows:

[0060] Upon power-up of the USB interface multiplexing circuit, the power input terminal IN forms a charging circuit for the first capacitor C1 via the fifth resistor R5, the first capacitor C1, and the eleventh resistor R11. A voltage difference exists across the first capacitor C1 (A positive, B negative), Vab ≈ 1.2V. At this time, transistor Q2's Vbe = 0, indicating it is in the off state, and MOSFET Q1's Vgs = 0, also indicating it is in the off state. The drain output terminal OUT of MOSFET Q1 has no voltage output. Simultaneously, the ID pin of the main control module U1 is pulled low to ground by the first resistor R1, indicating it is in HOST mode.

[0061] When the tactile switch SW1 is pressed briefly, the first capacitor C1, the tactile switch SW1, and the ninth resistor R9 form the discharge circuit of the first capacitor C1. Figure 2(As shown in the clockwise direction), current flows through the ninth resistor R9, creating a voltage difference across it. The Vbe of transistor Q2 equals the voltage across the ninth resistor R9. Since both Vbe of transistor Q2 and the voltage across the ninth resistor R9 are approximately 0.6V, transistor Q2 is turned on. After transistor Q2 is turned on, the power input terminal IN5V forms a path through the eighth resistor R8, the twelfth resistor R12, transistor Q2, and the eleventh resistor R11, generating a voltage drop across the eighth resistor R8. This causes Vgs of MOSFET Q1 to be less than Vgs(th) and less than 0, turning MOSFET Q1 on. The drain output voltage of MOSFET Q1 is approximately 5V. At this time, after voltage division by the second resistor R2 and the first resistor R1, the ID pin of the main control module U1 is pulled high, entering DEVICE mode.

[0062] When the tactile switch SW1 is released, the 5V output voltage of MOSFET Q1 forms a circuit through the sixth resistor R6, the ninth resistor R9, and the eleventh resistor R11. According to the superposition theorem, the voltage of the eleventh resistor R11 is about 1.2V, the voltage of the ninth resistor R9 is about 1.8V, and the Vbe of transistor Q2 is about 0.6V, ensuring that transistor Q2 is turned on and realizing the self-locking of mode switching circuit 100.

[0063] When the tactile switch SW1 is pressed again, the second capacitor C2, the ninth resistor R9, and the tactile switch SW1 form the discharge circuit of the second capacitor C2. Figure 2 (As shown in the counterclockwise direction), at this time the base of transistor Q2 ( Figure 2 As shown at point C, the voltage is pulled low, the voltage Vbe between the BE of transistor Q2 is <0.6V, transistor Q2 is cut off, there is no voltage difference across the eighth resistor R8, MOSFET Q1 is also cut off, the drain of MOSFET Q1 has no output and is pulled low, the ID pin of the main control module U1 is pulled low, which is the HOST mode.

[0064] When the tactile switch SW1 is released again, the power input terminal IN, through resistor R5 (the fifth resistor), capacitor C1 (the first capacitor), and resistor R11 (the eleventh resistor), forms a charging circuit for capacitor C1, recharging capacitor C1. A voltage difference exists across capacitor C1. Figure 2 (Point A is shown as positive, and point B as negative), Vab≈1.2V. Pressing the button again will repeat the circuit operation.

[0065] It should be noted that the tactile switch SW1 is also called a push-button switch. When in use, pressure is applied in the direction of operation to close the switch and turn it on. When the pressure is released, the switch turns off. Its internal structure relies on the change of force on the metal spring to achieve the on and off state.

[0066] In this embodiment, the HOST mode / DEVICE mode switching of the main control module U1 is realized through the mode switching circuit 100. The mode switching circuit 100 uses MOSFET Q1 as the output, which has strong load-carrying capacity and can adapt to different equivalent load resistances.

[0067] In some embodiments, the mode switching circuit 100 further includes: a seventh resistor R7 and a light-emitting diode ED1, one end of the seventh resistor R7 being connected to the other end of the second resistor R2, the drain of the MOS transistor Q1, and one end of the sixth resistor R6; the other end of the seventh resistor R7 being connected to the anode of the light-emitting diode ED1, and the cathode of the light-emitting diode ED1 being grounded.

[0068] In this embodiment, when the ID pin of the main control module U1 is pulled low to ground by the first resistor R1 and is in HOST mode, the LED ED1 is off; when the ID pin of the main control module U1 is pulled high and is in DEVICE mode, the LED ED1 is on. The LED ED1 can serve as an indicator light for the main control module U1 in HOST mode / DEVICE mode, which is clear and easy to observe and use.

[0069] In some embodiments, the data channel control circuit 200 includes a third resistor R3 and a fourth resistor R4. One end of the fourth resistor R4 is connected to the source of the MOS transistor Q1, one end of the eighth resistor R8, the other end of the fifth resistor R5, the first stationary terminal 31 of the single-pole double-throw switch SWITCH, the other end of the thirteenth resistor R3, and the output terminal OUT of the power switch U4. The other end of the fourth resistor R4 is connected to one end of the third resistor R3 and the S pin of the data channel switching switch U2. The other end of the third resistor R3 is grounded.

[0070] In this embodiment, the data channel control circuit 200 is used for switching data channels. When firmware flashing of chip U3 is required, when the single-pole double-throw switch SWITCH is in the second fixed terminal 21 and the moving terminal 1 is on, the S pin of the data channel switching switch U2 is pulled low by the third resistor R3, and the data channel of USB interface J1 is connected to the data channel of chip U3; when the single-pole double-throw switch SWITCH is in the first fixed terminal 31 and the moving terminal 1 is on, the third resistor R3 and the fourth resistor R4, after voltage division, pull the S pin of the data channel switching switch U2 high, and the data channel of USB interface J1 is connected to the data channel of the main control module U1.

[0071] This invention achieves automatic switching of the USB data channel in hardware by switching the VBUS line channel using a single-pole double-throw switch (SWITCH) and using pull-up and pull-down resistors (R3 and R4). This eliminates the need for software intervention and ensures high reliability. It is particularly suitable for products using an external monitoring chip U3, where the USB interface multiplexing circuit logs are stored. Since the USB interface multiplexing circuit logs are not stored internally in the main control module U1, but are instead stored by the external monitoring chip U3, all logs of the USB interface multiplexing circuit's operation can be retrieved. When the USB interface multiplexing circuit malfunctions or freezes, problem analysis is performed by reading the logs stored in the external monitoring chip U3, greatly improving the efficiency of problem analysis.

[0072] The working principle of the USB interface multiplexing circuit provided in this embodiment of the invention is as follows:

[0073] (1) Set the single-pole double-throw switch SWITCH to the second stationary terminal 21. The second stationary terminal 21 and the moving terminal 1 are connected. Insert the USB data cable. External devices (such as computers) supply power to the data channel switching switch U2 and the chip U3 through the VBUS pin.

[0074] (2) If the VCC pin of chip U3 supports 5V power supply, the VBUS line of USB interface J1 can be used to supply 5V power to chip U3 directly. The second stationary terminal 21 of the single-pole double-throw switch SWITCH and the VCC pin of chip U3 are physically connected directly, and there is no need to add voltage regulator U5. If the VCC pin of chip U3 uses 3.3V or other power supply voltage, a voltage regulator U5 needs to be added between the second stationary terminal 21 of the single-pole double-throw switch SWITCH and the VCC pin of chip U3.

[0075] (3) At this time, the S pin of the data channel switching switch U2 is pulled down to ground by the third resistor R3, and is at a low level. The data channel of the USB interface J1 is connected to the data channel of the chip U3, so the firmware of the chip U3 can be burned.

[0076] (4) Set the single-pole double-throw switch SWITCH to the first stationary terminal 31. The first stationary terminal 31 and the moving terminal 1 are connected. At this time, transistor Q2 is cut off and MOSFET Q1 is cut off. The ID pin of the main control module U1 is at a low level. Insert the USB data cable. The 5V voltage on the VBUS line pulls the S pin of the data channel switching switch U2 high, and the data channel of the USB interface J1 is connected to the data channel of the main control module U1.

[0077] (5) The 5V voltage on the VBUS line supplies power to the mode switching circuit 100. After briefly pressing the tactile switch SW1 and releasing it, the first capacitor C1 discharges through the discharge circuit composed of the tactile switch SW1 and the ninth resistor R9, and generates a voltage drop across the ninth resistor R9. The voltage difference Vba across the first capacitor C1 is approximately 1.2V, which is greater than the BE conduction voltage drop of 0.6V between the transistor Q2, causing the transistor Q2 to conduct. Subsequently, the MOSFET Q1 conducts, and the ID pin of the main control module U1 is pulled high. The main control module U1 is in DEVICE mode, and the LED ED1 lights up.

[0078] (6) The circuit formed by the sixth resistor R6, the ninth resistor R9, and the eleventh resistor R11 keeps the circuit self-locking.

[0079] (7) Since the VBUS pin of the main control module U1 is also pulled high to 5V of the external VBUS line, the main control module U1 pulls DP high and starts enumeration, so the firmware of the main control module U1 can be burned.

[0080] (8) After the firmware of the main control module U1 and the chip U3 is burned, when there is no need to burn the firmware of the chip U3, the single-pole double-throw switch SWITCH is switched to the first stationary terminal 31 by default, so that the first stationary terminal 31 and the moving terminal 1 are kept connected.

[0081] (9) Press the tactile switch SW1 briefly again and release it. The second capacitor C2, the ninth resistor R9, and the tactile switch SW1 form the discharge circuit of the second capacitor C2. Figure 2 (In the counterclockwise direction shown), the voltage at point C is pulled low, the voltage between the BE of transistor Q2 is Vbe < 0.6V, transistor Q2 is cut off, there is no voltage difference across the eighth resistor R8, MOSFET Q1 is also cut off, pin 3 of MOSFET Q1 has no output and is pulled low, the ID pin of the main control module U1 is pulled low, it is in HOST mode, and the LED ED1 is off.

[0082] (10) When the touch switch SW1 is pressed again, the circuit repeats the action of step (5);

[0083] (11) After the USB interface multiplexing circuit is powered on, when the USB interface multiplexing circuit detects that it is in HOTS mode, the software pulls the GPIO pin high, the power switch U4 is turned on, and the power supply is supplied to the outside through the power switch U4, the single-pole double-throw switch SWITCH, and the VBUS line.

[0084] (12) When the power switch U4 outputs 5V, it also pulls the S pin of the data channel switching switch U2 high, and the data channel of the USB interface J1 is connected to the data channel of the main control module U1, so that the OTG function of the main control module U1 can be realized.

[0085] (13) Due to the presence of the twelfth resistor R12 and the appropriate resistance value of the twelfth resistor R12 (the resistance value is much higher than the equivalent load resistance of the external USB device), the current flowing into the VBUS pin of the main control module U1 will be very small, the energy loss of the power switch U4 on the twelfth resistor R12 will also be very small, and almost all the energy of the power switch U4 will flow to the external USB device.

[0086] (14) When the USB interface multiplexing circuit is powered off and then powered on again, the MOS transistor Q1 in the mode switching circuit 100 is not turned on by default, and the main control module U1 is in HOST mode for connecting external USB devices.

[0087] By repeatedly pressing the tactile switch SW1, the host mode / devotion mode of the main control module U1 can be switched. This enables the three-in-one multiplexing function of the USB interface J1.

[0088] refer to Figure 3 , Figure 3 This is a schematic diagram of the simulation results of the USB interface multiplexing circuit provided by the present invention. The simulation results show that it conforms to the above theoretical analysis. Specifically, a voltage-controlled switch is used to simulate the button action of the tactile switch SW1. The dashed line represents the characteristic curve of the voltage-controlled switch: the rising edge represents the button being pressed, the falling edge represents the button being released, the high-level pulse width of 2 seconds represents the button pressing duration (debouncing), and the low-level pulse width of 4 seconds represents the button releasing time. Each cycle (2 seconds high level + 4 seconds low level) represents one button press and release, and this process repeats. The solid line represents the output voltage curve of the MOSFET Q1. Figure 3 It can be seen that the output voltage of MOSFET Q1 flips with each rising edge of the tactile switch SW1, that is, the output voltage state flips once every time the switch is pressed and released.

[0089] Furthermore, embodiments of the present invention provide a control method for a USB interface multiplexing circuit, applied to the USB interface multiplexing circuit described in any of the above embodiments, the method comprising the following steps:

[0090] Step S100: Determine the operating mode of the USB interface multiplexing circuit; the operating modes of the USB interface multiplexing circuit include: firmware burning of chip U3, firmware burning of main control module U1, and OTG function of main control module U1.

[0091] Step S200: Determine the power supply target of the power supply circuit 300 based on the working mode of the USB interface multiplexing circuit, and control the power supply circuit 300 to supply power to the power supply target; wherein, the power supply target includes chip U3 and main control module U1. When firmware is burned to chip U3, the power supply circuit 300 supplies power to chip U3; when firmware is burned to main control module U1 or OTG function is used, the power supply circuit 300 supplies power to main control module U1.

[0092] Step S300: When the power supply circuit 300 supplies power to the main control module U1, the data channel control circuit 200 triggers a switching signal to the data channel switching switch U2 to select the data channel of the main control module U1; when the power supply circuit 300 supplies power to the chip U3, the data channel control circuit 200 triggers a switching signal to the data channel switching switch U2 to select the data channel of the chip U3.

[0093] Step S400: In response to the switching signal triggered by the data channel control circuit 200, when the power supply circuit 300 supplies power to the main control module U1, the data channel switching switch U2 selects the data channel of the main control module U1 to connect with the data channel of the USB interface J1; when the power supply circuit 300 supplies power to the chip U3, the data channel switching switch U2 selects the data channel of the chip U3 to connect with the data channel of the USB interface J1.

[0094] Step S500: When the main control module U1 uses the OTG function, it responds to the user-triggered switching action and switches the working mode of the main control module U1 through the mode switching circuit 100; wherein, the working mode of the main control module U1 includes DEVICE mode and HOST mode.

[0095] Although the description of this invention has been quite detailed and particularly focused on several of the described embodiments, it is not intended to limit it to any of these details or embodiments or any particular embodiment. Rather, it should be considered as effectively covering the intended scope of this disclosure by referring to the appended claims and taking into account the broad possible interpretations of these claims provided by the prior art. Furthermore, the invention has been described above with regard to embodiments foreseeable by the inventors in order to provide a useful description, and non-substantial modifications to the invention that have not yet been foreseen may still represent equivalent modifications to this disclosure.

Claims

1. A USB interface multiplexing circuit, characterized in that, include: USB interface, data channel switching switch, main control module, chip, mode switching circuit, data channel control circuit and power supply circuit; The USB interface is connected to the data channel switching switch, which is connected to the main control module and the chip respectively. The main control module is also connected to the mode switching circuit. One end of the data channel control circuit is connected to the mode switching circuit and the power supply circuit respectively, and the other end of the data channel control circuit is connected to the data channel switching switch. The power supply circuit is connected to the USB interface, the main control module, and the chip respectively; The power supply circuit is used to supply power to the chip when firmware is burned to the chip; to supply power to the main control module when firmware is burned to the main control module or the OTG function is used; and to supply power to external devices when the main control module is using the OTG function and the main control module is in HOST mode. The mode switching circuit is used to switch the operating mode of the main control module when the main control module uses the OTG function; wherein, the operating mode of the main control module includes DEVICE mode and HOST mode; The data channel control circuit is used to trigger a switching signal to select the data channel of the main control module when the power supply circuit supplies power to the main control module; and to trigger a switching signal to select the data channel of the chip when the power supply circuit supplies power to the chip. The data channel switching switch is used to respond to the switching signal triggered by the data channel control circuit. When the power supply circuit supplies power to the main control module, it selects the data channel of the main control module to connect with the data channel of the USB interface; when the power supply circuit supplies power to the chip, it selects the data channel of the chip to connect with the data channel of the USB interface. The power supply circuit includes: a power supply, a power switch, a voltage regulator, a single-pole double-throw switch, and a thirteenth resistor; The power supply is connected to the VCC pin of the main control module, the enable pin of the power switch is connected to the GPIO pin of the main control module, one end of the thirteenth resistor is connected to the VBUS pin of the main control module, the other end of the thirteenth resistor, the output terminal of the power switch, and one end of the data channel control circuit are all connected to the mode switching circuit, the other end of the thirteenth resistor is also connected to the first stationary terminal of the single-pole double-throw switch, the second stationary terminal of the single-pole double-throw switch is connected to the VCC pin of the chip, and the moving terminal of the single-pole double-throw switch is connected to the VBUS pin of the USB interface through the VBUS line.

2. The USB interface multiplexing circuit according to claim 1, characterized in that, A voltage regulator is provided between the second stationary terminal of the single-pole double-throw switch and the VCC pin of the chip.

3. The USB interface multiplexing circuit according to claim 1, characterized in that, When the main control module uses the OTG function, it responds to user-triggered switching actions. If the switching action is to switch the main control module's operating mode to DEVICE mode via the mode switching circuit, the ID pin of the main control module is triggered to a high level, putting the main control module in DEVICE mode, and the GPIO pin of the main control module is pulled low, turning off the power switch. If the switching action is to switch the main control module's operating mode to HOST mode via the mode switching circuit, the ID pin of the main control module is triggered to a low level, putting the main control module in DEVICE mode, and the GPIO pin of the main control module is pulled high, turning off the power switch.

4. A USB interface multiplexing circuit according to claim 1, characterized in that, The mode switching circuit includes: a first resistor, a second resistor, a fifth resistor, a sixth resistor, a seventh resistor, an eighth resistor, a ninth resistor, a tenth resistor, an eleventh resistor, a twelfth resistor, a first capacitor, a second capacitor, a transistor, a MOSFET, and a tactile switch; One end of the first resistor and one end of the second resistor are connected to the ID pin of the main control module. The other end of the first resistor is grounded. The other end of the second resistor is connected to the drain of the MOSFET and one end of the sixth resistor. The two ends of the eighth resistor are connected to the gate and source of the MOSFET. The gate of the MOSFET is connected to one end of the twelfth resistor. The other end of the twelfth resistor is connected to the collector of the transistor. The other end of the sixth resistor is connected to one end of the tactile switch, one end of the ninth resistor, one end of the second capacitor, and the base of the transistor. The other end of the tactile switch is connected to one end of the fifth resistor, one end of the first capacitor, and one end of the tenth resistor. The other end of the fifth resistor is connected to one end of the data channel control circuit, the output terminal of the power switch, the other end of the thirteenth resistor, and the first stationary terminal of the single-pole double-throw switch. The other ends of the first capacitor, the ninth resistor, the second capacitor, and the emitter of the transistor are connected to one end of the eleventh resistor. The other ends of the tenth resistor and the eleventh resistor are grounded.

5. A USB interface multiplexing circuit according to claim 4, characterized in that, The mode switching circuit further includes a seventh resistor and a light-emitting diode. One end of the seventh resistor is connected to the other end of the second resistor, the drain of the MOS transistor, and one end of the sixth resistor. The other end of the seventh resistor is connected to the anode of the light-emitting diode, and the cathode of the light-emitting diode is grounded.

6. A USB interface multiplexing circuit according to claim 4, characterized in that, The data channel control circuit includes a third resistor and a fourth resistor. One end of the fourth resistor is connected to the source of the MOS transistor, one end of the eighth resistor, the other end of the fifth resistor, the first stationary terminal of the single-pole double-throw switch, the other end of the thirteenth resistor, and the output terminal of the power switch. The other end of the fourth resistor is connected to one end of the third resistor and the S-pin of the data channel switching switch. The other end of the third resistor is grounded.

7. A control method for a USB interface multiplexing circuit, applied to the USB interface multiplexing circuit according to any one of claims 1 to 6, characterized in that, The method includes the following steps: Step S100: Determine the operating mode of the USB interface multiplexing circuit; the operating modes of the USB interface multiplexing circuit include: firmware flashing of the chip, firmware flashing of the main control module, and the main control module using the OTG function; Step S200: Determine the power supply target of the power supply circuit based on the working mode of the USB interface multiplexing circuit, and control the power supply circuit to supply power to the power supply target; wherein, the power supply target includes a chip and a main control module. When firmware is burned to the chip, the power supply circuit supplies power to the chip; when firmware is burned to the main control module or the OTG function is used, the power supply circuit supplies power to the main control module. Step S300: When the power supply circuit supplies power to the main control module, the data channel control circuit triggers a switching signal to select the data channel of the main control module to the data channel switching switch; when the power supply circuit supplies power to the chip, the data channel control circuit triggers a switching signal to select the data channel of the chip to the data channel switching switch. Step S400: In response to the switching signal triggered by the data channel control circuit, when the power supply circuit supplies power to the main control module, the data channel switching switch selects the data channel of the main control module to connect with the data channel of the USB interface; when the power supply circuit supplies power to the chip, the data channel switching switch selects the data channel of the chip to connect with the data channel of the USB interface. Step S500: When the main control module uses the OTG function, it responds to the user-triggered switching action and switches the working mode of the main control module through the mode switching circuit; wherein, the working mode of the main control module includes DEVICE mode and HOST mode.