An apparatus, method for device identification, and an electronic device
By using the ADC pin to directly connect to the CC pin in electronic devices, combined with software detection logic, the complex circuit and high cost problems caused by the CC detection chip are solved, and the accurate identification of external device types is achieved.
Patent Information
- Application Number
- CN202410766769.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-15
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2043-03-15
AI Technical Summary
In the prior art, determining the type of external equipment through CC detection chips results in complex circuit structure and high hardware costs.
The ADC pin is directly connected to the CC pin, combined with the software detection logic, and the CC detection chip is omitted, and the insertion status and external device type of the terminal are detected by detecting the first voltage and the second voltage.
Reduces circuit complexity and hardware cost, while achieving accurate identification of external device types.
Smart Images

Figure CN118606244B_ABST
Abstract
Description
[0001] This application is a divisional application. The application number of the original application is 202310270247.4, and the original application date is March 15, 2023. The entire content of the original application is incorporated herein by reference. Technical Field
[0002] This application relates to the technical field of Universal Serial Bus (USB) connection, and particularly to a device identification apparatus, method, and electronic device. Background Art
[0003] The Universal Serial Bus Type-C (USB Type-C) interface is an interface type that supports both right-side and left-side insertion. It can be used as a charging interface, a display interface, and a data transmission interface, which can improve the user experience.
[0004] The Type-C interface has Configuration Channel (CC) pins. Generally, a CC detection chip can be used to detect the voltage coupled to the CC pins to determine the type of the external device connected thereto.
[0005] However, for an electronic device to determine the type of the external device connected thereto, an additional CC detection chip needs to be added, or other chips that can achieve the same function, such as a Power Delivery (PD) chip, are adopted, resulting in a complex circuit structure and a high hardware cost. Summary of the Invention
[0006] This application provides a device identification apparatus, method, and electronic device, which can solve the problem that determining the type of the external device connected thereto by a chip results in a complex circuit structure and a high hardware cost, eliminates the detection chip, reduces the circuit complexity, and reduces the hardware cost.
[0007] In a first aspect, the present application provides a device identification apparatus, which is applied to an electronic device. The apparatus includes: a first port, including a first configuration channel CC1 pin and a second configuration channel CC2 pin; the CC1 pin is coupled to a first voltage; the CC2 pin is coupled to a second voltage; wherein, the first voltage, and / or, the second voltage changes in response to the insertion of a first terminal into the first port and the removal of the first terminal from the first port; a processor, including a first analog-to-digital conversion ADC1 pin and a second analog-to-digital conversion ADC2 pin; the ADC1 pin is connected to the CC1 pin to form a first detection path; the ADC1 pin is configured to detect the first voltage through the first detection path; the ADC2 pin is connected to the CC2 pin to form a second detection path; the ADC2 pin is configured to detect the second voltage through the second detection path; the processor is configured to identify the insertion state of the first terminal according to the first voltage and the second voltage, and identify the device type of an external device connected to the first terminal.
[0008] In the device identification apparatus shown in the present application, a first detection path is formed by the ADC1 pin and the CC1 pin, and a second detection path is formed by the ADC2 pin and the CC2 pin to respectively detect the first voltage and the second voltage. At the same time, in cooperation with the software detection logic, the functions of identifying the insertion state of the first terminal and the device type of the external device connected to the first terminal are realized, the detection chip is omitted, the circuit complexity is reduced, and the hardware cost is reduced.
[0009] In one implementation, it further includes: a first pull-up resistor, one end of which is coupled to the port power supply and the other end is coupled to the first detection path; the first pull-up resistor is configured to pull up the first voltage to a preset threshold range by using the port power supply; a second pull-up resistor, one end of which is coupled to the port power supply and the other end is coupled to the second detection path; the second pull-up resistor is configured to pull up the second voltage to a preset threshold range by using the port power supply. By adopting this implementation, the first pull-up resistor can provide the port power supply to the CC1 pin, and the second pull-up resistor can provide the port power supply to the CC2 pin. In this way, the first voltage and the second voltage can be within the preset threshold range, and then the insertion state of the first terminal and the device type of the external device connected to the first terminal can be identified according to the preset threshold range.
[0010] In one implementation, it further includes: a first switch, one end of which is coupled to the port power supply and the other end is coupled to the first detection path, and is in series with a first pull-up resistor; a second switch, one end of which is coupled to the port power supply and the other end is coupled to the second detection path, and is in series with a second pull-up resistor. With this implementation, the first switch can control the connection or disconnection of the first pull-up resistor, and the second switch can control the connection or disconnection of the second pull-up resistor. In this way, when it is necessary to detect the insertion state of the first terminal and the device type of the external device, the first switch and the second switch can be closed, and when it is not necessary to identify the insertion state of the first terminal and the device type of the external device, the first switch and the second switch can be disconnected. The setting of the first switch and the second switch can avoid the influence of the continuous connection of the first pull-up resistor and the second pull-up resistor on voltage detection.
[0011] In one implementation, it further includes: a first pull-down resistor, one end of which is coupled to the first detection path and the other end is coupled to the ground; the first pull-down resistor is configured to pull down the first voltage to within a preset threshold range; a second pull-down resistor, one end of which is coupled to the second detection path and the other end is coupled to the ground; the second pull-down resistor is configured to pull down the second voltage to within a preset threshold range. With this implementation, the first pull-down resistor and the second pull-down resistor can provide an inherent pull-down resistor for the electronic device, so that when the first terminal is inserted into the first port, the external device can accurately identify the device type of the electronic device.
[0012] In one implementation, it further includes: a third pull-down resistor, one end of which is coupled to the first detection path and the other end is coupled to the ground, and is in parallel with the first pull-down resistor; a third switch, one end of which is coupled to the first detection path and the other end is coupled to the ground, and is in series with the third pull-down resistor; a fourth pull-down resistor, one end of which is coupled to the second detection path and the other end is coupled to the ground, and is in parallel with the second pull-down resistor; a fourth switch, one end of which is coupled to the second detection path and the other end is coupled to the ground, and is in series with the fourth pull-down resistor. With this implementation, the third pull-down resistor and the fourth pull-down resistor can provide different resistance values to adjust the corresponding first voltage and second voltage. At the same time, when it is necessary to detect the insertion state of the first terminal and the device type of the external device, the third switch and the fourth switch can be closed, and when it is not necessary to detect the insertion state of the first terminal and the device type of the external device, the third switch and the fourth switch can be disconnected to adapt to different scenarios of electronic device applications.
[0013] In one implementation, it further includes: a first diode located on the first detection path, with the anode of the first diode coupled to the ADC1 pin and the cathode of the first diode coupled to the CC1 pin; a second diode located on the second detection path, with the anode of the second diode coupled to the ADC2 pin and the cathode of the second diode coupled to the CC2 pin. With this implementation, the unidirectional conductivity of the first diode and the second diode can prevent the high voltage introduced from the first terminal at the CC1 pin and the CC2 pin from damaging the ADC1 pin and the ADC2 pin.
[0014] In one implementation, the processor includes at least one of a system-on-chip (SOC), a central processing unit (CPU), and a power management unit (PMU). With this implementation, the technical solutions shown in this application can be implemented on multiple processor chips.
[0015] In one implementation, the processor is specifically configured to: obtain a first voltage and a second voltage; match the first voltage and the second voltage with the status codes in a preset first truth table respectively to obtain a first code combination, where the first code combination includes a first target code corresponding to the first voltage and a second target code corresponding to the second voltage; match the first code combination with the code combinations in a preset second truth table to determine the insertion state of the first terminal and / or the device type of the external device. With this implementation, on a simplified circuit without a detection chip, combining this software detection logic can achieve the functions of identifying the insertion state of the first terminal and the device type of the external device connected to the first terminal, eliminating the detection chip, reducing the circuit complexity, and reducing the hardware cost.
[0016] In one implementation, the processor is further configured to: determine the insertion state of the first terminal according to the first voltage and the second voltage; if the insertion state of the first terminal is inserted into the first port, execute the step of matching the first voltage and the second voltage with the status codes in the preset first truth table respectively. With this implementation, the insertion state of the first terminal can be directly determined by the first voltage and the second voltage shown by ADC1 and ADC2.
[0017] In one implementation, the processor is further configured to: after determining the insertion state of the first terminal, if the insertion state of the first terminal is not inserted into the first port, delay for a first duration to obtain the first voltage and the second voltage. With this implementation, it is possible to detect based on the speed at which the user inserts or removes the first terminal to meet the identification requirements for external devices.
[0018] In one implementation, the processor is further configured to: before obtaining the first voltage and the second voltage, detect whether the electronic device is in a sleep state; the sleep state includes: the operating system kernel of the electronic device is completely asleep; if the electronic device is not in the sleep state, obtain the first voltage and the second voltage; if the electronic device is in the sleep state, delay for a second duration to detect whether the electronic device is in the sleep state. By adopting this implementation, the insertion state of the first terminal and the device type of the external device can be recognized only in the non-sleep state, so as to reduce the power consumption of the electronic device.
[0019] In one implementation, the processor is further configured to: after determining the device type of the external device, perform a Universal Serial Bus enumeration with the external device; if the enumeration is successful, determine that the external device is connected; determine whether it matches the device type of the external device according to the first voltage and the second voltage; if the first voltage and the second voltage do not match the device type of the external device, determine whether the first terminal has been unplugged; if the first terminal has been unplugged, detect again whether the electronic device is in the sleep state; if the first terminal has not been unplugged, obtain the insertion state of the first terminal again. By adopting this implementation, after determining that the external device is inserted and the enumeration is successful, regardless of whether the electronic device is in the sleep state, continuously detect the insertion state of the first terminal and the device type of the external device. If the device type of the external device does not match, trigger a re-enumeration. When the first terminal has been unplugged, further determine whether the electronic device is asleep. If the electronic device is asleep, there is no need to continue detecting the voltage. In this way, the purpose of reducing power consumption can be achieved.
[0020] In one implementation, the processor is further configured to: if the first voltage and the second voltage match the device type of the external device, delay for a third duration to obtain the first voltage and the second voltage. By adopting this implementation, the acquisition of the first voltage and the second voltage can be delayed for a third duration to timely obtain the insertion state of the first terminal and the device type of the external device.
[0021] In one implementation, the processor is specifically configured to: determine a first target threshold corresponding to the first voltage, and determine a first target code according to the first target threshold; and determine a second target threshold corresponding to the second voltage, and determine a second target code according to the second target threshold. By adopting this implementation, the insertion state of the first terminal is determined by matching the first voltage with the first target threshold and matching the second voltage with the second target threshold.
[0022] In one implementation, the processor is further configured to: if the first target threshold or the second target threshold is the first preset threshold, determine the number of pull-up resistors coupled to the first terminal according to the first voltage, the second voltage, and the first preset threshold. With this implementation, it can be identified whether one pull-up resistor or two pull-up resistors are coupled from the first terminal to the port power supply of the external device based on the first voltage, the second voltage, and the first preset threshold. In this way, the data line type of the universal serial bus can be determined.
[0023] In one implementation, the processor is further configured to: if the first target threshold or the second target threshold is the second preset threshold, determine that the first terminal is a dual-role port (DRP); determine whether the first port is a downstream-facing port (DFP) or an upstream-facing port (UFP) according to the internal configuration of the electronic device. With this implementation, according to the matching result, the role capabilities of the first terminal can be determined. If the first terminal is a dual-role port, the role corresponding to the first port can be determined.
[0024] In one implementation, the device type of the external device includes at least one of an on-the-go (OTG) device for data exchange, a debugging device, an audio device, a power adapter, and a power delivery (PD) device for energy transfer. With this implementation, the solution shown in this application can identify the device types of various external devices.
[0025] In one implementation, the processor is specifically configured to: if a first diode is provided in the first detection path and a second diode is provided in the second detection path, the first target threshold is determined according to the temperature of the first diode, and the second target threshold is determined according to the temperature of the second diode. In this way, in the circuit with diodes and the circuit without diodes, the threshold values are adaptively adjusted to ensure the accuracy of identifying the insertion state of the first terminal and the device type of the external device.
[0026] In a second aspect, this application provides an electronic device, including the device identification device as described in the first aspect and its implementations above.
[0027] In a third aspect, the present application provides a device identification method, which is applied to the device identification device in the first aspect and its implementation manners as described above, and includes: obtaining a first voltage and a second voltage; the first voltage is the voltage coupled to the first configuration channel CC1 pin of the first port in the device identification device, and the second voltage is the voltage coupled to the second configuration channel CC2 pin of the first port; the first voltage, and / or, the second voltage changes in response to the insertion of the first terminal into the first port and the extraction of the first terminal from the first port; respectively matching the first voltage and the second voltage with the status codes in a preset first truth table to obtain a first code combination, where the first code combination includes a first target code corresponding to the first voltage and a second target code corresponding to the second voltage; matching the first code combination with the code combination in a preset second truth table to determine the insertion state of the first terminal, and / or, the device type of the external device. By adopting this implementation manner, on a simplified circuit without a detection chip, combining this software detection logic can realize the functions of identifying the insertion state of the first terminal and the device type of the external device connected to the first terminal, eliminating the detection chip, reducing the circuit complexity, and reducing the hardware cost.
[0028] In one implementation manner, it further includes: determining the insertion state of the first terminal according to the first voltage and the second voltage; if the insertion state of the first terminal is inserted into the first port, perform the step of respectively matching the first voltage and the second voltage with the status codes in the preset first truth table. By adopting this implementation manner, the insertion state of the first terminal can be directly determined through the first voltage and the second voltage shown by ADC1 and ADC2.
[0029] In one implementation manner, after determining the insertion state of the first terminal, it further includes: if the insertion state of the first terminal is not inserted into the first port, delay for a first duration to obtain the first voltage and the second voltage. By adopting this implementation manner, it can be detected based on the speed at which the user inserts or extracts the first terminal to meet the identification requirements for external devices.
[0030] In one implementation manner, before obtaining the first voltage and the second voltage, it includes: detecting whether the electronic device corresponding to the device identification device is in a sleep state; the sleep state includes: the operating system kernel of the electronic device is completely asleep; if the electronic device is not in the sleep state, obtain the first voltage and the second voltage; if the electronic device is in the sleep state, delay for a second duration to detect whether the electronic device is in the sleep state. By adopting this implementation manner, the insertion state of the first terminal and the device type of the external device can be identified only in the non-sleep state to reduce the power consumption of the electronic device.
[0031] In one implementation, after determining the device type of the external device, the following steps are further included: performing Universal Serial Bus (USB) enumeration with the external device; if the enumeration is successful, determining that the external device is connected; determining whether the first voltage and the second voltage match the device type of the external device; if the first voltage and the second voltage do not match the device type of the external device, determining whether the first terminal has been unplugged; if the first terminal has been unplugged, detecting again whether the electronic device is in a sleep state; if the first terminal has not been unplugged, obtaining the insertion state of the first terminal again. By adopting this implementation, after determining that the external device is inserted and the enumeration is successful, regardless of whether the electronic device is in a sleep state, the insertion state of the first terminal and the device type of the external device are continuously detected. If the device type of the external device does not match, a re-enumeration is triggered. When the first terminal has been unplugged, it is further determined whether the electronic device is in a sleep state. If the electronic device is in a sleep state, there is no need to continue detecting the voltage. In this way, the purpose of reducing power consumption can be achieved.
[0032] In one implementation, the following is further included: if the first voltage and the second voltage match the device type of the external device, obtaining the first voltage and the second voltage after delaying for a third duration. By adopting this implementation, the acquisition of the first voltage and the second voltage can be delayed for the third duration to timely obtain the insertion state of the first terminal and the device type of the external device.
[0033] In one implementation, matching the first voltage and the second voltage with the status codes in a preset first truth table respectively includes: determining a first target threshold corresponding to the first voltage and determining a first target code according to the first target threshold; and determining a second target threshold corresponding to the second voltage and determining a second target code according to the second target threshold. By adopting this implementation, the insertion state of the first terminal is determined by matching the first voltage with the first target threshold and matching the second voltage with the second target threshold.
[0034] In one implementation, the following is further included: if the first target threshold or the second target threshold is a first preset threshold, determining the number of pull-up resistors coupled to the first terminal according to the first voltage, the second voltage, and the first preset threshold. By adopting this implementation, it can be identified whether one pull-up resistor is coupled to the port power supply of the external device or two pull-up resistors are coupled to the port power supply of the external device through the first voltage, the second voltage, and the first preset threshold. In this way, the data line type of the Universal Serial Bus can be determined.
[0035] In one implementation, it further includes: if the first target threshold or the second target threshold is the second preset threshold, determining that the first terminal is a dual-role port (DRP); determining the first port as a downstream-facing port (DFP) or an upstream-facing port (UFP) according to the internal configuration of the electronic device corresponding to the device identification device. With this implementation, according to the matching result, the role capabilities of the first terminal can be determined. If the first terminal is a dual-role port, the role corresponding to the first port can be determined.
[0036] In one implementation, the device type of the external device includes at least one of: an On-The-Go (OTG) device for data exchange, a debugging device, an audio device, a power adapter, and a Power Delivery (PD) device for energy transfer. With this implementation, the solution shown in this application can identify the device types of various external devices.
[0037] In one implementation, if a first diode is provided in the first detection path and a second diode is provided in the second detection path, the first target threshold is determined according to the temperature of the first diode, and the second target threshold is determined according to the temperature of the second diode. In this way, in the circuit with diodes set and the circuit without diodes set, the threshold values are adaptively adjusted, which can ensure the accuracy of identifying the insertion state of the first terminal and the device type of the external device. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] To more clearly illustrate the technical solutions of the embodiments of this application, the following will briefly introduce the drawings required for the embodiments. Obviously, for those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0039] Figure 1 is a schematic diagram of a Type-C interface application scenario;
[0040] Figure 2 is a schematic diagram of a Type-C interface structure;
[0041] Figure 3 is a circuit diagram of the CC pin connection when a Type-C plug is inserted forward;
[0042] Figure 4 is a circuit diagram of the CC pin connection when a Type-C plug is inserted backward;
[0043] Figure 5 is a schematic diagram of a chip detection circuit;
[0044] Figure 6 is a schematic diagram of the hardware structure of the electronic device provided by the embodiment of this application;
[0045] Figure 7It is a software structure block diagram of the electronic device 100 provided by an embodiment of the present application;
[0046] Figure 8 It is the first circuit diagram of the device identification device provided by an embodiment of the present application;
[0047] Figure 9 It is the second circuit diagram of the device identification device provided by an embodiment of the present application;
[0048] Figure 10 It is the first flowchart of the device identification method provided by an embodiment of the present application;
[0049] Figure 11 It is the second flowchart of the device identification method provided by an embodiment of the present application;
[0050] Figure 12 It is the third flowchart of the device identification method provided by an embodiment of the present application. Detailed implementation manners
[0051] Next, the technical solutions of the embodiments of the present application will be clearly described in conjunction with the accompanying drawings in the embodiments of the present application.
[0052] In the description of the present application, unless otherwise specified, " / " means "or". For example, A / B may represent A or B. The "and / or" herein is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B may represent: A exists alone, A and B exist simultaneously, and B exists alone. In addition, "at least one" means one or more, and "a plurality" means two or more. The terms such as "first" and "second" do not limit the quantity and execution order, and the terms such as "first" and "second" do not necessarily limit to be different.
[0053] It should be noted that in the present application, words such as "exemplary" or "for example" are used to represent examples, illustrations or explanations. Any embodiment or design solution described as "exemplary" or "for example" in the present application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Exactly speaking, using words such as "exemplary" or "for example" aims to present relevant concepts in a specific manner.
[0054] The terms used in the implementation manners part of the present application are only used to explain the specific embodiments of the present application, rather than aiming to limit the present application. Next, the embodiments of the present application will be described in detail in conjunction with the accompanying drawings.
[0055] Universal Serial Bus (USB) is a serial bus standard used to standardize the connection and communication between a computer and external devices.
[0056] Among them, the Universal Serial Bus Type-C (USB Type-C) interface, hereinafter referred to as the Type-C interface, is an interface type that supports front and reverse insertion and can be used as a charging interface, a display interface, and a data transmission interface, which can improve the user experience.
[0057] Figure 1 It is a schematic diagram of the application scenario of the Type-C interface. As Figure 1 shown, the Type-C interface is composed of a Type-C socket 011 and a Type-C plug 012. Taking the electronic device 001 having the Type-C socket 011 and the external device 002 having the Type-C plug 012 as an example, the external device 002 is inserted into the Type-C socket 011 through the Type-C plug 012 to connect to the electronic device 001.
[0058] Figure 2 It is a schematic diagram of the structure of the Type-C interface. As Figure 2 shown, the Type-C socket 011 usually has at most twenty-four pins, such as four pairs of Transmit (TX) pins / Receive (RX) pins, two pairs of USB Data Positive (USB-DP) / USB Data Minus (USB-DM) pins, one pair of SideBand Use (SBU) pins, two Configuration Channel (CC) pins, four VoltageBus (VBUS) pins, and four ground pins.
[0059] The Type-C plug 012 can be provided with at most twenty-four pins corresponding to the Type-C socket 011, or can be provided with a smaller number of pins according to different functions to be realized, so as to realize functions such as charging and data transmission respectively.
[0060] Based on the number of pins set on the Type-C plug 012, the Type-C interface can be applied to at least one scenario such as a charging scenario and a data transmission scenario.
[0061] During the connection process between the electronic device 001 and the external device 002, the electronic device 001 and the external device 002 need to communicate with each other to determine their own roles, and then transmit current and / or data in different scenarios according to their corresponding roles.
[0062] Both ends of the Type-C interface usually correspond to the host device and the peripheral device. Taking electronic device 001 as the host device and external device 002 as the peripheral device as an example, the port corresponding to the host device is called the downstream facing port (DFP), and the port corresponding to the peripheral device is called the upstream facing port (UFP). Among them, DFP has a narrow interpretation and a broad interpretation. The narrow interpretation specifically refers to the downstream transmission of data in the USB Type-C Cable and Connector Specification, revision 1.1, and the broad interpretation refers to the downstream transmission of data and power supply to the outside. Correspondingly, the narrow interpretation of UFP specifically refers to the upstream transmission of data, and the broad interpretation refers to the upstream transmission of data and power supply from the outside. In this application, both DFP and UFP adopt the corresponding broad interpretation to be applicable to different scenarios such as charging scenarios and data transmission scenarios.
[0063] Among them, the working modes of both ends of the Type-C interface between some electronic devices can be changed, so that the host device and the peripheral device can be converted with each other. If electronic device 001 can be converted from the host device to the peripheral device, the port corresponding to electronic device 001 can be used as both DFP and UFP, which is a dual role port (DRP). It should be noted that not all working modes between electronic devices can be changed. Only when both ends of the Type-C interface are DRP, the host device and the peripheral device can be converted with each other, such as a mobile phone and a computer. When one end of the Type-C interface is not DRP, the host device and the peripheral device cannot be converted with each other, such as a power adapter and a mobile phone.
[0064] Based on this, electronic device 001 can have one of the following three role capabilities.
[0065] The first role capability: The port corresponding to electronic device 001 is DFP, acting as the host device. After electronic device 001 establishes a connection with external device 002, it supplies power to external device 002 or sends down data. It should be noted that at this time, the port corresponding to external device 002 must be UFP or DRP. By way of example, electronic device 001 is a power adapter and external device 002 is a mobile phone.
[0066] The second role ability: The port corresponding to the electronic device 001 is a UFP, acting as a slave device. After establishing a connection with the external device 002, the electronic device 001 draws power from or uploads data to the external device 002. It should be noted that at this time, the external device 002 must be a DFP or a DRP. For example, the electronic device 001 is a storage device, such as a USB flash drive, a mobile hard disk, etc., and the external device 002 is a mobile phone.
[0067] The third role ability: The port corresponding to the electronic device 001 is a DRP. If the port corresponding to the external device 002 is a UFP, after the electronic device 001 establishes a connection with the external device 002, the electronic device 001 acts as a master device; if the port corresponding to the external device 002 is a DFP, after the electronic device 001 establishes a connection with the external device 002, the electronic device 001 acts as a slave device; if the port corresponding to the external device 002 is a DRP, after the electronic device 001 establishes a connection with the external device 002, the electronic device 001 randomly selects to act as a master device or a slave device and performs corresponding functions according to the selected role. For example, the electronic device 001 is a mobile phone and the external device 002 is a computer.
[0068] Correspondingly, the external device 002 has role abilities corresponding to those of the electronic device 001, which are not elaborated in this application.
[0069] It should be noted here that this application does not limit the device types of the electronic device 001 and the external device 002. The following is only an exemplary description with the electronic device 001 being a device with a Type-C socket 011 and the external device 002 being a device with a Type-C plug 012. The electronic device 001 and the external device 002 can be interchanged according to the actual situation. Among them, the Type-C plug 012 can be a plug on a data cable detachably connected to the external device 002 or a plug integrally formed with the external device 002. In this application, the Type-C plug 012 is described as a part of the external device 002, and the Type-C plugs 012 in this application are all exemplified by plugs on data cables provided with chips.
[0070] The role abilities corresponding to the electronic device 001 and the external device 002 are determined through the CC pins.
[0071] Specifically, the CC pins can be used to confirm the insertion direction of the Type-C plug 012, confirm the transmission direction between the electronic device 001 and the external device 002, and perform load power configuration.
[0072] The internal circuit designs of the CC pins in the electronic device 001 for different roles are different. If the port corresponding to the electronic device 001 is DFP, the CC pin is usually pulled up to a high level through the pull-up resistor Rp; if the port corresponding to the electronic device 001 is UFP, the CC pin is usually grounded through the pull-down resistor Rd; if the port corresponding to the electronic device 001 is DRP, the CC pin is alternately pulled up to a high level through the pull-up resistor Rp or grounded through the pull-down resistor Rd. Therefore, when the electronic device 001 is not connected to the external device 002, the voltage coupled to the CC pin on the electronic device 001 alternates between a high level and a low level. Among them, CC detection chips are usually provided in both the electronic device 001 and the external device 002 for voltage detection. In this way, both the electronic device 001 and the external device 002 can detect the voltage coupled to the CC pin through the CC detection chip, and then determine their corresponding roles.
[0073] When the port corresponding to the electronic device 001 is DRP and the electronic device 001 is in the sleep state, the CC detection chip can switch between DFP and UFP once every 50 ms. When switching to DFP, the CC detection chip controls the CC pin to connect to at least one pull-up resistor Rp, and when switching to UFP, the CC detection chip controls the CC pin to connect to at least one pull-down resistor Rd. Among them, the CC detection chip controls the CC pin to connect to the pull-up resistor Rp or the pull-down resistor Rd by controlling the switching of the switch on the corresponding path.
[0074] Figure 3 It is a circuit diagram of the CC pin connection when the Type-C plug is inserted forward.
[0075] Figure 4 It is a circuit diagram of the CC pin connection when the Type-C plug is inserted backward.
[0076] Such as Figure 3 and Figure 4 As shown, the CC detection chip can also identify the forward and reverse insertion directions of the Type-C plug 012 according to the voltage detected on the CC pin.
[0077] For the convenience of description, the Type-C socket 011 of the electronic device 001 usually has two CC pins, which will be respectively referred to as the CC1 pin and the CC2 pin below. The external device 002 usually has two CC pins, which will be respectively referred to as the CC1-1 pin and the CC2-1 pin below. The Type-C plug 012 usually has only one CC pin, which will be referred to as the CC1-A pin below.
[0078] For example, the CC1-A pin is connected to the CC1-1 pin. When the Type-C plug 012 is inserted into the Type-C socket 011, a connection is established between the CC1 pin or the CC2 pin and the CC1-1 pin through the CC1-A pin. If a data transmission connection is established between the CC1 pin and the CC1-1 pin, the CC2 pin can be used to provide port power at this time.
[0079] If the port corresponding to the electronic device 001 is a DFP and the port corresponding to the external device 002 is a UFP, since there is usually a pull-up resistor Rp in the DFP and a pull-down resistor Rd in the UFP, when the electronic device 001 is connected to the external device 002, the CC detection chip of the electronic device 001 can recognize that the CC1 pin is pulled low by the CC1-1 pin of the external device 002. At this time, the electronic device 001 can determine that the insertion direction of the Type-C plug 012 is forward; correspondingly, the CC detection chip can recognize that the CC2 pin is pulled low by the CC1-1 pin of the external device 002. At this time, the electronic device 001 can determine that the insertion direction of the Type-C plug 012 is reverse.
[0080] The CC detection chip can also confirm the data transmission direction between the electronic device 001 and the external device 002.
[0081] When the insertion direction of the Type-C plug 012 is forward, the CC1 pin is connected to the CC1-1 pin. At this time, data is transmitted from the RX1+ / - and TX1+ / - pins of the Type-C socket 011 to the RX1+ / - and TX1+ / - pins of the Type-C plug 012 (not shown in the figure).
[0082] When the insertion direction of the Type-C plug 012 is reverse, the CC1 pin is connected to the CC2-1 pin. At this time, data is transmitted from the RX1+ / - and TX1+ / - pins of the Type-C socket 011 to the RX2+ / - and TX2+ / - pins of the Type-C plug 012 (not shown in the figure).
[0083] The main control chip in the electronic device 001 usually has only one pair of TX / RX channels. Since electronic devices such as mobile phones have high data rate requirements, during data transmission, it is necessary to switch the signal path through a multiplexer (Mux) chip to ensure impedance consistency and signal transmission quality. In this way, the Mux chip selects a pair from the two pairs of TX / RX channels formed by connecting to the external device 002 and connects it to the main control chip to maintain a correct communication connection. This process needs to be controlled by the CC detection chip, and the CC detection chip needs to measure the voltage of the CC pin to determine the direction of the data line and the Type-C socket 011, and then determine the data transmission direction.
[0084] The CC detection chip can also perform load power configuration.
[0085] Taking the port corresponding to the electronic device 001 as the UFP as an example, the CC detection chip can obtain the output capability of the port DFP corresponding to the external device 002 by detecting the voltage on the CC pin.
[0086] The CC detection chip also has the function of determining the device type corresponding to the external device 002 based on the voltage on the CC pin of the electronic device 001.
[0087] For example, if the CC1 pin of the electronic device 001 is floating and the CC2 pin is connected to the pull-up resistor Rp, it is determined that the device type of the connected external device 002 is an on-the-go (OTG) device.
[0088] Some electronic devices (such as mobile phones) usually configure a CC detection chip to implement the above functions (or use other chips that can achieve the same functions, such as a Power Delivery (PD) chip, or a platform chip integrated with CC detection function).
[0089] Figure 5 It is a schematic diagram of a chip detection circuit. As Figure 5 shown, taking the PD chip as an example, the processor 003 in the electronic device 001 is usually connected to the PD chip 004 through an Inter-Integrated Circuit (I2C) bus (including the I2C bidirectional transmission line (I2C_CLK) 005 and the I2C data transmission line (I2C_DATA) 006). The PD chip 004 forms a CC detection path 007 with the CC1 pin or the CC2 pin on the Type-C socket 011, and forms a power path 008 with the VBUS pin. The PD chip 004 transmits the detected voltage to the processor 003 through the Input (INT) line 009. Generally, CC detection is all through chip detection, resulting in a relatively high hardware cost. Therefore, it is urgent to reduce the production cost.
[0090] To solve the above problems, an embodiment of the present application provides a device identification apparatus, which can be applied to an electronic device. The electronic device in the embodiment of the present application can be, for example, a tablet computer (portable android device, PAD), a personal digital assistant (PDA), a handheld device with wireless communication function, a computing device, a vehicle-mounted device or a wearable device, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical, a wireless terminal in smart grid, a wireless terminal in transportation safety, a wireless terminal in smart city, a wireless terminal in smart home, etc., a mobile terminal or a fixed terminal with a touch screen. The electronic device involved in the present application can be equipped with Harmony or other operating systems, and the present application does not limit this.
[0091] Figure 6 is a schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present application. As Figure 6As shown, the electronic device 100 may include a processor 110, a memory 120, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, a button 190, a motor 191, a camera 192, a display screen 193, and a subscriber identification module (SIM) card interface 194, etc. Among them, the sensor module 180 may include a touch sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a geomagnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, etc. Among them, the gyroscope sensor 180B, the barometric pressure sensor 180C, the geomagnetic sensor 180D, the acceleration sensor 180E, etc. can all be used to detect the motion state of the electronic device. Therefore, they can also be called motion sensors.
[0092] It can be understood that the structure schematically shown in the embodiments of this application does not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0093] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.
[0094] The memory 120 can be used to store computer-executable program codes, and the executable program codes include instructions. The memory 120 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, 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 magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the memory 120, and / or the instructions stored in the memory provided in the processor.
[0095] The USB interface 130 is an interface that conforms to the USB standard specification. Specifically, it can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used for data transmission between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio through the headphones. This interface can also be used to connect other electronic devices, such as AR devices, etc.
[0096] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0097] The charging management module 140 is used to receive a charging input from a charger. Among them, the charger can be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 can receive the charging input from the wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 can receive the wireless charging input through the wireless charging coil of the electronic device 100. While the charging management module 140 charges the battery 142, it can also supply power to the electronic device through the power management module 141.
[0098] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives inputs from the battery 142 and / or the charging management module 140 and supplies power to the processor 110, the memory 120, the display screen 193, the camera 192, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 can also be disposed in the same device.
[0099] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.
[0100] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: the antenna 1 can be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0101] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor and convert it into electromagnetic waves through the antenna 1 for radiation. In some embodiments, at least some functional modules of the mobile communication module 150 can be disposed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 can be disposed in the same device.
[0102] The modulation and demodulation processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 193. In some embodiments, the modulation and demodulation processor may be an independent device. In other embodiments, the modulation and demodulation processor may be independent of the processor 110 and be provided in the same device as the mobile communication module 150 or other functional modules.
[0103] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSSs), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive the signals to be transmitted from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 for radiation.
[0104] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, such that electronic device 100 can communicate with a network and other devices through wireless communication technologies. The wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).
[0105] Electronic device 100 implements a display function through a GPU, display screen 193, and an application processor, etc. The GPU is a microprocessor for image processing, and is connected to display screen 193 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.
[0106] The display screen 193 is used to display images, videos, etc. The display screen 193 includes a display panel. The display panel can adopt a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 193, where N is a positive integer greater than 1.
[0107] The electronic device 100 can implement the shooting function through the ISP, the camera 192, the video codec, the GPU, the display screen 193, and the application processor, etc.
[0108] The ISP is used to process the data fed back by the camera 192. For example, when taking a photo, the shutter is opened, and the light passes through the lens and is transmitted to the camera photosensitive element. The optical signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image through algorithms. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 192.
[0109] The camera 192 is used to capture static images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in standard RGB, RYYB, YUV, etc. formats. In some embodiments, the electronic device 100 may include one or N cameras 192, where N is a positive integer greater than 1.
[0110] The electronic device 100 can implement the audio function through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor, etc. Such as music playback, recording, etc.
[0111] The touch sensor 180A, also referred to as a "touch control device". The touch sensor 180A can be disposed on the display screen 193. The touch sensor 180A and the display screen 193 together form a touch screen, also referred to as a "touch control screen". The touch sensor 180A is used to detect touch operations acting on or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 193. In some other embodiments, the touch sensor 180A can also be disposed on the surface of the electronic device 100, at a different position from that of the display screen 193.
[0112] The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., the x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can be used for anti-shake during shooting. Exemplarily, when the shutter is pressed, the gyroscope sensor 180B detects the angle of jitter of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and enables the lens to offset the jitter of the electronic device 100 through reverse movement to achieve anti-shake. The gyroscope sensor 180B can also be used for navigation and somatosensory game scenarios.
[0113] The barometric pressure sensor 180C is used to measure barometric pressure. In some embodiments, the electronic device 100 calculates the altitude based on the barometric pressure value measured by the barometric pressure sensor 180C to assist in positioning and navigation.
[0114] The geomagnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the geomagnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip according to the geomagnetic sensor 180D. Furthermore, according to the detected opening and closing state of the leather case or the flip, features such as automatic unlocking of the flip can be set.
[0115] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0116] The distance sensor 180F is used to measure distance. The electronic device 100 can measure distance through infrared or laser. In some embodiments, in a shooting scenario, the electronic device 100 can use the distance sensor 180F to measure distance to achieve rapid focusing.
[0117] The proximity light sensor 180G may include, for example, a light-emitting diode and a light detector, such as a photodiode. The light-emitting diode may be an infrared light-emitting diode. The electronic device 100 emits infrared light outward through the light-emitting diode. The electronic device 100 uses the photodiode to detect the infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 may determine that there is no object near the electronic device 100. The electronic device 100 may use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear during a call, so as to automatically turn off the screen to achieve the purpose of power saving. The proximity light sensor 180G can also be used in the leather case mode and the pocket mode for automatic unlocking and locking of the screen.
[0118] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to achieve fingerprint unlocking, access the application lock, fingerprint photography, fingerprint answering of incoming calls, etc.
[0119] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 executes a temperature processing strategy using the temperature detected by the temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J in order to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 caused by low temperature. In still other embodiments, when the temperature is lower than yet another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
[0120] The keys 190 include a power-on key, volume keys, etc. The keys 190 can be mechanical keys. They can also be touch keys. The electronic device 100 can receive key inputs and generate key signal inputs related to the user settings and function control of the electronic device 100.
[0121] The motor 191 can generate vibration prompts. The motor 191 can be used for vibration prompts for incoming calls and can also be used for touch vibration feedback. For example, touch operations on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. For touch operations on different areas of the display screen 193, the motor 191 can also correspond to different vibration feedback effects. Different application scenarios (such as time reminder, receiving information, alarm clock, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0122] The SIM card interface 194 is used to connect to a SIM card. The SIM card can be inserted into or removed from the SIM card interface 194 to achieve contact and separation from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 194 can support Nano SIM cards, Micro SIM cards, SIM cards, etc. Multiple cards can be inserted into the same SIM card interface 194 simultaneously. The types of multiple cards can be the same or different. The SIM card interface 194 can also be compatible with different types of SIM cards. The SIM card interface 194 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communication. In some embodiments, the electronic device 100 uses an eSIM, that is, an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0123] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiments of this application, the Android system with a layered architecture is taken as an example to exemplarily illustrate the software structure of the electronic device 100.
[0124] Figure 7 It is a block diagram of the software structure of the electronic device 100 provided by the embodiments of this application.
[0125] The layered architecture divides the software into several layers, and each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0126] The application layer may include a series of application packages.
[0127] As Figure 7 shown, the application packages may include applications such as battery management, camera, gallery, calendar, call, map, navigation, music, video, short message, etc.
[0128] The application framework layer provides application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some predefined functions.
[0129] As Figure 7As shown, the application framework layer may include a window manager, an InputManager, a SensorManager, a phone manager, a resource manager, a notification manager, etc.
[0130] The InputManager can be used to monitor user input events, such as click events, swipe events, etc. performed by the user's finger on the display screen 193 of the electronic device 100. By monitoring the input events, the electronic device 100 can determine whether the electronic device is being used.
[0131] The SensorManager is used to monitor data returned by various sensors in the electronic device, such as motion sensor data, proximity light sensor data, temperature sensor data, etc. Using the data returned by each sensor, the electronic device can determine whether it is jittery, or whether the display screen 193 is blocked, etc.
[0132] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for the scheduling and management of the Android system.
[0133] The core libraries consist of two parts: one part is the functional functions that need to be called by the Java language, and the other part is the core libraries of Android.
[0134] The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0135] The system libraries can include multiple functional modules. For example: surface manager, Media Libraries, 3D graphics processing library (e.g., OpenGL ES), 2D graphics engine (e.g., SGL), etc.
[0136] The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
[0137] The Media Libraries support the playback and recording of various common audio and video formats, as well as static image files, etc. The Media Libraries can support multiple audio and video coding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0138] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing, etc.
[0139] The 2D graphics engine is a drawing engine for 2D drawing.
[0140] The kernel layer is the layer between hardware and software. The kernel layer at least includes a display driver, a camera driver, an audio driver, a sensor driver, and a power driver.
[0141] In the embodiments of the present application, software programs such as a power driver, a battery management, and a sensor driver can cooperate with hardware such as a processor, a USB interface, a charging management module, and a power management module to implement the method steps and functions involved in the embodiments of the present application.
[0142] It can be understood that the structure illustrated in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than those illustrated, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0143] Figure 8 This is the first circuit diagram of the device identification device provided by the embodiments of the present application. As Figure 8 shown, the device identification device 200 may include a first port 201. By way of example, the first port 201 may be a Type-C socket.
[0144] The first port 201 may include a first configuration channel CC1 pin 2011 and a second configuration channel CC2 pin 2012. Among them, the CC1 pin 2011 is coupled to a first voltage U1, and the CC2 pin 2012 is coupled to a second voltage U2. The first voltage U1, and / or, the second voltage U2 changes in response to the insertion of the first terminal 202 into the first port 201 and the removal of the first terminal 202 from the first port 201.
[0145] By way of example, the first terminal 202 may be a Type-C plug. The first terminal 202 may be a Type-C plug on a data cable detachably connected to an external device 300, or a Type-C plug integrally formed with the external device 300.
[0146] The external device 300 corresponding to the first terminal 202 usually has two CC pins, which will be hereinafter respectively referred to as CC1-1 pin and CC2-1 pin. There is usually only one CC pin in the first terminal 202, which will be hereinafter referred to as CC1-A pin.
[0147] Exemplarily, the CC1-A pin is connected to the CC1-1 pin. When the first terminal 202 is inserted into the first port 201, the CC1 pin 2011 or the CC2 pin 2012 establishes a connection through the CC1-A pin and the CC1-1 pin. If the CC1 pin 2011 establishes a connection for data transmission with the CC1-1 pin, at this time, the CC2 pin 2012 can be used to provide the port power supply (Voltage DrainDrain, VDD) 220. It should be noted that the functions of the CC2 pin include but are not limited to providing the port power supply 220, and it can also be left floating or perform other functions. Among them, the port power supply 220 is the operating voltage inside the electronic device 100.
[0148] Based on this, after the CC1 pin 2011 or the CC2 pin 2012 establishes a connection through the CC1-A pin and the CC1-1 pin, the first voltage U1, and / or the second voltage U2 changes in response to the insertion of the first terminal 202 into the first port 201. For example, it changes from alternating between high and low levels to a stable intermediate level. Correspondingly, the first voltage U1, and / or the second voltage U2 changes in response to the removal of the first terminal 202 from the first port 201. For example, it changes from a stable intermediate level to alternating between high and low levels.
[0149] The device identification device 200 may further include a processor 203. The processor 203 may be connected with a plurality of analog-to-digital conversion (Analog to Digital Converter, ADC) pins. In the embodiments of the present application, the first analog-to-digital conversion ADC1 pin 2031 and the second analog-to-digital conversion ADC2 pin 2032 in the processor 203 are used for illustration.
[0150] In some embodiments, the processor 203 may be at least one of a system-on-chip (System On Chip, SOC), a central processing unit (Central Processing Unit, CPU), and a power management unit (Power Management Unit, PMU). These types of chips can provide the ADC1 pin 2031 and the ADC2 pin 2032 for voltage detection. It should be noted here that the types of chips provided in the embodiments of the present application are only used for exemplary illustration, and in actual applications, other types of chips with ADC pins can also be used, and the present application does not limit this.
[0151] Among them, the ADC1 pin 2031 is connected to the CC1 pin 2011 to form a first detection path 204. The ADC1 pin 2031 is configured to detect a first voltage U1 through the first detection path 204. The ADC2 pin 2032 is connected to the CC2 pin 2012 to form a second detection path 205. The ADC2 pin 2032 is configured to detect a second voltage U2 through the second detection path 205.
[0152] The processor 203 is configured to identify the insertion state of the first terminal 202 based on the first voltage U1 and the second voltage U2, and identify the device type of the external device 300 connected to the first terminal 202.
[0153] It should be noted here that generally, the ADC1 pin 2031 and the ADC2 pin 2032 in the above chip are not connected to the CC1 pin 2011 and the CC2 pin 2012. Usually, they are connected to sensors to obtain the voltages of the sensors, so that the chip controls the sensors through software logic; or the ADC1 pin 2031 and the ADC2 pin 2032 are only used as vacant reserve pins. In the embodiment of the present application, the connection manner of the CC logic chip to the CC1 pin 2011 and the CC2 pin 2012 is changed, and the detection manner of the CC logic chip for the CC1 pin 2011 and the CC2 pin 2012 is changed. The ADC1 pin 2031 and the ADC2 pin 2032 are directly connected to the CC1 pin 2011 and the CC2 pin 2012, and the CC1 pin 2011 and the CC2 pin 2012 are detected by configuring software logic in the processor. Furthermore, the insertion state of the first terminal 202 is identified based on the first voltage U1 and the second voltage U2, and the device type of the external device 300 connected to the first terminal 202 is identified. In this way, one detection chip can be saved during the production process of the electronic device 100, the circuit complexity is reduced, and the hardware cost is reduced.
[0154] Figure 9 It is the second circuit diagram of the device identification device provided by the embodiment of the present application. As Figure 9 shown, in some embodiments, the device identification device 200 may further include a first pull-up resistor 206 and a second pull-up resistor 207. Among them, one end of the first pull-up resistor 206 is coupled to the port power supply 220, and the other end is coupled to the first detection path 204. The first pull-up resistor 206 is configured to pull up the first voltage U1 to a preset threshold range by using the port power supply 220. One end of the second pull-up resistor 207 is coupled to the port power supply 220, and the other end is coupled to the second detection path 205. The second pull-up resistor 207 is configured to pull up the second voltage U2 to a preset threshold range by using the port power supply 220.
[0155] In some embodiments, the first pull-up resistor 206 may be disposed outside the ADC1 pin 2031 and externally pulled up to the port power supply 220. The first pull-up resistor 206 may also be an internal pull-up resistor of the ADC1 pin 2031, pulled up from inside the ADC1 pin 2031 to the port power supply 220. The second pull-up resistor 207 may be disposed outside the ADC2 pin 2032 and externally pulled up to the port power supply 220. The second pull-up resistor 207 may also be an internal pull-up resistor of the ADC2 pin 2032, pulled up from inside the ADC2 pin 2032 to the port power supply 220.
[0156] In some embodiments, the device identification device 200 may further include a first switch 208 and a second switch 209. Among them, one end of the first switch 208 is coupled to the port power supply 220, and the other end is coupled to the first detection path 204 and is in series with the first pull-up resistor 206. One end of the second switch 209 is coupled to the port power supply 220, and the other end is coupled to the second detection path 205 and is in series with the second pull-up resistor 207.
[0157] It should be noted here that Figure 9 The positions of the first switch 208 and the second switch 209 are only for illustrative purposes. In a specific implementation, the first switch 208 may be disposed between the port power supply 220 and the first pull-up resistor 206, or may be disposed between the first pull-up resistor 206 and the first detection path 204. This application does not limit this. Similarly, for the second switch 209, this application will not elaborate on this.
[0158] Correspondingly, the first switch 208 may be disposed outside or inside the ADC1 pin 2031 according to the position of the first pull-up resistor 206, and the second switch 209 may be disposed outside or inside the ADC2 pin 2032 according to the position of the second pull-up resistor 207.
[0159] The pull-up resistor can clamp an uncertain signal at a high level through the resistor and play a current-limiting role, and can be used to provide the port power supply 220 during the process of identifying the external device 300 to supply power to the external device 300. In this way, when the first switch 208 is closed, the first pull-up resistor 206 can provide the port power supply 220 for the CC1 pin 2011 on the first detection path 204. When the second switch 209 is closed, the second pull-up resistor 207 can provide the port power supply 220 for the CC1 pin 2011 on the second detection path 205. The resistance values of the first pull-up resistor 206 and the second pull-up resistor 207 can be reasonably configured according to the voltage value of the port power supply 220 or the pull-down voltage value of the first port 201 when the first terminal 202 is inserted. This application embodiment does not limit the resistance values of the first pull-up resistor 206 and the second pull-up resistor 207.
[0160] Among them, the first pull-up resistor 206 can pull up the first voltage U1 to within a preset threshold range, and the preset threshold range here can be the range of the voltage value corresponding to the pull-up resistor. The same applies to the second pull-up resistor 207, which will not be elaborated in this application. In this way, when the first port 201 serves as a DFP, the first pull-up resistor 206 or the second pull-up resistor 207 can supply power to the first terminal 202. At this time, the first pull-up resistor 206 pulls up the first voltage U1 to the preset threshold range, or the second pull-up resistor 207 pulls up the second voltage U2 to the preset threshold range. It should be noted here that the preset threshold range in the embodiments of this application is only used for illustrative purposes and can be set according to actual situations.
[0161] When the first switch 208 and the second switch 209 are turned off, neither the first pull-up resistor 206 nor the second pull-up resistor 207 is connected, and power supply cannot be performed through the port power supply 220. At this time, the first port 201 can only serve as a UFP. It should be noted here that the first switch 208 and the second switch 209 can be selectively set. If the continuous connection of the first pull-up resistor 206 and the second pull-up resistor 207 has no effect on the detection of the first voltage U1 and the second voltage U2, the first switch 208 and the second switch 209 can be not set.
[0162] In some embodiments, the device identification device 200 may further include a first pull-down resistor 210 and a second pull-down resistor 211. One end of the first pull-down resistor 210 is coupled to the first detection path 204, and the other end is coupled to the ground 212. The first pull-down resistor 210 is configured to pull down the first voltage U1 to within a preset threshold range. One end of the second pull-down resistor 211 is coupled to the second detection path 205, and the other end is coupled to the ground 212. The second pull-down resistor 211 is configured to pull down the second voltage U2 to within a preset threshold range.
[0163] The pull-down resistor can clamp an uncertain signal at a low level through the resistor, and can be used to pull down the high level of the external device 300 when the external device 300 is connected, so as to provide a stable intermediate level for the external device 300. The first pull-down resistor 210 and the second pull-down resistor 211 can be the inherent resistors of the electronic device 100. When the first port 201 serves as a UFP, they can be used for the external device 300 to accurately identify the electronic device 100, so that the electronic device 100 can receive data or draw power inward.
[0164] It should be noted here that the resistance values of the first pull-down resistor 210 and the second pull-down resistor 211 can be reasonably configured. For example, the resistance value range of the first pull-down resistor 210 can be 5.1 kΩ ± 20%, preferably, the resistance value range of the first pull-down resistor 210 is 5.1 kΩ ± 1%; the resistance value range of the second pull-down resistor 211 can be 5.1 kΩ ± 20%; preferably, the resistance value range of the second pull-down resistor 211 is 5.1 kΩ ± 1%.
[0165] In some embodiments, the device identification device 200 may further include a third pull-down resistor 213, a third switch 214, a fourth pull-down resistor 215, and a fourth switch 216. Among them, one end of the third pull-down resistor 213 is coupled to the first detection path 204, and the other end is coupled to the ground 212, and is in parallel with the first pull-down resistor 210. One end of the third switch 214 is coupled to the first detection path 204, and the other end is coupled to the ground 212, and is in series with the third pull-down resistor 213. One end of the fourth pull-down resistor 215 is coupled to the second detection path 205, and the other end is coupled to the ground 212, and is in parallel with the second pull-down resistor 211. One end of the fourth switch 216 is coupled to the second detection path 205, and the other end is coupled to the ground 212, and is in series with the fourth pull-down resistor 215.
[0166] The third pull-down resistor 213 and the fourth pull-down resistor 215 can be used to adjust the first voltage U1 and the second voltage U2 during the process of identifying the external device 300, so as to ensure that the first voltage U1 and the second voltage U2 can be at a stable intermediate level. Therefore, the third switch 214 and the fourth switch 216 are only turned on during the process of identifying the external device 300. When the first port 201 is a UFP, the third switch 214 and the fourth switch 216 are open.
[0167] It should be noted here that the resistance values of the third pull-down resistor 213 and the fourth pull-down resistor 215 can be reasonably configured, and the embodiments of the present application will not elaborate on this.
[0168] In some embodiments, when the port power supply 220 is 1.8V, since the first pull-down resistor 210 and the second pull-down resistor 211 are usually fixed resistors of 5.1 kΩ, the preset threshold range is usually set according to the first pull-up resistor 206 and the second pull-up resistor 207. For example, the resistance value of the first pull-up resistor 206 is 5.1 kΩ, and the resistance value of the second pull-up resistor 207 is 5.1 kΩ. When the CC pin is in a floating state, the voltage division of the first voltage U1 and the second voltage U2 is 0.9V. After the first terminal 202 is inserted, the resistor coupled to the first terminal 202 and the first pull-down resistor 210 and the second pull-down resistor 211 form a parallel circuit. If the external device 300 corresponding to the first terminal 202 is an On-The-Go (OTG) device for data exchange, and the data exchange device can have a pull-down resistor of 5.1 kΩ, then when the first terminal 202 of the data exchange device is inserted, the threshold should be 0.6V. The preset threshold range can be set based on reasonable circuit deviations. For example, in this embodiment, the preset threshold range is set to 0.6V ± 20%.
[0169] In some embodiments, the device identification device 200 may further include a first diode 217 and a second diode 218. Among them, the first diode 217 is located on the first detection path 204. The anode of the first diode 217 is coupled to the ADC1 pin 2031, and the cathode of the first diode 217 is coupled to the CC1 pin 2011. The second diode 218 is located on the second detection path 205. The anode of the second diode 218 is coupled to the ADC2 pin 2032, and the cathode of the second diode 218 is coupled to the CC2 pin 2012.
[0170] Since a high voltage may be introduced to the CC1 pin 2011 and the CC2 pin 2012 from the first terminal 202 when the first terminal 202 is inserted into the first port 201, in this way, it may cause damage to the ADC1 pin 2031 and the ADC2 pin 2032. Therefore, the one-way conductivity of the first diode 217 and the second diode 218 can prevent damage to the CC1 pin 2011 and the CC2 pin 2012.
[0171] It should be noted here that since the CC1 pin 2011 and the CC2 pin 2012 are close to the VBUS pin, the CC1 pin and the CC2 pin usually need to withstand a constant high voltage of 5V or even 10V from the VBUS pin. Therefore, in some electronic devices 100, the CC1 pin 2011 and the CC2 pin 2012 are configured as pins that can withstand constant high voltage when leaving the factory. If the ADC1 pin and the ADC2 pin can also be configured with the highest voltage, then the first diode 217 and the second diode 218 can be not set.
[0172] The circuit of the device identification device 200 provided in the above embodiment does not set a detection chip, reducing the complexity of the circuit and the hardware cost.
[0173] An embodiment of the present application also provides a device identification method. This method can be applied to the device identification device 200 provided in the above embodiments of the present application. For example, each step of this device identification method can be executed by the processor 203 in the device identification device 200 provided in the above embodiments. That is to say, it can be understood that the processor 203 is configured to execute each step of this device identification method.
[0174] Figure 10 It is the first flowchart of the device identification method provided in the embodiment of the present application.
[0175] As Figure 10 shown, this method may include the following steps S1 - S3.
[0176] Step S1, obtain a first voltage U1 and a second voltage U2.
[0177] Among them, the first voltage U1 and the second voltage U2 are obtained by the processor 203 from the ADC1 pin 2031 and the ADC2 pin 2032. After obtaining the first voltage U1 and the second voltage U2, the processor 203 realizes the same function as the CC detection chip through software logic, avoiding the detection and control of the first voltage U1 and the second voltage U2 by the CC detection chip.
[0178] Since the insertion state of the first terminal 202 and the device type of the external device 300 are different, the corresponding first voltage U1 and second voltage U2 are different. Therefore, different status codes are set according to the insertion state of the first terminal 202 and the device type of the external device 300, and then the insertion state of the first terminal 202 and / or the device type of the external device 300 is determined according to the status code.
[0179] Step S2, respectively match the first voltage U1 and the second voltage U2 with the status codes in the preset first truth table to obtain a first code combination. The first code combination includes a first target code corresponding to the first voltage U1 and a second target code corresponding to the second voltage U2.
[0180] Among them, the status code can be a code preset based on the value of the first voltage U1 and the value of the second voltage U2. The status code can be used to represent the connection state of the CC1 pin 2011 or the CC2 pin 2012 with the CC1 - 1 pin or the CC2 - 1 pin.
[0181] In some embodiments, the processor 203 may determine a first target threshold corresponding to the first voltage U1, and determine a first target code according to the first target threshold; and determine a second target threshold corresponding to the second voltage U2, and determine a second target code according to the second target threshold.
[0182] That is, at least one threshold needs to be set based on different voltage values, and each threshold corresponds to a status code. In this way, by determining the preset threshold ranges where the values of the first voltage U1 and the second voltage U2 are located, the connection status between the current CC1 pin 2011 or CC2 pin 2012 and the CC1-1 pin or CC2-1 pin can be judged.
[0183] For example, a first threshold, a second threshold, a third threshold, a fourth threshold, and a fifth threshold are set, and each threshold corresponds to a different status code respectively; the first threshold corresponds to the first status code A, the second threshold corresponds to the second status code B, the third threshold corresponds to the third status code C, the fourth threshold corresponds to the fourth status code D, and the fifth threshold corresponds to the fifth status code E. If the first voltage U1 is within the range of the first threshold, the first status code A can be used to represent that the CC1 pin 2011 is in a floating state; if the first voltage U1 is within the range of the second threshold, the second status code B can be used to represent that the CC1 pin 2011 is in a data exchange state and the CC1 pin 2011 is loaded with a pull-down resistor; if the first voltage U1 is within the range of the third threshold, the third status code C can be used to represent that the CC1 pin is in a state where an analog audio device is inserted and the CC1 pin 2011 is loaded with a pull-down resistor; if the first voltage U1 is within the range of the fourth threshold, the fourth status code D can be used to represent that the CC1 pin 2011 is in a state where a power adapter is inserted; if the first voltage U1 is within the range of the fifth threshold, the fifth status code E can be used to represent that the CC1 pin 2011 is in a state where a Power Delivery (PD) device is inserted. The same applies to the second voltage U2, and the present application will not elaborate on this.
[0184] It should be noted here that the ranges of the first threshold to the fifth threshold do not cover each other, and the specific ranges are set according to the corresponding different states and can be adjusted according to the actual situation.
[0185] Among them, the threshold corresponding to the first voltage U1 among at least one threshold is the first target threshold, and the status code corresponding to the first target threshold is the first target code. The threshold corresponding to the second voltage U2 among at least one threshold is the second target threshold, and the status code corresponding to the second target threshold is the second target code. The above process can be specifically implemented by matching the first voltage U1 and the second voltage U2 with a preset first truth table.
[0186] The preset first truth table can be built into the memory 120 of the electronic device 100 or into the register inside the processor 203. The embodiments of the present application do not limit this.
[0187] Among them, the preset first truth table can be as shown in the following table:
[0188]
[0189] Exemplarily, the first voltage U1 = 280 mV, and the corresponding first target code is A.
[0190] It should be noted here that the first threshold, the second threshold, the third threshold, the fourth threshold, and the fifth threshold range can be different voltage ranges respectively. The specific setting method of the threshold values is configured according to the differences between different states. For example, the voltage corresponding to the floating state of the CC pin is 280 mV, and its corresponding threshold can be set to 280 mV ± 20%, that is, the first threshold is 280 mV ± 20%. The above values are only for illustrative purposes, and the present application does not limit this. The threshold can also be set in other ways. For example, the threshold is set according to the resistance value or the current value. The present application does not elaborate on the various setting methods of the threshold.
[0191] Among them, corresponding to different circuit setting methods, the values of the first threshold to the fifth threshold need to be adjusted adaptively.
[0192] In some embodiments, if the first detection path 204 is provided with the first diode 217, and the second detection path 205 is provided with the second diode 218, the first target threshold is determined according to the temperature of the first diode 217, and the second target threshold is determined according to the temperature of the second diode 218.
[0193] In some embodiments, since the device identification device 200 includes the first diode 217 and the second diode 218, and the diode circuit generates a conduction impedance difference with the change of the operating temperature, therefore, based on different temperatures, the first threshold to the fifth threshold in the preset first truth table are set, so that the connection state between the first port 201 and the first terminal 202 can be determined more accurately.
[0194] That is to say, when the first detection path 204 is not provided with the first diode 217 and the second detection path 205 is not provided with the second diode 218, the value ranges of the first threshold to the fifth threshold are different from those when the first detection path 204 is provided with the first diode 217 and the second detection path 205 is provided with the second diode 218. Correspondingly, the first target threshold and the second target threshold are also different when the corresponding circuits are different.
[0195] In this application, the code form of the target code is only for illustrative purposes. The target code is not limited to being set as A, B, C, D, and E, and can also be set as other forms of characters or numbers.
[0196] Furthermore, the status code can be a code preset based on the waveforms of the first voltage U1 and the second voltage U2. Correspondingly, the matching method of the first voltage U1 and the second voltage U2 can be adjusted according to the waveforms, and the threshold can be set according to the waveforms. This application does not limit the matching method of the status code.
[0197] After obtaining the first target code corresponding to the first voltage U1 and the second target code corresponding to the second voltage U2 based on the above embodiments, the first target code and the second target code are matched with a preset second truth table.
[0198] The preset second truth table can be built into the memory 120 of the electronic device 100 or into the register inside the processor 203. This application embodiment does not limit this.
[0199] Among them, the preset second truth table can be as shown in the following table:
[0200] First voltage U1 Second voltage U2 Insertion state of the first terminal 202 Device type of the external device 300 A A Not inserted No device type A B Inserted Data exchange device B A Inserted Data exchange device B B Inserted Debugging device C C Inserted Audio device
[0201] In some embodiments, the data exchange device can be devices such as a USB flash drive, a Type-C digital headset, a keyboard, and a mouse. The debugging device is the Debug accessory. The audio device is the Audio accessory.
[0202] Exemplarily, if the first target code corresponding to the first voltage U1 is A and the second target code corresponding to the second voltage U2 is B, the first target code A and the second target code B form the first code combination AB.
[0203] Step S3, match the first code combination with the code combinations in the preset second truth table to determine the insertion state of the first terminal 202 and / or the device type of the external device 300.
[0204] Exemplarily, matching the first code combination AB with the code combinations in the preset second truth table can determine that the insertion state of the first terminal 202 is inserted into the first port 201, and the device type of the external device 300 is a data exchange device.
[0205] Exemplarily, the first code combination is AA. Matching the first code combination AA with the code combinations in the preset second truth table can only determine that the insertion state of the first terminal 202 is not inserted into the first port 201, and there is no corresponding device type for the external device 300.
[0206] It should be noted here that the code combinations in the preset second truth table include, but are not limited to, AA, AB, BA, BB, CC shown in the above second truth table. The embodiments of the present application only exemplarily illustrate the code combinations, and more code combinations can also be set according to actual situations to represent different insertion states and device types.
[0207] In this way, the processor 203 can obtain the first voltage U1 and the second voltage U2 from the simplified circuit without the set chip, and implement the device identification method based on the first voltage U1 and the second voltage U2 to determine the insertion state of the first terminal 202 and / or the device type of the external device 300, eliminating the need for detecting the chip, reducing the circuit complexity, and reducing the hardware cost.
[0208] Figure 11 This is the second flowchart of the device identification method provided by the embodiments of the present application. As Figure 11 shown, in some embodiments, before step S3, there is also step S4.
[0209] Step S4, determining the insertion state of the first terminal 202 according to the first voltage U1 and the second voltage U2.
[0210] If the insertion state of the first terminal 202 is inserted into the first port 201, execute step S3.
[0211] If the insertion state of the first terminal 202 is not inserted into the first port 201, execute step S5.
[0212] It can be understood that if the insertion state of the first terminal 202 is not inserted into the first port 201, it can be considered that there is no device type corresponding to the external device 300.
[0213] Different from the foregoing embodiments, after obtaining the values of the first voltage U1 and the second voltage U2, first judge the insertion state of the first terminal 202 according to the values of the first voltage U1 and the second voltage U2. In the specific implementation process, the processor 203 can preset a first value and a second value. The first value is the voltage value corresponding to the first voltage U1 when the first terminal 202 is not inserted into the first port 201, and the second value is the voltage value corresponding to the second voltage U2 when the first terminal 202 is not inserted into the first port 201. If the first voltage U1 is the first value and the second voltage U2 is the second value, determine that the insertion state of the first terminal 202 is not inserted into the first port 201. If the first voltage U1 is not the first value, or the second voltage U2 is not the second value, determine that the insertion state of the first terminal 202 is inserted into the first port 201. In this way, first judge the insertion state of the first terminal 202 according to the values, and after the insertion state of the first terminal 202 is inserted into the first port 201, further adopt the method of matching through the first truth table.
[0214] Further, as Figure 11 shown, in some embodiments, after step S4, step S5 is further included.
[0215] Step S5: Delay for a first duration and jump to S1.
[0216] In some embodiments, the first duration can be set to 1 second. The first duration can be set based on the actual speed at which the user plugs and unpluggs the first terminal 202, so that the processor 203 polls to obtain the first voltage U1 and the second voltage U2 within the first duration, meeting the identification requirements for the external device 300.
[0217] It should be noted here that the specific value of the first duration in the embodiments of the present application is not limited, and the first duration can be set according to the actual situation.
[0218] In the above embodiments, after the processor 203 determines that the insertion state of the first terminal 202 is not inserted into the first port 201, the steps of matching the device type of the external device 300 can be reduced, and the device types of the first terminal 202 and the external device 300 can be identified based on the actual speed at which the user plugs and unpluggs the first terminal 202.
[0219] Figure 12 is the third flowchart of the device identification method provided by the embodiments of the present application. As Figure 12 shown, in some embodiments, before step S1, step S6 is further included.
[0220] Step S6: Before obtaining the first voltage U1 and the second voltage U2, detect whether the electronic device 100 is in a sleep state; the sleep state includes: the operating system kernel of the electronic device 100 is completely asleep.
[0221] If the electronic device is not in the sleep state, execute step S1.
[0222] If the electronic device is in the sleep state, re - execute step S6.
[0223] In some embodiments, if the electronic device is in the sleep state, delay for a second duration, and then re - execute step S6.
[0224] The electronic device 100 has a sleep state and a non - sleep state. Since in the sleep state, some external devices 300 cannot perform their functions, therefore, even if the first voltage U1 and the second voltage U2 are obtained in the sleep state, the external device 300 cannot be further driven to perform its functions. Therefore, not obtaining the first voltage U1 and the second voltage U2 in the sleep state can reduce power consumption.
[0225] In some embodiments, a low-power space is provided in the partial electronic device 100. Even when the kernel is completely dormant, the low-power space can still operate. For example, the low-power space can be a Sensorhub. Therefore, the ADC1 pin 2031 and the ADC2 pin 2032 can be disposed inside the low-power space. In this way, in the sleep state, it is possible to identify the insertion state of the first terminal 201 and the device type of the external device 300 under low power consumption.
[0226] In some embodiments, the sleep state does not include the state where the electronic device 100 turns off the screen but is still playing music. Since the earphone is a common external device 300, and when the user is listening to music, usually no other operations may be performed, and the electronic device 100 turns off the screen to reduce power consumption. In this scenario, it is still necessary to continuously obtain the first voltage U1 and the second voltage U2 to ensure a good connection state of the external device 300.
[0227] Further as Figure 12 shown, in some embodiments, after step S3, steps S7 - S12 are further included.
[0228] Step S7, after determining the device type of the external device 300, perform a Universal Serial Bus enumeration with the external device 300.
[0229] USB enumeration is a process in which the external device 300 is connected to the electronic device 100 and assigns a specific address code to the electronic device 100. The address code is used to access the electronic device 100. In this way, communication can be established between the electronic device 100 and the external device 300.
[0230] Step S8, if the enumeration is successful, determine that the external device 300 has been connected.
[0231] Step S9, after determining that the external device 300 has been connected, obtain the first voltage U1 and the second voltage U2.
[0232] It should be noted here that the first voltage U1 and the second voltage U2 can be the voltages obtained in step S1, or can be the voltages re-obtained after determining that the external device 300 has been connected. The embodiments of the present application do not limit this.
[0233] Step S10, determine whether it matches the device type of the external device 300 according to the first voltage U1 and the second voltage U2.
[0234] After the external device 300 is connected, the processor 203 also needs to determine whether the external device 300 remains present. Therefore, the processor 203 determines again whether it matches the device type of the external device 300 according to the first voltage U1 and the second voltage U2. If the first voltage U1 and the second voltage U2 do not match the device type of the external device 300, S11 is executed. If the first voltage U1 and the second voltage U2 match the device type of the external device 300, S12 is executed.
[0235] Step S11: Determine whether the first terminal 202 has been unplugged.
[0236] For example, the first target code corresponding to the first voltage U1 is A, and the second target code corresponding to the second voltage U2 is B. At this time, the device type of the corresponding external device 300 is a data exchange device. If the second target code corresponding to the second voltage U2 changes to A, at this time, it does not have the device type of the external device 300, which does not match the device type of the data exchange device. It is further determined that the first terminal 202 has been unplugged.
[0237] Among them, the processor 203 can determine that the first terminal 202 has been unplugged according to whether the first target code and the second target code are an AA code combination. The processor 203 can also determine that the first terminal 202 has been unplugged according to whether the first voltage U1 and the second voltage U2 match the preset first value and second value.
[0238] If the first terminal 202 has been unplugged, detect again whether the electronic device 100 is in the sleep state.
[0239] If the first terminal 202 has not been unplugged, obtain the insertion state of the first terminal 202 again.
[0240] Step S12: Delay for a third duration and jump to step S9.
[0241] In this way, the processor 203 can determine whether the external device 300 remains present.
[0242] In some embodiments, the third duration can be set to 1 second. The third duration can be set based on the actual speed at which the user plugs and unpluggs the first terminal 202, so that the processor 203 polls to obtain the first voltage U1 and the second voltage U2 within the third duration to meet the identification requirements of the external device 300.
[0243] In some embodiments, the device type of the external device 300 may also be a preset specific device type. For example, the specific device type is a headset. Such a specific device type is an external device 300 that can still operate after the screen is turned off. Thus, if the first voltage U1 and the second voltage U2 also match the specific device type, the acquisition of the first voltage U1 and the second voltage U2 can be delayed by a fourth duration, and the fourth duration is greater than the third duration. In this way, the power consumption can be reduced by extending the acquisition time of the first voltage U1 and the second voltage U2.
[0244] In the above embodiments, the processor 203 can identify the device type of the first terminal 202 and the external device 300 based on the actual insertion and extraction speed of the user for the first terminal 202.
[0245] In some embodiments, if the device type of the external device 300 is a specific device type, after the electronic device 100 is turned on, step S1 is triggered to be executed.
[0246] In some embodiments, it further includes:
[0247] If the first target threshold or the second target threshold is a first preset threshold, the number of pull-up resistors coupled to the first terminal 202 is determined according to the first voltage U1, the second voltage U2, and the first preset threshold.
[0248] Among them, the first preset threshold may be a fourth threshold. If the first target threshold or the second target threshold is the fourth threshold, the combination of the first voltage U1, the second voltage U2, and the fourth threshold can determine whether the first terminal 202 is coupled with one pull-up resistor or two pull-up resistors.
[0249] It should be noted here that when the processor 203 detects the first voltage U1 or the second voltage U2, it can determine that the first terminal 202 is pulled up to the VBUS pin by a single resistor. When the processor 203 detects the first voltage U1 and the second voltage U2, it can determine that the first terminal 202 is pulled up to the VBUS pin by a double resistor. Based on this, the data line type can be identified.
[0250] In some embodiments, it further includes:
[0251] If the first target threshold or the second target threshold is a second preset threshold, it is determined that the first terminal 202 is a dual-role port DRP; the first port 202 is determined as a downstream port DFP or an upstream port UFP according to the internal configuration of the electronic device 100.
[0252] Among them, the second preset threshold may be a fifth threshold. Thus, if the first target threshold or the second target threshold is the fifth threshold, it is determined that the first terminal 202 is a DRP.
[0253] In some embodiments, the device types of the external devices include at least one of: data exchange OTG devices, debugging devices, audio devices, power adapters, and power delivery PD devices.
[0254] The device identification apparatus 200 and the device identification method shown in this application form a first detection path 204 through the ADC1 pin 2031 and the CC1 pin 2011, and form a second detection path 205 through the ADC2 pin 2032 and the CC2 pin 2012 to respectively detect the first voltage U1 and the second voltage U2. At the same time, in cooperation with the software detection logic, the functions of identifying the insertion state of the first terminal 202 and the device type of the external device 300 connected to the first terminal 202 are realized, eliminating the detection chip, reducing the circuit complexity, and reducing the hardware cost.
[0255] The device identification method shown in this application, based on the device identification apparatus 200, in cooperation with the software detection logic, realizes the functions of identifying the insertion state of the first terminal 202 and the device type of the external device 300 connected to the first terminal 202, eliminating the detection chip, reducing the circuit complexity, and reducing the hardware cost. The above mainly introduces the solution provided by the embodiments of this application from the perspective of the electronic device. It can be understood that in order for the electronic device to implement the above functions, it includes the corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should easily realize that, combined with the steps of a device identification method in each example described in the embodiments disclosed in this application, this application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the form of hardware or software of the electronic device driving the hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.
[0256] The embodiments of this application can divide the above-mentioned electronic device into functional modules or functional units according to the above method examples. For example, each functional module or functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing module. The above-mentioned integrated module can be implemented in the form of hardware, or in the form of a software functional module or functional unit. Among them, the division of modules or units in the embodiments of this application is illustrative, only a logical function division, and there can be other division methods in actual implementation.
[0257] An embodiment of the present application further provides a chip system, which includes at least one processor and at least one interface circuit. The processor and the interface circuit can be interconnected by a line. For example, the interface circuit can be used to receive signals from other devices (such as the memory of an electronic device). For another example, the interface circuit can be used to send signals to other devices. Exemplarily, the interface circuit can read the instructions stored in the memory and send the instructions to the processor. When the instructions are executed by the processor, the electronic device can execute the respective steps in the above embodiments. Of course, the chip system can also include other discrete devices, and the embodiments of the present application do not make specific limitations thereto.
[0258] An embodiment of the present application further provides a computer-readable storage medium, which includes computer instructions. When the computer instructions run on the above-mentioned electronic device, the electronic device is caused to execute the respective functions or steps performed by the mobile phone in the above method embodiments.
[0259] An embodiment of the present application further provides a computer program product. When the computer program product runs on a computer, the computer is caused to execute the respective functions or steps performed by the mobile phone in the above method embodiments.
[0260] Through the description of the above embodiments, those skilled in the art can clearly understand that for the convenience and brevity of description, only the above division of each functional module is used as an example. In actual applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
[0261] In several embodiments provided by the present application, it should be understood that the disclosed device and method can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the module or unit is only a logical function division. In actual implementation, there can be other division methods. For example, multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces. The indirect coupling or communication connection of the device or unit can be in an electrical, mechanical or other form.
[0262] The unit described as a separated component may or may not be physically separated. The component displayed as a unit may be a physical unit or multiple physical units, that is, it can be located in one place, or can be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0263] In addition, in each embodiment of the present application, each functional unit can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0264] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on such an understanding, the technical solution of the embodiments of the present application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. The software product is stored in a storage medium and includes several instructions for causing a device (which can be a single-chip microcomputer, a chip, etc.) or a processor to execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: various media such as a USB flash drive, a mobile hard disk, a read only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc that can store program codes.
[0265] The above content is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. An electronic device, characterized in that, Comprising: A first port, including a first configuration channel CC1 pin and a second configuration channel CC2 pin; A processor, including a first analog-to-digital conversion ADC1 pin and a second analog-to-digital conversion ADC2 pin; The ADC1 pin is connected to the CC1 pin to form a first detection path; The ADC2 pin is connected to the CC2 pin to form a second detection path; The processor is configured to: detect a first voltage of the CC1 pin through the first detection path, and detect a second voltage of the CC2 pin through the second detection path; wherein, the first voltage, and / or, the second voltage changes in response to a first terminal being inserted into the first port and the first terminal being pulled out of the first port; The processor is further configured to: obtain the first voltage and the second voltage; match the first voltage and the second voltage with status codes in a preset first truth table respectively to obtain a first code combination, the first code combination including a first target code corresponding to the first voltage and a second target code corresponding to the second voltage; Match the first code combination with a code combination in a preset second truth table to determine the insertion state of the first terminal, and / or, the device type of an external device connected to the first terminal.
2. The electronic device according to claim 1, wherein The processor is further configured to: identify the insertion state of the first terminal according to the first voltage and the second voltage, and identify the device type of the external device.
3. The electronic device according to claim 1, wherein Further comprising: A first pull-up resistor, one end of which is coupled to a port power supply and the other end is coupled to the first detection path; The first pull-up resistor is configured to pull up the first voltage to a preset threshold range by using the port power supply; A second pull-up resistor, one end of which is coupled to the port power supply and the other end is coupled to the second detection path; The second pull-up resistor is configured to pull up the second voltage to a preset threshold range by using the port power supply.
4. The electronic device according to claim 3, characterized in that, Further comprising: A first switch, one end of which is coupled to the port power supply and the other end is coupled to the first detection path, in series with the first pull-up resistor; A second switch, one end of which is coupled to the port power supply and the other end is coupled to the second detection path, in series with the second pull-up resistor.
5. The electronic device according to any one of claims 1-4, characterized in that, Further comprising: A first pull-down resistor, one end of which is coupled to the first detection path and the other end is coupled to ground; The first pull-down resistor is configured to pull down the first voltage to a preset threshold range; A second pull-down resistor, one end of which is coupled to the second detection path and the other end is coupled to ground; The second pull-down resistor is configured to pull down the second voltage to a preset threshold range.
6. The electronic device according to claim 5, wherein Further comprising: A third pull-down resistor, one end of which is coupled to the first detection path and the other end is coupled to ground, in parallel with the first pull-down resistor; A third switch, one end of which is coupled to the first detection path and the other end is coupled to ground, in series with the third pull-down resistor; A fourth pull-down resistor, one end of which is coupled to the second detection path and the other end is coupled to ground, in parallel with the second pull-down resistor; A fourth switch, one end of which is coupled to the second detection path and the other end of which is coupled to ground, is connected in series with the fourth pull-down resistor.
7. The electronic device according to claim 1, wherein Further included are: A first diode, which is located on the first detection path, the anode of the first diode being coupled to the ADC1 pin and the cathode of the first diode being coupled to the CC1 pin; A second diode, which is located on the second detection path, the anode of the second diode being coupled to the ADC2 pin and the cathode of the second diode being coupled to the CC2 pin.
8. The electronic device according to claim 1, wherein the processor includes at least one of a system-on-chip (SOC), a central processing unit (CPU), and a power management unit (PMU).
9. The electronic device according to claim 6 or 7, wherein the processor is further configured to: Determine the insertion state of the first terminal according to the first voltage and the second voltage; If the insertion state of the first terminal is that it has been inserted into the first port, perform the step of matching the first voltage and the second voltage with the status codes in a preset first truth table respectively.
10. The electronic device according to claim 9, wherein the processor is further configured to: After determining the insertion state of the first terminal, if the insertion state of the first terminal is that it has not been inserted into the first port, delay for a first duration to obtain the first voltage and the second voltage.
11. The electronic device according to claim 10, wherein the processor is further configured to: Before obtaining the first voltage and the second voltage, detect whether the electronic device is in a sleep state; The sleep state includes: the operating system kernel of the electronic device is completely asleep; If the electronic device is not in the sleep state, obtain the first voltage and the second voltage; If the electronic device is in the sleep state, delay for a second duration to detect whether the electronic device is in the sleep state.
12. The electronic device according to claim 11, wherein the processor is further configured to: After determining the device type of the external device, perform a Universal Serial Bus (USB) enumeration with the external device; If the enumeration is successful, determine that the external device has been connected; Judge whether it matches the device type of the external device according to the first voltage and the second voltage; If the first voltage and the second voltage do not match the device type of the external device, judge whether the first terminal has been unplugged; If the first terminal has been unplugged, detect again whether the electronic device is in the sleep state; If the first terminal has not been unplugged, obtain the insertion state of the first terminal again.
13. The electronic device according to claim 12, wherein the processor is further configured to: If the first voltage and the second voltage match the device type of the external device, delay for a third duration to obtain the first voltage and the second voltage.
14. The electronic device according to claim 9, wherein the processor is further configured to: Determining a first target threshold corresponding to the first voltage, and determining the first target code according to the first target threshold; And, determining a second target threshold corresponding to the second voltage, and determining the second target code according to the second target threshold.
15. The electronic device according to claim 14, characterized in that: The processor is further configured to: If the first target threshold or the second target threshold is a first preset threshold, the number of pull-up resistors coupled to the first terminal is determined according to the first voltage, the second voltage, and the first preset threshold.
16. The electronic device according to claim 14, characterized in that: The processor is further configured to: If the first target threshold or the second target threshold is a second preset threshold, determining that the first terminal is a dual role port DRP; The first port is determined to be a downstream port DFP or an upstream port UFP according to the internal configuration of the electronic device.
17. The electronic device according to claim 1, characterized in that: The device type of the external device includes: at least one of a data exchange OTG device, a debugging device, an audio device, a power adapter, and a power transmission PD device.
18. The electronic device according to claim 14, characterized in that: The processor is further configured to: If the first detection path is provided with a first diode, and the second detection path is provided with a second diode, the first target threshold is determined according to the temperature of the first diode, and the second target threshold is determined according to the temperature of the second diode.
19. A device identification method, characterized in that, Applied to an electronic device, the electronic device comprises a first port and a processor, the first port comprises a first configuration channel CC1 pin and a second configuration channel CC2 pin, the processor comprises a first analog-to-digital conversion ADC1 pin and a second analog-to-digital conversion ADC2 pin, the ADC1 pin is connected with the CC1 pin to form a first detection path, the ADC2 pin is connected with the CC2 pin to form a second detection path; the method comprises: The processor detects a first voltage of the CC1 pin through the first detection path, and detects a second voltage of the CC2 pin through the second detection path; wherein the first voltage and / or the second voltage changes in response to the first terminal being inserted into the first port and the first terminal being removed from the first port; The processor acquires the first voltage and the second voltage; The processor matches the first voltage and the second voltage with state codes in a preset first truth table respectively to obtain a first code combination, where the first code combination includes a first target code corresponding to the first voltage and a second target code corresponding to the second voltage; The processor matches the first code combination with a code combination in a preset second truth table to determine the insertion state of the first terminal and / or the device type of the external device connected to the first terminal.
20. The device identification method according to claim 19, wherein Also includes: The processor determines the insertion state of the first terminal according to the first voltage and the second voltage; If the insertion state of the first terminal is inserted into the first port, the processor performs the step of matching the first voltage and the second voltage with the status codes in a preset first truth table respectively.
21. The device identification method according to claim 19 or 20, characterized in that After determining the insertion state of the first terminal, it further includes: If the insertion state of the first terminal is not inserted into the first port, the processor delays for a first duration to obtain the first voltage and the second voltage.
22. The device identification method according to claim 21, characterized in that, Before the processor obtains the first voltage and the second voltage, it includes: The processor detects whether the electronic device is in a sleep state; the sleep state includes: the operating system kernel of the electronic device is completely asleep; If the electronic device is not in the sleep state, the processor obtains the first voltage and the second voltage; If the electronic device is in the sleep state, the processor delays for a second duration to detect whether the electronic device is in the sleep state.
23. The device identification method according to claim 22, characterized in that, After determining the insertion state of the first terminal, and / or the device type of the external device connected to the first terminal, it further includes: The processor performs a Universal Serial Bus enumeration with the external device; If the enumeration is successful, the processor determines that the external device has been connected; The processor determines whether it matches the device type of the external device according to the first voltage and the second voltage; If the first voltage and the second voltage do not match the device type of the external device, the processor determines whether the first terminal has been unplugged; If the first terminal has been unplugged, the processor detects again whether the electronic device is in the sleep state; If the first terminal has not been unplugged, the processor obtains the insertion state of the first terminal again.
24. The device identification method according to claim 23, characterized in that, It further includes: If the first voltage and the second voltage match the device type of the external device, the processor delays for a third duration to obtain the first voltage and the second voltage.
25. The device identification method according to claim 19 or 20, characterized in that, The processor matches the first voltage and the second voltage with the status codes in a preset first truth table respectively, including: The processor determines a first target threshold corresponding to the first voltage, and determines a first target code according to the first target threshold; And, determines a second target threshold corresponding to the second voltage, and determines a second target code according to the second target threshold.
26. The device identification method according to claim 25, characterized in that, It further includes: If the first target threshold or the second target threshold is a first preset threshold, the processor determines the number of pull-up resistors coupled to the first terminal according to the first voltage, the second voltage, and the first preset threshold.
27. The device identification method according to claim 26, wherein It further includes: If the first target threshold or the second target threshold is a second preset threshold, the processor determines that the first terminal is a Dual-Role Port (DRP); The processor determines the first port as a Downstream Facing Port (DFP) or an Upstream Facing Port (UFP) according to the internal configuration of the electronic device.
28. The device identification method according to claim 19, wherein The device types of the external device include at least one of: a data exchange OTG device, a debugging device, an audio device, a power adapter, and an energy transfer PD device.
29. The device identification method according to claim 23, wherein if a first diode is provided in the first detection path and a second diode is provided in the second detection path, the first target threshold is determined according to the temperature of the first diode, and the second target threshold is determined according to the temperature of the second diode.
Citation Information
Patent Citations
Pin testing device and method, control equipment and storage medium
CN113590402A
Interface identification circuit, interface identification method and intelligent terminal
CN113922465A
CC detection function circuit of Type C
CN215986443U