USB device identification circuit, identification method and electronic device
By designing a USB device identification circuit that monitors the change in the power pin level of the USB port, the problem of master-slave identification in Type-A USB port is solved, and the accurate master-slave identification of USB devices is realized, avoiding false triggering and device damage.
Patent Information
- Application Number
- CN202311817253.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-26
- Publication Date
- 2025-06-27
AI Technical Summary
The prior art has difficulties in master-slave identification of electronic devices in Type-A USB ports, especially in identifying communication directions of D+ and D-leads.
A USB device identification circuit is designed to identify the master-slave identity of the connected device by monitoring the level changes on the power pin VBUS of the USB port. The circuit includes a control unit, a current limiting unit, a voltage divider unit and a voltage regulator. Through level change monitoring and control of the voltage regulator, the master-slave identification of the USB device is realized.
This method realizes accurate identification of the master-slave identity of the USB device, avoids the problems of false triggering and device damage, and provides a new recognition method that is different from communication direction recognition compared to commonly used methods in the industry.
Smart Images

Figure CN120216422A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and more specifically to the field of wired communications, and particularly to a USB device identification circuit, a USB device identification method, and an electronic device. Background Art
[0002] Electronic devices can communicate with each other through the USB (Universal Serial Bus) protocol. Of course, an electronic device can also obtain power input or provide power output through its built-in USB port. USB communication belongs to a serial and polling mechanism.
[0003] For an electronic device with a USB port (denoted as electronic device A), when another electronic device with USB communication function (denoted as electronic device B) is inserted into the USB port of electronic device A, electronic device A must be able to detect that there is an electronic device B connected (inserted) in its own USB port and correctly identify whether electronic device B is a slave device or a master device, so as to establish a communication connection between electronic device A and electronic device B. If electronic device A cannot detect that there is another electronic device connected in its own USB port, or cannot correctly identify the master / slave device identity of the other electronic device inserted into its own USB port, then communication between electronic device A and electronic device B cannot be achieved through the USB protocol. Moreover, if electronic device A cannot correctly identify the master / slave device identity of electronic device B, it may cause electronic device A to erroneously trigger the slave mode, resulting in electronic device A continuously supplying power to its own USB port, and at least one of electronic device B and electronic device A being damaged.
[0004] Therefore, generally, an electronic device with USB communication function must be able to detect the connection (insertion) of its own USB port and perform master-slave identification (a special case is that when a PC (Personal Computer) uses a Type-A USB port, the PC is defaulted to be the master device). There are many types of USB ports, and one of them is the Type-A type. The Type-A USB port has only four leads: VBUS, D+, D-, and GND. It is technically difficult to perform master-slave identification on the electronic device connected to this type of USB port. In the industry, master-slave identification is usually performed according to the communication direction of the D+ and D- leads. Summary of the Invention
[0005] The purpose of the embodiments of the present application is to provide a USB device identification circuit, a USB device identification method, and an electronic device, which can identify the master-slave identity of the electronic device connected to the USB port on the electronic device, and the identification method is different from the identification method commonly used in the industry to perform master-slave identification by relying on the communication direction of the D+ and D- leads.
[0006] The first aspect of the embodiments of the present application provides a USB device identification circuit, including:
[0007] A control unit, the first port of the control unit is connected to the power supply pin of the USB port of the USB device identification circuit;
[0008] A current limiting unit, the first end of the current limiting unit is used to input a first voltage signal, and the second end of the current limiting unit is connected to the power supply pin;
[0009] A voltage dividing unit, the first end of the voltage dividing unit is connected to the power supply pin, and the second end of the voltage dividing unit is connected to the second port of the control unit;
[0010] A voltage regulator, the first end of the voltage regulator is connected to the power supply pin, and the control end of the voltage regulator is connected to the third port of the control unit.
[0011] The second aspect of the embodiments of the present application provides an electronic device, which includes the USB device identification circuit described in the first aspect.
[0012] The third aspect of the embodiments of the present application provides a USB device identification method, which is applied to the USB device identification circuit described in the first aspect or the electronic device described in the second aspect. The method includes:
[0013] When the control unit monitors that the level on the power supply pin is pulled low in the first monitoring mode, it controls the voltage regulator to start working;
[0014] The control unit switches to the master device mode and enumerates the USB device; if the enumeration is successful, the control unit determines that the USB device is a slave device;
[0015] Wherein, the first monitoring mode is that the control unit monitors the change of the level on the power supply pin through the first port.
[0016] In the embodiments of the present application, the USB device identification circuit can detect the level change on the power supply pin of the USB port, and identify the master and slave of the USB device connected to the USB port based on the situation of the level change. Its implementation method is relatively simple, and compared with the identification method that usually determines the master and slave by the communication direction of the D+ and D- leads in the industry, it provides a new identification method different from the one commonly used in the industry that determines the master and slave by the communication direction of the D+ and D- leads. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application;
[0018] Figure 2 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application;
[0019] Figure 3 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application;
[0020] Figure 4 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application;
[0021] Figure 5 is a flowchart of a USB device identification method provided by an embodiment of the present application;
[0022] Figure 6 is a schematic diagram of an application scenario of a USB device identification circuit provided by an embodiment of the present application;
[0023] Figure 7 is Figure 6 a schematic diagram of the level change on the VBUS pin in the USB port 13 in the shown application scenario;
[0024] Figure 8 is a flowchart of a USB device identification method provided by an embodiment of the present application;
[0025] Figure 9 is a flowchart of a USB device identification method provided by an embodiment of the present application;
[0026] Figure 10 is a flowchart of a USB device identification method provided by an embodiment of the present application;
[0027] Figure 11 is a flowchart of a USB device identification method provided by an embodiment of the present application;
[0028] Figure 12 is a schematic structural diagram of an electronic device further provided by an embodiment of the present application. Detailed implementation manners
[0029] The following will clearly describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments in the present application belong to the scope of protection of the present application.
[0030] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that such used data may be interchanged under appropriate circumstances so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. generally belong to the same category, and do not limit the number of objects. For example, the first object may be one or multiple. In addition, "and / or" in the specification and claims means at least one of the connected objects, and the character " / " generally indicates that the related objects before and after are in an "or" relationship.
[0031] A USB device recognition circuit, a USB device recognition method, and an electronic device provided by an embodiment of the present application will be described below with reference to the accompanying drawings.
[0032] An embodiment of the present application provides a USB device recognition circuit. As Figure 1 shown Figure 1 is a schematic structural diagram of a USB device recognition circuit provided by an embodiment of the present application. The USB device recognition circuit 10 includes: a control unit 11, a current limiting unit 14, a voltage dividing unit 15, and a voltage regulator 12.
[0033] Optionally, the control unit 11 may be Figure 1 the main MCU (Microcontroller Unit) shown in, and of course it may also be other types of chips. The first port of the control unit 11 (such as Figure 1 the INT port of the main MCU shown in) is connected to the power supply pin of the USB port 13 (such as Figure 1 the VBUS pin of the USB port 13 shown in), the second port of the control unit 11 (such as Figure 1 the ADC port of the main MCU shown in) is connected to the second end of the voltage dividing unit 15 (such as Figure 1 the end of the resistor R2 connected to one end of the third resistor R3 shown in), and the third port of the control unit 11 (such as Figure 1 the GPIO port of the main MCU shown in) is connected to the control end of the voltage regulator 12 (such as Figure 1 the EN pin of the voltage regulator 12 shown in).
[0034] The first end of the current limiting unit 14 is used to input a first voltage signal V1. Optionally, the first voltage signal V1 is constantly 3.3V (volts). The second end of the current limiting unit 14 is connected to the power supply pin VBUS of the USB port 13. Exemplarily, the current limiting unit 14 includes Figure 1 the first resistor R1 shown in Figure 1 . The first end of the first resistor R1 is used to input the first voltage signal V1, and the second end of the first resistor R1 is connected to the power supply pin VBUS of the USB port 13. Of course, the current limiting unit 14 is not limited to Figure 1 the implementation shown in Figure 1 , and other implementations are also possible. For example, the current limiting unit 14 can be composed of a variable resistor with a variable resistance value, or can be composed of multiple fixed resistors with fixed resistance values connected in series or in parallel, or can be other current limiting elements.
[0035] The first end of the voltage dividing unit 15 is connected to the power supply pin VBUS of the USB port 13, the second end of the voltage dividing unit 15 is connected to the second port of the control unit 11, and the third end of the voltage dividing unit 15 is coupled to the ground. Exemplarily, the voltage dividing unit 15 includes Figure 1 the second resistor R2 and the third resistor R3 shown in Figure 1 . The first end of the second resistor R2 is connected to the power supply pin VBUS of the USB port 13, the second end of the second resistor R2 is connected to the first end of the third resistor R3, and the second end of the third resistor R3 is coupled to the ground. Of course, the voltage dividing unit 15 is not limited to Figure 1 the implementation shown in Figure 1 , and other implementations are also possible. For example, the second resistor R2 can be a variable resistor, or can be the total resistance value of R2 formed by multiple fixed resistors connected in series or in parallel, or can be other voltage dividing elements.
[0036] The first end of the voltage regulator 12 is used to input a second voltage signal V2. Optionally, the second voltage signal V2 is constantly 12V. The second end of the voltage regulator 12 is connected to the power supply pin VBUS of the USB port 13. In the default state, the voltage regulator 12 remains off; in response to receiving an enabling signal sent by the control unit 11, it is turned on, and the second voltage signal V2 is converted into a third voltage signal V3 and output to the power supply pin VBUS of the USB port 13 through the second end; in response to receiving a disabling signal sent by the control unit 11, it is turned off. In some optional implementations, the voltage regulator 12 can be a DC-DC converter. In some other optional implementations, the voltage regulator 12 can be an LDO (low dropout regulator) voltage regulator. Of course, in some other optional implementations, the voltage regulator 12 can also be implemented based on other voltage transformation and regulation principles, and those skilled in the art can flexibly select based on requirements, which will not be elaborated here.
[0037] The second pin of the USB port 13 (e.g., Figure 1 the GND pin of the USB port 13 shown in
[0038] As Figure 2 shown, Figure 2 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application. The main difference between this USB device identification circuit 20 and the Figure 1 shown USB device identification circuit 10 is that it further includes: a first diode D1. The first end (i.e., the positive terminal) of the first diode D1 is connected to the first port of the control unit 11, and the second end (i.e., the negative terminal) of the first diode D1 is connected to the power supply pin VBUS of the USB port 13.
[0039] As Figure 3 shown, Figure 3 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application. The main difference between this USB device identification circuit 30 and the Figure 1 shown USB device identification circuit 10 is that it further includes: a second diode D2. The first end (i.e., the positive terminal) of the second diode D2 is connected to the second end of the voltage regulator 12, and the second end (i.e., the negative terminal) of the second diode D2 is connected to the power supply pin VBUS of the USB port 13 (i.e., connected to the first end of the second resistor R2).
[0040] The first diode D1 and the second diode D2 can, to a certain extent, prevent current backflow from burning out the control unit 11 and the voltage regulator 12 when the power supply pin VBUS on the USB port 13 in this USB device identification circuit is reversely connected, that is, protect the safety of this USB device identification circuit.
[0041] As Figure 4 shown, Figure 4 is a schematic structural diagram of a USB device identification circuit provided by an embodiment of the present application. The main difference between this USB device identification circuit 40 and the Figure 1 shown USB device identification circuit 10 is that it further includes: a first diode D1 and a second diode D2. For the description of the first diode D1 and the second diode D2, please refer to the relevant descriptions of the embodiments shown in Figure 2 and Figure 3 shown, and details will not be repeated here.
[0042] An embodiment of the present application provides an electronic device, and this electronic device includes any one of the foregoing USB device identification circuits.
[0043] The embodiment of the present application provides a method for identifying a USB device, which is applied to the aforementioned USB device identification circuit or electronic device, and is used to detect whether another electronic device is connected (inserted) into the USB port 13, and when it is detected that an electronic device is connected to the USB port 13, identify the master-slave identity of the electronic device connected to the USB port 13. As Figure 5 shown, Figure 5 is a flowchart of a method for identifying a USB device provided by an embodiment of the present application. The following will describe the method for identifying a USB device in conjunction with Figure 1 and Figure 5 The method for identifying a USB device includes the following steps:
[0044] S101, when the control unit 11 monitors that the level on the power supply pin VBUS is pulled low in the first monitoring mode, the control unit 11 controls the voltage regulator 12 to start working. Among them, the first monitoring mode is that the control unit 11 monitors the change of the level on the power supply pin VBUS of the USB port 13 (such as the VBUS pin of the USB port 13 shown in Figure 1 through the first port (such as the INT port of the main MCU shown in Figure 1 ).
[0045] S102, the control unit 11 switches to the master device mode and enumerates the USB device; if the enumeration is successful, step S103 is executed.
[0046] S103, the control unit 11 determines that the USB device is a slave device.
[0047] It should be particularly noted that in the default state, the control unit 11 monitors the change of the level on the power supply pin VBUS of the USB port 13 through the first port. And in the default state, the voltage regulator 12 also remains in the off state, that is, the voltage regulator 12 does not work and does not convert the second voltage signal V2 into the third voltage signal V3 for output. Therefore, in the default state, the level on the power supply pin VBUS of the USB port 13 is equal to the voltage of the first voltage signal V1. Exemplarily, V1 = 3.3V.
[0048] After other electronic devices are connected to the USB port 13, the VBUS pin of the other electronic devices will be connected to the power supply pin VBUS of the USB port 13, and the GND pin of the other electronic devices will be connected to the second pin of the USB port 13. If the electronic device connected to the USB port 13 is a slave device, the level on the VBUS pin of the USB port 13 is usually pulled down from the first voltage signal V1 (such as 3.3V). The control unit 11 can detect the change process that the level on the VBUS pin of the USB port 13 is pulled down from the first voltage signal V1 (such as 3.3V) from its own first port (such as the INT port). Therefore, it can be initially assumed that the USB device connected to the USB port 13 is a slave device.
[0049] The control unit 11 sends an enabling instruction to the voltage regulator 12 through the third port to control the enabling of the voltage regulator 12. The voltage regulator 12 is enabled in response to receiving the enabling instruction, converts the second voltage signal (such as 12V) into the third voltage signal V3 and outputs it to the power supply pin VBUS of the USB port 13 to supply power to the device inserted into the USB port 13. Then the main MCU performs USB enumeration on the USB device connected to the USB port 13 in the master device mode.
[0050] Among them, USB enumeration is a part of the USB communication protocol. For details, please refer to the USB communication protocol and will not be elaborated here. It should be noted that USB enumeration can only be initiated by the master device. The slave device waits passively to be enumerated.
[0051] In the case of successful enumeration, it is determined that the USB device connected to the USB port 13 is a slave device.
[0052] The following uses Figure 1 An exemplary application of the USB device recognition circuit shown in to illustrate S101. As Figure 6 shown, Figure 6 is a schematic diagram of an application scenario of a USB device recognition circuit provided by an embodiment of the present application. After the USB flash drive 50 is connected (Plug in) to the USB port 13, the VBUS pin of the USB flash drive 50 will be connected to the power supply pin VBUS of the USB port 13, and the GND pin of the USB flash drive 50 will be connected to the second pin of the USB port 13. The USB flash drive 50 also includes a capacitor C connected between the VBUS pin and the GND pin of the USB flash drive 50, a Flash memory, and a Controller connected to the VBUS pin of the USB flash drive 50.
[0053] As Figure 7 shown, it shows Figure 6 the voltage change situation on the power supply pin VBUS of the USB port 13 in the scenario shown, Figure 7The line 71 therein reflects the voltage change on the power pin VBUS of the USB port 13, and the line 72 is the flip test reference. Please refer to Figure 6 and Figure 7 , in the default state, the USB device identification circuit 10 is in the first monitoring mode, the default level on the power pin VBUS of the USB port 13 is V1, and when the USB flash drive 50 is inserted into the USB port 13 (i.e., Figure 7 the moment t1 shown in), the capacitor C of the USB flash drive 50 starts to charge, causing the level on the power pin VBUS of the USB port 13 to be instantaneously pulled down, and the INT port of the main MCU will monitor this change in the level on the power pin VBUS of the USB port 13. Once the main MCU monitors this change, it can preliminarily confirm that the USB flash drive 50 inserted into the USB port 13 is a slave device.
[0054] In some alternative embodiments, as Figure 8 shown, Figure 8 is a flowchart of a USB device identification method provided by an embodiment of the present application. Figure 8 The main difference between the USB device identification method provided by the embodiment shown in Figure 5 and the USB device identification method provided by the embodiment shown in
[0055] is that it further includes the following steps:
[0056] After further determining through enumeration that the device inserted into the USB port 13 is a slave device, the control unit 11 (such as Figure 1 the main MCU exemplified in) can communicate with this slave device. The control unit 11 determines the connection status of this slave device to the USB port 13 by periodically enumerating or reading this slave device. In the case of enumeration failure or reading failure, it is determined that the USB device connected to the USB port 13 has been unplugged, and the main MCU continues to switch to the first monitoring mode to monitor the level on the power pin VBUS of the USB port and controls the voltage regulator 12 to stop working.
[0057] In some alternative embodiments, as Figure 9 shown, Figure 9 is a flowchart of a USB device identification method provided by an embodiment of the present application. Figure 9 The main difference between the USB device identification method provided by the embodiment shown in Figure 5 and the USB device identification method provided by the embodiment shown in
[0058] S105. When the control unit 11 detects that the level on the power supply pin VBUS is pulled high in the first monitoring mode, it switches to monitoring the level on the power supply pin VBUS through the second monitoring mode. The second monitoring mode is that the control unit 11 monitors the change in the level on the power supply pin VBUS of the USB port 13 through a second port (such as the ADC port of the main MCU shown in Figure 1 .
[0059] When the main MCU detects that the level on the power supply pin VBUS of the USB port 13 is pulled high from the first voltage signal V1 (such as 3.3V), it switches to continuously monitoring the change in the level on the power supply pin VBUS of the USB port 13 through a second port (such as the ADC port).
[0060] S106. When the control unit 11 detects that the level on the power supply pin VBUS is greater than the first threshold in the second monitoring mode, the control unit 11 switches to the slave device mode and executes step S107 when the USB device enumeration is successful. When the USB device enumeration fails, step S108 is executed.
[0061] The first threshold can be flexibly set according to requirements. Usually, it is set to 4V, but it can also be set to 5V or other values according to actual requirements.
[0062] When the main MCU detects through a second port (such as the ADC port) that the level on the power supply pin VBUS of the USB port 13 is greater than the first threshold (such as 4V), the main MCU switches to the slave device mode and waits to be enumerated by the USB.
[0063] S107. The control unit 11 determines that the USB device is the master device.
[0064] When the USB device inserted into the USB port 13 successfully enumerates the main MCU (i.e., the main MCU detects that it has been successfully enumerated), it is determined that the USB device connected to the USB port 13 is the master device. For example, the master device can be a PC.
[0065] S108. The control unit 11 controls the voltage regulator 12 to start working.
[0066] S109. The control unit 11 switches to the master device mode and enumerates the USB device.
[0067] S110. If the enumeration is successful, the control unit 11 determines that the USB device is the slave device.
[0068] Optionally, the slave device can be a USB HUB.
[0069] For the related steps S108 - S110, reference may be made to the relevant descriptions of the foregoing steps S101 - S103, which will not be elaborated herein.
[0070] In some alternative embodiments, such as Figure 10 shown, Figure 10 is a flowchart of a USB device identification method provided by an embodiment of the present application. Figure 10 The main difference between the USB device identification method provided by the embodiment shown and Figure 9 the USB device identification method provided by the embodiment shown is that the following steps are further included:
[0071] If the enumeration fails in step S012 or S109, execute S111.
[0072] S111, the control unit 11 determines that the USB device is an invalid device, and controls the voltage regulator 12 to stop working;
[0073] S112, the control unit 11 switches to the first monitoring mode to continue monitoring the level on the power supply pin VBUS.
[0074] In the case of enumeration failure, it is determined that the USB device connected to the USB port 13 is an invalid device, and the first monitoring mode is switched to monitor the level on the power supply pin VBUS of the USB port 13, that is, the main MCU continues to detect the level on the USB port 13 through the INT port and sends a shutdown signal to the voltage regulator 12 to turn off the voltage regulator 12 and stop supplying power to the power supply pin VBUS of the USB port 13. The main MCU switches to the first monitoring mode to continue monitoring the level on the power supply pin VBUS of the USB port 13.
[0075] In some alternative embodiments, such as Figure 11 shown, Figure 11 is a flowchart of a USB device identification method provided by an embodiment of the present application. Figure 11 The main difference between the USB device identification method provided by the embodiment shown and Figure 9 the USB device identification method provided by the embodiment shown is that the following steps are further included:
[0076] S113, when the control unit 11 monitors that the level on the power supply pin VBUS of the USB port 13 is not greater than the first threshold in the second monitoring mode, it is determined that the USB device has been unplugged.
[0077] The control unit 11 (for example Figure 1After the main MCU in the example (in the case of enumeration) further determines that the device inserted into USB port 13 is a master device or a slave device (of the USB HUB type), it can communicate with the master device or the slave device (of the USB HUB type). The control unit 11 continuously monitors the state of the level on the power pin VBUS of USB port 13 through a second port (such as an ADC port). In the subsequent case where it is monitored through the second monitoring mode that the level on the power pin VBUS of USB port 13 is not greater than a first threshold (such as 4V), it is determined that the USB device connected to USB port 13 has been ejected from USB port 13.
[0078] When the control unit 11 monitors in the second monitoring mode that the level on the power pin VBUS of the USB port 13 is not greater than the first threshold, it determines that the USB device connected to the USB port 13 is an invalid device and switches to the first monitoring mode to monitor the level on the power pin VBUS of the USB port 13.
[0079] When the main MCU monitors that the level on the power pin VBUS of USB port 13 is pulled high from the first voltage signal V1 (such as 3.3V), it switches to continuously monitoring the change of the level on the power pin VBUS of USB port 13 through a second port (such as an ADC port). However, if the control unit 11 monitors in the second monitoring mode that the level on the power pin VBUS of USB port 13 is also not greater than the first threshold, it determines that the USB device connected to USB port 13 is an invalid device and switches to the first monitoring mode to continue monitoring the level on the power pin VBUS of USB port 13.
[0080] In some alternative embodiments, those skilled in the art can Figures 5 to 12 flexibly combine the described USB device identification method. For example, Figure 10 the shown embodiment is combined with Figure 11 the shown embodiment, and the related embodiments obtained are also within the protection scope of this application. For relevant descriptions, please refer to the foregoing, and details will not be repeated here.
[0081] In the embodiments of this application, the USB device identification circuit can detect the change of the level on the power pin VBUS of the USB port and perform master-slave identification on the USB connected to the USB port according to the situation of the level change. Its implementation method is relatively simple, and compared with the identification method that usually uses the communication direction of the D+ and D- leads in the industry to perform master-slave identification, it provides a new identification method different from the one usually used in the industry that uses the communication direction of the D+ and D- leads to perform master-slave identification.
[0082] Figure 12Schematic diagram of the hardware structure of an electronic device according to an embodiment of the present application.
[0083] The electronic device 140 includes, but is not limited to: a radio frequency unit 141, a network module 142, an audio output unit 143, an input unit 144, a sensor 145, a display unit 146, a user input unit 147, an interface unit 148, a memory 149, a processor 1410, and other components. Those skilled in the art can understand that the electronic device 140 may further include a power supply (such as a battery) for supplying power to each component, and the power supply can be logically connected to the processor 1410 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system. Figure 12 The structure of the electronic device shown in the figure does not limit the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine some components, or have different component arrangements, which will not be elaborated here.
[0084] Among them, the processor 1410 includes the aforementioned control unit 11, which is used for:
[0085] When it is detected in the first monitoring mode that the level on the power supply pin is pulled low, controlling the voltage regulator to start working;
[0086] Switching to the master device mode and enumerating the USB device;
[0087] If the enumeration is successful, determining that the USB device is a slave device;
[0088] Among them, the first monitoring mode is that the control unit monitors the change of the level on the power supply pin through the first port.
[0089] It should be understood that in the embodiment of the present application, the network module 142 may include any one of the aforementioned Figures 1 to 4 USB device identification circuits.
[0090] The input unit 144 may include a Graphics Processing Unit (GPU) 1441 and a microphone 1442. The GPU 1441 processes the image data of static pictures or videos obtained by an image capturing device (such as a camera) in a video capturing mode or an image capturing mode. The display unit 146 may include a display panel 1461, and the display panel 1461 may be configured in the form of, for example, a liquid crystal display, an organic light emitting diode, etc. The user input unit 147 includes at least one of a touch panel 1471 and other input devices 1472. The touch panel 1471 is also referred to as a touch screen. The touch panel 1471 may include two parts: a touch detection device and a touch controller. The other input devices 1472 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, and a joystick, which will not be elaborated herein.
[0091] The memory 149 can be used to store software programs and various data. The memory 149 mainly includes a first storage area for storing programs or instructions and a second storage area for storing data. Among them, the first storage area can store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 149 can include a volatile memory or a non-volatile memory, or the memory 149 can include both a volatile memory and a non-volatile memory. Among them, the non-volatile memory can be a Read-Only Memory (ROM), a Programmable ROM (PROM), an Erasable Programmable ROM (EPROM), an Electrically Erasable Programmable ROM (EEPROM), or a flash memory. The volatile memory can be a Random Access Memory (RAM), a Static RAM (SRAM), a Dynamic RAM (DRAM), a Synchronous DRAM (SDRAM), a Double Data Rate SDRAM (DDR SDRAM), an Enhanced SDRAM (ESDRAM), a Synchlink DRAM (SLDRAM), and a Direct Rambus RAM (DRRAM). The memory 149 in the embodiments of the present application includes, but is not limited to, these and any other suitable types of memories.
[0092] The processor 1410 may include one or more processing units; optionally, the processor 1410 integrates an application processor and a modem processor. Among them, the application processor mainly processes operations related to the operating system, user interface, application programs, etc., and the modem processor mainly processes wireless communication signals, such as a baseband processor. It can be understood that the above-mentioned modem processor may not be integrated into the processor 1410 either.
[0093] Any of the above product embodiments can implement each process of the above USB device recognition method embodiment through the operation of its own processor, and can achieve the same technical effects. To avoid repetition, they will not be described one by one.
[0094] In the implementation manners provided in the embodiments of the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device implementation manners described above are only illustrative. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be through some interfaces, indirect couplings or communication connections of devices or units, and can be in electrical, mechanical or other forms.
[0095] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this implementation manner.
[0096] In addition, each functional unit in the various implementation manners of the embodiments of the present application can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units.
[0097] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs that can store program codes.
[0098] The above are only the implementation manners of the embodiments of the present application, and do not limit the patent scope of the embodiments of the present application. The above specific implementation manners are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art, any equivalent structural or equivalent process transformation made by using the specification and drawings of the embodiments of the present application, or directly or indirectly applied in other related technical fields, without departing from the spirit and scope protected by the claims of the present application, can still make many forms, and all of them are equally included in the patent protection scope of the embodiments of the present application.
Claims
1. A USB device recognition circuit, characterized in that, Comprising: A control unit, wherein a first port of the control unit is connected to a power supply pin of a USB port of the USB device identification circuit; A current limiting unit, wherein a first end of the current limiting unit is used for inputting a first voltage signal, and a second end of the current limiting unit is connected to the power supply pin; A voltage dividing unit, wherein a first end of the voltage dividing unit is connected to the power supply pin, and a second end of the voltage dividing unit is connected to a second port of the control unit; A voltage regulator, wherein a first end of the voltage regulator is connected to the power supply pin, and a control end of the voltage regulator is connected to a third port of the control unit.
2. The USB device identification circuit according to claim 1, wherein The current limiting unit includes: A first resistor, wherein a first end of the first resistor is used for inputting a first voltage signal, and a second end of the electrical instrument resistor is connected to the power supply pin.
3. The USB device identification circuit according to claim 1, wherein The voltage dividing unit includes: A second resistor, wherein a first end of the second resistor is connected to the power supply pin, and a second end of the second resistor is connected to a second port of the control unit; A third resistor, wherein a first end of the third resistor is connected to a second end of the second resistor, and a second end of the third resistor is coupled to the ground.
4. The USB device identification circuit according to claim 1, wherein Further comprising: A first diode, wherein a first end of the first diode is connected to a first port of the control unit, and a second end of the first diode is connected to the power supply pin.
5. The USB device identification circuit according to claim 1, characterized in that, Further comprising: A second diode, wherein a first end of the second diode is connected to a second end of the voltage regulator, and a second end of the second diode is connected to a first end of the voltage dividing unit.
6. An electronic device, characterized in that, Comprising the USB device identification circuit according to any one of claims 1 to 5.
7. A method for identifying a USB device, characterized in that, Applied to the USB device identification circuit according to any one of claims 1 to 5 or the electronic device according to claim 6, the method includes: When the control unit monitors that the level on the power supply pin is pulled low in the first monitoring mode, the control unit controls the voltage regulator to start working; The control unit switches to the master device mode and enumerates the USB device; If the enumeration is successful, the control unit determines that the USB device is a slave device; Wherein, the first monitoring mode is that the control unit monitors the change of the level on the power supply pin through the first port.
8. The USB device recognition method according to claim 7, wherein, The method further includes: After the enumeration is successful, the control unit periodically enumerates or reads the USB device. When the enumeration fails or the reading fails, it is determined that the USB device has been unplugged and the control unit controls the voltage regulator to stop working.
9. The USB device recognition method according to claim 7, wherein The method further includes: When the control unit monitors that the level on the power supply pin is pulled high in the first monitoring mode, it switches to monitoring the level on the power supply pin through the second monitoring mode; the second monitoring mode is that the control unit monitors the change of the level on the power supply pin through the second port; When the control unit monitors that the level on the power supply pin is greater than a first threshold in the second monitoring mode, the control unit switches to the slave device mode and determines that the USB device is the master device when the enumeration of the USB device is successful.
10. The USB device identification method according to claim 9, wherein The method further includes: When the enumeration of the USB device fails, the control unit controls the voltage regulator to start working; The control unit switches to the master device mode and enumerates the USB device; If the enumeration is successful, the control unit determines that the USB device is a slave device.
11. The USB device identification method according to claim 7 or 10, characterized in that, The method further includes: If the enumeration fails, the control unit determines that the USB device is an invalid device, and controls the voltage regulator to stop working; The control unit switches to the first monitoring mode to continue monitoring the level on the power supply pin.
12. The USB device recognition method according to claim 9, characterized in that, The method further includes: When the control unit monitors that the level on the power supply pin of the USB port is not greater than the first threshold in the second monitoring mode, it determines that the USB device has been unplugged.