Disclosure of Invention
The application provides a method and a device for switching an OTG (on-the-go) of a mobile phone, which avoid the phenomenon that the mobile phone cannot be normally charged after being connected to a charging power supply.
A first aspect of the present application provides a method for switching an OTG of a mobile phone, including: under the condition that the mobile phone is in an OTG mode, the mobile phone detects the current value of a Vbus pin in a Universal Serial Bus (USB) interface of the mobile phone; and when the current value is smaller than a first threshold, the mobile phone is switched from the OTG mode to a charging mode. When the current value is greater than a second threshold, the mobile phone executes an OTG identification process in the OTG mode; wherein the first threshold is smaller than the second threshold.
In one exemplary approach, the first threshold comprises: anywhere between 0 and 1 milliamp.
In one exemplary approach, the second threshold comprises: anywhere between 1 milliamp and 10 milliamps.
In an exemplary manner, when the current value is less than a first threshold, the switching the handset from the OTG mode to the charging mode includes: and when the current value is smaller than a first threshold, the mobile phone ends the OTG identification process and closes the output voltage of the Vbus pin.
A second aspect of the present application provides a mode switching apparatus, including: the detection module is used for detecting the current value of a Vbus pin in a Universal Serial Bus (USB) interface of the mobile phone under the condition that the mobile phone is in an OTG mode. And the switching module is used for switching the mobile phone from the OTG mode to the charging mode when the current value is smaller than a first threshold. And the execution module is used for executing the OTG identification process in the OTG mode when the current value is greater than a second threshold, wherein the first threshold is less than the second threshold.
In one exemplary approach, the first threshold comprises: any value between 0 and 1 milliamp; the second threshold includes: anywhere between 1 milliamp and 10 milliamps.
In an exemplary manner, the switching module includes: and the switching submodule is used for ending the OTG identification process of the mobile phone and closing the output voltage of the Vbus pin when the current value is smaller than a first threshold.
A third aspect of the present application provides a handset comprising a processor, a memory for storing instructions, and a transceiver for communicating with other devices, the processor being configured to execute the instructions stored in the memory to cause the handset to perform a method as claimed in any one of the first aspects of the present application.
A fourth aspect of the present application provides a computer-readable storage medium having stored thereon instructions that, when executed, cause a computer to perform the method according to any of the first aspects of the present application.
A fifth aspect of the present application provides a computer program product comprising instructions that, when executed, cause a computer to perform the method of any of the first aspects of the present application.
A sixth aspect of the present application provides a system-on-chip or system-on-chip, where the system-on-chip or system-on-chip is applicable to a network device, and the system-on-chip or system-on-chip includes: the network device comprises at least one communication interface, at least one processor and at least one memory, wherein the communication interface, the memory and the processor are interconnected through a bus, and the processor enables the network device to execute the method according to the first aspect of the application by executing the instructions stored in the memory.
The embodiment of the application provides a method and a device for switching an OTG (on-the-go) function of a mobile phone, and an inventor finds that the phenomenon that the mobile phone with the OTG function cannot be normally charged after being connected to a charging power supply often occurs in the prior art because the mobile phone enters an OTG mode by mistake, specifically, in a USB (universal serial bus) pin, an ID (identification) pin is adjacent to a Grounding (GND) pin, and in the using process of the mobile phone, the mobile phone can be in a humid or dust environment, so that a USB (universal serial bus) port is corroded, short circuits can be caused by corrosion of the adjacent ID pin and the GND pin in the USB port, the level of the ID pin of the mobile phone is lowered, the mobile phone enters the OTG mode by mistake, and the mobile phone cannot be normally charged. Based on the discovery, in the embodiment of the application, under the condition that the mobile phone is in the OTG mode, the mobile phone detects the current value of the Vbus pin of the power bus in the USB interface of the universal serial bus of the mobile phone; it can be understood that if the current value is too small, it may be considered that no current loop is formed in the Vbus pin, that is, no other electronic device is connected to the mobile phone, and further, it may be considered that the mobile phone is triggered by mistake to enter the OTG mode, so that when the current value is smaller than the first threshold, the mobile phone is switched from the OTG mode to the charging mode, and when the current value is larger than the second threshold, the mobile phone executes the OTG identification process in the OTG mode, thereby avoiding the occurrence of the phenomenon that the mobile phone cannot be charged normally due to entering the OTG mode by mistake.
Detailed Description
The terminology used in the following examples is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in the specification of the present application and the appended claims, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, such as "one or more", unless the context clearly indicates otherwise. It should also be understood that in the following embodiments of the present application, "at least one", "one or more" means one, two or more. The term "and/or" is used to describe an association relationship that associates objects, meaning that three relationships may exist; for example, a and/or B, may represent: a alone, both A and B, and B alone, where A, B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
Reference throughout this specification to "one embodiment" or "some embodiments," or the like, means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the present application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.
Embodiments of OTG-enabled electronic devices, user interfaces for such electronic devices, and for using such electronic devices are described below. In some embodiments, the electronic device may be a portable electronic device, such as a cell phone, a tablet, a wearable electronic device with wireless communication capabilities (e.g., a smart watch), and the like, that also includes other functionality, such as personal digital assistant and/or music player functionality. Exemplary embodiments of the portable electronic device include, but are not limited to, a mount
Or other operating system. The portable electronic device may also be other portable electronic devices such as a laptop computer (laptop) or the like. It should also be understood that in other embodiments, the electronic device may not be a portable electronic device, but may be a desktop computer.
The mobile phone related to the embodiment of the application may include a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a Central Processing Unit (CPU), a Memory Management Unit (MMU), and a memory (also referred to as a main memory). The operating system may be any one or more computer operating systems that implement business processing through processes (processes), such as a Linux operating system, a Unix operating system, an Android operating system, an iOS operating system, or a Windows operating system. The application layer comprises applications such as a browser, an address list, word processing software, instant messaging software and the like.
In specific application, in a mobile phone with an OTG function (which may also be referred to as an OTG device), after a USB interface of the OTG device is connected to a charging power supply, there is no way to charge the OTG device normally.
The inventor finds that the OTG device cannot be normally charged after being connected to the charging power supply, which may be caused by the OTG device entering the OTG mode by mistake. Specifically, in the USB pin, the ID pin is adjacent to a Ground (GND) pin, and during the use of the mobile phone, the mobile phone may be in a wet or dust environment, so that the USB port of the mobile phone is corroded, and the adjacent ID pin and the GND pin in the USB port may cause a short circuit due to corrosion, so that the level of the ID pin is lowered, and the mobile phone enters the OTG mode by mistake. In particular, for the mobile phone in the charging mode, if there is an OTG request, the mobile phone software does not respond, and continues the charging mode; similarly, for the mobile phone in the OTG mode, if there is a charging request, the mobile phone software does not respond, and continues the OTG mode. Therefore, the phenomenon that the mobile phone cannot be charged normally after being connected to the charging power supply is caused.
Based on the discovery, the embodiment of the application detects the current value of the Vbus pin by using the current detection unit in the mobile phone, and further determines whether the mobile phone triggers the OTG mode by mistake. Specifically, fig. 1 is a circuit schematic diagram of a mode switching application scenario according to an embodiment of the present disclosure, and as shown in fig. 1, a mobile phone according to an embodiment of the present disclosure may include a USB connector 10, a processor 20, and a current detection unit 30.
Specifically, the USB connector 10 may include five pins: ID pin, GND pin, D-pin, D + pin, and Vbus pin. One end of the current detection unit 30 is connected to the Vbus pin, the other end of the current detection unit 30 is connected to the processor 20, and the processor 20 can detect the current value of the Vbus pin through the current detection unit 30; the ID pin is connected to the processor 20, and the level state (high level or low level) of the ID pin can be acquired or controlled by the processor 20; the D-pin and the D + pin are connected with the processor 20, and when the USB connector is connected to other electronic equipment, the other electronic equipment can carry out data communication and the like with the processor 20 of the mobile phone through the D-pin and/or the D + pin; the Vbus pin is also connected to the processor 20, and the level state (high level or low level) of the Vbus pin and the like can be acquired or controlled by the processor 20; the GND pin is connected to the processor 20, and common ground of the USB connector 10 and the processor 20 is realized.
The connection in the embodiment of the present application may be realized by welding, coupling, or the like, and this is not particularly limited in the embodiment of the present application.
Generally, when the ID pin of the mobile phone is at a high level, the mobile phone is in a charging mode, the mobile phone can be normally charged, and the voltage of the ID pin may be 1.8V or higher; when the ID pin of the mobile phone is at a low level, the mobile phone is in an OTG mode, the mobile phone can execute an OTG processing procedure, Vbus outputs a voltage of about 5V, and the D-pin or D + pin can perform communication interaction with an electronic device connected to the mobile phone.
It should be noted that, in the OTG mode, when the ID pin of the mobile phone is at a low level, it indicates that the mobile phone is an OTG master device, and it is suitable that the other electronic device performing OTG communication with the mobile phone is an OTG slave device, the master device may send a control instruction to the slave device, and the slave device may perform corresponding operation according to the control instruction.
It can be understood that, if other electronic devices can also implement the OTG function, after the mobile phone is connected to the other electronic devices through the OTG, the OTG role of the mobile phone and the other electronic devices can be changed (as the master device or as the slave device) according to the setting of the ID pin of the mobile phone and the setting of the ID pin of the other electronic devices, which is not specifically limited in this embodiment of the application.
In practical applications, the processor 20 may be an execution main body for executing the OTG switching method of the mobile phone, and the processor 20 may be a central processing unit of the mobile phone, or the like. The current detection unit 30 may be determined according to an actual application scenario, and for example, the current detection unit 30 may be composed of resistors, transistors, and other electrical devices. It can be understood that, in a typical mobile phone, the current detection unit 30 between the Vbus pin and the processor 20 can detect the current of the Vbus pin, and an Analog-to-Digital converter (ADC) reads a register, so as to obtain the current value of the Vbus pin. The processor 20 and the current detection unit 30 are not particularly limited in the embodiment of the present application.
Fig. 2 is a flowchart of a method for switching an OTG of a mobile phone according to an embodiment of the present disclosure, and as shown in fig. 2, based on the current structure of fig. 1, the method according to the embodiment may include the following steps:
step S101: under the condition that the mobile phone is in the OTG mode, the mobile phone detects the current value of a Vbus pin in a USB interface of the mobile phone.
In the embodiment of the present application, the OTG mode may specifically refer to: the mobile phone can execute OTG processing flow with other electronic equipment through the USB, and the Vbus pin of the mobile phone USB outputs about 5V voltage to the other electronic equipment.
In specific application, whether the mobile phone enters the OTG mode or not can be determined by the level state of the ID pin of the USB port, and specifically, the mobile phone can be considered to be in the OTG mode when the ID pin of the mobile phone is at a low level.
It can be understood that, in practical application, whether the mobile phone enters the OTG mode may also be determined in other manners, for example, after the mobile phone is connected to the charging power supply, if the mobile phone cannot be normally charged, the mobile phone may also be considered to be in the OTG mode.
In the embodiment of the application, under the condition that the mobile phone is in the OTG mode, the mobile phone detects the current value of the Vbus pin of the power bus in the USB interface of the universal serial bus of the mobile phone. Specifically, referring to fig. 1, the detection of the current of the Vbus pin may be implemented by a current detection unit 30 between the Vbus pin and the processor 20, and the register may be read by an analog-to-digital converter (ADC), so as to obtain the current value of the Vbus pin. It can be understood that, in practical application, the current value of the Vbus pin of the power bus in the USB interface of the universal serial bus of the mobile phone may also be detected in other manners, which is not specifically limited in this embodiment of the present application.
Step S102: and when the current value is smaller than a first threshold value, the mobile phone is switched from the OTG mode to a charging mode.
In the embodiment of the present application, the first threshold may be determined according to an actual application scenario, and in a specific application, if the current value of the Vbus pin is too small, it may be considered that no current loop is formed in the Vbus pin, that is, no other electronic device is connected to the mobile phone, so the first threshold may be 0 or a smaller value, and the first threshold is not specifically limited in the embodiment of the present application. Considering that the current identification accuracy of a general current detection unit is 1mA, and the actual current of the Vbus pin is 0, the detected current value may be 0 to 1mA, that is, although the Vbus pin is detected to be not 0, the Vbus pin is not actually connected to the slave device, so that, in order to avoid a current test error of the Vbus pin due to the accuracy of the current detection unit, in some embodiments of the present application, the first threshold may be 0 to 1 mA.
In the embodiment of the application, under the condition that the current value of the Vbus pin is smaller than the first threshold, no slave device is connected to the mobile phone, no current is consumed on a VBus path, and the mobile phone enters an OTG mode due to original false triggering such as interface short circuit, so that the mobile phone is switched from the OTG mode to a charging mode, and the mobile phone can be normally charged in the charging mode.
In an optional implementation manner, when the current value is smaller than a first threshold value, switching the mobile phone from the OTG mode to a charging mode includes:
and when the current value is smaller than a first threshold, the mobile phone ends the OTG identification process and closes the output voltage of the Vbus pin.
In this application embodiment, when the mobile phone is in the OTG mode, the mobile phone may automatically execute the OTG identification process, specifically, the mobile phone will be in a state of communication interaction with the slave device, and the mobile phone outputs an output voltage of about 5V to the slave device through the Vbus pin, so that the specific implementation of switching the mobile phone from the OTG mode to the charging mode may be: the mobile phone ends the OTG identification process and closes the output voltage of the Vbus pin. In a specific application, the OTG identification process of the mobile phone may be ended by a software program in the processor, or may be ended by another method, which is not specifically limited in this embodiment of the present application.
Step S103: and when the current value is greater than the second threshold, the mobile phone executes the OTG identification process in the OTG mode.
In this embodiment of the present application, the second threshold is greater than the first threshold, and the second threshold may be determined according to an actual application scenario, and in a specific application, if the Vbus pin is connected to a slave device, specifically, the slave device may be a usb disk or other OTG slave devices, the Vbus pin and the slave device may form a current loop, and the current loop generally has a higher current value, so that the second threshold may be a higher value, and the second threshold is not specifically limited in this embodiment of the present application. In practical application, considering that the current identification accuracy of a general current detection unit is 1mA and the current consumption of the slave device is generally above 10mA, in an implementation manner of the embodiment of the present application, the second threshold is between 1mA and 10mA, and when the current value is greater than the second threshold, it may be determined that the Vbus pin is connected to the slave device.
In the embodiment of the application, when the current value is greater than the second threshold, the mobile phone may be considered to have access to the slave device, and therefore the mobile phone may execute the OTG identification procedure in the OTG mode.
In summary, the present application provides a method and an apparatus for switching an OTG of a mobile phone, and an inventor finds that, in the prior art, a phenomenon that the mobile phone capable of implementing the OTG function cannot be normally charged after being connected to a charging power supply often occurs because the mobile phone enters an OTG mode by mistake, specifically, in a USB pin, an ID pin is adjacent to a Ground (GND) pin, and in a using process of the mobile phone, the mobile phone may be in a humid or dusty environment, so that a USB port is corroded, and short circuits may be caused by corrosion between the adjacent ID pin and the GND pin in the USB port, so that a level of the ID pin of the mobile phone is lowered, and the mobile phone enters the OTG mode by mistake, thereby causing the mobile phone to be unable to be normally charged. Based on the discovery, in the embodiment of the application, under the condition that the mobile phone is in the OTG mode, the mobile phone detects the current value of the Vbus pin of the power bus in the USB interface of the universal serial bus of the mobile phone; it can be understood that if the current value is too small, it may be considered that no current loop is formed in the Vbus pin, that is, no other electronic device is connected to the mobile phone, and further, it may be considered that the mobile phone is triggered by mistake to enter the OTG mode, so that when the current value is smaller than the first threshold, the mobile phone is switched from the OTG mode to the charging mode, and when the current value is larger than the second threshold, the mobile phone executes the OTG identification process in the OTG mode, thereby avoiding the occurrence of the phenomenon that the mobile phone cannot be charged normally due to entering the OTG mode by mistake.
Fig. 3 shows a functional structure schematic diagram of a mobile phone OTG switching device according to an embodiment of the present application, and as shown in fig. 3, the device includes:
the detecting module 310 is configured to detect a current value of a Vbus pin of a power bus in a USB interface of a universal serial bus of a mobile phone when the mobile phone is in an OTG mode.
The switching module 320 is configured to switch the mobile phone from the OTG mode to the charging mode when the current value is smaller than a first threshold.
The executing module 320 is configured to execute the OTG identification process in the OTG mode when the current value is greater than a second threshold, where the first threshold is smaller than the second threshold.
In one exemplary approach, the first threshold comprises: any value between 0 and 1 milliamp; the second threshold includes: anywhere between 1 milliamp and 10 milliamps.
In an exemplary manner, the switching module includes: and the switching submodule is used for ending the OTG identification process of the mobile phone and closing the output voltage of the Vbus pin when the current value is smaller than a first threshold.
The embodiment of the application provides a method and a device for switching an OTG (on-the-go) function of a mobile phone, and an inventor finds that the phenomenon that the mobile phone with the OTG function cannot be normally charged after being connected to a charging power supply often occurs in the prior art because the mobile phone enters an OTG mode by mistake, specifically, in a USB (universal serial bus) pin, an ID (identification) pin is adjacent to a Grounding (GND) pin, and in the using process of the mobile phone, the mobile phone can be in a humid or dust environment, so that a USB (universal serial bus) port is corroded, short circuits can be caused by corrosion of the adjacent ID pin and the GND pin in the USB port, the level of the ID pin of the mobile phone is lowered, the mobile phone enters the OTG mode by mistake, and the mobile phone cannot be normally charged. Based on the discovery, in the embodiment of the application, under the condition that the mobile phone is in the OTG mode, the mobile phone detects the current value of the Vbus pin of the power bus in the USB interface of the universal serial bus of the mobile phone; it can be understood that if the current value is too small, it may be considered that no current loop is formed in the Vbus pin, that is, no other electronic device is connected to the mobile phone, and further, it may be considered that the mobile phone is triggered by mistake to enter the OTG mode, so that when the current value is smaller than the first threshold, the mobile phone is switched from the OTG mode to the charging mode, and when the current value is larger than the second threshold, the mobile phone executes the OTG identification process in the OTG mode, thereby avoiding the occurrence of the phenomenon that the mobile phone cannot be charged normally due to entering the OTG mode by mistake.
Fig. 4 illustrates a mobile phone provided in an embodiment of the present application, and as shown in fig. 4, the mobile phone includes a processor 410, a memory 420, and a transceiver 430, where the memory 420 is used to store instructions, the transceiver 430 is used to communicate with other devices, and the processor 410 is used to execute the instructions stored in the memory, so as to cause the mobile phone to perform the method according to any one of the present applications.
Embodiments of the present application also provide a computer-readable storage medium storing instructions that, when executed, cause a computer to perform a method as in any of the present applications.
Embodiments of the present application also provide a computer program product comprising instructions that, when executed, cause a computer to perform a method as in any of the present applications.
An embodiment of the present application further provides a system on chip or a system on chip, where the system on chip or the system on chip may be applied to a network device, and the system on chip or the system on chip includes: the network device comprises at least one communication interface, at least one processor and at least one memory, wherein the communication interface, the memory and the processor are interconnected through a bus, and the processor enables the network device to execute the method in the application by executing instructions stored in the memory.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the unit is only one logical functional division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions to enable a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to execute some steps of the method according to various embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a read-only memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.