Master-slave device mode switching circuit and working method thereof
By introducing a switching circuit into the terminal processor and using OTG switching instructions to drive the switching module and resistors, the problem of mobile terminals needing special OTG data cables to switch to master device mode is solved. This enables master-slave mode switching with ordinary USB data cables, reducing user costs and improving user experience.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING ZHONGHANG WORLDWIDE ELECTRONIC TECH CO LTD
- Filing Date
- 2022-07-11
- Publication Date
- 2026-06-16
AI Technical Summary
Existing mobile terminals require a special OTG cable to switch to host mode via their USB interface, which increases user costs.
A switching circuit is introduced into the terminal processor, and the switching module and resistor are driven by OTG switching instructions to realize automatic switching between master and slave device modes.
Switching between master and slave modes on mobile devices can be achieved without an additional OTG cable, reducing data cable costs for users and improving user experience.
Smart Images

Figure CN115185863B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electronic technology, and in particular to a master-slave device mode switching circuit and its operating method. Background Technology
[0002] Currently, mobile terminals such as smartphones and tablets are widely used, and USB interfaces are also widely used in electronic devices such as mobile terminals, becoming one of the standard interfaces for electronic devices. However, in using the existing technology, the inventors have discovered at least the following problems:
[0003] The default state of the USB interface of existing mobile terminals is usually slave mode. If you want to switch to master mode to read slave devices such as USB flash drives, you must insert a special OTG (On-The-Go, a technology for USB device connection or data exchange published by the USB standardization organization) data cable into the mobile terminal through the USB interface to enter master mode. This means that the mobile terminal needs to use two data cables to switch between master and slave modes. The cables are not interchangeable, which increases the cost for users. Summary of the Invention
[0004] The present invention aims to solve the above-mentioned technical problems to at least a certain extent, and provides a master-slave device mode switching circuit and its working method.
[0005] The technical solution adopted in this invention is:
[0006] In a first aspect, the present invention provides a master-slave device mode switching circuit, including a USB interface electrically connected to a terminal processor, and a switch circuit electrically connected to the terminal processor; the switch circuit includes a switch module and a resistor, the controlled terminal of the switch module is electrically connected to the control terminal of the terminal processor, one end of the switch of the switch module is electrically connected to the detection terminal of the terminal processor through the resistor, and the other end of the switch of the switch module is grounded.
[0007] In this invention, the switching circuit can be driven by the OTG switch command obtained by the terminal processor, so that the terminal processor can determine whether the pull-down resistor corresponding to the switching circuit is detected, and then switch the master-slave device mode of the host corresponding to the terminal processor. This facilitates the mobile terminal to switch between master-slave device modes. Thus, even when using a regular USB data cable, the mobile terminal can easily enter the master device mode, which helps to save data cable application costs, provides a good user experience, and has the value of widespread application.
[0008] In one possible design, the switching module uses an N-channel MOSFET, the gate of the switching module is electrically connected to the control terminal of the terminal processor, the drain of the switching module is electrically connected to the detection terminal of the terminal processor through the resistor, and the source of the switching module is grounded.
[0009] In one possible design, the resistor has a resistance of 5.1 kΩ.
[0010] In one possible design, the terminal processor is an XY6763 processor.
[0011] In one possible design, the switching circuit is provided in two sets.
[0012] Secondly, the present invention provides a method for operating a master-slave device mode switching circuit, comprising:
[0013] The terminal processor acquires the OTG switch command;
[0014] The terminal processor drives the switching circuit to operate according to the OTG switch command, so that the terminal processor can determine whether the pull-down resistor corresponding to the switching circuit is detected, and then switch the master-slave device mode of the host corresponding to the terminal processor.
[0015] In one possible design, the OTG switch command includes an OTG enable command;
[0016] When the OTG switch instruction obtained by the terminal processor is an OTG enable instruction, the terminal processor sends a high level to the controlled terminal of the switch module according to the OTG enable instruction;
[0017] When the switch of the switching module is turned on, the terminal processor detects the pull-down resistor;
[0018] The terminal processor controls the host corresponding to the terminal processor to enter the master device mode.
[0019] In one possible design, the OTG switch command includes an OTG disconnect command;
[0020] When the OTG switch command obtained by the terminal processor is an OTG disconnect command, the terminal processor sends a low level to the controlled terminal of the switch module according to the OTG disconnect command;
[0021] The switch of the switching module is off, and the terminal processor does not detect the pull-down resistor;
[0022] The terminal processor controls the host corresponding to the terminal processor to enter slave device mode. Attached Figure Description
[0023] Figure 1 This is a circuit schematic diagram of the terminal processor in a master-slave device mode switching circuit of the present invention;
[0024] Figure 2 This is a circuit diagram of the switching circuit in a master-slave device mode switching circuit of the present invention;
[0025] Figure 3 This is a circuit schematic diagram of the USB interface in a master-slave device mode switching circuit of the present invention;
[0026] Figure 4 This is a flowchart illustrating the operation method of a master-slave device mode switching circuit in this invention. Detailed Implementation
[0027] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0028] It should be understood that although the terms first, second, etc., may be used herein to describe various units, these units should not be limited by these terms. These terms are only used to distinguish one unit from another. For example, a first unit may be referred to as a second unit, and similarly, a second unit may be referred to as a first unit, without departing from the scope of the exemplary embodiments of the invention.
[0029] It should be understood that the term "and / or" that may appear in this article is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, B exists alone, and A and B exist simultaneously.
[0030] It should be understood that when a unit is referred to as "connected", "linked" or "coupled" to another unit in this document, it can be directly connected or coupled to another unit, or an intermediate unit may exist.
[0031] It should be understood that the terminology used herein is for describing particular embodiments only and is not intended to limit the exemplary embodiments of the invention. Where used herein, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that when the terms “comprising,” “including,” “containing,” and / or “including” are used herein, they specify the presence of the stated features, integers, steps, operations, units, and / or components, and do not exclude the presence or addition of one or more other features, quantities, steps, operations, units, components, and / or combinations thereof.
[0032] Example 1:
[0033] The second aspect of this embodiment provides a master-slave device mode switching circuit, including a USB interface electrically connected to a terminal processor, and a switch circuit electrically connected to the terminal processor; the switch circuit includes a switch module and a resistor, the controlled terminal of the switch module is electrically connected to the control terminal of the terminal processor, one end of the switch of the switch module is electrically connected to the detection terminal of the terminal processor through the resistor, and the other end of the switch of the switch module is grounded.
[0034] In this embodiment, the terminal processor can be a processor corresponding to existing mobile terminals such as mobile phones and tablets, and is not limited here. As an example, the circuit schematic of the terminal processor in this embodiment is as follows: Figure 1 As shown, the terminal processor uses an XY6763 processor. It should be understood that when using an XY6763 processor, the GPIO (General Purpose Input / Output) pins of the terminal processor are control terminals, electrically connected to the controlled terminals of the switch module, to output high and low levels to the controlled terminals of the switch module and to read the high and low levels output by the switch module. The Type-C pins of the terminal processor are detection terminals, electrically connected to the resistor. As an example, in this embodiment, the GPIO71 pin of the terminal processor is used as a control terminal and electrically connected to the controlled terminals of the switch module. In actual applications, the controlled terminals of the switch module can be configured with any GPIO pin of the terminal processor.
[0035] It should be noted that the MT6763 processor is a high-performance 4G smart module based on the MediaTek MT6763 platform, capable of running the Android operating system. It supports multiple standards such as LTE-FDD / LTE-TDD / WCDMA / TD-SCDMA / EVDO / CDMA / GSM; it supports WiFi communication, BT4.0LE short-range wireless communication, and GPS / GLONASS / BeiDou satellite positioning; it also supports multiple voice and audio codecs, and integrates an ARM Mali G71 MP2 770MHz high-performance graphics engine, which can smoothly play 4K video. It also has multiple audio and video input / output interfaces and rich GPIO interfaces.
[0036] The switching circuit includes a switching module and a resistor. The switching module may, but is not limited to, using switching components such as MOSFETs (Metal-O-Metal Transistors) or transistors. When a transistor is used, the base of the transistor is electrically connected to the control terminal of the terminal processor, the collector of the transistor is electrically connected to the detection terminal of the terminal processor through the resistor, and the emitter of the transistor is grounded.
[0037] Specifically, in this embodiment, the circuit diagram of the switching circuit is as follows: Figure 2 As shown, the switching module uses an N-channel MOSFET. The gate of the switching module is electrically connected to the control terminal of the terminal processor, and the drain of the switching module is electrically connected to the detection terminal of the terminal processor through the resistor. The source of the switching module is grounded. It should be understood that when the switching module uses an N-channel MOSFET, the gate of the switching module is the controlled terminal, and the drain and source of the switching module are the two ends of the switch. The resistor has a resistance of 5.1 kΩ.
[0038] Furthermore, in this embodiment, two sets of switching circuits are provided, and the controlled terminals of the switching modules in both sets of switching circuits are electrically connected to the same control terminal of the terminal processor. Specifically, in this embodiment, one set of switching circuits includes a first switching module Q1 and a first resistor R1, and the other set of switching circuits includes a second switching module Q2 and a second resistor R2. The first switching module Q1 and the second switching module Q2 can be, but are not limited to, using switching components such as MOSFETs or transistors. In this embodiment, both the first switching module Q1 and the second switching module Q2 are N-channel MOSFETs. Specifically, the gate of the first switching module Q1 and the gate of the second switching module Q2 are both electrically connected to the control terminal of the terminal processor corresponding to the mobile terminal. The drain of the first switching module Q1 is electrically connected to the detection terminal of the terminal processor through the first resistor R1, and the source of the first switching module Q1 is grounded. The drain of the second switching module Q2 is electrically connected to the detection terminal of the terminal processor through the second resistor R2, and the source of the second switching module Q2 is grounded.
[0039] In this embodiment, when the terminal processor receives the OTG switch command, it can transmit a high level or a low level to the controlled end of the switch module through its control terminal, so as to switch the master-slave device mode of the host corresponding to the terminal processor. Specifically, the OTG switch command includes an OTG enable command and an OTG disable command. When the terminal processor receives an OTG enable command, its control terminal is pulled high, the gate of the switch module is at a high level, the drain and source of the switch module are connected, the detection terminal of the terminal processor is grounded through a resistor, and the terminal processor detects a 5.1KΩ pull-down resistor. At this time, the terminal processor controls the host corresponding to the terminal processor to enter master device mode, so that the host can read data from the slave device connected to the terminal processor via the USB interface. Conversely, when the terminal processor receives an OTG disable command, its control terminal is pulled low, the gate of the switch module is at a low level, the drain and source of the switch module are disconnected, and the detection terminal of the terminal processor cannot detect the 5.1KΩ pull-down resistor. At this time, the terminal processor controls the host corresponding to the terminal processor to enter slave device mode, so that the host data can be read by other master devices connected to the terminal processor via the USB interface.
[0040] The circuit schematic of the USB interface is as follows: Figure 3 As shown, it can be used to connect to host devices such as laptops or desktop computers, as well as slave devices such as USB flash drives or external hard drives.
[0041] This embodiment adds a switching circuit to the terminal processor of mobile terminals such as mobile phones and tablets. The switching circuit can be driven by the OTG switching command obtained by the terminal processor, so that the terminal processor can determine whether the pull-down resistor corresponding to the switching circuit is detected, and then switch the master / slave device mode of the host corresponding to the terminal processor. This facilitates the switching of the mobile terminal between master / slave device modes. Thus, even when using a regular USB data cable, the mobile terminal can easily enter the master device mode, which helps to save data cable application costs, provides a better user experience, and has the value for widespread application.
[0042] Example 2:
[0043] This embodiment provides a method for operating a master-slave device mode switching circuit, implemented based on the master-slave device mode switching circuit in Embodiment 1; as follows: Figure 4 As shown, the operation method of the master-slave device mode switching circuit may include, but is not limited to, the following steps:
[0044] The terminal processor acquires the OTG switch command;
[0045] The terminal processor drives the switching circuit to operate according to the OTG switch command, so that the terminal processor can determine whether the pull-down resistor corresponding to the switching circuit is detected, and then switch the master-slave device mode of the host corresponding to the terminal processor.
[0046] In this embodiment, the OTG switch command includes an OTG enable command;
[0047] When the OTG switch instruction obtained by the terminal processor is an OTG enable instruction, the terminal processor sends a high level to the controlled terminal of the switch module according to the OTG enable instruction;
[0048] When the switch of the switching module is turned on, the terminal processor detects the pull-down resistor;
[0049] The terminal processor controls the host corresponding to the terminal processor to enter the master device mode.
[0050] In this embodiment, the OTG switch command includes an OTG disconnect command;
[0051] When the OTG switch command obtained by the terminal processor is an OTG disconnect command, the terminal processor sends a low level to the controlled terminal of the switch module according to the OTG disconnect command;
[0052] The switch of the switching module is off, and the terminal processor does not detect the pull-down resistor;
[0053] The terminal processor controls the host corresponding to the terminal processor to enter slave device mode.
[0054] In this embodiment, the electronic device corresponding to the terminal processor can be a smartphone, tablet computer, laptop computer, or desktop computer, etc., and may be referred to as a terminal, portable terminal, desktop terminal, etc., without limitation. The electronic device also includes a memory for storing computer program instructions, which are configured to perform any of the operations as described in Embodiment 2 when executed, wherein the terminal processor is used to execute the computer program instructions to complete any of the operations as described in Embodiment 2.
[0055] It should be noted that if the master-slave device mode switching function in this embodiment is implemented as a software functional unit and sold or used as an independent product, it can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.
[0056] Obviously, those skilled in the art will understand that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using computer-executable program code, thereby storing them in a storage device for execution by a computing device, or fabricating them separately as individual integrated circuit modules, or fabricating multiple modules or steps as a single integrated circuit module. Thus, the present invention is not limited to any particular hardware and software combination.
[0057] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. These modifications or substitutions do not cause the essence of the corresponding technical solutions to depart from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A master-slave device mode switching circuit, characterized in that: The device includes a USB interface electrically connected to a terminal processor, and a switching circuit electrically connected to the terminal processor. The switching circuit includes a switching module and a resistor. The controlled terminal of the switching module is electrically connected to the control terminal of the terminal processor. One end of the switch of the switching module is electrically connected to the detection terminal of the terminal processor through the resistor. The detection terminal is the Type-C pin of the terminal processor. The other end of the switch of the switching module is grounded. The switching module uses an N-channel MOSFET. The gate of the switching module is electrically connected to the control terminal of the terminal processor, the drain of the switching module is electrically connected to the detection terminal of the terminal processor through the resistor, and the source of the switching module is grounded. The switching circuit is provided in two sets; The operation of the master-slave device mode switching circuit includes: The terminal processor acquires the OTG switch command; The terminal processor drives the switching circuit to operate according to the OTG switch command, so that the terminal processor can determine whether the pull-down resistor corresponding to the switching circuit is detected, and then switch the master-slave device mode of the host corresponding to the terminal processor.
2. The master-slave device mode switching circuit according to claim 1, characterized in that: The resistance of the resistor is 5.1KΩ.
3. The master-slave device mode switching circuit according to claim 1, characterized in that: The terminal processor is an XY6763 processor.
4. The master-slave device mode switching circuit according to claim 1, characterized in that: The OTG switch command includes the OTG enable command; When the OTG switch instruction obtained by the terminal processor is an OTG enable instruction, the terminal processor sends a high level to the controlled terminal of the switch module according to the OTG enable instruction; When the switch of the switching module is turned on, the terminal processor detects the pull-down resistor; The terminal processor controls the host corresponding to the terminal processor to enter the master device mode.
5. A master-slave device mode switching circuit according to claim 4, characterized in that: The OTG switch command includes the OTG disconnect command; When the OTG switch command obtained by the terminal processor is an OTG disconnect command, the terminal processor sends a low level to the controlled terminal of the switch module according to the OTG disconnect command; The switch of the switching module is off, and the terminal processor does not detect the pull-down resistor; The terminal processor controls the host corresponding to the terminal processor to enter slave device mode.