Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The flow diagrams depicted in the figures are merely illustrative and not necessarily all of the elements and operations/steps are included or performed in the order described. For example, some operations/steps may be further divided, combined, or partially combined, so that the order of actual execution may be changed according to actual situations.
Some embodiments of the present application are described in detail below with reference to the accompanying drawings. The following embodiments and features of the embodiments may be combined with each other without conflict.
The embodiment of the application provides a terminal Type-C interface foreign matter detection method, a terminal Type-C interface foreign matter detection device and a storage medium, which are used for detecting the terminal Type-C interface foreign matter.
As shown in fig. 1, fig. 1 is a terminal Type-C interface foreign matter detection system provided in an embodiment of the present application, where the system includes a terminal and a charger end, and the terminal is in communication connection with the charger end.
When the terminal is in communication connection with the charger end, mutual data transmission can be achieved.
The terminal comprises electronic equipment such as a mobile phone, a tablet personal computer, a notebook computer, a desktop computer, a personal digital assistant, wearable equipment and the like.
Hereinafter, a method for detecting foreign matters on the terminal Type-C interface provided in the embodiment of the present application will be described in detail based on the foreign matters detection system on the terminal Type-C interface.
Referring to fig. 2, fig. 2 is a flowchart of a first embodiment of a method for detecting foreign matters on a Type-C interface of a terminal according to the present application. The terminal Type-C interface foreign matter detection method can be used in a terminal Type-C interface foreign matter detection system.
As shown in fig. 2, the terminal Type-C interface foreign matter detection method includes steps S101 to S105.
Step S101, based on a current data reading instruction sent by a terminal main control, the terminal reads current consumption data on a charging path;
in this embodiment, in the charging process of the terminal, the terminal main control of the terminal sends a current data reading instruction to the control unit of the power management module of the terminal, so as to read the consumption current data on the charging path.
In an embodiment, as shown in fig. 3, fig. 3 is a schematic diagram of current consumption of a charging circuit with foreign matters according to an embodiment of the present application. Wherein, the charging head output current is IBUS, the charging path consumption current is ICHG, and the foreign matter consumption current is IFOD.
In one embodiment, as shown in fig. 3, the output current IBUS at the charger end is the sum of the charging input current ICHG and the foreign object current branch IFOD, so that if the current IBUS and the current ICHG have a positive difference, the foreign object can be qualitatively present, and the severity of the foreign object is quantified according to the difference, and the foreign object is provided to the terminal for detection and safety decision.
In one embodiment, the terminal master control sends get_cur_ichg instructions to the control unit of the power management module through the I2C, the control unit reads the Ichg data measured by the current sampling circuit on the chg_vin path in the power management module, and then the control unit sends the Ichg data to the terminal master control through the I2C, so that the terminal master control detects the input current Ichg of the power management module in real time through the "control/data" link I2C.
Step S102, based on the configuration channel, the terminal inquires output current data of a charger end in real time;
in this embodiment, the terminal master control queries the output current IBUS of the charger terminal in real time through the configuration channel (CC channel, configuration Channel) of Type-C.
In an embodiment, as shown in fig. 4, fig. 4 is a schematic diagram of a current detection structure inside a charger according to an embodiment of the present application. Wherein, the inside of the charger end comprises current measurement, power supply control and CC communication. Wherein, CC1 or CC2 (CC channel) is responsible for the master control communication with the terminal.
In one embodiment, the communication of the CC1 or CC2 ports complies with the PDR3 specification of the USB IF, and the data packets are half duplex communication, and the data packets include a preamble, a packet control code, and an information code. The information code is defined and provided by a protocol layer and adopts 4B/5B encoding and decoding, the packet control code is provided by a physical layer and adopts 4B/5B encoding and decoding, the synchronous code is provided by the physical layer, and finally the whole data packet is encoded and decoded by a BMC encoding and decoding unit (BMC En/decoding) and then transmitted through CC1 or CC 2.
In one embodiment, the 4B/5B code is one of the line layer code types in hundred megaEthernet (i.e., fast Ethernet), which is a 5bit binary number representing a 4bit binary number. The coding is characterized in that each 4 bits of the data stream to be transmitted is used as a group, and then the data stream is converted into a corresponding 5bit code according to a 4B/5B coding rule. The 5bit codes have 32 combinations in total, but only 16 of them are employed, corresponding to 16 of the 4bit codes, and the other 16 are either unused or used as control codes to indicate the start and end of a frame, the status of the fiber line (stationary, idle, suspended), etc.
In one embodiment, the charger device internally powers the interior through the higher of the voltages in VBUS (usb charging port) and VBAT (battery). When the voltage of VBUS rises above the v_bus_uvloz value or the voltage of VBAT exceeds the v_bat_uvloz value, the sleep comparator, the battery depletion comparator and the BAT drive are active, the i2C interface is ready to communicate, and all registers are reset to default values. After the POR, the host can access all registers.
In one embodiment, the CC channel serves as configuration channel, which plays a significant role in all of the various modes of USB Type-C-Normal, PD, ALT, access-including: insert detection, identify cable direction, negotiate between two ports to establish DFP and UFP identities, discover and configure VBUS, current mode or PD mode, configure Vconn, discover and configure other peripheral mode-alternate (alt) and peripheral (access) modes.
Step S103, calculating the current difference between the terminal and the charger terminal based on the consumption current data and the output current data;
in this embodiment, after receiving the output current data sent by the charger end, the terminal master control of the terminal may determine the corresponding consumption current data according to the synchronization code, so as to calculate a current difference between the consumption current data and the output current data.
In an embodiment, when the current difference is smaller than the preset difference threshold, the current loss is considered to be in a normal range, and it is determined that the charging interface between the terminal and the charger terminal is normal and free of foreign matters, and the charging interface is in a normal charging process.
Step S104, when the current difference value is larger than a preset difference value threshold value, determining that abnormal electric leakage exists at an interface between the terminal and the charger end.
In an embodiment, when the current difference between the consumption current data and the output current data is greater than the preset difference threshold, the extra current consumption is out of the normal range at this time, which is considered to be caused by the foreign object consumption current, so that it can be determined that there is abnormal leakage at the interface, that is, that there is foreign object at the interface.
The embodiment provides a terminal Type-C interface foreign matter detection method, which comprises the steps that based on a current data reading instruction sent by a terminal main control, the terminal reads current consumption data on a charging path; based on the configuration channel, the terminal inquires output current data of the charger end in real time; calculating a current difference between the terminal and the charger terminal based on the consumption current data and the output current data; and when the current difference value is larger than a preset difference value threshold value, determining that abnormal electric leakage exists at an interface between the terminal and the charger terminal. Calculating the current difference value of the output current and the consumption current by collecting the consumption current data of the charging channel of the terminal and the output current data of the charger end, so as to judge whether the charging channel has extra current consumption; when the current difference is larger than a preset difference threshold, it can be judged that extra current consumption exists on the charging path, and the reason for the extra current consumption is probably due to foreign matter consumption, so that it can be judged that foreign matters exist at the interface between the terminal and the charger end, abnormal leakage is caused, and therefore detection of foreign matters at the terminal Type-C interface is achieved.
Referring to fig. 5, fig. 5 is a flowchart of a second embodiment of a method for detecting foreign matters on a Type-C interface of a terminal according to the present application.
Based on the embodiment shown in fig. 2, in this embodiment, the step S102 specifically includes:
step S201, based on the configuration channel, a query data packet is sent to a control unit of the charger end;
step S202, based on the query data packet, the control unit at the charger end reads the output current data acquired by the current sensing unit in real time;
in this embodiment, the terminal main control of the terminal sends a GetPwrCur (control code CtrlMSG) data packet to the control unit (Digital Control Logic) at the charger end through the CC channel, and the control unit reads data of the Current sensing unit (Current Sense), that is, outputs Current data, through the internal analog differential signal channel.
In one embodiment, the current sensing unit is capable of collecting current data of a charging head output power supply (VBUS) in real time.
In one embodiment, differential transmission is a signal transmission technique, and is distinguished from conventional one signal line and one ground line, in that differential transmission transmits signals on both lines, and the two signals have the same amplitude and opposite phases. The transmitted signals on these two wires are differential signals. The signal receiving end compares the difference value of the two voltages to judge the logic state sent by the sending end. On a circuit board, the differential trace must be two wires of equal length, equal width, in close proximity and at the same level. The control unit and the current sensing unit realize simultaneous data transmission, so that the output current data is acquired and transmitted in real time.
Step 203, based on the output current data, the charger end generates a current data packet, and based on the configuration channel, sends the current data packet to the terminal.
In one embodiment, the current data packet includes an information code, a synchronization code, and a packet control code.
In an embodiment, the generating, by the charger side, a current data packet based on the output current data includes:
encoding the output current data into at least one encoded current data based on a preset data encoding rule;
generating a target information code based on the encoded current data and an additional control code;
and generating the current data packet based on the target information code, the synchronous code and the packet control code.
In an embodiment, the preset data encoding rule is a count encoding rule of 10bit data.
In one embodiment, after the control unit at the charger end reads the data of the sensing unit, 10mA per bit is used for counting and encoding 10 bits of data, an additional control code is added based on the 10 bits of data to generate a 32bit information code, and then a synchronous code and a packet control code are added to encapsulate the data into a CurDataDataMSG data packet, namely a current data packet.
In one embodiment, the core data of the CurData (data code DataMSG) packet is 10bit current data code, for example, the actual IBUS is 1810mA, then the 10bit data is 00 1011 0101, the corresponding decimal data is 181, and the current data is 10mA/bit, namely 1810mA.
In one embodiment, the encapsulation process of the data includes data processing in terms of an application layer, a transport layer, a network layer, a data link layer, and a physical layer. At the application layer, the data is translated into voice-binary coded data used in the network world; at the transport layer, the upper layer data is split into small data segments and the TCP message header is encapsulated for each segmented data. The TCP header has a key field information-port number, which is used for identifying an upper layer protocol or application program and ensuring the normal communication of upper layer application data; at the network layer, the upper layer data is encapsulated with a new message header, namely an IP header; at the data link layer, the upper layer data is encapsulated with a MAC header, and the inside of the MAC header is provided with key field information, namely a MAC address; the physical layer converts the bit stream of these binary digits into an electrical signal for transmission in the network.
In an embodiment, after the charger end generates the current data packet, the data packet is sent to the main control of the terminal through CC1 or CC2 (CC channel), the main control receives and analyzes the received data according to the reverse processing of the data packet encapsulation, so that the main control of the terminal reads the 10bit current data of the charging end, and finally generates the output current data IBUS of the charging end.
Referring to fig. 6, fig. 6 is a flowchart of a third embodiment of a method for detecting foreign matters on a Type-C interface of a terminal according to the present application.
Based on the embodiment shown in fig. 2, in this embodiment, the step S104 specifically includes:
step 301, when the current difference value is detected to be greater than the preset difference value threshold value, based on a preset period, the consumption current data and the output current data are collected again, and the current difference value is calculated;
step S302, when the number of times that the current difference value is larger than the preset difference value threshold reaches the preset number of times within the preset duration, determining that abnormal electric leakage exists at the interface between the terminal and the charger end.
In an embodiment, after obtaining consumption current data and output current data and calculating to obtain a current difference value, when the current difference value (i.e. IFOD) of the two data is in a reasonable range, the terminal master control detects and judges that the interface state is safe and normal; when the charger end data IBUS is larger than the terminal data ICHG and reaches a threshold value, the terminal main control immediately judges that the interface has abnormal electric leakage.
In an embodiment, in order to ensure that the data is reliable, the terminal main control can collect batch data at a high speed, ensure consistency and validity of all the data, further identify that the data is reliable and effective, and prevent missing detection and false detection. The detection of foreign matter can be made by periodically making the current detection so as to cover the entire charging process.
In an embodiment, in the process of charging, to avoid excessive data collection, a collection period may be set, and current data may be collected according to the collection period.
In an embodiment, a preset time period may be set, the preset time period is longer than a preset period, at least one output current data and consumption current data are collected in the preset time period, that is, at least one current difference value is obtained through calculation, if the current difference value obtained through calculation of the data collected in the preset time period is greater than a preset difference value threshold value for a preset number of times, it may be determined that abnormal leakage exists in the interface, for example, three current data are collected in the preset time period, and at least two current difference values in the three current data are greater than the preset difference value threshold value, it may be considered that the interface has abnormal leakage.
In an embodiment, when the current difference is detected to be greater than a preset difference threshold, timing may be performed, current data may be collected according to a preset period, and when a duration of the current difference greater than the preset difference threshold reaches a preset duration, abnormal leakage may be considered to exist in the interface.
In an embodiment, after determining that the interface between the terminal and the charger terminal has abnormal leakage when the current difference is greater than a preset difference threshold, the method further includes: and the terminal main control interrupts the charging process and sends an alarm signal so as to display an alarm to a user through the terminal.
In one embodiment, when it is determined that an abnormal leakage exists in the interface, the terminal master control rapidly closes the charging process, and simultaneously the system starts the terminal screen popup window, the warning tone, the indicator lamp, and the like, and the master control simultaneously notifies the control unit of the charging terminal to close the power FET (PWR FET) through the PwrCtrl (CtrlMsg) data packet of the CC, and cuts off the VBUS output.
The following describes a specific implementation principle of the foreign matter detection method for the terminal Type-C interface provided by the present application through a specific embodiment.
In a specific embodiment, referring to the embodiment shown in fig. 2, step S102 is further described in detail in this specific embodiment, and specifically, the implementation steps of the method for detecting a foreign object on a Type-C interface of a terminal provided in the present application are as follows:
step S101, based on a current data reading instruction sent by a terminal main control, the terminal reads current consumption data on a charging path;
in this embodiment, the terminal master control of the terminal sends a get_cur_ichg instruction to the control unit of the power management module through the I2C, the control unit of the terminal reads the Ichg data measured by the current sampling circuit on the chg_vin path in the power management module, and then the control unit of the terminal sends the Ichg data to the terminal master control through the I2C, so that the terminal master control detects the input current Ichg of the power management module in real time through the "control/data" link I2C, that is, the terminal reads the consumption current data collected in real time on the charging path.
Step S102, based on the configuration channel, the terminal inquires output current data of a charger end in real time;
further, the step S102 specifically includes:
based on the configuration channel, the terminal sends a data query instruction to the charger end;
based on the data query instruction, the control unit at the charger end reads the output current data acquired by the current sensing unit through an internal analog differential signal channel;
based on the control unit of the charger end, counting and encoding the output current data to generate encoded data;
packaging and generating the current data packet based on the coded data, the synchronous code and the packet control code;
based on the configuration channel, the charger end sends the current data packet to the terminal, and decodes the current data packet based on terminal main control of the terminal, so that the terminal obtains the output current data;
meanwhile, the terminal master control of the terminal inquires the output current IBUS of the charger end in real time through CC (Configuration Channel) communication of Type-C, and is responsible for communication with the master control of the terminal with reference to fig. 3 and 4, CC1 or CC2 (CC channel).
The terminal main control of the terminal sends a GetPwrCur (control code CtrlMSG) data packet to a control unit (Digital Control Logic) at the charger end through a CC channel, the control unit at the charger end reads data of a Current sensing unit (Current Sense) through an internal analog differential signal channel, and the Current sensing unit can acquire Current data of a charging head output power supply (VBUS), namely output Current data at the charger end in real time.
After the control unit at the charger end reads the data of the sensing unit, 10mA per bit is used for counting and encoding 10 bits of data, an additional control code is added to generate a 32bit information code based on the 10bit data, and then a synchronous code and a packet control code are added to encapsulate the data into a CurData (data code DataMSG) data packet.
And then the charger end sends the data packet to the terminal main control of the terminal through the CC1 or the CC2 (CC channel), the terminal main control of the terminal receives and analyzes the received data according to the reverse processing of the data packet encapsulation, so that the main control of the terminal reads the 10bit current data of the charging end and finally generates the output current data IBUS of the charging end.
Step S103, calculating the current difference between the terminal and the charger terminal based on the consumption current data and the output current data;
the output current data IBUS at the charger end is the sum of the charging input current ICHG and the foreign matter current branch IFOD, so that if the current of IBUS and the current of ICHG have a positive difference, the foreign matter can be qualitatively present, the severity of the foreign matter is quantified according to the difference, and the foreign matter is provided for the terminal to detect the foreign matter and make a safety decision.
Step S104, when the current difference value is larger than a preset difference value threshold value, determining that abnormal electric leakage exists at an interface between the terminal and the charger end.
After obtaining consumption current data and output current data and calculating to obtain a current difference value, when the current difference value (i.e. IFOD) of the two data is in a reasonable range, the terminal main control detects and judges that the interface state is safe and normal; when the charger end data IBUS is larger than the terminal data ICHG and reaches a threshold value, the terminal main control immediately judges that the interface has abnormal electric leakage.
When the interface is judged to have abnormal electric leakage, the terminal main control rapidly closes the charging process, meanwhile, the system starts a terminal screen popup window, warning sounds, indicator lights and the like, and the main control informs a control unit of the charging end to close a power FET (PWR FET) through a PwrCtrl (CtrlMsg) data packet of the CC, and cuts off VBUS output.
Referring to fig. 7, fig. 7 is a schematic block diagram of a terminal Type-C interface foreign matter detection device provided in an embodiment of the present application. The terminal Type-C interface foreign matter detection device is used for executing the terminal Type-C interface foreign matter detection method. The terminal Type-C interface foreign matter detection device can be configured in a terminal.
As shown in fig. 7, the terminal Type-C interface foreign matter detection device 300 includes: a consumption current data reading module 301, an output current data reading module 302, a current difference calculation module 303, and an interface abnormality judgment module 304.
A current consumption data reading module 301, configured to read current consumption data on a charging path based on a current data reading instruction sent by a terminal main control;
the output current data reading module 302 is configured to query output current data of the charger end in real time based on the configuration channel;
a current difference calculation module 303, configured to calculate a current difference between the terminal and the charger terminal based on the consumption current data and the output current data;
and the interface abnormality judging module 304 is configured to determine that abnormal leakage exists between the terminal and the interface of the charger terminal when the current difference is greater than a preset difference threshold.
In an embodiment, the output current data reading module 302 is further configured to send a query packet to the control unit of the charger end based on the configuration channel; based on the query data packet, the control unit at the charger end reads the output current data acquired by the current sensing unit in real time; and generating a current data packet by the charger terminal based on the output current data, and sending the current data packet to the terminal based on the configuration channel.
In one embodiment, the current data packet includes an information code, a synchronization code, and a packet control code.
In an embodiment, the output current data reading module 302 is further configured to encode the output current data into at least one encoded current data based on a preset data encoding rule; generating a target information code based on the encoded current data and an additional control code; and generating the current data packet based on the target information code, the synchronous code and the packet control code.
In an embodiment, the preset data encoding rule is a count encoding rule of 10bit data.
In an embodiment, the interface abnormality determination module 304 is further configured to, when detecting that the current difference is greater than the preset difference threshold, re-collect the consumption current data and the output current data based on a preset period, and calculate the current difference; and when the times that the current difference value is larger than the preset difference value threshold value reach the preset times within the preset duration, determining that abnormal electric leakage exists at the interface between the terminal and the charger end.
In an embodiment, the terminal Type-C interface foreign matter detection device 300 further includes an anomaly alarm module, configured to interrupt the charging process by the terminal master control, and send an alarm signal to display an alarm to a user through the terminal.
It should be noted that, for convenience and brevity of description, specific working processes of the above-described apparatus and each module may refer to corresponding processes in the foregoing embodiment of the terminal Type-C interface foreign matter detection method, which are not described herein again.
The apparatus provided by the above embodiments may be implemented in the form of a computer program which may be run on a computer device as shown in fig. 8.
Referring to fig. 8, fig. 8 is a schematic block diagram of a computer device according to an embodiment of the present application. The computer device may be a terminal.
With reference to FIG. 8, the computer device includes a processor, memory, and a network interface connected by a system bus, where the memory may include a non-volatile storage medium and an internal memory.
The non-volatile storage medium may store an operating system and a computer program. The computer program comprises program instructions which, when executed, cause the processor to perform any one of the terminal Type-C interface foreign object detection methods.
The processor is used to provide computing and control capabilities to support the operation of the entire computer device.
The internal memory provides an environment for the execution of a computer program in the non-volatile storage medium, which when executed by the processor, causes the processor to perform any one of the terminal Type-C interface foreign object detection methods.
The network interface is used for network communication such as transmitting assigned tasks and the like. It will be appreciated by those skilled in the art that the structure shown in fig. 8 is merely a block diagram of some of the structures associated with the present application and is not limiting of the computer device to which the present application may be applied, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
It should be appreciated that the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field-programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. Wherein the general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
Wherein in one embodiment the processor is configured to run a computer program stored in the memory to implement the steps of:
based on a current data reading instruction sent by a terminal main control, the terminal reads current consumption data on a charging communication path;
based on the configuration channel, the terminal inquires output current data of the charger end in real time;
calculating a current difference between the terminal and the charger terminal based on the consumption current data and the output current data;
and when the current difference value is larger than a preset difference value threshold value, determining that abnormal electric leakage exists at an interface between the terminal and the charger terminal.
In an embodiment, when the processor implements the configuration channel, the terminal queries output current data of the charger in real time, and is configured to implement:
based on the configuration channel, sending a query data packet to a control unit of the charger end;
based on the query data packet, the control unit at the charger end reads the output current data acquired by the current sensing unit in real time;
and generating a current data packet by the charger terminal based on the output current data, and sending the current data packet to the terminal based on the configuration channel.
In one embodiment, the current data packet includes an information code, a synchronization code, and a packet control code.
In an embodiment, when the processor implements the generating a current data packet by the charger terminal based on the output current data, the processor is configured to implement:
encoding the output current data into at least one encoded current data based on a preset data encoding rule;
generating a target information code based on the encoded current data and an additional control code;
and generating the current data packet based on the target information code, the synchronous code and the packet control code.
In an embodiment, the preset data encoding rule is a count encoding rule of 10bit data.
In an embodiment, when the processor determines that the interface between the terminal and the charger terminal has abnormal leakage when the current difference is greater than a preset difference threshold, the processor is configured to implement:
when the current difference value is detected to be larger than the preset difference value threshold value, the consumption current data and the output current data are collected again based on a preset period, and the current difference value is calculated;
and when the times that the current difference value is larger than the preset difference value threshold value reach the preset times within the preset duration, determining that abnormal electric leakage exists at the interface between the terminal and the charger end.
In an embodiment, after determining that an abnormal leakage exists at an interface between the terminal and the charger terminal when the current difference is greater than a preset difference threshold, the processor is further configured to implement:
and the terminal main control interrupts the charging process and sends an alarm signal so as to display an alarm to a user through the terminal.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, the computer program comprises program instructions, and the processor executes the program instructions to realize any of the terminal Type-C interface foreign matter detection methods provided by the embodiment of the application.
The computer readable storage medium may be an internal storage unit of the computer device according to the foregoing embodiment, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, which are provided on the computer device.
While the invention has been described with reference to certain preferred embodiments, it will be understood by those skilled in the art that various changes and substitutions of equivalents may be made and equivalents will be apparent to those skilled in the art without departing from the scope of the invention. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.