Interface control method and device, electronic equipment and storage medium
The functional modules inside the electronic device are turned on through software arbitration, which solves the problem of increasing the number of devices in the prior art hardware switches, improves space utilization and realizes flexible control of the charging interface.
Patent Information
- Application Number
- CN202311318850.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-11
- Publication Date
- 2025-04-11
AI Technical Summary
When controlling the charging interface, existing electronic devices rely on physical hardware switches, resulting in an increase in hardware circuit devices and a decrease in space utilization.
By monitoring the insertion event, determining the type of external equipment, the software arbitration method connects the target functional module and the data communication line, realizes flexible switching of the functional modules, and reduces the use of hardware switches.
The number of hardware circuit devices in electronic devices is reduced, the utilization rate of internal space is improved, and flexible control of the charging interface is achieved.
Smart Images

Figure CN119807107A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of electronic technology, and in particular to an interface control method, device, electronic device and storage medium. Background Art
[0002] With the development of science and technology, various electronic devices appear in people's daily lives. People can use electronic devices for learning, entertainment, etc. When the battery of an electronic device is out of power, a charger is used to charge the electronic device.
[0003] At present, for most electronic devices, there are many types of charging interfaces, such as Type C interface, etc., and various charging chips are used to control the charging interface inside the electronic device. For example, a corresponding fast charging chip is usually set inside an electronic device that supports fast charging, and the fast charging chip is controlled to be connected to the charging interface when charging through a corresponding adapter. In the existing scheme, the control of the fast charging chip and the charging interface is controlled by a physical hardware switch, and the control chip or control module set inside the electronic device is controlled by the physical hardware switch to realize the control of the charging interface. In this case, the design of the physical hardware switch increases the number of components in the hardware circuit to a certain extent, and reduces the utilization rate of the internal space of the electronic device. Summary of the invention
[0004] In order to further reduce the number of components in the hardware circuit of an electronic device and improve the utilization rate of the internal space of the electronic device, the embodiment of the present application provides an interface control method, device, electronic device and storage medium. The technical solution is as follows:
[0005] In one aspect, the present application provides an interface control method, which is applied to an electronic device, wherein the electronic device includes at least two functional modules, and the at least two functional modules are respectively connected to a data communication line, and the method includes:
[0006] Monitoring whether an insertion event occurs in the electronic device;
[0007] In the event of an insertion event, determining a device type of the inserted external device;
[0008] According to the device type of the external device, a target functional module is determined, and the target functional module is connected to the data communication line to implement the function corresponding to the target functional module. The target functional module is one of the at least two functional modules, and different functional modules correspond to different functions, including at least one of charging and discharging and data transmission.
[0009] In one aspect, the present application provides an interface control device, which is applied to an electronic device, wherein the electronic device includes at least two functional modules, and the at least two functional modules are respectively connected to a data communication line, and the device includes:
[0010] A first monitoring module, used for monitoring whether an insertion event occurs in the electronic device;
[0011] A first determination module, used for determining the device type of the inserted external device when an insertion event occurs;
[0012] The second determination module is used to determine the target function module according to the device type of the external device, and connect the target function module with the data communication line to realize the function corresponding to the target function module, the target function module is one of the at least two function modules, different function modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission.
[0013] In another aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and the computer program is executed by the processor to implement the interface control method as described in one aspect.
[0014] In another aspect, the present application provides a computer-readable storage medium, wherein the storage medium stores a computer program, and the computer program is executed by a processor to implement the interface control method as described in one aspect.
[0015] On the other hand, an embodiment of the present application provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the interface control method as described in one aspect above.
[0016] On the other hand, an embodiment of the present application provides an application publishing platform, which is used to publish a computer program product, wherein when the computer program product runs on a computer, the computer executes the interface control method as described in one aspect above.
[0017] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0018] Monitor whether an insertion event occurs in an electronic device; in the event of an insertion event, determine the device type of the inserted external device; determine a target functional module according to the device type of the external device, and connect the target functional module to a data communication line to implement a function corresponding to the target functional module, wherein the target functional module is one of at least two functional modules, and different functional modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission. In the present application, the electronic device connects different internal functional modules to a data communication line in hardware, determines the device type of the external device based on the occurrence of an insertion event, and thus determines whether the target functional module is connected to the data communication line, so that the target functional module in the plurality of functional modules is connected to the data communication line through a software process, and no additional switch device is required to control, thereby reducing the number of components in the hardware circuit of the electronic device and improving the utilization rate of the internal space of the electronic device. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 is a schematic structural diagram of an example of an electronic device provided in an embodiment of the present application;
[0021] Figure 2 is a schematic diagram of a charging circuit of a terminal device involved in an embodiment of the present application;
[0022] Figure 3 is a structural schematic diagram of a charging circuit of another terminal device involved in an embodiment of the present application;
[0023] Figure 4 is a method flow chart of an interface control method provided by an exemplary embodiment of the present application;
[0024] Figure 5 It is a circuit diagram of a data communication line inside an electronic device involved in an exemplary embodiment of the present application;
[0025] Figure 6 is a method flow chart of an interface control method provided by an exemplary embodiment of the present application;
[0026] Figure 7 is a schematic diagram of the structure of a type C interface involved in an exemplary embodiment of the present application;
[0027] Figure 8 is a hardware structure block diagram of an electronic device involved in an exemplary embodiment of the present application;
[0028] Fig. 9 is a method flow chart of an interface control method provided by an exemplary embodiment of the present application;
[0029] Fig.10 is a structural block diagram of an interface control device provided by an exemplary embodiment of the present application;
[0030] Fig.11 It is a structural diagram of another example of the interface control device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0031] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0032] The term "multiple" as used herein refers to two or more than two. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the related objects are in an "or" relationship.
[0033] The solution provided by the present application can be used in real-life scenarios where people use electronic devices in their daily lives and insert adapters or other external devices into electronic devices. To facilitate understanding, some terms and application scenarios involved in the embodiments of the present application are briefly introduced below.
[0034] The Central Processing Unit (CPU) is one of the main chips in electronic devices and the core component of electronic devices. Its main function is to interpret computer instructions and process data in computer software. All operations in electronic devices are performed by the CPU, which is the core component responsible for reading instructions, decoding instructions and executing instructions.
[0035] Microcontroller Unit (MCU), also known as single chip microcomputer or single chip microcomputer, can appropriately reduce the frequency and specifications of the CPU and reduce the workload of the CPU.
[0036] Analog Digital Singal Processor (ADSP) is a common chip for processing digital signals.
[0037] Power Management IC (PMIC): It is used to manage the power devices in the host system and is commonly used in mobile phones and various terminal devices.
[0038] USBPHY (Universal Serial Bus Physical Layer, USBPHY): Physical layer hardware of the Universal Serial Bus (USB) interface for data transmission.
[0039] With the continuous development of science and technology, people use electronic devices in more and more scenarios in their daily lives. Electronic devices are powered by batteries. When the battery of an electronic device is low on power, the battery of the electronic device needs to be charged.
[0040] Please refer to Figure 1 , is a schematic diagram of an example structure of an electronic device provided in an embodiment of the present application. Figure 1 The electronic device shown includes components such as a processor 110 , a memory 120 , a transceiver 130 , a display unit 140 , an input unit 150 , and a power module 160 .
[0041] The processor 110 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 120, and calling data stored in the memory 120, the processor 110 performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor 110 may include one or more processing units; optionally, the processor 110 may integrate an application processor, which mainly processes operating devices, user interfaces, and application programs, etc. Of course, other processors may also be included, which are not listed here one by one.
[0042] The memory 120 can be used to store software programs and modules. The processor 110 executes various electronic functional applications and data processing by running the software programs and modules stored in the memory 120. The memory 120 can mainly include a program storage area and a data storage area, wherein the program storage area can store operating devices, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the electronic device (such as audio data, a phone book, etc.), etc. In addition, the memory 120 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0043] The transceiver 130 can provide wireless communication solutions for electronic applications including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc. The transceiver 130 can be one or more devices integrating at least one communication processing module, for example, an antenna and a baseband processor are integrated into the transceiver 130, or an antenna and a modem processor are integrated into the transceiver 130, etc., which are not limited here.
[0044] The display unit 140 can be used to display information input by the user or information provided to the user and various electronic menus. The display unit 140 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc., which is not limited here.
[0045] The input unit 150 can be used to receive input digital or character information, and to generate key signal inputs related to electronic user settings and function controls. Specifically, the input unit 150 can collect user operations on or near it, and drive the corresponding connection device according to a pre-set program. In addition, the input unit 150 may include a touch panel, which can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel, the input unit 150 may also include other input devices. Specifically, other input devices may include, but are not limited to, one or more of function keys (such as volume control keys, switch keys, etc.), trackballs, joysticks, etc.
[0046] The electronic device also includes a power module 160 for supplying power to various components. Optionally, the power module 160 can be logically connected to the processor 110 through a power management device, so that the power management device can manage charging, discharging, power consumption and other functions.
[0047] Although not shown, the terminal device may further include a camera. Optionally, the camera may be located at the front or rear of the terminal device, which is not limited in the embodiment of the present application.
[0048] It is to be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the terminal device. In other embodiments of the present application, the terminal device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0049] Optionally, the above-mentioned terminal devices may include but are not limited to wearable devices (such as smart bracelets, smart watches, smart glasses, etc.), mobile phones, tablet computers, laptops, smart glasses, smart watches, MP3 players (Moving Picture Experts Group Audio Layer III, Moving Picture Experts Compression Standard Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4) players, desktop computers, laptops, etc.
[0050] Usually, the above Figure 1 The electronic device shown needs to be equipped with a corresponding operating system and run based on the operating system. For example, the operating system of the electronic device can be an Android system, an iOS system, a Linux system, etc.
[0051] Optionally, the electronic device is usually equipped with a charging interface, and the electronic device is connected to the charging interface through various functional modules or charging chips. For example, when charging, the electronic device can be electrically connected to the adapter through the charging interface through the charging chip provided inside. When the electronic device is used as a power source to supply power to other external devices (such as headphones, etc.), the electronic device is electrically connected to the other external devices through the charging interface through other chips.
[0052] For example, please refer to Figure 2 , which shows a schematic diagram of the structure of a charging circuit of a terminal device involved in an embodiment of the present application. Figure 2 As shown, it includes a CPU module 201, an ADSP module 202, a serial port module 203, an MCU module 204, a PMIC module 205, a USBPHY module 206, a first switch 207, and a second switch 208. There are two forms of hardware solutions for realizing fast charging of terminal equipment, one is a microcontroller unit (MCU) method, and the other is a fast charging VOOCPHY method. Figure 2 The figure shows a typical circuit structure diagram of a fast charging solution with an MCU in a terminal device.
[0053] exist Figure 2 In the example, when the terminal device is not connected to the adapter, the charging current is 0, and the first switch 207 is connected to the second switch 208 by default, and the second switch 208 is connected to the serial port module 203, so that when the terminal device is directly connected to the serial port module 203, the serial port data can be output from D+D- (data communication line) by default. When the terminal device is connected to the adapter, the first switch 207 will be connected to the PMIC module 205. When the APSD recognizes that the charger type is a dedicated charging port (Dedicated Charging Port, DCP), the electronic device sets the first switch 207 to the second switch 208, and sets the second switch 208 to the MCU module 204 at the same time, so that the MCU<---->second switch<---->first switch<---->adapter forms a path, and communicates directly through D+D-.
[0054] Please refer to Figure 3 , which shows a schematic diagram of the structure of a charging circuit of another terminal device involved in an embodiment of the present application. Figure 3 As shown, it includes a CPU module 301, an ADSP module 302, a serial port module 303, a VOOCPHY module 304, a USBPHY module 305, and a first switch 306. Figure 3The figure shows a typical circuit structure diagram of a fast charging solution based on ADSP+VOOCPHY in a terminal device. When the terminal device is not connected to the adapter, the charging current is 0, and the first switch 306 is also connected to the serial port module. When the terminal device is connected to the adapter, the first switch 306 is connected to the port shared by PM8350B+VOOCPHY+USBPHY, where PM8350B is an exemplary register.
[0055] Through the above Figure 2 or Figure 3 According to the scheme, in the existing technology, in order to realize the connection between different chips or modules inside the terminal device and the external device, it is realized through a hardware switch, that is, the control chip or control module set inside the electronic device is controlled by the physical hardware switch to turn on the control of the charging interface. The space occupied by the hardware switch needs to be considered in the circuit layout. Therefore, in this case, the design of the physical hardware switch increases the number of components in the hardware circuit to a certain extent, reducing the utilization rate of the internal space of the electronic device.
[0056] In order to further reduce the number of components in the hardware circuit of electronic devices and improve the utilization rate of the internal space of electronic devices, the present application provides an interface control method that can be applied to electronic devices. Through software arbitration, the required functional modules are turned on when different external devices are inserted, and the lines are flexibly switched to achieve the effect of simplifying the circuit.
[0057] Please refer to Figure 4 , which shows a method flow chart of an interface control method provided by an exemplary embodiment of the present application, the interface control method can be applied to an electronic device, the electronic device includes at least two functional modules, and the at least two functional modules are respectively connected to the data communication line (D+D-). Figure 4 As shown, the interface control method may include the following steps:
[0058] Step 401, monitoring whether an insertion event occurs in the electronic device.
[0059] Optionally, the electronic device is provided with a physical interface, such as a charging interface for charging a power source, and the external device can be connected to the electronic device by being inserted into the physical interface. The electronic device can monitor whether an insertion event occurs through the physical interface, and if an insertion event occurs, the subsequent step 402 is executed, and if no insertion event occurs, the monitoring can be continued.
[0060] Please refer to Figure 5 , which shows a circuit diagram of a data communication line inside an electronic device involved in an exemplary embodiment of the present application. Figure 5As shown, it includes a first functional module 501, a second functional module 502, and a data communication line (D+D-) 503. Figure 5 In the embodiment, each functional module is connected to the data communication line (D+D-), which is equivalent to sharing the same data communication line (D+D-). If an external device is inserted into the electronic device, it will also establish a connection with a functional module inside the electronic device through the data communication line (D+D-).
[0061] Step 402: when an insertion event occurs, determine the device type of the inserted external device.
[0062] Optionally, when the electronic device detects an insertion event, that is, an external device is inserted, the electronic device determines the device type of the inserted external device. Optionally, the device type includes a first type and a second type. When the external device is of the first type (such as headphones, USB flash drives and other external devices), the electronic device needs to supply power to the external device as a power source. When the external device is of the second type (such as adapters, computers and other external devices), the external device supplies power to the electronic device as a power source to perform charging and other processes. For different types of external devices, the electronic device needs to turn on different functional modules. Therefore, in this step, the device type is determined so that the subsequent steps can determine the connection between the corresponding functional modules and the data communication line according to the device type.
[0063] Step 403, determine the target functional module according to the device type of the external device, and connect the target functional module to the data communication line to implement the function corresponding to the target functional module. The target functional module is one of at least two functional modules, and different functional modules correspond to different functions, including at least one of charging and discharging and data transmission.
[0064] Optionally, the electronic device determines which functional module is connected to the data communication line (D+D-) according to the device type of the determined external device, so as to provide different functions. For example, when the target functional module is a universal serial bus USB physical module, a PMIC module, the PMIC module can provide a management function for the battery charging process, and the USB physical module can provide functions such as data interaction between the electronic device and the external device. Therefore, if the device type of the external device determined above is the first type, the external device is a USB flash drive, headphones, etc., the USB physical module needs to be connected between the electronic device and the external device, and the required data is transmitted through the path between the USB physical module and the data communication line. If the device type of the external device determined above is the second type, the external device is an adapter, etc., the PMIC module needs to be connected between the electronic device and the external device, and the charging process is managed through the path between the PMIC module and the data communication line.
[0065] Through the above process, the electronic device can use software arbitration to determine which functional module among the functional modules that share a D+D- line to be turned on, thereby accurately controlling the permissions of D+D-, so that different functional modules can implement related functions. There is no need to arrange hardware switches for switching, which saves the use of hardware switches on the device, reduces the number of components in the hardware circuit of the electronic device, saves costs, and improves the utilization rate of the internal space of the electronic device.
[0066] In summary, monitor whether an insertion event occurs in an electronic device; in the event of an insertion event, determine the device type of the inserted external device; determine the target functional module according to the device type of the external device, and connect the target functional module to the data communication line to realize the function corresponding to the target functional module, the target functional module is one of at least two functional modules, different functional modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission. In this application, the electronic device connects different internal functional modules to the data communication line in hardware, determines the device type of the external device based on the occurrence of the insertion event, and thus determines that the target functional module is connected to the data communication line. In this way, the target power module in multiple functional modules is connected to the data communication line through the software process, and there is no need to set up additional switch devices for control, which reduces the number of components of the hardware circuit of the electronic device and improves the utilization rate of the internal space of the electronic device.
[0067] In one possible implementation, each of the above functional modules includes a configuration register, and the configuration register is used for each functional module to configure the data communication line to achieve flexible conduction. The following takes the example that each functional module includes a USB physical module, a PMIC module, and a fast charging module, and the data communication lines D+D- of these functional modules are directly connected in physical hardware to introduce the above solution.
[0068] Among them, the data communication lines D+D- of each functional module inside the electronic device are directly connected in physical hardware. It can be understood that there is no need for any hardware switching method. The USB physical module, PMIC module, and fast charging module can each communicate directly with external devices through D+D-. Therefore, it is necessary to use software arbitration to reasonably schedule the control authority of D+D- according to the type of external device and the working timing of the electronic device.
[0069] Please refer to Figure 6 , which shows a method flow chart of an interface control method provided by an exemplary embodiment of the present application, the interface control method can be applied to an electronic device, the electronic device includes at least two functional modules, and the at least two functional modules are respectively connected to the data communication line (D+D-). Figure 6As shown, the interface control method may include the following steps:
[0070] Step 601, monitoring whether an insertion event occurs in the electronic device.
[0071] Optionally, the electronic device monitors whether an insertion event occurs in the electronic device through a physical interface of the data communication line. The physical interface may be a charging interface, such as a type C interface. If an external device is inserted into the physical interface, an insertion event is detected, and if no external device is inserted into the physical interface, no insertion event occurs.
[0072] After the electronic device is started, it will always monitor whether there is an external device plugged in. Taking the Type C interface as an example, the electronic device will monitor through the CC pin of the Type C protocol. Figure 7 , which shows a schematic diagram of the structure of a type C interface involved in an exemplary embodiment of the present application. Figure 7 As shown, it includes cc pin 701 and other pins 702. The pins of the type C interface are symmetrical and support forward and reverse insertion. The type C interface supports protocols such as USB and DP. Electronic devices can identify the connected external device based on cc pin 701.
[0073] Step 602: When an insertion event occurs, determine the device type of the inserted external device.
[0074] Optionally, when the electronic device detects an insertion event, it further determines the device type of the inserted external device. The device type of the external device includes the type of the powered device and the type of the power supply device. That is, one type is a device that supplies power to the electronic device, such as a HOST device, a charger adapter, etc. Another type is a device that supplies power to the external device from the electronic device, such as a USB flash drive, headphones, etc.
[0075] In a possible implementation, when the electronic device detects that the above-mentioned physical interface is plugged by an external device, it can determine the device type of the external device according to the pull-up / pull-down resistor of the target pin in the physical interface. For example, the physical interface is a type C interface, and the target pin is a cc pin. When an insertion event occurs in the physical interface, the electronic device can determine the device type of the inserted external device as follows: when an insertion event occurs in the physical interface, determine the resistance type of the resistor connected to the cc pin of the type C interface; and determine the device type of the inserted external device according to the resistance type.
[0076] For example, when the physical interface detects an insertion event, the electronic device can obtain the resistance type of the resistor connected to the cc pin, and determine the device type of the inserted external device according to the resistance type. Please refer to Table 1, which shows a corresponding relationship table between a resistance type and a device type involved in an exemplary embodiment of the present application.
[0077] Table 1 Correspondence between resistor types and device types
[0078] Resistor Type Device Type Rp resistance Power supply equipment type Rd resistance Powered device type
[0079] The corresponding relationship shown in Table 1 above is exemplary. In actual applications, for device types with finer granularity, more resistor types may correspond, which will not be described here. If the resistor type of the resistor connected to the cc pin of the type C interface is detected as an Rp resistor, by querying Table 1, it can be obtained that the corresponding device type is a power supply device type.
[0080] In one possible implementation, when an insertion event occurs at the charging interface, the electronic device determines the resistance type of the resistor connected to the CC pin of the Type C interface as follows: when an insertion event occurs at the charging interface, obtain the voltage value of the CC pin of the Type C interface; calculate the size of the resistor connected to the CC pin of the Type C interface based on the voltage value; and determine the resistance type of the resistor connected to the CC pin of the Type C interface based on the resistance size.
[0081] For example, the electronic device detects an insertion event through the physical interface, obtains the voltage value of the cc pin of the type C interface, calculates the resistance of the resistor connected at this time according to the voltage value, and determines the type of resistor according to the resistance. Since the cc pin is pre-connected to GND through a preset resistor, if an external device is inserted, the external device will also affect the resistance at the cc pin, and the voltage value of the cc pin of the type C interface obtained inside the electronic device will also change. The voltage value obtained by the electronic device calculates the corresponding resistance, thereby determining the resistance type of the resistor. Please refer to Table 2, which shows a corresponding relationship table between a resistance range and a resistance type involved in an exemplary embodiment of the present application.
[0082] Table 2 Correspondence between resistance range and resistance type
[0083] Resistance Range Resistor Type Resistance Range 1 Rp resistance Resistance Range 2 Rd resistance
[0084] The corresponding relationship shown in Table 2 is exemplary. In practical applications, more fine-grained resistor types may correspond to more resistor ranges, which will not be described in detail here. If the range of the calculated resistance value is resistance range 1, then by querying Table 2, it can be obtained that the corresponding resistance type is Rp resistance.
[0085] That is to say, in the type C interface of the electronic device, the cc pin needs to have a pull-up / pull-down resistor inside the downstream port (Downstream Facing Port, DFP) and the upstream port (Upstream Facing Port, UFP), respectively, and the pull-up / pull-down resistor is used to identify the respective functions. The electronic device detects the cc pin to determine whether the pull-up resistor (Rp resistor) or the pull-down resistor (Rd resistor) is connected, thereby confirming the load information (i.e., the device type of the connected external device). The cc pin inside the DFP is pulled up to the power supply through different Rp, and the cc pin inside the UFP is pulled down to GND through a 5.1K resistor (i.e., a preset resistor). If the resistor type is an Rp resistor, the DFP can be considered to be connected to an external device such as a HOST device or a power adapter; if the resistor type is an Rd resistor, the UFP can be considered to be connected to a powered external device such as a headset, a USB flash drive, etc. Here, it is also exemplary that the cc pin inside the UFP is pulled down to GND through a 5.1K resistor. In actual applications, the resistors connected to the cc pins in different typec cables or otg cables may be different, and this is not limited here.
[0086] Step 603: Determine the target functional module according to the device type of the external device.
[0087] Optionally, after determining the device type of the external device, the electronic device determines a target functional module that meets the requirements of the device type according to the device type of the external device, so that subsequent electronic devices can better interact with the external device and implement functions corresponding to the target functional module.
[0088] Optionally, the electronic device includes at least two functional modules including a USB physical module and a PMIC module; the electronic device can determine the target functional module according to the device type of the external device as follows: when the device type of the external device is a powered device type, determine that the USB physical module is the target functional module; when the device type of the external device is a power supply device type, determine that the PMIC module is the target functional module.
[0089] For example, the electronic device can also establish a correspondence between different device types and different functional modules. The functional module corresponding to the above-mentioned powered device type is a USB physical module, and the functional module corresponding to the power supply device type is a PMIC module. The electronic device determines the target functional module from at least two functional modules through the correspondence.
[0090] Optionally, the at least two functional modules included in the electronic device also include a fast charging module; when the device type of the external device is a power supply device type, after determining that the PMIC module is the target functional module, the electronic device can also determine the charging port type through the PMIC module; when the charging port type is a dedicated charging port DCP type, the target functional module is switched to the fast charging module; when the charging port type is not a dedicated charging port DCP type, the target functional module is switched to the USB physical module.
[0091] The fast charging module is used to control the fast charging of electronic devices. For example, the fast charging module can be a VOOCPHY module, a SVOOCPHY module, etc. When the fast charging module is included, if the device type of the external device determined by the electronic device is a power supply device type, the PMIC module is determined to be the target functional module, and step 604 is executed to set the state of the PMIC and the data communication line D+D- to a conduction model, and load the BC1.2 protocol on the data communication line D+D- through the PMIC module to further identify the charging port type of the currently connected external device. If the charging port type of the external device is a dedicated port type DCP, then it is a standard adapter (i.e., an adapter that supports fast charging). At this time, the electronic device will switch the target functional module to the fast charging module, so that the state of the fast charging module and the data communication line can be set to a conduction mode later to provide a fast charging function. If the charging port type of the external device is not a dedicated port type DCP, it may be a standard downstream port SDP or a charging downstream port CDP, then it is an ordinary charging device, such as a computer with data interaction capability. At this time, the electronic device will switch the target functional module to a USB physical module, so that the status of the USB physical module and the data communication line can be set to a conduction mode later, providing data interaction and ordinary charging functions.
[0092] That is to say, after the electronic device determines the device type of the external device, it can first determine the corresponding target functional module from the USB physical module and the PMIC module. When the device type of the external device is a power supply device type, and the electronic device itself also has a fast charging module, a secondary identification is performed on the basis of the fast charging module, and the charging port types of different external devices are identified through the PMIC module, and then it is determined again whether the data communication line D+D- needs to be switched to the fast charging module to facilitate fast charging. Alternatively, the data communication line D+D- is switched to the USB physical module to facilitate data exchange between power supply devices such as computers and electronic devices.
[0093] Step 604, setting the state between the target functional module and the data communication line to a conducting mode, and setting the state between the remaining functional modules and the data communication line to a non-conducting mode, so that the target functional module and the data communication line are conducting.
[0094] Optionally, after the electronic device determines the target functional module, it sets the state of the target functional module and the data communication line to a conduction mode, so that the target functional module transmits the target signal through the data communication line to realize the function corresponding to the target functional module. The target functional module is one of at least two functional modules, and different functional modules correspond to different functions, including at least one of charging and discharging and data transmission.
[0095] Optionally, each functional module includes a configuration register, which is used for each functional module to configure the data communication line, setting the state of the target functional module and the data communication line to a conduction mode, and setting the state of the remaining functional modules and the data communication line to a non-conduction mode, including: setting the state of the target functional module and the data communication line to a conduction mode through the configuration register, and setting the state of the remaining functional modules and the data communication line to a high-impedance mode.
[0096] For example, each functional module in the electronic device is configured with a configuration register, and the conduction between the target functional module and the data communication line is controlled by adjusting the state of the configuration register. For example, the above-mentioned at least two functional modules include: a USB physical module and a PMIC module. When it is determined that the USB physical module is the target functional module, the configuration register set for the data communication line in the USB physical module is set to a conduction mode, and the configuration register set for the data communication line in the PMIC module is set to a high-impedance mode; when it is determined that the PMIC module is the target functional module, the configuration register set for the data communication line in the PMIC module is set to a conduction mode, and the configuration register set for the data communication line in the USB physical module is set to a high-impedance mode.
[0097] For example, the at least two functional modules include: a USB physical module, a PMIC module and a fast charging module. When it is determined that the USB physical module is the target functional module, the configuration register for the data communication line in the USB physical module is set to the conduction mode, the configuration register for the data communication line in the PMIC module is set to the high-impedance mode, and the configuration register for the data communication line in the fast charging module is set to the high-impedance mode. When it is determined that the PMIC module is the target functional module, the configuration register for the data communication line in the PMIC module is set to the conduction mode, the configuration register for the data communication line in the USB physical module is set to the high-impedance mode, and the configuration register for the data communication line in the fast charging module is set to the high-impedance mode. And execute the above-mentioned step of determining the charging port type through the PMIC module. If the charging port type determined in the subsequent step is a dedicated charging port DCP type, switch the target functional module to the fast charging module; at this time, re-set the configuration register for the data communication line in the fast charging module to the conduction mode, set the configuration register for the data communication line in the PMIC module to the high impedance mode, and set the configuration register for the data communication line in the USB physical module to the high impedance mode. If the determined charging port type is not a dedicated charging port DCP type, switch the target functional module to the USB physical module; at this time, re-set the configuration register for the data communication line in the USB physical module to the conduction mode, set the configuration register for the data communication line in the PMIC module to the high impedance mode, and set the configuration register for the data communication line in the fast charging module to the high impedance mode.
[0098] In a possible implementation, the electronic device also includes a serial port module, which can be used to receive parallel data characters of the CPU, convert them into continuous serial data streams and send them out, and can also convert the received serial data streams into parallel data characters to supply the CPU. The serial port module is also connected to the data communication line. When the electronic device detects that no insertion event has occurred, the general input / output port GPIO of the serial port module is set to a transceiver mode, and the state of each functional module and the data communication line is set to a non-conduction mode, so that the serial port module and the data communication line are connected. For example, when the electronic device does not have an insertion event, the physical interface of the electronic device is idle. At this time, the general input / output port GPIO of the serial port module is set to a transceiver mode, so that the serial port module and the data communication line D+D- are connected, and other functional modules are set to a high-impedance mode. The physical interface is a type C interface. The electronic device can set the GPIO of the TX\RX two lines of the serial port module to a serial port transceiver mode. At this point, if the electronic device is connected to the serial port line, the bit stream information of the relevant debug log will be output synchronously in real time on D+D-, which is convenient for developers to debug and analyze problems.
[0099] Optionally, after determining that the target functional module is connected to the data communication line, the electronic device can also set the general input / output port GPIO of the serial port module to input mode. That is, the several target functional modules involved in the above embodiments are determined, and the state of the target functional module and the data communication line is set to the conduction mode by configuring the register, and the state of the remaining functional modules and the data communication line is set to the high-impedance mode, and the GPIO of the serial port module is set to the input mode. The serial port mode configured to the input mode will not output the level, thereby reducing the communication impact on other functional modules when they are connected.
[0100] Optionally, after executing the above process, continue to monitor whether the electronic device has an unplug event; if an unplug event occurs, re-execute the step of monitoring whether the electronic device has an plug event. In this cycle, the electronic device is monitored in real time, and the conduction status of each functional module and the data communication line D+D- is changed in time.
[0101] It should be noted that the above-mentioned USB physical module, PMIC module, fast charging module and serial port module can be integrated into the integrated circuit chip (System-on-a-Chip, SOC) of the electronic device and uniformly deployed through the SOC. Figure 8 , which shows a hardware structure block diagram of an electronic device involved in an exemplary embodiment of the present application. Figure 8 As shown, it includes a SOC chip 801, a serial port module 802, a USB physical module 803, a PMIC module 804, a fast charging module 805, a data communication line D+D-806, and a physical interface 807. Each functional module shares a data communication line D+D-806, and the conduction or non-conduction of each functional module and the data communication line D+D-806 can be controlled by the SOC. The implementation details can refer to this embodiment and will not be repeated here.
[0102] In summary, monitor whether an insertion event occurs in an electronic device; in the event of an insertion event, determine the device type of the inserted external device; determine the target functional module according to the device type of the external device, and connect the target functional module to the data communication line to realize the function corresponding to the target functional module, the target functional module is one of at least two functional modules, different functional modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission. In this application, the electronic device connects different internal functional modules to the data communication line in hardware, determines the device type of the external device based on the occurrence of the insertion event, and thus determines that the target functional module is connected to the data communication line. In this way, the target power module in multiple functional modules is connected to the data communication line through the software process, and there is no need to set up additional switch devices for control, which reduces the number of components of the hardware circuit of the electronic device and improves the utilization rate of the internal space of the electronic device.
[0103] In addition, the present application controls the conduction between the functional module and D+D- in real time through software arbitration to ensure the normal implementation of existing functions and is compatible with different platforms, such as QCOM and MTK platforms. Moreover, the type of charging interface is further determined based on the fast charging protocol, and the conduction between the fast charging module and D+D- is provided, which simplifies the circuit design.
[0104] Below, taking the electronic device as a mobile phone, the physical interface of the mobile phone as a type C interface, and regarding the connection between the above-mentioned control target functional module and the data communication line as transferring the control authority of the data communication line to the target functional module as an example, the interface control methods provided in the above-mentioned embodiments are explained by examples.
[0105] Please refer to Fig. 9 , which shows a method flow chart of an interface control method provided by an exemplary embodiment of the present application, and the interface control method can be applied to a mobile phone. Fig. 9 As shown, the interface control method may include the following steps.
[0106] Step 901: The mobile phone determines whether an external device is inserted.
[0107] Step 902: Check whether a cc pin interrupt occurs.
[0108] If no cc pin interruption occurs, execute step 903 to step 904; if a cc pin interruption occurs, execute step 905.
[0109] Step 903: Give the control authority of D+D- to the serial port module.
[0110] Step 904, setting the GPIO of the serial port module to the serial port transceiver mode, and setting the configuration registers of other functional modules to the high impedance mode.
[0111] That is to say, when there is no cc pin insertion interrupt or cc pin unplug interrupt, the control authority of D+D- will be handed over to the serial port module. At this time, the D+D- configuration register of the USBPHY\PMIC\fast charging module needs to be set to high-impedance mode. Set the GPIO of the TX\RX lines of the serial port module to the serial port transceiver mode. At this point, the mobile phone connected to the serial port line will output the relevant debug log bit stream information on D+D- in real time, which is convenient for developers to debug and analyze problems.
[0112] Step 905, determine whether it is the Rd resistor.
[0113] If it is an Rd resistor, it means that the external device is a device device (powered device type), and step 906 to step 907 are executed. If it is not an Rd resistor, it means that it is an Rp resistor and the external device is a source device (powered device type), and step 908 is executed.
[0114] Step 906: Hand over the control authority of D+D- to the USBPHY module.
[0115] Step 907, setting the configuration register of the USBPHY module to the conduction mode, setting the configuration registers of other functional modules to the high impedance mode, and setting the GPIO of the serial port module to the input mode.
[0116] That is to say, when there is a cc pin interrupt, it will determine whether the cc pin of the mobile phone is connected to the Rd resistor or the Rp resistor. If it is the Rd resistor, then the external device connected can only be a device (such as a USB flash drive, digital headphones, etc.). At this time, the mobile phone acts as a source to power the external device, and the control authority of D+D- can only be given to the USBPHY module for data communication between the mobile phone and the device. At this time, the D+D- configuration registers of the PMIC module and the fast charging module need to be set to high-impedance mode; set the GPIO of the serial port module to input mode. If the input mode is configured, the serial port will not output the level, which will not affect the communication of the USBPHY.
[0117] Step 908: hand over the control authority of D+D- to the PMIC module.
[0118] Step 909, setting the configuration register of the PMIC module to the conduction mode, setting the configuration registers of other functional modules to the high impedance mode, and setting the GPIO of the serial port module to the input mode.
[0119] Step 910: The PMIC module performs charging protocol identification and identifies the charging port type.
[0120] Step 911, determine whether the charging port type is a DCP type.
[0121] If it is a DCP type, execute steps 912 to 913; if it is not a DCP type, execute steps 914 to 915.
[0122] Step 912, hand over the control authority of D+D- to the fast charging module.
[0123] Step 913, set the configuration register of the fast charging module to the conduction mode, set the configuration registers of other functional modules to the high-impedance mode, and set the GPIO of the serial port module to the input mode.
[0124] Step 914: hand over the control authority of D+D- to the USBPHY module.
[0125] Step 915, setting the configuration register of the USBPHY module to the conduction mode, setting the configuration registers of other functional modules to the high impedance mode, and setting the GPIO of the serial port module to the input mode.
[0126] During the execution of step 908 to step 915, when there is a cc pin interruption, and the connected external device is represented by an Rp resistor, the mobile phone is used as a device, and the external device is used as a source to power the mobile phone (such as an adapter). Then, the D+D- control authority needs to be given to the PMIC module for the type identification of the connected charger. That is, the D+D- configuration registers of the USBPHY module and the fast charging module are set to high-impedance mode; the GPIO of the serial port module is set to input mode.
[0127] Then PMIC controls D+D- to load the charging protocol (such as BC1.2 protocol) on it, and then it can be identified as the type of charging port of the currently connected external device. If it is DCP, it is a standard adapter. If it is SDP or CDP, the connected power source is a computer with data exchange capabilities. Therefore, secondary identification can be performed on the basis of DCP. When DCP is identified, the control authority of D+D- must be handed over to the fast charging module, and then the D+D- configuration registers of the PMIC module and the USBPHY module are set to high-impedance mode; the GPIO of the serial port module is set to input mode. If it is SDP or CDP, the control authority of D+D- will be handed over to the USBPHY module for the computer to exchange data with the mobile phone, so that the mobile phone can access the mobile phone files in the form of folders, that is, the D+D- configuration registers of the PMIC module and the fast charging module are set to high-impedance mode; the GPIO of the serial port module is set to input mode.
[0128] Step 916, monitor the type C interface unplug event.
[0129] Optionally, the mobile phone monitors the insertion and removal events of typec at all times, that is, monitors whether the mobile phone has a connected resistor, and determines whether it is an Rp resistor or an Rd resistor, so that the control authority of D+D- can be changed in real time according to the status of typec.
[0130] In summary, in this application, different functional modules inside the mobile phone are connected to the data communication line. Based on the occurrence of the insertion event, the device type of the external device is determined, thereby determining that the target functional module is connected to the data communication line. The target power module among multiple functional modules is connected to the data communication line through the software process. There is no need to set up additional switch devices for control, which reduces the number of components in the hardware circuit of the mobile phone and improves the utilization rate of the internal space of the mobile phone. It can effectively and correctly control the D+D- permissions in real time, so that the relevant functions can be implemented normally, and there is no need to use the hardware switch of the load switch.
[0131] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.
[0132] Please refer to Fig.10 , which shows a structural block diagram of an interface control device provided by an exemplary embodiment of the present application. The interface control device 1000 can be used in an electronic device to perform Figure 4 , Figure 6 or Fig. 9 All or part of the steps in the method provided by the illustrated embodiment are performed by the electronic device. The electronic device includes at least two functional modules, and the at least two functional modules are connected to the data communication line one by one. The interface control device 1000 includes:
[0133] The first monitoring module 1001 is used to monitor whether an insertion event occurs in the electronic device;
[0134] A first determination module 1002 is used to determine the device type of the inserted external device when an insertion event occurs;
[0135] The second determination module 1003 is used to determine, based on the device type of the external device, whether the target function module is connected to the data communication line, so that the target function module transmits the target signal through the data communication line to implement the function corresponding to the target function module, the target function module is one of the at least two function modules, different function modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission.
[0136] In summary, monitor whether an insertion event occurs in an electronic device; in the event of an insertion event, determine the device type of the inserted external device; determine the target functional module according to the device type of the external device, and connect the target functional module to the data communication line to realize the function corresponding to the target functional module, the target functional module is one of at least two functional modules, different functional modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission. In this application, the electronic device connects different internal functional modules to the data communication line in hardware, determines the device type of the external device based on the occurrence of the insertion event, and thus determines that the target functional module is connected to the data communication line. In this way, the target power module in multiple functional modules is connected to the data communication line through the software process, and there is no need to set up additional switch devices for control, which reduces the number of components of the hardware circuit of the electronic device and improves the utilization rate of the internal space of the electronic device.
[0137] Optionally, the second determining module 1003 includes: a first determining unit, a first setting unit;
[0138] The first determining unit is used to determine the target functional module according to the device type of the external device;
[0139] The first setting unit is used to set the state of the target functional module and the data communication line to a conducting mode, and the state of other functional modules and the data communication line to a non-conducting mode, so that the target functional module and the data communication line are conducting.
[0140] Optionally, each functional module includes a configuration register, and the configuration register is used for each functional module to configure the data communication line, and the first setting unit is further used to:
[0141] The state of the target functional module and the data communication line is set to the conduction mode through the configuration register, and the state of the remaining functional modules and the data communication line is set to the high impedance mode.
[0142] Optionally, the at least two functional modules include a universal serial bus USB physical module and a power management chip PMIC module;
[0143] The first determining module 1002 includes: a second determining unit and a third determining unit;
[0144] The second determining unit is used to determine that the USB physical module is the target functional module when the device type of the external device is a powered device type;
[0145] The third determining unit is configured to determine that the PMIC module is the target functional module when the device type of the external device is a power supply device type.
[0146] Optionally, the at least two functional modules further include a fast charging module;
[0147] The device also includes:
[0148] A third determination module, configured to determine a charging port type through the PMIC module after determining that the PMIC module is the target functional module when the device type of the external device is a power supply device type;
[0149] A first switching module, configured to switch the target functional module to the fast charging module when the charging port type is a dedicated charging port DCP type;
[0150] The second switching module is used to switch the target functional module to the USB physical module when the charging port type is not the dedicated charging port DCP type.
[0151] Optionally, the electronic device further includes a serial port module, and the serial port module is also connected to the data communication line. The device further includes:
[0152] The first setting module is used to set the general input / output port GPIO of the serial port module to a transceiver mode and set the status of each functional module and the data communication line to a non-conduction mode when no insertion event occurs, so that the serial port module and the data communication line are connected.
[0153] Optionally, the device further comprises:
[0154] The second setting module is used to set the general input / output port GPIO of the serial port module to an input mode after the target functional module is determined to be connected to the data communication line.
[0155] Optionally, the first monitoring module 1001 is used to:
[0156] Whether an insertion event occurs to the electronic device is monitored through the physical interface of the data communication line.
[0157] Optionally, the physical interface is a type C interface, and the first determining module 1002 includes: a fourth determining unit and a fifth determining unit;
[0158] The fourth determining unit is used to determine the resistance type of the resistor connected to the cc pin of the type C interface when an insertion event occurs;
[0159] The fifth determining unit is configured to determine a device type of the inserted external device according to the resistor type.
[0160] Optionally, the fourth determining unit includes: a first acquiring subunit, a first calculating subunit and a first determining subunit;
[0161] The first acquisition subunit is used to acquire the voltage value of the CC pin of the type C interface when an insertion event occurs in the charging interface;
[0162] The first calculation subunit is used to calculate the resistance connected to the cc pin of the type C interface according to the voltage value;
[0163] The first determining subunit is used to determine the resistance type of the resistor connected to the CC pin of the type C interface according to the resistance size.
[0164] Optionally, the device further comprises:
[0165] A second monitoring module, configured to monitor whether an unplugging event occurs in the electronic device after determining that the target functional module is connected to the data communication line according to the device type of the external device;
[0166] The first execution module is used to re-execute the step of monitoring whether an insertion event occurs in the electronic device when an unplugging event occurs.
[0167] Please refer to Fig.11 , which is a structural diagram of another example of the interface control device provided in the embodiment of the present application. Among them, the interface control device 1100 can be an electronic device that can implement the functions in the method provided in the embodiment of the present application. Among them, the interface control device 1100 can be a chip system. In the embodiment of the present application, the chip system can be composed of chips, or it can include chips and other discrete devices.
[0168] In hardware implementation, the above communication module may be a transceiver, and the transceiver is integrated in the interface control device 1100 to form the communication interface 1103 .
[0169] The interface control device 1100 includes at least one processor 1101, which is used to implement or support the interface control device 1100 to implement the functions of the electronic device in the method provided in the embodiment of the present application. Exemplarily, the processor 1101 can monitor whether an insertion event occurs in the electronic device; in the event of an insertion event, determine the device type of the inserted external device; according to the device type of the external device, determine that the target functional module is connected to the data communication line, so that the target functional module transmits the target signal through the data communication line, and implements the function corresponding to the target functional module and other steps. Please refer to the detailed description in the method example for details, which will not be repeated here.
[0170] The interface control device 1100 may also include at least one memory 1102 for storing program instructions and / or data. The memory 1102 is coupled to the processor 1101. The coupling in the embodiment of the present application is an indirect coupling or communication connection between devices, units or modules, which may be electrical, mechanical or other forms, and is used for information exchange between devices, units or modules. The processor 1101 may operate in coordination with the memory 1102. The processor 1101 may execute program instructions stored in the memory 1102. At least one of the at least one memory may be included in the processor.
[0171] The interface control device 1100 may also include a communication interface 1103, which is used to communicate with other devices through a transmission medium, so that the device in the interface control device 1100 can communicate with other devices. Exemplarily, the other device may be a network side device. The processor 1101 may use the communication interface 1103 to send and receive data. The communication interface 1103 may specifically be a transceiver.
[0172] The specific connection medium between the communication interface 1103, the processor 1101 and the memory 1102 is not limited in the embodiment of the present application. Fig.11 In the embodiment, the memory 1102, the processor 1101 and the communication interface 1103 are connected via a bus 1104. Fig.11 The connections between the other components are shown in bold lines, which are only for illustration and are not intended to be limiting. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.11 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0173] In the embodiment of the present application, the processor 1101 may be a general-purpose processor, a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiment of the present application. The general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiment of the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0174] In an embodiment of the present application, the memory 1102 may be a non-volatile memory, such as a hard disk drive (HDD) or a solid-state drive (SSD), etc., or a volatile memory (volatile memory), such as a random access memory (RAM). The memory is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory in the embodiment of the present application may also be a circuit or any other device that can implement a storage function, for storing program instructions and / or data.
[0175] Optionally, an embodiment of the present application further provides an electronic device, the electronic device comprising a processor and a memory, the memory storing a computer program, the computer program being executed by the processor to implement all or part of the steps performed by the electronic device in the interface control method described in the above embodiments.
[0176] Optionally, an embodiment of the present application further provides a computer-readable medium storing a computer program, which is executed by a processor to implement all or part of the steps performed by the electronic device in the interface control method described in the above embodiments.
[0177] Optionally, an embodiment of the present application also provides a computer program product, which stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set are loaded and executed by the processor to implement the interface control method described in the above embodiments, and all or part of the steps executed by the electronic device.
[0178] It should be noted that: when the device provided in the above embodiment performs the control of the electronic device, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the device and method embodiments provided in the above embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.
[0179] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0180] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0181] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. An interface control method, characterized in that: Applied to an electronic device, the electronic device includes at least two functional modules, the at least two functional modules are respectively connected to a data communication line, and the method includes: Monitoring whether an insertion event occurs in the electronic device; In the event of an insertion event, determining a device type of the inserted external device; According to the device type of the external device, a target functional module is determined, and the target functional module is connected to the data communication line to implement the function corresponding to the target functional module. The target functional module is one of the at least two functional modules, and different functional modules correspond to different functions, including at least one of charging and discharging and data transmission.
2. The method according to claim 1, characterized in that The step of connecting the target functional module to the data communication line comprises: The state of the target functional module and the data communication line is set to a conducting mode, and the state of the remaining functional modules and the data communication line is set to a non-conducting mode, so that the target functional module and the data communication line are conducting.
3. The method according to claim 2, characterized in that Each functional module includes a configuration register, and the configuration register is used for each functional module to configure the data communication line, and the state of the target functional module and the data communication line is set to a conducting mode, and the state of the remaining functional modules and the data communication line is set to a non-conducting mode, including: The state of the target functional module and the data communication line is set to the conduction mode through the configuration register, and the state of the remaining functional modules and the data communication line is set to the high impedance mode.
4. The method according to claim 3, characterized in that The at least two functional modules include a universal serial bus USB physical module and a power management chip PMIC module; The step of determining the target functional module according to the device type of the external device includes: When the device type of the external device is a powered device type, determining that the USB physical module is the target functional module; When the device type of the external device is a power supply device type, it is determined that the PMIC module is the target functional module.
5. The method according to claim 4, characterized in that The at least two functional modules also include a fast charging module; After determining that the PMIC module is the target functional module when the device type of the external device is a power supply device type, the method further includes: Determine the charging port type by the PMIC module; When the charging port type is a dedicated charging port DCP type, switching the target functional module to the fast charging module; When the charging port type is not the dedicated charging port DCP type, the target functional module is switched to the USB physical module.
6. The method according to claim 1, characterized in that The electronic device further includes a serial port module, and the serial port module is also connected to the data communication line. The method further includes: When no insertion event occurs, the general input / output port GPIO of the serial port module is set to a transceiver mode, and the states of each functional module and the data communication line are set to a non-conduction mode, so that the serial port module and the data communication line are connected.
7. The method according to claim 6, characterized in that After determining that the target functional module is connected to the data communication line, the method further includes: The general purpose input / output port GPIO of the serial port module is set to input mode.
8. The method according to any one of claims 1 to 7, characterized in that: The monitoring of whether an insertion event occurs in the electronic device comprises: Whether an insertion event occurs to the electronic device is monitored through the physical interface of the data communication line.
9. The method according to claim 8, characterized in that The physical interface is a type C interface, and when an insertion event occurs, determining the device type of the inserted external device includes: In the event of an insertion event, determining the resistance type of the resistor connected to the cc pin of the type C interface; The device type of the inserted external device is determined based on the resistor type.
10. The method according to claim 9, characterized in that The step of determining the resistance type of the resistor connected to the CC pin of the Type C interface when an insertion event occurs includes: When an insertion event occurs, obtaining a voltage value of a cc pin of the type C interface; Calculate the resistance connected to the cc pin of the type C interface according to the voltage value; According to the size of the resistor, the resistance type of the resistor connected to the CC pin of the type C interface is determined.
11. The method according to any one of claims 1 to 7, characterized in that: After determining the target functional module according to the device type of the external device and connecting the target functional module to the data communication line, the method further includes: Monitoring whether an unplugging event occurs in the electronic device; In the event of an unplugging event, the step of monitoring whether an insertion event occurs in the electronic device is performed again.
12. An interface control device, characterized in that: Applied to electronic equipment, the electronic equipment includes at least two functional modules, the at least two functional modules are respectively connected to a data communication line, and the device includes: A first monitoring module, used for monitoring whether an insertion event occurs in the electronic device; A first determination module, used for determining the device type of the inserted external device when an insertion event occurs; The second determination module is used to determine the target function module according to the device type of the external device, and connect the target function module with the data communication line to realize the function corresponding to the target function module, the target function module is one of the at least two function modules, different function modules correspond to different functions, and the functions include at least one of charging and discharging and data transmission.
13. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein a computer program is stored in the memory, and the computer program is executed by the processor to implement the interface control method according to any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and the computer program is executed by a processor to implement the interface control method according to any one of claims 1 to 11.