Power role switching method and system and electronic equipment
By adjusting the signal line function and output voltage according to user operation in the signal line connection between the dual-character devices, the problem of switching power roles during charging of the dual-character device is solved, and efficient switching of power roles is achieved, which enhances the user's Experience.
Patent Information
- Application Number
- CN202310809719.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2024-12-31
AI Technical Summary
During the charging process between two dual-character devices, it is difficult for the existing technology to achieve efficient switching of power roles.
In the signal line connection between the first electronic device and the second electronic device, the command is sent according to the user's operation, and the function and output voltage of the signal line are adjusted, the switching of the power role is realized, ensuring that the role is accurately switched during charging and power supply processes .
It realizes accurate power role switching during the charging process of dual-role devices, improves user experience, and enhances the ease of use and practicality of the device.
Smart Images

Figure CN119231676A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of terminal technology, and in particular, relates to a power role switching method, system and electronic device. Background Art
[0002] With the rapid development of electronic devices and charging technology, electronic devices such as mobile phones, laptops, tablets or smart large screens can be dual-role devices with charging and power supply functions. That is, these dual-role devices can be used as power supply devices (i.e., power supply roles) to provide power to other electronic devices, and can also be used as charging devices to receive power provided by power supply devices, which greatly improves the user experience. Among them, in the charging process of two electronic devices that are both dual-role devices, how to switch the power supply roles has become an urgent problem to be solved. Summary of the invention
[0003] The embodiments of the present application provide a method, system and electronic device for switching power roles, which can accurately switch power roles during the charging process of two electronic devices that are both dual-role devices, thereby improving user experience.
[0004] In a first aspect, an embodiment of the present application provides a method for switching a power role, which is applied to a first electronic device. Initially, the first electronic device is a charging device, which is used to receive power provided by a second electronic device. The first electronic device and the second electronic device both have a charging function and a power supply function. The first electronic device is connected to the second electronic device through a first signal line and a second signal line. The first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device. The method includes:
[0005] The first electronic device receives a first operation, where the first operation is used to switch a power source role during charging;
[0006] According to the first operation, the first electronic device sends a first instruction to the second electronic device, where the first instruction is used to instruct the second electronic device to switch to a charging device;
[0007] According to the first operation, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device to switch the first electronic device to a power supply device.
[0008] In the power role switching method provided above, during the charging process of two electronic devices both being dual-role devices, the power role can be accurately switched according to the first operation detected in the first electronic device, thereby improving the user experience.
[0009] The first operation may be a switching operation, and the first instruction may be a switching instruction.
[0010] Exemplarily, the first electronic device sending a first instruction to the second electronic device includes:
[0011] The first electronic device determines whether the first electronic device meets a switching condition;
[0012] When the first electronic device meets the switching condition, the first electronic device sends the first instruction to the second electronic device.
[0013] In the power role switching method provided in this implementation, whether to switch the power role can be determined based on whether the first electronic device meets the switching condition, thereby improving the accuracy of the power role switching.
[0014] In one example, the method further includes:
[0015] The first electronic device receives a second instruction, where the second instruction is used to agree to switch the power role, and the second instruction is sent by the second electronic device to the first electronic device after receiving the first instruction.
[0016] The second instruction may be an approval instruction for approving the switching of the power role.
[0017] Optionally, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device, including:
[0018] After receiving the second instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
[0019] In another example, after the first electronic device receives the second instruction, the method further includes:
[0020] The first electronic device sends a third instruction to the second electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0021] The third instruction may be an ACK for confirming receipt of the approval instruction.
[0022] Optionally, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device, including:
[0023] After a second preset time after the first electronic device sends the third instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
[0024] In a possible implementation, after the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, the method further includes:
[0025] The first electronic device detects a level on the second signal line;
[0026] When a high level is detected on the second signal line within a third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device is successful; or,
[0027] When the high level on the second signal line is not detected within the third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device fails, and restarts the charging protocol handshake.
[0028] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0029] After determining that the handshake between the first electronic device and the second electronic device is successful for a fourth preset time, the first electronic device adjusts the output voltage of the first electronic device.
[0030] In the power role switching method provided in this implementation, after determining that the first electronic device and the second electronic device have successfully shaken hands for a fourth preset time, the output voltage of the first electronic device can be adjusted to power on VBUS to avoid power supply conflicts on VBUS and improve user experience.
[0031] Exemplarily, the first electronic device adjusting the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusting the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, includes:
[0032] The first electronic device sets the first signal line to a pull-up state, and sets the second signal line to a high-impedance state.
[0033] In a possible implementation manner, the first electronic device and the second electronic device are further connected via a CC signal line;
[0034] After the first electronic device receives the first operation, the method further includes:
[0035] According to the first operation, the first electronic device adjusts a level state of the CC signal line in the first electronic device.
[0036] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0037] The first electronic device adjusts the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
[0038] Exemplarily, the first electronic device adjusting the output voltage of the first electronic device includes:
[0039] The first electronic device adjusts the output voltage of the first electronic device to a first preset value.
[0040] In a second aspect, an embodiment of the present application provides a power role switching device, which is applied to a first electronic device. Initially, the first electronic device is a charging device, which is used to receive power provided by a second electronic device. The first electronic device and the second electronic device both have charging functions and power supply functions. The first electronic device is connected to the second electronic device through a first signal line and a second signal line. The first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device. The device includes:
[0041] An input module, configured to receive a first operation, wherein the first operation is configured to switch a power source role during charging;
[0042] a sending module, configured to send a first instruction to the second electronic device according to the first operation, wherein the first instruction is used to instruct the second electronic device to switch to a charging device;
[0043] an adjustment module, configured to adjust, according to the first operation, the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device to switch the first electronic device to a power supply device.
[0044] Exemplarily, the sending module is further used to determine whether the first electronic device meets a switching condition; when the first electronic device meets the switching condition, send the first instruction to the second electronic device.
[0045] In one example, the apparatus further comprises:
[0046] The receiving module is used to receive a second instruction, where the second instruction is used to agree to switch the power role, and the second instruction is sent by the second electronic device to the first electronic device after receiving the first instruction.
[0047] Optionally, the adjustment module is further used to, after receiving the second instruction, adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device.
[0048] In another example, the sending module is further used to send a third instruction to the second electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0049] Optionally, the adjustment module is further used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device after a second preset time of sending the third instruction.
[0050] In a possible implementation manner, the device further includes:
[0051] A detection module is used to detect the level on the second signal line; when a high level is detected on the second signal line within a third preset time, it is determined that the handshake between the first electronic device and the second electronic device is successful; or when a high level is not detected on the second signal line within the third preset time, it is determined that the handshake between the first electronic device and the second electronic device has failed, and the charging protocol handshake is restarted.
[0052] Optionally, the adjustment module is further configured to adjust the output voltage of the first electronic device after determining that the handshake between the first electronic device and the second electronic device is successful for a fourth preset time.
[0053] Exemplarily, the adjustment module is further used to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0054] In a possible implementation manner, the first electronic device and the second electronic device are further connected via a CC signal line;
[0055] The adjustment module is further used to adjust the level state of the CC signal line in the first electronic device according to the first operation.
[0056] Optionally, the adjustment module is further used to adjust the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
[0057] Exemplarily, the adjustment module is further used to adjust the output voltage of the first electronic device to a first preset value.
[0058] In a third aspect, an embodiment of the present application provides a method for switching a power role, which is applied to a second electronic device, wherein initially, the second electronic device is a power supply device, which is used to provide power to a first electronic device, and both the first electronic device and the second electronic device have charging and power supply functions, and the second electronic device is connected to the first electronic device through a first signal line and a second signal line, the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device, and the method includes:
[0059] The second electronic device receives a first instruction, the first instruction is used to instruct the second electronic device to switch to a charging device, the first instruction is sent by the first electronic device to the second electronic device when the first electronic device receives a first operation, and the first operation is used to switch the power source role during the charging process;
[0060] The second electronic device adjusts the output voltage of the second electronic device according to the first instruction, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, so as to switch the second electronic device to a charging device.
[0061] In one example, after the second electronic device receives the first instruction, the method further includes:
[0062] After receiving the first instruction, the second electronic device sends a second instruction to the first electronic device, where the second instruction is used to agree to switch the power role.
[0063] Optionally, the second electronic device adjusts the output voltage of the second electronic device according to the first instruction, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including:
[0064] After sending the second instruction, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0065] In another example, after the second electronic device sends a second instruction to the first electronic device, the method further includes:
[0066] The second electronic device receives a third instruction, where the third instruction is sent by the first electronic device to the second electronic device after the first electronic device receives the second instruction, and the third instruction is used to confirm receipt of the second instruction.
[0067] Optionally, the second electronic device adjusts the output voltage of the second electronic device according to the first instruction, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including:
[0068] After receiving the third instruction for a first preset time, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0069] Exemplarily, the second electronic device adjusting the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusting the second signal line to be a signal line for the second electronic device to send data to the first electronic device, includes:
[0070] The second electronic device sets the first signal line to a high impedance state, and sets the second signal line to a pull-up state.
[0071] Exemplarily, the second electronic device adjusting the output voltage of the second electronic device includes:
[0072] The second electronic device adjusts the output voltage of the second electronic device to a second preset value.
[0073] In one example, after the second electronic device adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, the method further includes:
[0074] The second electronic device detects the level on the first signal line;
[0075] When a high level is detected on the first signal line within a third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device is successful; or,
[0076] When the high level on the first signal line is not detected within the third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device fails, and restarts the charging protocol handshake.
[0077] In a possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0078] The method further comprises:
[0079] After determining that the second electronic device and the first electronic device have successfully shaken hands, the second electronic device detects whether the voltage on the VBUS power line meets a preset condition, where the preset condition is determined according to the second preset value;
[0080] When it is detected within a fifth preset time that the voltage on the VBUS power line meets the preset condition, the second electronic device receives the electric energy provided by the first electronic device through a charging protocol;
[0081] When it is not detected within the fifth preset time that the voltage on the VBUS satisfies the preset condition, the second electronic device restarts the charging protocol handshake.
[0082] In another possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0083] The method further comprises:
[0084] The second electronic device adjusts the level state of the CC signal line in the second electronic device according to the first instruction.
[0085] Optionally, the second electronic device adjusting the output voltage of the second electronic device includes:
[0086] The second electronic device adjusts the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
[0087] In a fourth aspect, an embodiment of the present application provides a power role switching device, which is applied to a second electronic device. Initially, the second electronic device is a power supply device, which is used to provide power to a first electronic device. The first electronic device and the second electronic device both have charging functions and power supply functions. The second electronic device is connected to the first electronic device through a first signal line and a second signal line. The first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device. The device includes:
[0088] a receiving module, configured to receive a first instruction, wherein the first instruction is used to instruct the second electronic device to switch to a charging device, wherein the first instruction is sent by the first electronic device to the second electronic device when the first electronic device receives a first operation, wherein the first operation is used to switch the power source role during the charging process;
[0089] The adjustment module is used to adjust the output voltage of the second electronic device according to the first instruction, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device, so as to switch the second electronic device to a charging device.
[0090] In one example, the apparatus further comprises:
[0091] The sending module is used to send a second instruction to the first electronic device after receiving the first instruction, wherein the second instruction is used to agree to switch the power role.
[0092] Optionally, the adjustment module is further used to adjust the output voltage of the second electronic device after sending the second instruction, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0093] In another example, the receiving module is further used to receive a third instruction, where the third instruction is sent by the first electronic device to the second electronic device after receiving the second instruction, and the third instruction is used to confirm receipt of the second instruction.
[0094] Optionally, the adjustment module is further used to adjust the output voltage of the second electronic device after a first preset time of receiving the third instruction, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0095] Exemplarily, the adjustment module is further used to set the first signal line to a high impedance state, and set the second signal line to a pull-up state.
[0096] Exemplarily, the adjustment module is further used to adjust the output voltage of the second electronic device to a second preset value.
[0097] In one example, the apparatus further comprises:
[0098] The first detection module is used to detect the level on the first signal line; when a high level is detected on the first signal line within a third preset time, it is determined that the second electronic device has successfully handshaked with the first electronic device; or when a high level is not detected on the first signal line within the third preset time, it is determined that the second electronic device has failed to handshake with the first electronic device, and the charging protocol handshake is restarted.
[0099] In a possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0100] The device also includes:
[0101] A second detection module is used to detect whether the voltage on the VBUS power line meets a preset condition after determining that the second electronic device has successfully shaken hands with the first electronic device, and the preset condition is determined according to the second preset value; when it is detected that the voltage on the VBUS power line meets the preset condition within a fifth preset time, receive the electric energy provided by the first electronic device through a charging protocol; when it is not detected that the voltage on the VBUS meets the preset condition within the fifth preset time, restart the charging protocol handshake.
[0102] In another possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0103] The adjustment module is further configured to adjust the level state of the CC signal line in the second electronic device according to the first instruction.
[0104] Optionally, the adjustment module is further used to adjust the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
[0105] In a fifth aspect, an embodiment of the present application provides a power role switching system, the system comprising a first electronic device and a second electronic device, the first electronic device and the second electronic device both having a charging function and a power supply function, initially, the first electronic device is a charging device, the second electronic device is a power supply device, the first electronic device and the second electronic device are connected via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device;
[0106] The first electronic device is used to perform the steps in the power role switching method described in any one of the first aspects above;
[0107] The second electronic device is used to execute the steps in the power role switching method described in any one of the third aspects above.
[0108] In a sixth aspect, an embodiment of the present application provides a method for switching a power role, which is applied to a second electronic device, wherein initially, the second electronic device is a power supply device, which is used to provide power to a first electronic device, and both the first electronic device and the second electronic device have a charging function and a power supply function, and the second electronic device is connected to the first electronic device through a first signal line and a second signal line, and the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device, and the method includes:
[0109] The second electronic device receives a first operation, where the first operation is used to switch a power source role during charging;
[0110] According to the first operation, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device;
[0111] According to the first operation, the second electronic device sends a first instruction to the first electronic device, where the first instruction is used to switch the first electronic device to a power supply device.
[0112] In one example, the method further includes:
[0113] The second electronic device receives a second instruction, where the second instruction is used to agree to switch the power role. The second instruction is sent to the second electronic device by the first electronic device after receiving the first instruction and determining that the first electronic device meets the switching condition.
[0114] Optionally, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including:
[0115] After receiving the second instruction, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0116] In another example, after the second electronic device receives the second instruction, the method further includes:
[0117] The second electronic device sends a third instruction to the first electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0118] Optionally, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including:
[0119] After a first preset time of sending the third instruction, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0120] Exemplarily, the second electronic device adjusting the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusting the second signal line to be a signal line for the second electronic device to send data to the first electronic device, includes:
[0121] The second electronic device sets the first signal line to a high impedance state, and sets the second signal line to a pull-up state.
[0122] Exemplarily, the second electronic device adjusting the output voltage of the second electronic device includes:
[0123] The second electronic device adjusts the output voltage of the second electronic device to a second preset value.
[0124] In a possible implementation, after the second electronic device adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, the method further includes:
[0125] The second electronic device detects the level on the first signal line;
[0126] When a high level is detected on the first signal line within a third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device is successful; or,
[0127] When the high level on the first signal line is not detected within the third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device fails, and restarts the charging protocol handshake.
[0128] In another possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0129] The method further comprises:
[0130] After determining that the second electronic device and the first electronic device have successfully shaken hands, the second electronic device detects whether the voltage on the VBUS power line meets a preset condition, where the preset condition is determined according to the second preset value;
[0131] When it is detected within a fifth preset time that the voltage on the VBUS power line meets the preset condition, the second electronic device is charged from the first electronic device through a charging protocol;
[0132] When it is not detected within the fifth preset time that the power on the VBUS power line meets the preset condition, the second electronic device restarts the charging protocol handshake.
[0133] In a possible implementation manner, the second electronic device is further connected to the first electronic device via a CC signal line;
[0134] After the second electronic device receives the first operation, the method further includes:
[0135] According to the first operation, the second electronic device switches a level state of the CC signal line in the second electronic device.
[0136] Optionally, the second electronic device adjusting the output voltage of the second electronic device includes:
[0137] The second electronic device adjusts the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
[0138] In a seventh aspect, an embodiment of the present application provides a power role switching device, which is applied to a second electronic device. Initially, the second electronic device is a power supply device, which is used to provide power to a first electronic device. The first electronic device and the second electronic device both have charging functions and power supply functions. The second electronic device is connected to the first electronic device through a first signal line and a second signal line. The first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device. The device includes:
[0139] An input module, configured to receive a first operation, wherein the first operation is configured to switch a power source role during charging;
[0140] an adjusting module, configured to adjust the output voltage of the second electronic device according to the first operation, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device;
[0141] The sending module is used to send a first instruction to the first electronic device according to the first operation, where the first instruction is used to switch the first electronic device to a power supply device.
[0142] In one example, the apparatus further comprises:
[0143] The receiving module is used to receive a second instruction, where the second instruction is used to agree to switch the power role. The second instruction is sent by the first electronic device to the second electronic device after the first electronic device receives the first instruction and determines that the first electronic device meets the switching condition.
[0144] Optionally, the adjustment module is also used to, after receiving the second instruction, enable the second electronic device to adjust the output voltage of the second electronic device, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0145] In another example, the sending module is further used to send a third instruction to the first electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0146] Optionally, the adjustment module is further used to adjust the output voltage of the second electronic device after a first preset time of sending the third instruction, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0147] Exemplarily, the adjustment module is further used to set the first signal line to a high impedance state, and set the second signal line to a pull-up state.
[0148] Exemplarily, the adjustment module is further used to adjust the output voltage of the second electronic device to a second preset value.
[0149] In a possible implementation manner, the device further includes:
[0150] The first detection module is used to detect the level on the first signal line; when a high level is detected on the first signal line within a third preset time, it is determined that the second electronic device has successfully handshaked with the first electronic device; or when a high level is not detected on the first signal line within the third preset time, it is determined that the second electronic device has failed to handshake with the first electronic device, and the charging protocol handshake is restarted.
[0151] In another possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0152] The device also includes:
[0153] A second detection module is used to detect whether the voltage on the VBUS power line meets a preset condition after determining that the second electronic device has successfully shaken hands with the first electronic device, and the preset condition is determined according to the second preset value; when it is detected that the voltage on the VBUS power line meets the preset condition within a fifth preset time, charge the first electronic device through a charging protocol; when it is not detected that the power on the VBUS power line meets the preset condition within the fifth preset time, restart the charging protocol handshake.
[0154] In a possible implementation manner, the second electronic device is further connected to the first electronic device via a CC signal line;
[0155] The adjustment module is further configured to switch a level state of the CC signal line in the second electronic device according to the first operation.
[0156] Optionally, the adjustment module is further used to adjust the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
[0157] In an eighth aspect, an embodiment of the present application provides a method for switching a power role, which is applied to a first electronic device, wherein initially, the first electronic device is a charging device, which is used to receive power provided by a second electronic device, and the first electronic device and the second electronic device both have a charging function and a power supply function, and the first electronic device is connected to the second electronic device via a first signal line and a second signal line, wherein the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device, and the method includes:
[0158] The first electronic device receives a first instruction, the first instruction is used to instruct the first electronic device to switch to a power supply device, the first instruction is sent by the second electronic device to the first electronic device after receiving a first operation, and the first operation is used to switch the power source role during charging;
[0159] According to the first instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device to switch the first electronic device to a power supply device.
[0160] In one example, after the first electronic device receives the first instruction, the method further includes:
[0161] The first electronic device determines whether the first electronic device meets a switching condition;
[0162] When the first electronic device meets the switching condition, the first electronic device sends a second instruction to the second electronic device, where the second instruction is used to agree to switch the power role.
[0163] Optionally, the first electronic device adjusting, according to the first instruction, the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusting the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusting the output voltage of the first electronic device, comprises:
[0164] After sending the second instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
[0165] In one example, after the first electronic device sends the second instruction to the second electronic device, the method further includes:
[0166] The first electronic device receives a third instruction, where the third instruction is sent by the second electronic device to the first electronic device after the second electronic device receives the second instruction, and the third instruction is used to confirm receipt of the second instruction.
[0167] Optionally, the first electronic device adjusting, according to the first instruction, the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusting the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusting the output voltage of the first electronic device, comprises:
[0168] After receiving the third instruction for a second preset time, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
[0169] In one example, after the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, the method further includes:
[0170] The first electronic device detects a level on the second signal line;
[0171] When a high level is detected on the second signal line within a third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device is successful; or,
[0172] When the high level on the second signal line is not detected within the third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device fails, and restarts the charging protocol handshake.
[0173] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0174] The first electronic device adjusts the output voltage of the first electronic device after determining that the handshake between the first electronic device and the second electronic device is successful for a third preset time.
[0175] Exemplarily, the first electronic device adjusting the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusting the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, includes:
[0176] The first electronic device sets the first signal line to a pull-up state, and sets the second signal line to a high-impedance state.
[0177] In a possible implementation manner, the first electronic device and the second electronic device are further connected via a CC signal line;
[0178] The method further comprises:
[0179] The first electronic device adjusts the level state of the CC signal line in the first electronic device according to the first instruction.
[0180] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0181] The first electronic device adjusts the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
[0182] Exemplarily, the first electronic device adjusting the output voltage of the first electronic device includes:
[0183] The first electronic device adjusts the output voltage of the first electronic device to a first preset value.
[0184] In a ninth aspect, an embodiment of the present application provides a power role switching device, which is applied to a first electronic device. Initially, the first electronic device is a charging device, which is used to receive power provided by a second electronic device. The first electronic device and the second electronic device both have charging functions and power supply functions. The first electronic device is connected to the second electronic device through a first signal line and a second signal line. The first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device. The device includes:
[0185] a receiving module, configured to receive a first instruction, wherein the first instruction is used to instruct the first electronic device to switch to a power supply device, wherein the first instruction is sent by the second electronic device to the first electronic device after receiving a first operation, wherein the first operation is used to switch the power source role during charging;
[0186] an adjustment module, for adjusting, according to the first instruction, the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusting the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusting the output voltage of the first electronic device to switch the first electronic device to a power supply device.
[0187] In one example, the apparatus further comprises:
[0188] The sending module is used to determine whether the first electronic device meets the switching condition; when the first electronic device meets the switching condition, send a second instruction to the second electronic device, wherein the second instruction is used to agree to switch the power role.
[0189] Optionally, the adjustment module is further used to, after sending the second instruction, adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device.
[0190] In one example, the receiving module is further used to receive a third instruction, where the third instruction is sent by the second electronic device to the first electronic device after receiving the second instruction, and the third instruction is used to confirm receipt of the second instruction.
[0191] Optionally, the adjustment module is further used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device after a second preset time of receiving the third instruction.
[0192] In one example, the apparatus further comprises:
[0193] A detection module is used to detect the level on the second signal line; when a high level is detected on the second signal line within a third preset time, it is determined that the handshake between the first electronic device and the second electronic device is successful; or when a high level is not detected on the second signal line within the third preset time, it is determined that the handshake between the first electronic device and the second electronic device has failed, and the charging protocol handshake is restarted.
[0194] Optionally, the adjustment module is further configured to adjust the output voltage of the first electronic device after determining that the handshake between the first electronic device and the second electronic device is successful for a third preset time.
[0195] Exemplarily, the adjustment module is further used to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0196] In a possible implementation manner, the first electronic device and the second electronic device are further connected via a CC signal line;
[0197] The adjustment module is further configured to adjust the level state of the CC signal line in the first electronic device according to the first instruction.
[0198] Optionally, the adjustment module is further used to adjust the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
[0199] Exemplarily, the adjustment module is further used to adjust the output voltage of the first electronic device to a first preset value.
[0200] In a tenth aspect, an embodiment of the present application provides a power role switching system, the system comprising a first electronic device and a second electronic device, the first electronic device and the second electronic device both having a charging function and a power supply function, initially, the first electronic device is a charging device, the second electronic device is a power supply device, the first electronic device and the second electronic device are connected via a first signal line and a second signal line, the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device;
[0201] The second electronic device is used to perform the steps in the power role switching method described in any one of the sixth aspects above;
[0202] The first electronic device is used to execute the steps in the power role switching method described in any one of the eighth aspects above.
[0203] In an eleventh aspect, an embodiment of the present application provides a first electronic device, wherein initially, the first electronic device is a charging device for receiving electric energy provided by a second electronic device, the first electronic device and the second electronic device both have a charging function and a power supply function, the first electronic device is connected to the second electronic device via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device;
[0204] The first electronic device comprises: a system chip, a protocol module, a power management module and an input module;
[0205] The input module is used to receive a first operation and send first information of the first operation to the system chip, wherein the first operation is used to switch the power source role during the charging process;
[0206] The system chip is used to instruct the protocol module to send a first instruction to the second electronic device according to the first information of the first operation, wherein the first instruction is used to instruct the second electronic device to switch to a charging device;
[0207] The protocol module is used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device;
[0208] The system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device.
[0209] Exemplarily, the system chip is further used to determine whether the first electronic device meets a switching condition; when the first electronic device meets the switching condition, instruct the protocol module to send the first instruction to the second electronic device.
[0210] In one example, the protocol module further receives a second instruction, where the second instruction is used to agree to switch the power role, and the second instruction is sent by the second electronic device to the first electronic device after receiving the first instruction.
[0211] Optionally, the protocol module is further configured to, after receiving the second instruction, adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device.
[0212] The system chip is further used to, after receiving the second instruction, instruct the protocol module to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and to adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device.
[0213] The system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device.
[0214] In another example, the protocol module is further used to send a third instruction to the second electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0215] The system chip is further used to instruct the protocol module to send a third instruction to the second electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0216] Optionally, the protocol module is further used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device after a second preset time of sending the third instruction. Or,
[0217] In one possible implementation, the protocol module is further used to detect the level on the second signal line; when a high level is detected on the second signal line within a third preset time, it is determined that the handshake between the first electronic device and the second electronic device is successful; or, when a high level is not detected on the second signal line within the third preset time, it is determined that the handshake between the first electronic device and the second electronic device has failed, and the charging protocol handshake is restarted.
[0218] Optionally, the system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device after determining that the first electronic device and the second electronic device have successfully shaken hands for a fourth preset time.
[0219] Exemplarily, the protocol module is further used to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0220] In a possible implementation manner, the first electronic device and the second electronic device are further connected via a CC signal line;
[0221] The protocol module is further used to adjust the level state of the CC signal line in the first electronic device according to the first operation.
[0222] Optionally, the system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
[0223] Exemplarily, the system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device to a first preset value.
[0224] In a twelfth aspect, an embodiment of the present application provides a second electronic device, wherein initially, the second electronic device is a power supply device, which is used to provide power to a first electronic device, the first electronic device and the second electronic device both have a charging function and a power supply function, the second electronic device is connected to the first electronic device via a first signal line and a second signal line, the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device;
[0225] The second electronic device includes: a system chip, a protocol module and a power management module:
[0226] The protocol module is used to receive a first instruction and send the first instruction to the system chip, the first instruction is used to instruct the second electronic device to switch to a charging device, the first instruction is sent by the first electronic device to the second electronic device when receiving a first operation, and the first operation is used to switch the power source role during the charging process;
[0227] The system chip is used to instruct the power management module to adjust the output voltage of the second electronic device according to the first instruction;
[0228] The protocol module is further used to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device according to the first instruction.
[0229] In one example, the protocol module is further used to send a second instruction to the first electronic device after receiving the first instruction, where the second instruction is used to agree to switch the power role.
[0230] Optionally, the system chip is also used to instruct the power management module to adjust the output voltage of the second electronic device, instruct the protocol module to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device after sending the second instruction.
[0231] Alternatively, the protocol module is further used to, after sending the second instruction, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0232] In another example, the protocol module is further used to receive a third instruction, where the third instruction is sent by the first electronic device to the second electronic device after receiving the second instruction, and the third instruction is used to confirm receipt of the second instruction.
[0233] Optionally, the system chip is also used to instruct the power management module to adjust the output voltage of the second electronic device, and instruct the protocol module to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device, after receiving the first preset time of the third instruction.
[0234] Alternatively, the protocol module is further used to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and to adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device after a first preset time of receiving the third instruction.
[0235] Exemplarily, the protocol module is further used to set the first signal line to a high impedance state, and set the second signal line to a pull-up state.
[0236] Exemplarily, the system chip is further used to instruct the power management module to adjust the output voltage of the second electronic device to a second preset value.
[0237] In one example, the protocol module is also used to detect the level on the first signal line; when a high level is detected on the first signal line within a third preset time, it is determined that the second electronic device has successfully handshaked with the first electronic device; or, when a high level is not detected on the first signal line within the third preset time, it is determined that the second electronic device has failed to handshake with the first electronic device, and the charging protocol handshake is restarted.
[0238] In a possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0239] The system chip is further used to, after determining that the second electronic device has successfully shaken hands with the first electronic device, instruct the power management module to detect whether the voltage on the VBUS power line meets a preset condition, and the preset condition is determined according to the second preset value; when it is detected that the voltage on the VBUS power line meets the preset condition within a fifth preset time, the system chip is further used to instruct the protocol module to receive the electric energy provided by the first electronic device through the charging protocol; when it is not detected that the voltage on the VBUS meets the preset condition within the fifth preset time, the system chip is further used to instruct the protocol module to restart the charging protocol handshake.
[0240] In another possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0241] The protocol module is further used to adjust the level state of the CC signal line in the second electronic device according to the first instruction.
[0242] Optionally, the system chip is further used to instruct the power management module to adjust the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
[0243] In a thirteenth aspect, an embodiment of the present application provides a second electronic device, wherein initially, the second electronic device is a power supply device, which is used to provide power to a first electronic device, the first electronic device and the second electronic device both have a charging function and a power supply function, the second electronic device is connected to the first electronic device via a first signal line and a second signal line, the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device;
[0244] The second electronic device comprises: a system chip, a protocol module, a power management module and an input module;
[0245] The input module is used to receive a first operation and send first information of the first operation to the system chip, wherein the first operation is used to switch the power source role during the charging process;
[0246] The system chip is used to instruct the power management module to adjust the output voltage of the second electronic device according to the first information of the first operation;
[0247] The protocol module is used to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device;
[0248] The system chip is further used to instruct the protocol module to send a first instruction to the first electronic device according to the first information of the first operation, where the first instruction is used to switch the first electronic device to a power supply device.
[0249] In one example, the protocol module is also used to receive a second instruction, where the second instruction is used to agree to switch the power role. The second instruction is sent by the first electronic device to the second electronic device after receiving the first instruction and determining that the first electronic device meets the switching conditions.
[0250] Optionally, the system chip is also used to instruct the power management module to adjust the output voltage of the second electronic device after receiving the second instruction, instruct the protocol module to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
[0251] In another example, the protocol module is further used to send a third instruction to the first electronic device, where the third instruction is used to confirm receipt of the second instruction.
[0252] Optionally, the system chip is also used to instruct the power management module to adjust the output voltage of the second electronic device, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and instruct the protocol module to adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device after a first preset time of sending the third instruction.
[0253] Exemplarily, the protocol module is further used to set the first signal line to a high impedance state, and set the second signal line to a pull-up state.
[0254] Exemplarily, the system chip is further used to adjust the output voltage of the second electronic device to a second preset value.
[0255] In one possible implementation, the protocol module is further used to detect the level on the first signal line; when a high level is detected on the first signal line within a third preset time, it is determined that the second electronic device has successfully handshaked with the first electronic device; or, when a high level is not detected on the first signal line within the third preset time, it is determined that the second electronic device has failed to handshake with the first electronic device, and the charging protocol handshake is restarted.
[0256] In another possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0257] The system chip is further used to, after determining that the second electronic device has successfully shaken hands with the first electronic device, instruct the power management module to detect whether the voltage on the VBUS power line meets a preset condition, and the preset condition is determined according to the second preset value; when it is detected that the voltage on the VBUS power line meets the preset condition within a fifth preset time, the system chip is further used to instruct the protocol module to charge the first electronic device through the charging protocol; when it is not detected that the power on the VBUS power line meets the preset condition within the fifth preset time, the system chip is further used to instruct the protocol module to restart the charging protocol handshake.
[0258] In a possible implementation manner, the second electronic device is further connected to the first electronic device via a CC signal line;
[0259] The protocol module is further configured to switch a level state of the CC signal line in the second electronic device according to the first operation.
[0260] Optionally, the system chip is further used to instruct the power management module to adjust the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
[0261] In a fourteenth aspect, an embodiment of the present application provides a first electronic device, wherein initially, the first electronic device is a charging device for receiving electric energy provided by a second electronic device, the first electronic device and the second electronic device both have a charging function and a power supply function, the first electronic device is connected to the second electronic device via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device;
[0262] The first electronic device includes: a system chip, a protocol module and a power management module:
[0263] The protocol module is used to receive a first instruction and send the first instruction to the system chip, the first instruction is used to instruct the first electronic device to switch to a power supply device, the first instruction is sent by the second electronic device to the first electronic device after receiving a first operation, and the first operation is used to switch the power source role during the charging process;
[0264] The protocol module is further used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device according to the first instruction;
[0265] The system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device according to the first instruction.
[0266] In one example, the system chip is also used to determine whether the first electronic device meets the switching conditions; when the first electronic device meets the switching conditions, it instructs the protocol module to send a second instruction to the second electronic device, and the second instruction is used to agree to switch the power role.
[0267] Optionally, the system chip is also used to, after sending the second instruction, instruct the protocol module to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and instruct the power management module to adjust the output voltage of the first electronic device.
[0268] In one example, the protocol module is further used to receive a third instruction, where the third instruction is sent by the second electronic device to the first electronic device after receiving the second instruction, and the third instruction is used to confirm receipt of the second instruction.
[0269] Optionally, the protocol module is further used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, after a second preset time of receiving the third instruction.
[0270] The system communication chip is further configured to instruct the power management module to adjust the output voltage of the first electronic device after a second preset time of receiving the third instruction.
[0271] In one example, the protocol module is also used to detect the level on the second signal line; when a high level is detected on the second signal line within a third preset time, it is determined that the handshake between the first electronic device and the second electronic device is successful; or, when a high level is not detected on the second signal line within the third preset time, it is determined that the handshake between the first electronic device and the second electronic device has failed, and the charging protocol handshake is restarted.
[0272] Optionally, the system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device after determining that the first electronic device and the second electronic device have successfully shaken hands for a third preset time.
[0273] Exemplarily, the protocol module is further used to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0274] In a possible implementation manner, the first electronic device and the second electronic device are further connected via a CC signal line;
[0275] The protocol module is further used to adjust the level state of the CC signal line in the first electronic device according to the first instruction.
[0276] Optionally, the system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
[0277] Exemplarily, the system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device to a first preset value.
[0278] In the fifteenth aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the electronic device implements the power role switching method described in any one of the first aspect, the third aspect, the sixth aspect, or the eighth aspect.
[0279] In the sixteenth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the computer implements the power role switching method described in any one of the first aspect, the third aspect, the sixth aspect or the eighth aspect.
[0280] In the seventeenth aspect, an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the power role switching method described in any one of the first aspect, the third aspect, the sixth aspect or the eighth aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0281] Figures 1 to 3 It is a charging diagram of a dual-role device;
[0282] Figure 4 is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0283] Figure 5 is a schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;
[0284] Figure 6 This is a schematic diagram of a power role switching system provided in an embodiment of the present application. Figure 1 ;
[0285] Figure 7 This is an example of an application scenario provided by the embodiment of the present application. Figure 1 ;
[0286] Figure 8 This is an example of an application scenario provided by the embodiment of the present application. Figure 2 ;
[0287] Fig. 9 This is a schematic flow chart of a method for switching power roles provided in an embodiment of the present application. Figure 1 ;
[0288] Fig.10 This is a schematic diagram of signal switching in power role switching provided by an embodiment of the present application;
[0289] Fig.11 This is a schematic flow chart of a method for switching power roles provided in an embodiment of the present application. Figure 2 ;
[0290] Fig.12 A schematic diagram of a power role switching system provided in an embodiment of the present application is shown. Figure 2 ;
[0291] Fig.13 is a schematic flow chart of a method for switching power roles provided in another embodiment of the present application;
[0292] Fig.14 is a schematic diagram of signal switching in power role switching provided by another embodiment of the present application;
[0293] Fig.15 It is a schematic flowchart of a power role switching method provided in yet another embodiment of the present application. DETAILED DESCRIPTION
[0294] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0295] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0296] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0297] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0298] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0299] In addition, the “plurality” mentioned in the embodiments of the present application should be interpreted as two or more.
[0300] The steps involved in the power role switching method provided in the embodiment of the present application are only examples. Not all steps are required to be executed, or not all information or messages are required. They can be increased or decreased as needed during use. In the embodiment of the present application, the same step or steps or messages with the same function can be referenced and learned from each other in different embodiments.
[0301] The business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. A person of ordinary skill in the art will appreciate that, with the evolution of network architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0302] With the rapid development of electronic devices and charging technology, electronic devices such as mobile phones, laptops, tablet computers or smart large screens can be dual-role devices with charging and power supply functions. That is, these dual-role devices can be used as power supply devices (i.e., power supply roles) to provide electrical energy to other electronic devices, and can also be used as charging devices to receive electrical energy provided by power supply devices, which greatly improves the user experience. Among them, in the charging process where both electronic devices are dual-role devices, how to switch the power role becomes an urgent problem to be solved. For example, for mobile phone A and tablet computer B with charging and power supply functions, during the process of mobile phone A charging tablet computer B, when the user wants to switch the power role, that is, wants to switch to tablet computer B to charge mobile phone A, how to switch the power role from mobile phone A to tablet computer B becomes an urgent problem to be solved.
[0303] It should be understood that the power supply device (also referred to as Source) is a device that can provide electrical energy. For example, the power supply device can be connected to the charging device via a charging cable, thereby providing electrical energy to the charging device.
[0304] The charging device (also referred to as a Sink) is a device that can receive electrical energy. For example, the charging device can be connected to the power supply device via a charging cable, so that the charging device can receive electrical energy provided by the power supply device.
[0305] Among them, charging may refer to an electronic device acting as a charging device and receiving electric energy provided by a power supply device. Power supply may refer to an electronic device acting as a power supply device and providing electric energy to a charging device. For example, for electronic device A and electronic device B, when electronic device A acts as a charging device and receives electric energy provided by electronic device B, the process of electronic device A receiving electric energy can be understood as charging, and the process of electronic device B providing electric energy can be understood as power supply.
[0306] See also Figures 1 to 3 , Figures 1 to 3 A schematic diagram of charging a dual-role device is shown. When dual-role devices (such as electronic device A and electronic device B) are charged based on the Power Delivery (PD) charging protocol, electronic device A and electronic device B can be connected via a USB Type-C cable.
[0307] It is understandable that the USB Type-C cable may include a signal line CC, a power line VBUS, and a ground line GND. Electronic device A and electronic device B may each include two CC pins, for example, CC1 and CC2. One of the CC pins (for example, CC1 or CC2) may be used as a connection between a charging device and a power supply device, that is, electronic device A and electronic device B may transmit signals and the like through the CC connected by the CC1 pin.
[0308] It should be understood that Figures 1 to 3 In the example, the power supply device can be represented as Source, and the charging device can be represented as Sink. Both the electronic device A and the electronic device B can include a voltage converter, a current detection module, and a Sink or Source identification module ( Figures 1 to 3 The voltage converter can be used to control the voltage during the charging process. The voltage detection module can be used to detect the voltage conditions on CC1 and CC2. The Sink or Source identification module can be used to identify whether the electronic device is a power supply device or a charging device.
[0309] Among them, when charging is not started, for example, when electronic device A and electronic device B are not connected, electronic device A and electronic device B can switch back and forth between the "charging device-not connected" state and the "power supply device-not connected" state. At this time, there is no power supply on VBUS in the USB Type-C cable.
[0310] After the electronic device A is connected to the electronic device B, initially, the electronic device A and the electronic device B may be randomly identified as a power supply device or a charging device.
[0311] like Figure 1 As shown in (a), when electronic device A is identified as a power supply device and electronic device B is identified as a charging device, CC1 of electronic device A can be pulled up through resistor Rp to generate a pull-up signal. CC1 of electronic device B can be pulled down through resistor Rd to generate a pull-down signal. Therefore, electronic device A can detect the pull-down signal of electronic device B on CC. At the same time, electronic device B can detect the pull-up signal of electronic device A on CC.
[0312] like Figure 1 As shown in (b), when electronic device A detects a pull-down signal from electronic device B on CC, electronic device A can switch electronic device A from the "power supply device-unconnected" state to the "power supply device-waiting for connection" state.
[0313] When electronic device B detects the pull-up signal of electronic device A on CC, electronic device B can switch the state of electronic device B from "charging device-unconnected" to "charging device-waiting for connection".
[0314] When electronic device A in the "power supply device-waiting for connection" state detects that the pull-down signal lasts for a certain period of time, electronic device A can switch the electronic device A from the "power supply device-waiting for connection" state to the "power supply device-connected" state, and can adjust the output voltage of electronic device A so that VBUS starts to power on.
[0315] When electronic device B detects that electronic device B is in the "charging device-waiting for connection" state for a certain period of time and detects that there is power on VBUS, electronic device B can switch electronic device B from the "charging device-waiting for connection" state to the "charging device-connected" state.
[0316] When electronic device A is in the "power supply device-connected" state and electronic device B is in the "charging device-connected" state, electronic device A can provide power to electronic device B through VBUS.
[0317] It should be understood that when it is necessary to switch the power role during the charging process, for example, when it is necessary to switch electronic device B from a charging device to a power supply device, the user can input a switching operation in electronic device A or electronic device B. After detecting the switching operation, electronic device A and electronic device B can switch the power roles according to the switching operation.
[0318] In one example, the user may input a switching operation in electronic device B. Assume that, when electronic device B detects the switching operation, electronic device A is in the "power supply device-connected" state, and electronic device B is in the "charging device-waiting for connection" state. At this time, Figure 2 As shown in (a) of FIG. 1 , electronic device B can pull up CC1 of electronic device B through resistor Rp to generate a pull-up signal. Figure 2 As shown in (b), electronic device B can switch the electronic device B from the "charging device-waiting for connection" state to the "trying to power supply" state.
[0319] After the electronic device B switches from the "charging device-waiting for connection" state to the "trying to power supply" state, that is, after the CC1 of the electronic device B is pulled up through the resistor Rp to generate a pull-up signal, the electronic device A will no longer detect the pull-down signal of the electronic device B. At this time, if Figure 2 As shown in (a) of FIG. 1 , electronic device A can pull down CC1 of electronic device A through resistor Rd to generate a pull-down signal. Figure 2 As shown in (b), electronic device A can switch electronic device A from the "power supply device-connected" state to the "charging device-unconnected" state, and adjust the output voltage of electronic device A to shut down the power supply of VBUS.
[0320] Electronic device A in the "charging device - not connected" state can still detect the pull-up signal of electronic device B on CC, so if Figure 2 As shown in (b), electronic device A can continue to switch electronic device A from the "charging device-not connected" state to the "charging device-waiting for connection" state.
[0321] At the same time, electronic device B in the "trying to power" state can detect the pull-down signal of electronic device A on CC, so if Figure 2 As shown in (b), electronic device B can switch electronic device B from the "trying to power" state to the "power supply device-connected" state, and adjust the output voltage of electronic device B so that VBUS starts to power on.
[0322] When electronic device A detects that electronic device A is in the "charging device-waiting for connection" state for a certain period of time and detects that VBUS has power, such as Figure 2 As shown in (b), electronic device A can switch the electronic device A from the "charging device-waiting for connection" state to the "charging device-connected" state.
[0323] After electronic device B is in the "power supply device-connected" state and electronic device A is in the "charging device-connected" state, electronic device B can provide power to electronic device A through VBUS, thereby switching electronic device A, which was originally used to provide power, into a charging device, and switching electronic device B, which was originally used to receive power, into a power supply device, thereby realizing the switching of power roles.
[0324] In another example, the user may also input a switching operation in electronic device A. Assume that when electronic device A detects the switching operation, electronic device A is in the "power supply device-waiting for connection" state, and electronic device B is in the "charging device-connected" state. At this time, Figure 2 As shown in (a) of FIG. 1 , electronic device A can pull down CC1 of electronic device A through resistor Rd to generate a pull-down signal. Figure 3 As shown, electronic device A can switch the state of electronic device A from "power supply device-waiting for connection" to "trying to charge" state.
[0325] After the electronic device A switches from the "power supply device-waiting for connection" state to the "attempting to charge" state, that is, after the CC1 of the electronic device A is pulled down through the resistor Rd to generate a pull-down signal, the electronic device B will no longer detect the pull-up signal of the electronic device A. Therefore, if Figure 2 As shown in (a) of FIG. 1 , electronic device B can pull up CC1 of electronic device B through resistor Rp to generate a pull-up signal. Figure 3 As shown, electronic device B can switch electronic device B from the "charging device-connected" state to the "power supply device-unconnected" state.
[0326] Electronic device B in the "power supply device - not connected" state can still detect the pull-down signal of electronic device A on CC, so if Figure 3 As shown, electronic device B can continue to switch electronic device B from the "power supply device-unconnected" state to the "power supply device-waiting for connection" state.
[0327] like Figure 3 As shown, when electronic device B detects that electronic device B is in the "power supply device-waiting for connection" state for a certain period of time, electronic device B can switch electronic device B from the "power supply device-waiting for connection" state to the "power supply device-connected" state, and adjust the output voltage of electronic device B to turn on VBUS power supply, that is, electronic device B can provide power to electronic device A through VBUS, thereby switching electronic device A, which originally provides power, to a charging device, and switching electronic device B, which originally receives power, to a power supply device, thereby realizing the switching of power roles.
[0328] like Figure 3As shown, after electronic device A detects that VBUS has power, electronic device A can be switched from the "attempting to charge" state to the "charging device - connected" state.
[0329] From the above description, it can be seen that when an electronic device uses a charging protocol that communicates with a single signal line (ie, CC), the electronic device can switch the power role according to the connection status of the CC, that is, the pull-up signal and the pull-down signal detected on the CC. However, this switching method is only applicable to charging protocols based on single signal line communication, and when an electronic device uses a charging protocol based on two signal lines for full-duplex communication, how to switch the power role is still a problem to be solved.
[0330] To solve the above problems, the embodiments of the present application provide a method, system, electronic device and computer-readable storage medium for switching power roles. The system may include a first electronic device and a second electronic device, both of which have a charging function and a power supply function. Initially, the first electronic device is a charging device, and the second electronic device is a power supply device. The first electronic device and the second electronic device are connected through a first signal line and a second signal line. The first signal line is a signal line for the first electronic device to receive data, and the second signal line is a signal line for the first electronic device to send data. The first signal line can be a signal line for the second electronic device to send data, and the second signal line can be a signal line for the second electronic device to receive data. When it is necessary to switch the power role, the user can perform a first operation in the first electronic device. After receiving the first operation, the first electronic device can send a first instruction to the second electronic device, and the first instruction is used to instruct the second electronic device to switch to a power supply device. After receiving the first instruction, the second electronic device can adjust the output voltage of the second electronic device, adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device, so as to switch the second electronic device to a charging device. In addition, the first electronic device can adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjust the output voltage of the first electronic device to switch the first electronic device to a power supply device. That is, after adjustment, the first signal line can be a signal line for the first electronic device to send data, the second signal line can be a signal line for the first electronic device to receive data, and the first signal line can be a signal line for the second electronic device to receive data, and the second signal line can be a signal line for the second electronic device to send data. That is, in the present application, during the charging process of two electronic devices that are both dual-role devices, the power roles can be accurately switched, the user experience is improved, and it has strong ease of use and practicality.
[0331] In the embodiment of the present application, the first electronic device and the second electronic device can be a mobile phone, a tablet computer, a wearable device, a vehicle-mounted device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), a desktop computer, and other electronic devices that can serve as dual-role devices. The embodiment of the present application does not impose any restrictions on the specific types of electronic devices.
[0332] The following first introduces the electronic device (ie, the first electronic device or the second electronic device) involved in the embodiment of the present application. Figure 4 , Figure 4 A structural schematic diagram of an electronic device 400 is shown.
[0333] The electronic device 400 may include a processor 410, an external memory interface 420, an internal memory 421, a universal serial bus (USB) interface 430, a charging management module 440, a power management module 441, a battery 442, an antenna 1, an antenna 2, a mobile communication module 450, a wireless communication module 460, a sensor module 470, a button 480, and a display screen 490, etc. Among them, the sensor module 470 may include a pressure sensor 470A, a gyroscope sensor 470B, an acceleration sensor 470C, a temperature sensor 470D, a touch sensor 470E, and the like.
[0334] It is understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 400. In other embodiments of the present application, the electronic device 400 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0335] The processor 410 may include one or more processing units, for example, the processor 410 may include an application processor (AP), a modem processor, a graphics processor (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. Different processing units may be independent devices or integrated into one or more processors.
[0336] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0337] The processor 410 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 410 is a cache memory. The memory may store instructions or data that the processor 410 has just used or cyclically used. If the processor 410 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 410, and thus improves the efficiency of the system.
[0338] In some embodiments, the processor 410 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0339] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 410 may include multiple groups of I2C buses. The processor 410 may be coupled to the touch sensor 470E, the charger, etc. through different I2C bus interfaces. For example, the processor 410 may be coupled to the touch sensor 470E through the I2C interface, so that the processor 410 communicates with the touch sensor 470E through the I2C bus interface to realize the touch function of the electronic device 400.
[0340] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 410 and the wireless communication module 460. For example: the processor 410 communicates with the Bluetooth module in the wireless communication module 460 through the UART interface to realize the Bluetooth function. The MIPI interface can be used to connect the processor 410 to peripheral devices such as the display screen 490. The MIPI interface includes a camera serial interface (CSI), a display serial interface (DSI), etc. In some embodiments, the processor 410 and the display screen 490 communicate through the DSI interface to realize the display function of the electronic device 400.
[0341] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 410 with the display screen 490, the wireless communication module 460, the sensor module 470, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0342] The USB interface 430 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 430 can be used to connect a charger to charge the electronic device 400, and can also be used to transfer data between the electronic device 400 and a peripheral device. It can also be used to connect headphones to play audio through the headphones. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0343] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 400. In other embodiments of the present application, the electronic device 400 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0344] The charging management module 440 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 440 may receive charging input from a wired charger through the USB interface 430. In some wireless charging embodiments, the charging management module 440 may receive wireless charging input through a wireless charging coil of the electronic device 400. While the charging management module 440 is charging the battery 442, it may also power the electronic device through the power management module 441.
[0345] The power management module 441 is used to connect the battery 442, the charging management module 440 and the processor 410. The power management module 441 receives input from the battery 442 and / or the charging management module 440, and supplies power to the processor 410, the internal memory 421, the display screen 490, and the wireless communication module 460. The power management module 441 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 441 can also be set in the processor 410. In other embodiments, the power management module 441 and the charging management module 440 can also be set in the same device.
[0346] The wireless communication function of the electronic device 400 can be implemented through the antenna 1, the antenna 2, the mobile communication module 450, the wireless communication module 460, the modem processor and the baseband processor.
[0347] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 400 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0348] The mobile communication module 450 can provide solutions for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 400. The mobile communication module 450 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 450 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 450 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 450 can be set in the processor 410. In some embodiments, at least some of the functional modules of the mobile communication module 450 can be set in the same device as at least some of the modules of the processor 410.
[0349] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be sent into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After the low-frequency baseband signal is processed by the baseband processor, it is passed to the application processor. The application processor displays an image or video through the display screen 490. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 410 and be set in the same device as the mobile communication module 450 or other functional modules.
[0350] The wireless communication module 460 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 400. The wireless communication module 460 can be one or more devices integrating at least one communication processing module. The wireless communication module 460 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 410. The wireless communication module 460 can also receive the signal to be sent from the processor 410, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0351] In some embodiments, the antenna 1 of the electronic device 400 is coupled to the mobile communication module 450, and the antenna 2 is coupled to the wireless communication module 460, so that the electronic device 400 can communicate with the network and other devices through wireless communication technology. The wireless communication technology 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. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0352] The electronic device 400 implements the display function through a GPU, a display screen 490, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 490 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 410 may include one or more GPUs, which execute program instructions to generate or change display information.
[0353] The display screen 490 is used to display images, videos, etc. The display screen 490 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 400 may include 1 or N display screens 490, where N is a positive integer greater than 1.
[0354] The digital signal processor is used to process digital signals, and can process not only digital image signals but also other digital signals. For example, when the electronic device 400 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0355] Video codecs are used to compress or decompress digital videos. The electronic device 400 may support one or more video codecs. Thus, the electronic device 400 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0356] NPU is a neural network (NN) computing processor, which can quickly process input information and continuously self-learn by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain. NPU can realize applications such as intelligent cognition of electronic device 400, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0357] The external memory interface 420 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 400. The external memory card communicates with the processor 410 through the external memory interface 420 to implement a data storage function, such as saving files such as videos in the external memory card.
[0358] The internal memory 421 can be used to store computer executable program codes, which include instructions. The internal memory 421 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 400 (such as a phone book, etc.), etc. In addition, the internal memory 421 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 410 executes various functional applications and data processing of the electronic device 400 by running instructions stored in the internal memory 421 and / or instructions stored in a memory provided in the processor.
[0359] The pressure sensor 470A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 470A can be set on the display screen 490. There are many types of pressure sensors 470A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 470A, the capacitance between the electrodes changes. The electronic device 400 determines the intensity of the pressure according to the change in capacitance. When a touch operation acts on the display screen 490, the electronic device 400 detects the touch operation intensity according to the pressure sensor 470A. The electronic device 400 can also calculate the touch position according to the detection signal of the pressure sensor 470A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than the first pressure threshold acts on the short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold acts on the short message application icon, an instruction to create a new short message is executed.
[0360] The gyro sensor 470B can be used to determine the motion posture of the electronic device 400. In some embodiments, the angular velocity of the electronic device 400 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 470B. The gyro sensor 470B can be used for navigation and somatosensory game scenes.
[0361] The acceleration sensor 470C can detect the magnitude of the acceleration of the electronic device 400 in all directions (generally three axes). When the electronic device 400 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.
[0362] The temperature sensor 470D is used to detect temperature. In some embodiments, the electronic device 400 uses the temperature detected by the temperature sensor 470D to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 470D exceeds a threshold, the electronic device 400 reduces the performance of the processor located near the temperature sensor 470D to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 400 heats the battery 442 to avoid abnormal shutdown of the electronic device 400 due to low temperature. In some other embodiments, when the temperature is lower than another threshold, the electronic device 400 performs a boost on the output voltage of the battery 442 to avoid abnormal shutdown caused by low temperature.
[0363] The touch sensor 470E is also called a "touch control device". The touch sensor 470E can be set on the display screen 490, and the touch sensor 470E and the display screen 490 form a touch screen, also called a "touch control screen". The touch sensor 470E is used to detect touch operations acting on or near it. The touch sensor can pass 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 490. In other embodiments, the touch sensor 470E can also be set on the surface of the electronic device 400, which is different from the position of the display screen 490.
[0364] The key 480 includes a power key, a volume key, etc. The key 480 may be a mechanical key or a touch key. The electronic device 400 may receive key input and generate key signal input related to user settings and function control of the electronic device 400.
[0365] The software system of the electronic device 400 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. For example, the software system of the electronic device 400 may adopt an Android operating system (OS), a Harmony OS, or an IOS with a layered architecture. The embodiment of the present application takes the Android system with a layered architecture as an example to exemplify the software structure of the electronic device 400.
[0366] Figure 5 It is a software structure block diagram of the electronic device 400 according to an embodiment of the present application.
[0367] The layered architecture divides the software into several layers, each with clear roles 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: the application layer, the application framework layer, the Android runtime and system library, and the kernel layer.
[0368] The application layer can include a series of application packages.
[0369] like Figure 5 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.
[0370] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0371] like Figure 5 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0372] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0373] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0374] The view system includes visual controls, such as controls for displaying text, controls for displaying images, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying images.
[0375] The phone manager is used to provide communication functions of the electronic device 400, such as management of call status (including connecting, hanging up, etc.).
[0376] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0377] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0378] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0379] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0380] The application layer and the application framework layer run in a 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 life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0381] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0382] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0383] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0384] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0385] A 2D graphics engine is a drawing engine for 2D drawings.
[0386] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0387] A method for switching power roles provided in an embodiment of the present application will be exemplarily described below in conjunction with the accompanying drawings and specific application scenarios.
[0388] See also Figure 6 , Figure 6 A schematic diagram of a power role switching system provided in an embodiment of the present application is shown. Figure 1 .
[0389] like Figure 6As shown in (a) in the figure, the system may include a first electronic device 601 and a second electronic device 602. Among them, the first electronic device 601 and the second electronic device 602 may both be dual-role devices with charging and power supply functions. That is to say, in some application scenarios, the first electronic device 601 may be used as a charging device to receive power provided by other power supply devices. For example, the first electronic device 601 may be used as a charging device, the second electronic device 602 may be used as a power supply device, and the first electronic device 601 may receive power provided by the second electronic device 602. In other application scenarios, the first electronic device 601 may be used as a power supply device to provide power to other electronic devices. For example, the first electronic device 601 may be used as a power supply device, the second electronic device 602 may be used as a charging device, and the second electronic device 602 may receive power provided by the first electronic device 601, that is, the first electronic device 601 may provide power to the second electronic device 602.
[0390] Optionally, the first electronic device 601 and the second electronic device 602 can be charged through a charging protocol. The charging protocol may be a charging protocol for full-duplex communication based on two signal lines. That is, during the charging process, for example, in the process of the first electronic device 601 providing power to the second electronic device 602, or in the process of the first electronic device 601 receiving power provided by the second electronic device 602, the first electronic device 601 and the second electronic device 602 can be connected through a charging cable. The charging cable may include at least two signal lines. One of the signal lines (hereinafter referred to as the first signal line) may be a positive data line (ie, Data+, D+), and the other signal line (hereinafter referred to as the second signal line) may be a negative data line (ie, Data-, D-).
[0391] It should be understood that for a power supply device, the positive data line can be a signal line for sending data (ie, Transmitter, TX), and the negative data line can be a signal line for receiving data (ie, Receiver, RX). For a charging device, the positive data line can be RX, and the negative data line can be TX.
[0392] For example, when the first electronic device 601 is a power supply device and the second electronic device 602 is a charging device, for the first electronic device 601, the first signal line may be TX and the second signal line may be RX. For the second electronic device 602, the first signal line may be RX and the second signal line may be TX. That is, when the first electronic device 601 provides power to the second electronic device 602, the first electronic device 601 may send data to the second electronic device 602 through the first signal line and may receive data sent by the second electronic device 602 through the second signal line. The second electronic device 602 may receive data sent by the first electronic device 601 through the first signal line and may send data to the first electronic device 601 through the second signal line.
[0393] For example, Figure 6 As shown in (a), when the first electronic device 601 is a charging device and the second electronic device 602 is a power supply device, for the first electronic device 601, the first signal line can be RX and the second signal line can be TX. For the second electronic device 602, the first signal line can be TX and the second signal line can be RX. That is, when the second electronic device 602 provides power to the first electronic device 601, the first electronic device 601 can receive data sent by the second electronic device 602 through the first signal line, and can send data to the second electronic device 602 through the second signal line. The second electronic device 602 can send data to the first electronic device 601 through the first signal line, and can receive data sent by the first electronic device 601 through the second signal line.
[0394] It should be noted that if Figure 6 As shown in (a) of FIG. 1 , the charging cable may further include VBUS and GND. During the charging process, the first electronic device 601 and the second electronic device 602 may be powered via VBUS. For example, when the first electronic device 601 is a power supply device and the second electronic device 602 is a charging device, the first electronic device 601 may provide power to the second electronic device 602 via VBUS. Figure 6 As shown in (a) in FIG. 5 , when the first electronic device 601 is a charging device and the second electronic device 602 is a power supply device, the second electronic device 602 can provide power to the first electronic device 601 through VBUS.
[0395] In the embodiment of the present application, initially, that is, when the first electronic device 601 and the second electronic device 602 are just connected for charging, the first electronic device 601 can be identified as a charging device or a power supply device, and the second electronic device 602 can be identified as a power supply device or a charging device.
[0396] It is understandable that the embodiment of the present application does not impose any restrictions on the specific identification method of the first electronic device 601 and the second electronic device 602 as charging devices or power supply devices, which can be determined according to the actual scenario.
[0397] For example, Figure 6 As shown in (b) of FIG. 1 , the charging cable may further include a CC. The first electronic device 601 may identify the second electronic device 602 as a charging device or a power supply device based on the signal detected on the CC. Similarly, the second electronic device 602 may identify the first electronic device 601 as a charging device or a power supply device based on the signal detected on the CC.
[0398] For example, Figure 6 As shown in (c) in the figure, the charging cable may also include other signal lines that can be used to identify the charging device or the power supply device. The first electronic device 601 can identify the second electronic device 602 as a charging device or a power supply device based on the other signal lines in the charging cable. Similarly, the second electronic device 602 can identify the first electronic device 601 as a charging device or a power supply device based on the other signal lines in the charging cable.
[0399] It should be understood that, in addition to the above-mentioned signal lines, the charging cable may also include other signal lines for other functions. Figure 6 In the description, the first electronic device 601 is used as a charging device and the second electronic device 602 is used as a power supply device.
[0400] The following is an exemplary description using an example where the first electronic device 601 is initially identified as a charging device and the second electronic device 602 is identified as a power supply device.
[0401] It should be understood that after the first electronic device 601 is identified as a charging device and the second electronic device 602 is identified as a power supply device, the first electronic device 601 can send a connection confirmation instruction to the second electronic device 602 to confirm whether the first electronic device 601 and the second electronic device 602 are connected. For example, the first electronic device 601 can send a ping instruction to the second electronic device 602, and can detect whether an ACK (Acknowledgment) returned by the second electronic device 602 to confirm the receipt of the ping instruction is received. When the first electronic device 601 receives an ACK returned by the second electronic device 602 to confirm the receipt of the ping instruction, the first electronic device 601 can determine that the first electronic device 601 and the second electronic device 602 are connected. At this time, the first electronic device 601 and the second electronic device 602 can be charged through the charging protocol, that is, the second electronic device 602 can provide power to the first electronic device 601 through the charging protocol.
[0402] Exemplarily, when the second electronic device 602 provides power to the first electronic device 601 through the charging protocol, if the user wants to switch the power role during the charging process, that is, wants to switch the first electronic device 601 from a charging device to a power supply device, and the second electronic device 602 from a power supply device to a charging device, so as to provide power to the second electronic device 602 through the first electronic device 601, the user can perform the switching operation in the first electronic device 601, or can perform the switching operation in the second electronic device 602. After the first electronic device 601 detects the switching operation, it can switch the power role according to the switching operation, or the second electronic device 602 detects the switching operation and can switch the power role according to the switching operation, so as to switch the first electronic device 601 to a power supply device and switch the second electronic device 602 to a charging device.
[0403] It should be noted that the embodiment of the present application does not impose any restrictions on the specific type of the switching operation, which can be determined according to the actual scenario. Optionally, the switching operation can be any operation such as a touch operation, a press operation or a gesture operation.
[0404] Optionally, the switching operation may be an operation of touching a switching button in the first electronic device 601 , or an operation of touching a switching button in the second electronic device 602 .
[0405] For example, during the charging process, the first electronic device 601 may display a power role switching button in the display interface of the first electronic device 601. When the user wants to switch the power role during the charging process, the user may touch the switching button in the first electronic device 601 to switch the power role.
[0406] For example, during the charging process, the second electronic device 602 may display a power role switching button in the display interface of the second electronic device 602. When the user wants to switch the power role during the charging process, the user may touch the switching button in the second electronic device 602 to switch the power role.
[0407] See also Figure 7 , Figure 7 The application scenario provided by the embodiment of the present application is shown Figure 1 This application scenario is described by taking the first electronic device 601 as a charging device and the second electronic device 602 as a power supply device as an example.
[0408] like Figure 7As shown in (a) of the figure, during the charging process, the first electronic device 601 may display a switching prompt interface (hereinafter referred to as the first switching prompt interface) 701 in the display interface of the first electronic device 601. The first switching prompt interface 701 may display prompt information on whether to switch the power role. For example, the prompt information may be "The current device is a charging device, do you want to switch to a power supply device?". At the same time, a "Yes" button 7011 and a "No" button 7012 may also be displayed in the first switching prompt interface 701. Among them, the "Yes" button 7011 is used to trigger the switching of the power role, and the "No" button 7012 is used to refuse to switch the power role.
[0409] When the user wants to switch the power role during the charging process, the user can touch the "Yes" button 7011 in the first switching prompt interface 701. When the first electronic device 601 detects the touch operation on the "Yes" button 7011, it can be determined that the power role needs to be switched, that is, the first electronic device 601 needs to be switched to a power supply device. At this time, the first electronic device 601 can trigger the switching of the power role. When the user does not want to switch the power role during the charging process, the user can touch the "No" button 7012 in the first switching prompt interface 701. When the first electronic device 601 detects the touch operation on the "No" button 7012, it can be determined that the power role does not need to be switched. At this time, the first electronic device 601 will not trigger the switching of the power role.
[0410] like Figure 7 As shown in (b), during the charging process, the second electronic device 602 may display a switching prompt interface (hereinafter referred to as the second switching prompt interface) 702 in the display interface of the second electronic device 602, and the second switching prompt interface 702 may display prompt information on whether to switch the power role, for example, the prompt information may be "The current device is a power supply device, do you want to switch to a power supply device?". At the same time, a "yes" button 7021 and a "no" button 7022 may also be displayed in the second switching prompt interface 702. Among them, the "yes" button 7021 is used to trigger the switching of the power role, and the "no" button 7022 is used to refuse to switch the power role.
[0411] When the user wants to switch the power role during the charging process, the user can touch the "Yes" button 7021 in the second switching prompt interface 702. When the second electronic device 602 detects the touch operation on the "Yes" button 7021, it can be determined that the power role needs to be switched, that is, the second electronic device 602 needs to be switched to a charging device. At this time, the second electronic device 602 can trigger the switching of the power role. When the user does not want to switch the power role, the user can click the "No" button 7012 in the second switching prompt interface 702. When the second electronic device 602 detects the touch operation on the "No" button 7022, it can be determined that the power role does not need to be switched. At this time, the second electronic device 602 will not trigger the switching of the power role.
[0412] Optionally, the switching operation may be an operation of pressing a specific physical button in the first electronic device 601 , or an operation of pressing a specific physical button in the second electronic device 602 .
[0413] For example, during the charging process, the user can press the "power +" button and the power button of the first electronic device 601 at the same time to switch the power role. For example, during the charging process, the user can press the "power +" button and the power button of the second electronic device 602 at the same time to switch the power role.
[0414] Optionally, the switching operation may be an operation of executing a specific gesture in the first electronic device 601, or an operation of executing a specific gesture in the second electronic device 602. For example, the specific gesture may be two or three fingers touching the display interface, or may be a single click or double click of two finger joints on the display interface, and so on.
[0415] For example, during the charging process, the user can touch the display interface of the first electronic device 601 with two fingers or three fingers to switch the power role. For example, during the charging process, the user can single-click or double-click the display interface of the first electronic device 601 with two finger joints to switch the power role. For example, during the charging process, the user can touch the display interface of the second electronic device 602 with two fingers or three fingers to switch the power role. For example, during the charging process, the user can single-click or double-click the display interface of the second electronic device 602 with two finger joints to switch the power role.
[0416] As can be seen from the above, the user can perform a switching operation in the first electronic device 601 to switch the power role during the charging process, that is, the first electronic device 601 can trigger the switching of the power role during the charging process according to the switching operation detected by the first electronic device 601. Alternatively, the user can perform a switching operation in the second electronic device 602 to switch the power role during the charging process, that is, the second electronic device 602 can trigger the switching of the power role during the charging process according to the switching operation detected by the second electronic device 602.
[0417] The following will be explained separately: 1. The first electronic device 601 triggers switching of the power role during charging according to the switching operation detected by the first electronic device 601; 2. The second electronic device 602 triggers switching of the power role during charging according to the switching operation detected by the second electronic device 602.
[0418] 1. The first electronic device 601 triggers switching of the power source role during charging according to the switching operation detected by the first electronic device 601
[0419] When the first electronic device 601 is a charging device and the second electronic device 602 is a power supply device, that is, the second electronic device 602 provides power to the first electronic device 601, when the user wants to trigger the switching of the power role on the first electronic device 601, the user can perform the switching operation in the first electronic device 601, for example, by clicking Figure 7 The "Yes" button 7011 shown in (a) of FIG. 6 is pressed. After the first electronic device 601 detects the switching operation, it determines that the power source role in the charging process needs to be switched.
[0420] In one example, after detecting the switching operation, the first electronic device 601 may send a switching instruction (hereinafter referred to as switching instruction A) to the second electronic device 602. That is, the first electronic device 601 may send the switching instruction A to the second electronic device 602 through the second signal line. The switching instruction A is used to request that the second electronic device 602 be switched to a charging device to achieve switching of the power source role during the charging process.
[0421] After the second electronic device 602 receives the switching instruction A, the output voltage of the second electronic device 602 can be adjusted. For example, the output voltage of the second electronic device 602 can be adjusted to a preset value (hereinafter referred to as preset value A), so that VBUS is powered off, thereby causing the second electronic device 602 to stop providing power to the first electronic device 601 through VBUS.
[0422] In addition, the second electronic device 602 may also switch the states of the first signal line and the second signal line in the second electronic device 602, that is, exchange RX and TX of the second electronic device 602. For example, initially, for the second electronic device 602, the first signal line may be TX, and the second signal line may be RX. After switching the states of the first signal line and the second signal line in the second electronic device 602, the first signal line may be RX, and the second signal line may be TX.
[0423] It should be understood that after the first electronic device 601 detects the switching operation, the state of the first signal line and the second signal line in the first electronic device 601 may also be switched, that is, the RX and TX of the first electronic device 601 are exchanged. For example, initially, for the first electronic device 601, the first signal line may be RX, and the second signal line may be TX. After the state of the first signal line and the second signal line in the first electronic device 601 is switched, the first signal line may be TX, and the second signal line may be RX.
[0424] After the first electronic device 601 detects the switching operation, it can also adjust the output voltage of the first electronic device 601. For example, the output voltage of the first electronic device 601 can be adjusted to a preset value (hereinafter referred to as preset value B) so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, thereby switching the first electronic device 601 to a power supply device and switching the second electronic device 602 to a charging device.
[0425] It should be noted that the embodiments of the present application do not impose any restrictions on the specific values of the preset value A and the preset value B, which can be determined according to the actual scenario. For example, the preset value A can be determined as 0V according to the actual scenario. For example, the preset value B can be determined as any value such as 5V, 10V, 20V, etc. according to the actual scenario.
[0426] Exemplarily, in order to avoid power supply conflicts on VBUS and ensure effective switching of power supply roles, the first electronic device 601 can detect the level on the second signal line (i.e., RX after switching) after switching the states of the first signal line and the second signal line. When the first electronic device 601 detects a high level on the second signal line within a preset time (hereinafter referred to as the preset time T01), the first electronic device 601 can determine that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands. At this time, the first electronic device 601 can adjust the output voltage of the first electronic device 601 to the preset value B after determining the preset time (hereinafter referred to as the preset time T1) at which the first electronic device 601 and the second electronic device 602 have successfully shaken hands, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0427] That is to say, after detecting the switching operation, the first electronic device 601 can first switch the states of the first signal line and the second signal line, and after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands within a preset time T1, the output voltage of the first electronic device 601 can be adjusted to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, thereby ensuring effective switching of power roles.
[0428] Among them, when the first electronic device 601 does not detect a high level on the second signal line within the preset time T01, the charging handshake protocol handshake can be restarted. When the restarted charging protocol handshake is successful, the first electronic device 601 can adjust the output voltage of the first electronic device 601 so that VBUS is powered on. When the restarted charging protocol handshake fails, the first electronic device 601 can exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0429] It should be understood that after the second electronic device 602 switches the states of the first signal line and the second signal line, it can also detect the level on the first signal line (i.e., RX after switching). When the second electronic device 602 detects a high level on the first signal line within a preset time (hereinafter referred to as the preset time T02), the second electronic device 602 can determine that the second electronic device 602 as a charging device and the first electronic device 601 as a power supply device have successfully shaken hands. After the second electronic device 602 determines that the second electronic device 602 as a charging device and the first electronic device 601 as a power supply device have successfully shaken hands, the second electronic device 602 can detect whether the voltage on VBUS meets the preset conditions. When the second electronic device 602 detects that the voltage on VBUS meets the preset conditions within the preset time (hereinafter referred to as the preset time T03), the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, and the charging protocol communication can be performed. At this time, the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0430] The preset condition may be determined according to the preset value B. The specific method of determining the preset condition may be determined according to the actual scenario, and the embodiment of the present application does not impose any specific restrictions on this. Optionally, a voltage interval may be determined according to the preset value B, and the preset condition may be that the voltage is within the voltage interval.
[0431] For example, when the preset value B is 5V, the preset condition can be determined as the voltage being between [4.5V, 5.5V]. That is, when the second electronic device 602 detects that the voltage on VBUS is between [4.5V, 5.5V], for example, when the voltage on VBUS is detected to be 5.2V, the second electronic device 602 can determine that the voltage on VBUS meets the preset condition. When the second electronic device 602 detects that the voltage on VBUS is not between [4.5V, 5.5V], for example, when the voltage on VBUS is detected to be 2V, the second electronic device 602 can determine that the voltage on VBUS does not meet the preset condition.
[0432] For example, when the preset value B is 10V, the preset condition can be determined as the voltage being between [8.5V, 11.5V]. That is, when the second electronic device 602 detects that the voltage on VBUS is between [8.5V, 11.5V], for example, when the voltage on VBUS is detected to be 10.2V, the second electronic device 602 can determine that the voltage on VBUS meets the preset condition. When the second electronic device 602 detects that the voltage on VBUS is not between [8.5V, 11.5V], for example, when the voltage on VBUS is detected to be 2V, the second electronic device 602 can determine that the voltage on VBUS does not meet the preset condition.
[0433] For example, when the preset value B is 15V, the preset condition can be determined as the voltage being between [12V, 16V]. That is, when the second electronic device 602 detects that the voltage on VBUS is between [12V, 16V], for example, when the voltage on VBUS is detected to be 14V, the second electronic device 602 can determine that the voltage on VBUS meets the preset condition. When the second electronic device 602 detects that the voltage on VBUS is not between [12V, 16V], for example, when the voltage on VBUS is detected to be 5V, the second electronic device 602 can determine that the voltage on VBUS does not meet the preset condition.
[0434] It is understandable that when the second electronic device 602 does not detect a high level on the first signal line within the preset time T02, or the second electronic device 602 detects that the voltage on VBUS does not meet the preset conditions within the preset time T03, the second electronic device 602 can restart the charging protocol handshake.
[0435] When the restarted charging protocol handshake is successful, and the voltage on VBUS is detected to meet the preset condition within the preset time T03 after the handshake is successful, the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol. When the restarted charging protocol handshake fails, the second electronic device 602 can exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0436] It should be noted that when the restarted charging protocol handshake fails, the first electronic device 601 or the second electronic device 602 exits charging, which is only an exemplary explanation and should not be understood as a limitation on the embodiments of the present application. The embodiments of the present application do not limit the number of restarted charging protocol handshakes, which can be determined specifically according to the actual scenario.
[0437] It should be noted that the values of the preset time T01, T02, T03 and the preset time T1 can be specifically determined according to the actual scenario, and the embodiments of the present application are not limited to this. For example, the preset time T01 can be set to any value such as 10ms, 20ms or 50ms according to the actual scenario. For example, the preset time T02 can be set to any value such as 10ms, 20ms or 50ms according to the actual scenario. For example, the preset time T03 can be set to any value such as 10ms, 20ms or 50ms according to the actual scenario. For example, the preset time T1 can be set to any value such as 0ms, 5ms, 10ms or 20ms according to the actual scenario.
[0438] Optionally, switching the state of the first signal line and the second signal line in the first electronic device 601 may be to set the first signal line in the first electronic device 601 to a pull-up state, and to set the second signal line in the first electronic device 601 to a high impedance state. Switching the state of the first signal line and the second signal line in the second electronic device 602 may be to set the first signal line in the second electronic device 602 to a high impedance state, and to set the second signal line to a pull-up state.
[0439] See also Figure 8 , Figure 8 The application scenario provided by the embodiment of the present application is shown Figure 2 .
[0440] like Figure 8As shown in (a), initially, the first electronic device 601 is a charging device, and the second electronic device 602 is a power supply device, that is, for the first electronic device 601, the first signal line can be RX, and the second signal line can be TX. For the second electronic device 602, the first signal line can be TX, and the second signal line can be RX. At this time, the second electronic device 602 can adjust the output voltage of the second electronic device 602 so that VBUS is powered on, so that the second electronic device 602 can provide power to the first electronic device 601 through VBUS.
[0441] When the user performs a switching operation in the first electronic device 601, the first electronic device 601 can switch the states of the first signal line and the second signal line in the first electronic device 601, that is, exchange the RX and TX of the first electronic device 601, such as Figure 8 As shown in (b), after switching, for the first electronic device 601, the first signal line may be TX, and the second signal line may be RX.
[0442] Similarly, the second electronic device 602 can switch the states of the first signal line and the second signal line in the second electronic device 602, that is, exchange the RX and TX of the second electronic device 602, such as Figure 8 As shown in (b), after switching, for the second electronic device 602, the first signal line may be RX, and the second signal line may be TX.
[0443] like Figure 8 As shown in (b), the second electronic device 602 may also adjust the output voltage of the second electronic device 602 so that the second electronic device 602 stops supplying power, so that the second electronic device 602 stops providing power to the first electronic device 601 through VBUS.
[0444] The first electronic device 601 can adjust the output voltage of the first electronic device 601 so that the first electronic device 601 starts to supply power, that is, the first electronic device 601 can provide power to the second electronic device 602 through VBUS, so that the first electronic device 601 can be switched from a charging device to a power supply device, and the second electronic device 602 can be switched from a power supply device to a charging device.
[0445] In another example, after the first electronic device 601 detects a switching operation, it can first determine whether the first electronic device 601 meets the switching condition (hereinafter referred to as switching condition A), that is, determine whether the first electronic device 601 can be switched to a power supply device, so that when the first electronic device 601 meets the switching condition A, the power role can be switched to ensure the effectiveness of the power role switching and improve the user experience.
[0446] It should be noted that the switching condition A can be specifically determined according to the actual scenario, and the embodiment of the present application does not impose any restrictions on this. For example, according to the actual scenario, the switching condition A can be determined to include at least one of power, battery temperature, cable impedance, voltage and current accuracy, and port leakage current.
[0447] For example, the switching condition A may be that the power level is greater than a preset power level (hereinafter referred to as preset power level A). The power level and the preset power level A may be represented by a percentage of the battery capacity. For example, the preset power level A may be 60% of the battery capacity. That is, when the first electronic device 601 determines that the power level of the first electronic device 601 is greater than the preset power level A, for example, when the power level of the first electronic device 601 is 80%, the first electronic device 601 may determine that the first electronic device 601 satisfies the switching condition A.
[0448] For example, the switching condition A may be that the battery temperature is less than or equal to a preset temperature (hereinafter referred to as preset temperature A). For example, the preset temperature A may be 20 degrees. That is, when the first electronic device 601 determines that the battery temperature of the first electronic device 601 is less than or equal to 20 degrees, the first electronic device 601 may determine that the first electronic device 601 meets the switching condition A.
[0449] For example, the switching condition A may be that the power level is greater than a preset power level A, and the battery temperature is less than or equal to a preset temperature A. That is, when the first electronic device 601 determines that the power level of the first electronic device 601 is less than or equal to the preset power level A, and the battery temperature of the first electronic device 601 is less than or equal to the preset temperature A, the first electronic device 601 may determine that the first electronic device 601 satisfies the switching condition A.
[0450] When the first electronic device 601 meets the switching condition A, the first electronic device 601 can send a switching instruction A to the second electronic device 602. After receiving the switching instruction, the second electronic device 602 can send an ACK (hereinafter referred to as ACK A1) to confirm the receipt of the switching instruction A and an approval instruction (hereinafter referred to as approval instruction A) to the first electronic device 601. That is, the second electronic device 602 can send ACK A1 and approval instruction A to the first electronic device 601 through the first signal line (that is, TX of the second electronic device 602).
[0451] Exemplarily, after the second electronic device 602 sends ACK A1 and the consent instruction A, the second electronic device 602 can adjust the output voltage of the second electronic device 602 so that VBUS is powered off, so that the second electronic device 602 stops supplying power, and thus the second electronic device 602 no longer provides power to the first electronic device 601 through VBUS. The second electronic device 602 can also switch the states of the first signal line and the second signal line in the second electronic device 602.
[0452] After the first electronic device 601 receives the ACK A1 and the consent instruction A returned by the second electronic device 602, the state of the first signal line and the second signal line in the first electronic device 601 can be switched, and the output voltage of the first electronic device 601 can be adjusted to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0453] Exemplarily, after receiving ACKA1 and the consent instruction A returned by the second electronic device 602, the first electronic device 601 may return an ACK (hereinafter referred to as ACKA2) to the second electronic device 602 to confirm receipt of the consent instruction A. That is, the first electronic device 601 may send ACK A2 to the second electronic device 602 via the second signal line (i.e., TX of the first electronic device 601).
[0454] After receiving the ACKA2 returned by the first electronic device 601, the second electronic device 602 can adjust the output voltage of the second electronic device 602 to power off the VBUS, so that the second electronic device 602 stops supplying power, and the second electronic device 602 no longer provides power to the first electronic device 601 through the VBUS. The second electronic device 602 can also switch the state of the first signal line and the second signal line in the second electronic device 602.
[0455] Alternatively, since the second electronic device 602 needs time to parse ACKA2 to determine whether it is indeed necessary to switch the power role, in order to ensure accurate switching of the power role, after receiving ACKA2, the second electronic device 602 can adjust the output voltage of the second electronic device 602 after a preset time (hereinafter referred to as the preset time T21) to stop power supply and switch the states of the first signal line and the second signal line in the second electronic device 602.
[0456] After the first electronic device 601 returns ACK A2 to the second electronic device 602, the states of the first signal line and the second signal line in the first electronic device 601 can be switched, and the output voltage of the first electronic device 601 can be adjusted to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0457] Optionally, after the first electronic device 601 returns ACK A2 to the second electronic device 602, the states of the first signal line and the second signal line in the first electronic device 601 can be switched first, and after determining that the handshake between the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device is successful within a preset time T1, the output voltage of the first electronic device 601 is adjusted so that VBUS is powered on, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 through VBUS.
[0458] Optionally, after the first electronic device 601 returns ACK A2 to the second electronic device 602, the time (e.g., time A) at which the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602 can be determined. Subsequently, the first electronic device 601 can switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time of time A (hereinafter referred to as preset time T31), and adjust the output voltage of the first electronic device 601. In other words, the first electronic device 601 can switch the first electronic device 601 to a power supply device after the second electronic device 602 determines to switch roles, that is, after the second electronic device 602 switches to a charging device, so as to effectively ensure the accuracy of the power role switching.
[0459] Exemplarily, the first electronic device 601 may first switch the states of the first signal line and the second signal line in the first electronic device 601 after the preset time T31 of the time A. Subsequently, the first electronic device 601 may adjust the output voltage of the first electronic device 601 after determining that the handshake between the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device is successful for the preset time T1, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, thereby reducing power supply conflicts on VBUS.
[0460] It should be noted that the values of the preset time T21 and the preset time T31 can be specifically determined according to the actual scenario, and the embodiment of the present application does not limit this. For example, the preset time T21 can be set to any value such as 2ms, 5ms or 10ms according to the actual scenario. For example, the preset time T31 can be set to any value such as 3ms, 5ms or 10ms according to the actual scenario.
[0461] It can be understood that when the first electronic device 601 does not meet the switching condition A, the first electronic device 601 can refuse to switch the power role, that is, the first electronic device 601 will not send a switching instruction A to the second electronic device 602. At this time, the first electronic device 601 will not switch the state of the first signal line and the second signal line in the first electronic device 601, so that the first electronic device 601 still acts as a charging device and the second electronic device 602 still acts as a power supply device.
[0462] Optionally, the control instruction (such as a ping instruction, ACK, a switching instruction, and an agreement instruction, etc.) sent between the first electronic device 601 and the second electronic device 602 may include a message header, a control instruction, and a cyclic redundancy check (CRC). The length of the message header may be 2 bytes, the length of the control instruction may be 1 byte, and the length of the CRC may also be 1 byte.
[0463] Optionally, the relevant content of the control instructions (such as ping instructions, ACK, switching instructions, and consent instructions, etc.) sent between the first electronic device 601 and the second electronic device 602 can be shown in Table 1. Among them, the numbers of the control instructions in Table 1 are only for exemplary interpretation and should not be understood as limiting the embodiments of the present application. In the embodiments of the present application, the numbers of the control instructions can also be set to other values according to actual needs.
[0464] Table 1
[0465] serial number Control instructions Sender Receiver 0x00 ping command Power supply equipment / charging equipment Power supply equipment / charging equipment 0x01 ACK Power supply equipment / charging equipment Power supply equipment / charging equipment 0x03 Agree to the instruction Power supply equipment / charging equipment Power supply equipment / charging equipment 0x10 Switching instructions Power supply equipment / charging equipment Power supply equipment / charging equipment
[0466] Optionally, the data message sent between the first electronic device 601 and the second electronic device 602 may include a message header, a command, a data length, data, and a CRC. The command is used to distinguish different data messages. The length of the message header may be 2 bytes, the length of the command may be 1 byte, the length of the data length may be 1 byte, the length of the data may be 1 to 59 bytes, and the length of the CRC may be 1 byte.
[0467] For example, the relevant content of the data message (such as a rejection instruction, etc.) sent between the first electronic device 601 and the second electronic device 602 can be shown in Table 2. Among them, the numbering of the data message in Table 2 is only for exemplary interpretation and should not be understood as a limitation on the embodiment of the present application. The embodiment of the present application can also set the numbering of the data message to other values according to actual needs.
[0468] Table 2
[0469] serial number Data Message Sender Receiver 0x09 Rejection of instruction Power supply equipment / charging equipment Power supply equipment / charging equipment
[0470] See also Fig. 9 , Fig. 9 The schematic flow chart of a method for switching power roles provided by an embodiment of the present application is shown as follows Figure 1 This embodiment is described by taking the case where the first electronic device 601 detects a switching operation to switch the power role as an example.
[0471] like Fig. 9 As shown, initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable, at which time the first electronic device 601 can be identified as a charging device, and the second electronic device 602 can be identified as a power supply device. Subsequently, the first electronic device 601 and the second electronic device 602 can initiate a charging protocol handshake. When the charging protocol handshake is successful, the first electronic device 601 and the second electronic device 602 can enter a normal charging process, that is, the first electronic device 601 can receive the power provided by the second electronic device 602. It should be understood that when the charging protocol handshake fails, the first electronic device 601 and the second electronic device 602 can exit charging.
[0472] like Fig. 9 As shown, in the process of the first electronic device 601 receiving the power provided by the second electronic device 602, when the user wants to trigger the switching of the power role on the first electronic device 601 side, the user can perform the switching operation in the first electronic device 601. That is, the first electronic device 601 can detect the switching operation in the first electronic device 601. When the switching operation is detected, the first electronic device 601 can first determine whether the first electronic device 601 meets the switching condition A. When the first electronic device 601 meets the switching condition A, the first electronic device 601 can send a switching instruction A to the second electronic device 602. When the switching operation is not detected, or the first electronic device 601 does not meet the switching condition A, the first electronic device 601 can still serve as a charging device to receive the power provided by the second electronic device 602.
[0473] The second electronic device 602 may determine whether the switching instruction A sent by the first electronic device 601 is received.
[0474] When receiving the switching instruction A, the second electronic device 602 can send ACK A1 and consent instruction A to the first electronic device 601. It should be understood that when the second electronic device 602 does not receive the switching instruction A, the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0475] The first electronic device 601 may determine whether the ACK A1 and the approval instruction A returned by the second electronic device 602 are received.
[0476] When receiving ACKA1 and the consent instruction A returned by the second electronic device 602, the first electronic device 601 can return ACK A2 to the second electronic device 602 to confirm receipt of the consent instruction A. When ACK A1 and the consent instruction A are not received, the first electronic device 601 can still serve as a charging device to receive power provided by the second electronic device 602.
[0477] The second electronic device 602 may determine whether ACK A2 returned by the first electronic device 601 is received.
[0478] When ACK A2 is received, the second electronic device 602 can adjust the output voltage of the second electronic device 602 after a preset time T21 to power off VBUS, and can switch the states of the first signal line and the second signal line in the second electronic device 602. When ACK A2 is not received, the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0479] After the first electronic device 601 returns ACK A2 to the second electronic device 602, the time A at which the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602 can be determined. The first electronic device 601 can first switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time T31 of the time A. Subsequently, the first electronic device 601 can adjust the output voltage of the first electronic device 601 after determining the preset time T1 at which the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device successfully shake hands, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0480] That is, after the first electronic device 601 switches the states of the first signal line and the second signal line in the first electronic device 601, it can be determined whether a high level is detected on the second signal line (i.e., RX of the first electronic device 601). When a high level is detected on the second signal line within the preset time T01, the first electronic device 601 can determine that the handshake between the first electronic device 601 and the second electronic device 602 is successful. After the preset time T1 is determined that the handshake is successful, the first electronic device 601 can adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0481] It should be understood that when a high level is not detected on the second signal line within the preset time T01, the first electronic device 601 can determine that the handshake has failed, and at this time, the first electronic device 601 can restart the charging protocol handshake. When the restarted charging protocol handshake is successful, the first electronic device 601 can adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0482] When the restarted charging protocol handshake fails, the first electronic device 601 may exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0483] It is understandable that after the second electronic device 602 switches the states of the first signal line and the second signal line, it can also detect the level on the first signal line (i.e., RX of the second electronic device 602). When the second electronic device 602 detects a high level on the first signal line within the preset time T02, the second electronic device 602 can determine that the second electronic device 602 as a charging device and the first electronic device 601 as a power supply device have successfully shaken hands. After the second electronic device 602 determines that the second electronic device 602 and the first electronic device 601 have successfully shaken hands, the second electronic device 602 can detect that the voltage on VBUS meets the preset conditions. When the second electronic device 602 detects that the voltage on VBUS meets the preset conditions within the preset time T03, the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 in a charging protocol, so that the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0484] The preset condition may be determined according to the preset value B. For details, please refer to the description of the preset condition above.
[0485] Similarly, when a high level is not detected on the first signal line within the preset time T02 or the voltage on VBUS is not detected to meet the preset condition within the preset time T03 (i.e., the voltage on VBUS does not meet the preset condition within the preset time T03), the second electronic device 602 can determine that the handshake has failed, and at this time, the second electronic device 602 can restart the charging protocol handshake. When the restarted charging protocol handshake is successful, and the voltage on VBUS is detected to meet the preset condition within the preset time T03 after the handshake is successful, the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 in the charging protocol, and at this time, the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0486] When the restarted charging protocol handshake fails, the second electronic device 602 may exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0487] It should be noted that when the restarted charging protocol handshake fails, the first electronic device 601 or the second electronic device 602 exits charging, which is only an exemplary explanation and should not be understood as a limitation on the embodiments of the present application. The embodiments of the present application do not limit the number of restarted charging protocol handshakes, which can be determined specifically according to the actual scenario.
[0488] See also Fig.10 , Fig.10 A schematic diagram of signal switching in power role switching provided by an embodiment of the present application is shown. Fig.10 by Fig. 9 The switching of the power roles shown is taken as an example for illustrative description.
[0489] like Fig.10 (a) and Fig.10 As shown in (b), initially, during the charging process when the first electronic device 601 is a charging device and the second electronic device 602 is a power supply device, for the first electronic device 601, the first signal line can be RX and the second signal line can be TX; for the second electronic device 602, the first signal line can be TX and the second signal line can be RX.
[0490] When the first electronic device 601 detects the switching operation, the first electronic device 601 may determine whether the first electronic device 601 satisfies the switching condition A. Fig.10 As shown in (a) in FIG. 5 , when the first electronic device 601 meets the switching condition A, the first electronic device 601 may send a switching instruction A to the second electronic device 602 via the second signal line.
[0491] After receiving the switching instruction A, the second electronic device 602 may send ACK A1 and the approval instruction A to the first electronic device 601 through the first signal line.
[0492] The first electronic device 601 receives ACK A1 and the approval instruction A, and may send ACK A2 to the second electronic device 602 through the second signal line.
[0493] like Fig.10 (a) and Fig.10 As shown in (b), after the second electronic device 602 receives ACK A2, it can adjust the output voltage of the second electronic device 602 after a preset time T21, so that VBUS is powered off, so that the second electronic device 602 stops powering, and the TX and RX of the second electronic device 602 can be exchanged.
[0494] like Fig.10 As shown in (b), the first electronic device 601 can exchange TX and RX of the first electronic device 601 after the preset time T31 when the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602, and can adjust the output voltage of the first electronic device 601 after the preset time T1 when it is determined that the handshake between the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device is successful, so that VBUS is powered on. It should be understood that Fig.10 In (b), an example is given in which after the first electronic device 601 exchanges TX and RX of the first electronic device 601, the first electronic device 601 detects a high level on the second signal line, thereby determining that the handshake between the first electronic device 601 and the second electronic device 602 is successful.
[0495] like Fig.10 As shown in (a), after exchanging TX and RX of the second electronic device 602, the second electronic device 602 can determine whether a high level is detected on the first signal line within the preset time T02. When the second electronic device 602 detects a high level on the first signal line within the preset time T02, the second electronic device 602 can determine that the second electronic device 602 and the first electronic device 601 have successfully shaken hands. After determining that the second electronic device 602 and the first electronic device 601 have successfully shaken hands, the second electronic device 602 can detect whether the voltage on VBUS meets the preset conditions. When it is detected that the voltage on VBUS meets the preset conditions within the preset time T03, the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 in a charging protocol, so that the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0496] like Fig.10 As shown in (b) of FIG. 1 , after the power role is switched, for the first electronic device 601, the first signal line may be TX, and the second signal line may be RX; for the second electronic device 602, the first signal line may be RX, and the second signal line may be TX. At the same time, the power supply on VBUS may also be changed as follows: Fig.10 That is, Fig.10 As shown in (b), initially, the second electronic device 602 can provide power to the first electronic device 601 through VBUS, and after the switching is completed, the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0497] See also Fig.11 , Fig.11 The schematic flow chart of a method for switching power roles provided by an embodiment of the present application is shown as follows Figure 2 This embodiment is described by taking the case where the first electronic device 601 detects a switching operation to switch the power role as an example.
[0498] Initially, the first electronic device 601 and the second electronic device 602 may be connected via a charging cable. At this time, the first electronic device 601 may be identified as a charging device, and the second electronic device 602 may be identified as a power supply device. After the first electronic device 601 is identified as a charging device and the second electronic device 602 is identified as a power supply device, the first electronic device 601 may send a ping command to the second electronic device 602 to confirm whether the first electronic device 601 and the second electronic device 602 are connected.
[0499] After receiving the ping command, the second electronic device 602 may send an ACK (hereinafter referred to as ACK0 ) to the first electronic device 601 to confirm receipt of the ping command.
[0500] After the first electronic device 601 receives ACK0, the first electronic device 601 and the second electronic device 602 may be charged through the charging protocol, that is, the first electronic device 601 may receive the power provided by the second electronic device 602 through the charging protocol.
[0501] When the first electronic device 601 receives power provided by the second electronic device 602 , when the user wants to trigger switching of the power role on the first electronic device 601 , the user can perform a switching operation in the first electronic device 601 .
[0502] like Fig.11 As shown, when the first electronic device 601 detects a switching operation, the first electronic device 601 may send a switching instruction A to the second electronic device 602 .
[0503] After receiving the switching instruction A, the second electronic device 602 may send an ACK A1 confirming receipt of the switching instruction A and an approval instruction A to the first electronic device 601 .
[0504] After receiving ACK A1 and the consent instruction A, the first electronic device 601 may return ACK A2 to the second electronic device 602 to confirm receipt of the consent instruction A.
[0505] After receiving the ACK A2 , the second electronic device 602 may adjust the output voltage of the second electronic device 602 to power off VBUS after a preset time T21 , and may switch the states of the first signal line and the second signal line in the second electronic device 602 .
[0506] After the first electronic device 601 returns ACK A2 to the second electronic device 602, the time A at which the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602 can be determined. The first electronic device 601 can first switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time T31 of the time A. Subsequently, the first electronic device 601 can adjust the output voltage of the first electronic device 601 after determining the preset time T1 at which the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device successfully shake hands, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0507] That is, after the first electronic device 601 switches the states of the first signal line and the second signal line in the first electronic device 601, it can be determined whether a high level is detected on the second signal line (i.e., RX of the first electronic device 601). When a high level is detected on the second signal line within the preset time T01, the first electronic device 601 can determine that the handshake between the first electronic device 601 and the second electronic device 602 is successful. After the preset time T1 is determined that the handshake is successful, the first electronic device 601 can adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0508] It is understandable that after the first electronic device 601 switches to a power supply device and the second electronic device 602 switches to a charging device, the second electronic device 602 can send a ping command to the first electronic device 601 to confirm whether the second electronic device 602 and the first electronic device 601 are connected.
[0509] After receiving the ping command, the first electronic device 601 may send an ACK (hereinafter referred to as ACK1 ) to the second electronic device 602 to confirm receipt of the ping command.
[0510] After the second electronic device 602 receives ACK1, the second electronic device 602 and the first electronic device 601 may be charged through the charging protocol, that is, the first electronic device 601 may provide power to the second electronic device 602 through the charging protocol.
[0511] See also Fig.12 , Fig.12 A schematic diagram of a power role switching system provided in an embodiment of the present application is shown. Figure 2 .
[0512] like Fig.12 As shown, the first electronic device 601 and the second electronic device 602 may include an interface, a protocol module A, a protocol module B, a system on chip (SOC), a power management module, an input module, and a battery, etc. It should be understood that the interface can match the charging cable, that is, the interface may include pins corresponding to the signal line, VBUS, CC, GND, etc. in the charging cable, so that the first electronic device 601 and the second electronic device 602 can be connected through the charging cable.
[0513] Among them, the protocol module A and / or the protocol module B can be used to provide the charging protocol used in the charging process (for example, a charging protocol based on CC or a charging protocol based on two signal lines, etc.). The power management module can be used to receive charging input to charge the battery, and can also be used for power output to provide power to other batteries. SOC can be used to control the process of receiving charging or the process of power output. The input module can be used to receive related operations input by the user.
[0514] The following will be combined Fig.12 The system shown and the first electronic device 601 detect a switching operation to exemplify the switching of power roles.
[0515] Initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable, at which time the first electronic device 601 can be identified as a charging device, and the second electronic device 602 can be identified as a power supply device. Subsequently, the first electronic device 601 and the second electronic device 602 can initiate a charging protocol handshake. When the charging protocol handshake is successful, the first electronic device 601 and the second electronic device 602 can enter a normal charging process, that is, the first electronic device 601 can receive the power provided by the second electronic device 602. It should be understood that when the charging protocol handshake fails, the first electronic device 601 and the second electronic device 602 can exit charging.
[0516] In the process of the first electronic device 601 receiving the electric energy provided by the second electronic device 602, when the user wants to trigger the switching of the power role on the first electronic device 601 side, the user can perform the switching operation in the first electronic device 601. That is, the input module of the first electronic device 601 (hereinafter referred to as the first input module) can detect the user operation in the first electronic device 601. When the first input module detects the user operation, the first input module can send relevant information corresponding to the user operation to the SOC of the first electronic device 601 (hereinafter referred to as the first SOC).
[0517] After the first SOC receives the relevant information corresponding to the user operation, it can determine whether the user operation is a switching operation for switching the power role. When it is determined that the user operation is a switching operation, the first SOC can determine whether the first electronic device 601 meets the switching condition A. When the first electronic device 601 meets the switching condition A, the first SOC can instruct the protocol module A or the protocol module B (hereinafter collectively referred to as the first protocol module) of the first electronic device 601 to send the switching instruction A to the second electronic device 602. When it is determined that the user operation is not a switching operation, or the first electronic device 601 does not meet the switching condition A, the first SOC will not instruct the first protocol module to send the switching instruction A, so that the first electronic device 601 can still be used as a charging device to receive the power provided by the second electronic device 602.
[0518] The protocol module A or the protocol module B (hereinafter collectively referred to as the second protocol module) of the second electronic device 602 can receive the switching instruction A sent by the first protocol module, and can parse the received switching instruction A to determine whether the switching instruction A sent by the first electronic device 601 is received, and can send the parsing result (i.e., whether the switching instruction A is received or not) to the SOC of the second electronic device 602 (hereinafter referred to as the second SOC).
[0519] Alternatively, after receiving the switching instruction A, the second protocol module may send the switching instruction A to the second SOC. After receiving the switching instruction A, the second SOC may parse the switching instruction A to determine whether the switching instruction A sent by the first electronic device 601 is received.
[0520] When receiving the switching instruction A sent by the first electronic device 601, the second SOC can instruct the second protocol module to send ACK A1 and consent instruction A to the first electronic device 601. It should be understood that when the switching instruction A sent by the first electronic device 601 is not received, the second SOC will not instruct the second protocol module to send ACK A1 and consent instruction A, so that the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0521] The first protocol module can receive ACK A1 and consent instruction A sent by the second protocol module, and can parse ACK A1 and consent instruction A to determine whether ACK A1 and consent instruction A returned by the second electronic device 602 are received, and can send the parsing result (i.e., ACK A1 and consent instruction A are received, or ACK A1 and consent instruction A are not received) to the first SOC.
[0522] Alternatively, after receiving ACK A1 and the consent instruction A, the first protocol module may send ACK A1 and the consent instruction A to the first SOC. After receiving ACK A1 and the consent instruction A, the first SOC may parse ACK A1 and the consent instruction A to determine whether ACK A1 and the consent instruction A returned by the second electronic device 602 are received.
[0523] When receiving ACK A1 and the consent instruction A returned by the second electronic device 602, the first protocol module may return ACK A2 to the second electronic device 602 to confirm receipt of the consent instruction A, or the first SOC may instruct the first protocol module to return ACK A2 to the second electronic device 602. When ACK A1 and the consent instruction A are not received, the first protocol module will not return ACK A2, or the first SOC will not instruct the first protocol module to return ACK A2, so that the first electronic device 601 can still serve as a charging device and receive the power provided by the second electronic device 602.
[0524] The second protocol module may receive ACK A2 returned by the first protocol module, and may parse ACK A2 to determine whether ACK A2 returned by the first electronic device 601 is received, and may send the parsing result (ie, ACK A2 is received or not received) to the second SOC.
[0525] Alternatively, after receiving ACK A2, the second protocol module may send ACK A2 to the second SOC. After receiving ACK A2, the second SOC may parse ACK A2 to determine whether ACK A2 returned by the first electronic device 601 is received.
[0526] After confirming receipt of ACK A2 returned by the first electronic device 601, the second SOC may instruct the power management module (hereinafter referred to as the second power management module) to adjust the output voltage of the second electronic device 602 after a preset time T21 to power off VBUS.
[0527] In addition, the second SOC may also instruct the second protocol module to switch the states of the first signal line and the second signal line in the second electronic device 602. Alternatively, the second protocol module may switch the states of the first signal line and the second signal line in the second electronic device 602 after receiving the ACK A2 returned by the first protocol module.
[0528] When ACK A2 is not received, the second SOC will not instruct the power management module to adjust the output voltage, and will not instruct the second protocol module to switch the state of the first signal line and the second signal line, so that the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0529] After the first protocol module returns ACK A2, the time A at which the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602 can be determined, and the state of the first signal line and the second signal line in the first electronic device 601 can be switched after a preset time T31 of the time A. Alternatively, after the first protocol module returns ACK A2, the first SOC can determine the time A at which the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602, and can instruct the first protocol module to switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time T31 of the time A.
[0530] Subsequently, the first SOC can instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands within a preset time T1, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0531] That is, after the first protocol module switches the states of the first signal line and the second signal line, the level on the second signal line (i.e., RX of the first electronic device 601) can be detected. When the first protocol module detects a high level on the second signal line within the preset time T01, the first protocol module can determine that the first electronic device 601 and the second electronic device 602 have successfully shaken hands, and send relevant information of the successful handshake to the first SOC. After determining the preset time T1 of the successful handshake, the first SOC can instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0532] Alternatively, after the first protocol module switches the states of the first signal line and the second signal line, the level on the second signal line can be detected and the detected level can be sent to the first SOC. The first SOC can determine whether a high level is detected within a preset time T01 based on the received level. When a high level is detected, the first SOC can determine that the handshake between the first electronic device 601 and the second electronic device 602 is successful, and after determining that the handshake is successful within the preset time T1, the first power management module can be instructed to adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0533] It should be understood that when the first protocol module does not detect a high level on the second signal line within the preset time T01, the first protocol module can determine that the handshake has failed. At this time, the first protocol module can restart the charging protocol handshake. When the restarted charging protocol handshake is successful, the first protocol module can send relevant information about the handshake success to the first SOC. After the first SOC determines that the handshake is successful, it can instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on.
[0534] Alternatively, when the first SOC determines that no high level is detected within the preset time T01 based on the received level, the first SOC may determine that the handshake has failed, and may instruct the first protocol module to restart the charging protocol handshake. When the restarted charging protocol handshake is successful, the first SOC may instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on.
[0535] When the restarted charging protocol handshake fails, the first SOC may exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0536] Whether the restarted handshake protocol is successful can be determined by the first protocol module or by the first SOC. For specific details, reference can be made to the related contents of whether the handshake is successful.
[0537] It is understandable that after the second protocol module switches the states of the first signal line and the second signal line, it can also detect the level on the first signal line (i.e., RX of the second electronic device 602). When the second protocol module detects a high level on the first signal line within the preset time T02, the second protocol module can determine that the second electronic device 602 as a charging device and the first electronic device 601 as a power supply device have successfully shaken hands, and send relevant information about the successful handshake to the second SOC. After determining that the second electronic device 602 and the first electronic device 601 have successfully shaken hands, the second SOC can instruct the second power management module to detect the voltage on VBUS.
[0538] After the second power management module detects the voltage on VBUS, it can determine whether the voltage on VBUS meets the preset conditions within the preset time T03, and can send the judgment result (i.e., whether the voltage on VBUS meets the preset conditions or does not meet the preset conditions within the preset time T03) to the second SOC. After receiving the judgment result, the second SOC can determine whether the voltage on VBUS meets the preset conditions within the preset time T03 according to the judgment result. When the voltage on VBUS meets the preset conditions within the preset time T03, the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second electronic device 602 can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0539] Alternatively, after the second power management module detects the voltage on VBUS, the detected voltage can be sent to the second SOC. The second SOC can determine whether the voltage on VBUS meets the preset condition within the preset time T03. When the voltage on VBUS meets the preset condition within the preset time T03, the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second electronic device 602 can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0540] Alternatively, after the second protocol module determines that the second electronic device 602 has successfully shaken hands with the first electronic device 601, the voltage on VBUS can be detected. After the second protocol module detects the voltage on VBUS, it can determine whether the voltage on VBUS meets the preset conditions within the preset time T03. When the voltage on VBUS meets the preset conditions within the preset time T03, the second protocol module can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second protocol module communicates with the first electronic device 601 through the charging protocol.
[0541] Alternatively, after the second protocol module detects the voltage on VBUS, the detected voltage can be sent to the second SOC. The second SOC can determine whether the voltage on VBUS meets the preset condition within the preset time T03. When the voltage on VBUS meets the preset condition within the preset time T03, the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second SOC can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0542] The preset condition may be determined according to the preset value B. For details, please refer to the description of the preset condition above.
[0543] Similarly, when the high level on the first signal line is not detected within the preset time T02 or the voltage on VBUS is not detected to meet the preset condition within the preset time T03 (i.e., the voltage on VBUS does not meet the preset condition within the preset time T03), the second protocol module or the second SOC can determine that the handshake fails. At this time, the second protocol module can restart the charging protocol handshake, or the second SOC can instruct the second protocol module to restart the charging protocol handshake. When the restarted charging protocol handshake is successful, and the voltage on VBUS is detected to meet the preset condition within the preset time T03 after the handshake is successful, the second protocol module or the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second protocol module can communicate with the first electronic device 601 through the charging protocol, or the second SOC can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0544] When the restarted charging protocol handshake fails, the second SOC may exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0545] Whether the restarted handshake protocol is successful can be determined by the second protocol module or by the second SOC. For specific details, please refer to the above-mentioned contents related to whether the handshake is successful.
[0546] (ii) The second electronic device 602 triggers switching of the power source role during the charging process according to the switching operation detected by the second electronic device 602
[0547] When the first electronic device 601 is a charging device and the second electronic device 602 is a power supply device, that is, the second electronic device 602 provides power to the first electronic device 601, when the user wants to trigger the switching of the power role on the second electronic device 602, the user can perform the switching operation in the second electronic device 602, for example, by clicking Figure 7 The "Yes" button 7021 shown in (b) in the figure. After the second electronic device 602 detects the switching operation, it can be determined that the power role in the charging process needs to be switched. At this time, the second electronic device 602 can send a switching instruction (hereinafter referred to as switching instruction B) to the first electronic device 601. That is, the second electronic device 602 can send the switching instruction B to the first electronic device 601 through the first signal line. The switching instruction B is used to request that the first electronic device 601 be switched to a power supply device to achieve the switching of the power role during the charging process.
[0548] It should be understood that when the second electronic device 602 detects a switching operation, the output voltage of the second electronic device 602 can be adjusted. For example, the output voltage of the second electronic device 602 can be adjusted to a preset value A so that VBUS is powered off, thereby causing the second electronic device 602 to stop providing power to the first electronic device 601 through VBUS.
[0549] At the same time, the second electronic device 602 can switch the states of the first signal line and the second signal line in the second electronic device 602, that is, exchange RX and TX of the second electronic device 602. For example, initially, for the second electronic device 602, the first signal line can be TX, and the second signal line can be RX. After switching the states of the first signal line and the second signal line in the second electronic device 602, the first signal line can be RX, and the second signal line can be TX.
[0550] In one example, after the first electronic device 601 receives the switching instruction B, the state of the first signal line and the second signal line in the first electronic device 601 can be switched, that is, the RX and TX of the first electronic device 601 are exchanged. For example, initially, for the first electronic device 601, the first signal line can be RX, and the second signal line can be TX. After the state of the first signal line and the second signal line in the first electronic device 601 is switched, the first signal line can be TX, and the second signal line can be RX.
[0551] The first electronic device 601 can also adjust the output voltage of the first electronic device 601. For example, the output voltage of the first electronic device 601 can be adjusted to a preset value B so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0552] Exemplarily, in order to avoid power supply conflicts on VBUS and ensure effective switching of power roles, the first electronic device 601 can detect the level on the second signal line (i.e., RX after switching) after switching the states of the first signal line and the second signal line. When the first electronic device 601 detects a high level on the second signal line within the preset time T01, the first electronic device 601 can determine that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands. At this time, the first electronic device 601 can adjust the output voltage of the first electronic device 601 to the preset value B after determining the preset time T1 that the first electronic device 601 and the second electronic device 602 have successfully shaken hands, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0553] That is to say, after receiving the switching instruction B, the first electronic device 601 can first switch the states of the first signal line and the second signal line, and after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands within a preset time T1, the output voltage of the first electronic device 601 can be adjusted to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, thereby ensuring effective switching of power roles.
[0554] Among them, when the first electronic device 601 does not detect a high level on the second signal line within the preset time T01, the charging handshake protocol handshake can be restarted. When the restarted charging protocol handshake is successful, the first electronic device 601 can adjust the output voltage of the first electronic device 601 so that VBUS is powered on. When the restarted charging protocol handshake fails, the first electronic device 601 can exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0555] It should be understood that after the second electronic device 602 switches the states of the first signal line and the second signal line, it can detect the level on the first signal line (i.e., RX after switching). When the second electronic device 602 detects a high level on the first signal line within the preset time T02, the second electronic device 602 can determine that the second electronic device 602 as a charging device and the first electronic device 601 as a power supply device have successfully shaken hands. After the second electronic device 602 determines that the second electronic device 602 and the first electronic device 601 have successfully shaken hands, the second electronic device 602 can detect whether the voltage on VBUS meets the preset conditions. When the second electronic device 602 detects that the voltage on VBUS meets the preset conditions within the preset time T03, the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, and the charging protocol communication can be performed, that is, the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0556] When the second electronic device 602 does not detect a high level on the first signal line within the preset time T02, or the second electronic device 602 detects that the voltage on VBUS does not meet the preset conditions within the preset time T03, the second electronic device 602 can restart the charging protocol handshake to determine whether to receive the power provided by the first electronic device 601 based on the restarted charging protocol handshake.
[0557] The preset condition may be determined according to the preset value B. The specific method of determining the preset condition may be determined according to the actual scenario, and the embodiment of the present application does not impose any specific restrictions on this. Optionally, a voltage interval may be determined according to the preset value B, and the preset condition may be that the voltage is within the voltage interval.
[0558] For example, when the preset value B is 5V, the preset condition can be determined as the voltage being between [4.5V, 5.5V]. That is, when the second electronic device 602 detects that the voltage on VBUS is between [4.5V, 5.5V], for example, when the voltage on VBUS is detected to be 5.2V, the second electronic device 602 can determine that the voltage on VBUS meets the preset condition. When the second electronic device 602 detects that the voltage on VBUS is not between [4.5V, 5.5V], for example, when the voltage on VBUS is detected to be 2V, the second electronic device 602 can determine that the voltage on VBUS does not meet the preset condition.
[0559] For example, when the preset value B is 10V, the preset condition can be determined as the voltage being between [8.5V, 11.5V]. That is, when the second electronic device 602 detects that the voltage on VBUS is between [8.5V, 11.5V], for example, when the voltage on VBUS is detected to be 10.2V, the second electronic device 602 can determine that the voltage on VBUS meets the preset condition. When the second electronic device 602 detects that the voltage on VBUS is not between [8.5V, 11.5V], for example, when the voltage on VBUS is detected to be 2V, the second electronic device 602 can determine that the voltage on VBUS does not meet the preset condition.
[0560] For example, when the preset value B is 15V, the preset condition can be determined as the voltage being between [12V, 16V]. That is, when the second electronic device 602 detects that the voltage on VBUS is between [12V, 16V], for example, when the voltage on VBUS is detected to be 14V, the second electronic device 602 can determine that the voltage on VBUS meets the preset condition. When the second electronic device 602 detects that the voltage on VBUS is not between [12V, 16V], for example, when the voltage on VBUS is detected to be 5V, the second electronic device 602 can determine that the voltage on VBUS does not meet the preset condition.
[0561] In another example, after the first electronic device 601 receives the switching instruction B, it can first determine whether the first electronic device 601 meets the switching condition (hereinafter referred to as switching condition B), that is, determine whether the first electronic device 601 can be switched to a power supply device, so that when the first electronic device 601 meets the switching condition B, the power role can be switched to ensure the effectiveness of the power role switching and improve the user experience.
[0562] It is understandable that the switching condition B can be specifically determined according to the actual scenario, and the embodiment of the present application does not impose any limitation on this. For example, according to the actual scenario, the switching condition B can be determined to include at least one of power, battery temperature, cable impedance, voltage and current accuracy, and port leakage current.
[0563] For example, the switching condition B may be that the power level is greater than a preset power level (hereinafter referred to as preset power level B). The power level and the preset power level B may be represented by a percentage of the battery capacity. For example, the preset power level B may be 70% of the battery capacity. That is, when the first electronic device 601 determines that the power level of the first electronic device 601 is less than or equal to the preset power level B, for example, when the power level of the first electronic device 601 is 90%, the first electronic device 601 may determine that the first electronic device 601 satisfies the switching condition B.
[0564] For example, the switching condition B may be that the battery temperature is less than or equal to a preset temperature (hereinafter referred to as preset temperature B). For example, the preset temperature B may be 20 degrees. That is, when the first electronic device 601 determines that the battery temperature of the first electronic device 601 is less than or equal to 20 degrees, the first electronic device 601 may determine that the first electronic device 601 meets the switching condition B.
[0565] For example, the switching condition B may be that the power level is greater than a preset power level B, and the battery temperature is less than or equal to a preset temperature B. That is, when the first electronic device 601 determines that the power level of the first electronic device 601 is greater than the preset power level B, and the battery temperature of the first electronic device 601 is less than or equal to the preset temperature B, the first electronic device 601 may determine that the first electronic device 601 satisfies the switching condition B.
[0566] When the first electronic device 601 meets the switching condition B, the first electronic device 601 can send an ACK (hereinafter referred to as ACK B1) confirming the receipt of the switching instruction B, and an approval instruction (hereinafter referred to as approval instruction B) for approving the switching to the second electronic device 602. That is, the first electronic device 601 can send the ACK B1 and the approval instruction B to the second electronic device through the second signal line (ie, TX in the first electronic device 601).
[0567] Exemplarily, after receiving the ACK B1 and the consent instruction B returned by the first electronic device 601, the second electronic device 602 can adjust the output voltage of the second electronic device 602 to power off the VBUS, so that the second electronic device 602 stops supplying power, so that the second electronic device 602 no longer provides power to the first electronic device 601 through the VBUS. In addition, the second electronic device 602 can also switch the states of the first signal line and the second signal line in the second electronic device 602.
[0568] After the first electronic device 601 sends ACK B1 and consent instruction B to the second electronic device 602, the state of the first signal line and the second signal line in the first electronic device 601 can be switched, and the output voltage of the first electronic device 601 can be adjusted to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0569] Exemplarily, after receiving ACKB1 and the consent instruction B returned by the first electronic device 601, the second electronic device 602 may return an ACK (hereinafter referred to as ACK B2) to the first electronic device 601 to confirm receipt of the consent instruction B. That is, the second electronic device 602 may send ACK B2 to the first electronic device 601 via the first signal line (i.e., TX in the second electronic device 602).
[0570] After receiving the ACK B1 and the consent instruction B returned by the first electronic device 601, or returning the ACK B2 to the first electronic device 601, the second electronic device 602 can adjust the output voltage of the second electronic device 602 to power off the VBUS, so that the second electronic device 602 stops providing power to the first electronic device 601. The second electronic device 602 can also switch the state of the first signal line and the second signal line in the second electronic device 602.
[0571] Alternatively, since the first electronic device 601 needs time to parse ACK B2 to determine whether it is indeed necessary to switch the power role, in order to ensure accurate switching of the power role, the second electronic device 602 can adjust the output voltage of the second electronic device 602 after returning to the preset time of ACKB2 (hereinafter referred to as the preset time T22) to stop power supply and switch the states of the first signal line and the second signal line in the second electronic device 602.
[0572] After the first electronic device 601 receives ACK B2 returned by the second electronic device 602, the state of the first signal line and the second signal line in the first electronic device 601 can be switched, and the output voltage of the first electronic device 601 can be adjusted to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 via VBUS.
[0573] Optionally, after the first electronic device 601 receives ACK B2 returned by the second electronic device 602, it can first switch the states of the first signal line and the second signal line in the first electronic device 601, and after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands within a preset time T1, adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0574] Optionally, after the first electronic device 601 receives the ACK B2 returned by the second electronic device 602, it can determine the time A when the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602. Subsequently, the first electronic device 601 can switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time (hereinafter referred to as the preset time T32) of the time A, and adjust the output voltage of the first electronic device 601. In other words, the first electronic device 601 can switch the first electronic device 601 to a power supply device after the second electronic device 602 determines to switch roles, that is, after the second electronic device 602 switches to a charging device, so as to effectively ensure the accuracy of the power role switching.
[0575] Exemplarily, the first electronic device 601 may first switch the states of the first signal line and the second signal line in the first electronic device 601 after the preset time T32 of the time A. Subsequently, the first electronic device 601 may adjust the output voltage of the first electronic device 601 after determining that the handshake between the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device is successful for the preset time T1, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, thereby reducing power supply conflicts on VBUS.
[0576] It should be noted that the values of the preset time T22 and the preset time T32 can be specifically determined according to the actual scenario, and the embodiment of the present application does not limit this. For example, the preset time T22 can be set to any value such as 2ms, 5ms or 10ms according to the actual scenario. For example, the preset time T32 can be set to any value such as 3ms, 5ms or 10ms according to the actual scenario.
[0577] It is understandable that when the first electronic device 601 does not meet the switching condition B, the first electronic device 601 can refuse to switch the power role and can send a rejection instruction (hereinafter referred to as rejection instruction B) to the second electronic device 602. That is, the first electronic device 601 can send the rejection instruction B to the second electronic device 602 through the second signal line. When the second electronic device 602 receives the rejection instruction B returned by the first electronic device 601, it can be determined that the first electronic device 601 refuses to switch the power role. At this time, the second electronic device 602 will not switch the state of the first signal line and the second signal line in the second electronic device 602, and the first electronic device 601 will not switch the state of the first signal line and the second signal line in the first electronic device 601, so that the first electronic device 601 can still be used as a charging device and the second electronic device 602 can still be used as a power supply device.
[0578] It should be noted that the format and / or content of the approval instruction B may be the same or different from that of the approval instruction A. The format and / or content of ACK B1, ACK B2, ACK A1 and ACK A2 may be the same or different.
[0579] See also Fig.13 , Fig.13 A schematic flow chart of a method for switching power roles provided by another embodiment of the present application is shown. This embodiment is exemplified by detecting a switching operation in the second electronic device 602 to switch the power roles.
[0580] like Fig.13As shown, initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable, at which time the first electronic device 601 can be identified as a charging device, and the second electronic device 602 can be identified as a power supply device. Subsequently, the first electronic device 601 and the second electronic device 602 can initiate a charging protocol handshake. When the charging protocol handshake is successful, the first electronic device 601 and the second electronic device 602 can enter a normal charging process, that is, the second electronic device 602 can provide power to the first electronic device 601. It should be understood that when the charging protocol handshake fails, the first electronic device 601 and the second electronic device 602 can exit charging.
[0581] like Fig.13 As shown, in the process of the second electronic device 602 providing power to the first electronic device 601, when the user wants to trigger the switching of the power role on the second electronic device 602 side, the user can perform the switching operation in the second electronic device 602. That is, the second electronic device 602 can detect the switching operation in the second electronic device 602. When the switching operation is detected, the second electronic device 602 can send a switching instruction B to the first electronic device 601. When the switching operation is not detected, the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0582] The first electronic device 601 may determine whether the switching instruction B sent by the second electronic device 602 is received.
[0583] When receiving the switching instruction B, the first electronic device 601 may first determine whether the first electronic device 601 meets the switching condition B. When the first electronic device 601 meets the switching condition B, the first electronic device 601 may send ACK B1 and the approval instruction B to the second electronic device 602. When the first electronic device 601 does not meet the switching condition B, the first electronic device 601 may send a rejection instruction B to the second electronic device 602. At this time, the first electronic device 601 can still serve as a charging device and receive the power provided by the second electronic device 602.
[0584] It should be understood that when the first electronic device 601 does not receive the switching instruction B, the first electronic device 601 can still serve as a charging device and receive power provided by the second electronic device 602 .
[0585] The second electronic device 602 may determine whether the ACK B1 and the approval instruction B returned by the first electronic device 601 are received.
[0586] When receiving ACK B1 and the consent instruction B returned by the first electronic device 601, the second electronic device 602 can return ACK B2 to the first electronic device 601 to confirm receipt of the consent instruction B. When ACK B1 and the consent instruction B are not received, the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0587] The second electronic device 602 may adjust the output voltage of the second electronic device 602 after a preset time T22 of returning ACK B2 to the first electronic device 601, so that VBUS is powered off, thereby causing the second electronic device 602 to stop providing power to the first electronic device 601. In addition, the second electronic device 602 may also switch the states of the first signal line and the second signal line in the second electronic device 602.
[0588] The first electronic device 601 may determine whether ACK B2 returned by the second electronic device 602 is received.
[0589] When receiving ACK B2, the first electronic device 601 can determine the time A when the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602, and can first switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time T32 of the time A. Subsequently, the first electronic device 601 can adjust the output voltage of the first electronic device 601 after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands at a preset time T1, so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0590] It should be understood that after the second electronic device 602 switches the state of the first signal line and the second signal line, it can also determine whether the second electronic device 602 and the first electronic device 601 have successfully shaken hands, and after determining that the handshake is successful, detect whether the voltage on VBUS meets the preset conditions, so as to determine whether the second electronic device 602 and the first electronic device 601 can be charged through the charging protocol, that is, whether the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0591] The specific contents of determining whether the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands and whether the voltage on VBUS detected by the second electronic device 602 meets the preset conditions can be referred to. Fig. 9 The specific description in will not be repeated here.
[0592] It should be understood that when the ACK B2 is not received, the first electronic device 601 can still function as a charging device and receive power provided by the second electronic device 602 .
[0593] See also Fig.14 , Fig.14 A schematic diagram of signal switching in power role switching provided by another embodiment of the present application is shown. Fig.14 by Fig.13 The switching of the power roles shown is taken as an example for illustrative description.
[0594] like Fig.14 As shown, initially, during the charging process when the first electronic device 601 is a charging device and the second electronic device 602 is a power supply device, for the first electronic device 601, the first signal line can be RX and the second signal line can be TX; for the second electronic device 602, the first signal line can be TX and the second signal line can be RX.
[0595] When the second electronic device 602 detects the switching operation, the second electronic device 602 may send a switching instruction B to the first electronic device 601 through the first signal line.
[0596] After receiving the switching instruction B, the first electronic device 601 can determine whether the first electronic device 601 meets the switching condition B. When the first electronic device 601 meets the switching condition B, the first electronic device 601 can send ACK B1 and the approval instruction B to the second electronic device 602 through the second signal line.
[0597] The second electronic device 602 receives the ACK B1 and the approval instruction B, and may send an ACK B2 to the first electronic device 601 through the first signal line.
[0598] After the preset time T22 when the second electronic device 602 sends ACK B2, the first electronic device 601 and the second electronic device 602 can start to adjust the output voltage and adjust the state of the first signal line and the second signal line, so that the second electronic device 602 stops supplying power and the first electronic device 601 starts supplying power.
[0599] like Fig.14As shown, after exchanging TX and RX of the second electronic device 602, the second electronic device 602 can determine whether a high level is detected on the first signal line within the preset time T02. When the second electronic device 602 detects a high level on the first signal line within the preset time T02, the second electronic device 602 can determine that the second electronic device 602 has successfully shaken hands with the first electronic device 601. After determining that the second electronic device 602 has successfully shaken hands with the first electronic device 601, the second electronic device 602 can detect whether the voltage on VBUS meets the preset condition. When it is detected that the voltage on VBUS meets the preset condition within the preset time T03, the second electronic device 602 can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol, so that the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0600] It should be noted that in the power role switching, the changes of the first signal line, the second signal line and the power supply changes on VBUS can be seen in Fig.10 As shown in (b) in the figure, no further details will be given here.
[0601] The following will be combined Fig.12 The system shown and the detection of the switching operation at the second electronic device 602 are used to exemplify the switching of the power roles.
[0602] Initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable, at which time the first electronic device 601 can be identified as a charging device, and the second electronic device 602 can be identified as a power supply device. Subsequently, the first electronic device 601 and the second electronic device 602 can initiate a charging protocol handshake. When the charging protocol handshake is successful, the first electronic device 601 and the second electronic device 602 can enter a normal charging process, that is, the second electronic device 602 can provide power to the first electronic device 601. It should be understood that when the charging protocol handshake fails, the first electronic device 601 and the second electronic device 602 can exit charging.
[0603] In the process of the second electronic device 602 providing power to the first electronic device 601, when the user wants to trigger the switching of the power role on the second electronic device 602 side, the user can perform the switching operation in the second electronic device 602. That is, the input module of the second electronic device 602 (hereinafter referred to as the second input module) can detect the user operation in the second electronic device 602. When the second input module detects the user operation, the second input module can send relevant information corresponding to the user operation to the second SOC of the second electronic device 602.
[0604] After receiving the relevant information corresponding to the user operation, the second SOC can determine whether the user operation is a switching operation for switching the power role. When it is determined that the user operation is a switching operation, the second SOC can instruct the second protocol module to send a switching instruction B to the first electronic device 601. When no switching operation is detected, the second SOC will not instruct the second protocol module to send the switching instruction B, so that the second electronic device 602 can still provide power to the first electronic device 601 as a power supply device.
[0605] The first protocol module of the first electronic device 601 can receive the switching instruction B sent by the second protocol module, and can parse the received switching instruction B to determine whether the switching instruction B sent by the second electronic device 602 is received, and can send the parsing result (i.e., whether the switching instruction B is received or not) to the first SOC of the first electronic device 601.
[0606] Alternatively, after receiving the switching instruction B, the first protocol module may send the switching instruction B to the first SOC. After receiving the switching instruction B, the first SOC may parse the switching instruction B to determine whether the switching instruction B sent by the second electronic device 602 is received.
[0607] When receiving the switching instruction B sent by the second electronic device 602, the first SOC can determine whether the first electronic device 601 meets the switching condition B. When the first electronic device 601 meets the switching condition B, the first SOC can instruct the first protocol module to send ACK B1 and the approval instruction B to the second electronic device 602. When the first electronic device 601 does not meet the switching condition B, the first SOC can instruct the first protocol module to send a rejection instruction B to the second electronic device 602. At this time, the first electronic device 601 can still serve as a charging device and receive the power provided by the second electronic device 602.
[0608] It should be understood that when the first electronic device 601 does not receive the switching instruction B sent by the second electronic device 602 , the first electronic device 601 can still serve as a charging device and receive power provided by the second electronic device 602 .
[0609] The second protocol module can receive ACK B1 and consent instruction B sent by the first protocol module, and can parse ACK B1 and consent instruction B to determine whether ACK A1 and consent instruction A returned by the first electronic device 601 are received, and can send the parsing result (i.e., ACK B1 and consent instruction B are received, or ACK B1 and consent instruction B are not received) to the second SOC.
[0610] Alternatively, after receiving ACK B1 and the consent instruction B, the second protocol module may send ACK B1 and the consent instruction B to the second SOC. After receiving ACK B1 and the consent instruction B, the second SOC may parse ACK B1 and the consent instruction B to determine whether ACK B1 and the consent instruction B returned by the first electronic device 601 are received.
[0611] When receiving ACK B1 and the consent instruction B returned by the first electronic device 601, the second protocol module may return ACK B2 to the first electronic device 601 to confirm receipt of the consent instruction B, or the second SOC may instruct the second protocol module to return ACK B2 to the first electronic device 601. When ACK B1 and the consent instruction B are not received, the second protocol module will not return ACK B2, or the second SOC will not instruct the second protocol module to return ACK B2, so that the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0612] After a preset time T22 of returning ACK B2 to the first electronic device 601, the second SOC may instruct the second power management module to adjust the output voltage of the second electronic device 602 so that VBUS is powered off, thereby causing the second electronic device 602 to stop providing power to the first electronic device 601. In addition, the second protocol module may switch the state of the first signal line and the second signal line in the second electronic device 602. Alternatively, the second SOC may also instruct the second protocol module to switch the state of the first signal line and the second signal line in the second electronic device 602.
[0613] The first protocol module may receive the ACK B2 sent by the second protocol module, and may parse the ACK B2 to determine whether the ACK B2 returned by the second electronic device 602 is received, and may send the parsing result (i.e., whether the ACK B2 is received or not received) to the first SOC. Alternatively, after the first protocol module receives the ACK B2, the ACK B2 may be sent to the first SOC. After the first SOC receives the ACK B2, the ACK B2 may be parsed to determine whether the ACK B2 returned by the second electronic device 602 is received.
[0614] When receiving the ACK B2 returned by the second electronic device 602, the first protocol module can determine the time A when the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602, and can switch the state of the first signal line and the second signal line in the first electronic device 601 after the preset time T32 of the time A. Alternatively, the first SOC can determine the time A when the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602, and can instruct the first protocol management module to switch the state of the first signal line and the second signal line in the first electronic device 601 after the preset time T32 of the time A.
[0615] Subsequently, after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully shaken hands within a preset time T1, the first SOC can instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0616] That is, after the first protocol module switches the states of the first signal line and the second signal line, the level on the second signal line can be detected. When the first protocol module detects a high level on the second signal line within the preset time T01, the first protocol module can determine that the handshake between the first electronic device 601 and the second electronic device 602 is successful, and sends relevant information of the successful handshake to the first SOC. After determining the preset time T1 of the successful handshake, the first SOC can instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0617] Alternatively, after the first protocol module switches the states of the first signal line and the second signal line, the level on the second signal line can be detected and the detected level can be sent to the first SOC. The first SOC can determine whether a high level is detected within a preset time T01 based on the received level. When a high level is detected, the first SOC can determine that the handshake between the first electronic device 601 and the second electronic device 602 is successful, and after determining that the handshake is successful within the preset time T1, the first power management module can be instructed to adjust the output voltage of the first electronic device 601 so that VBUS is powered on, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0618] It should be understood that when the first protocol module does not detect a high level on the second signal line within the preset time T01, the first protocol module may determine that the handshake has failed, and at this time, the first protocol module may restart the charging protocol handshake. When the restarted charging protocol handshake is successful, the first protocol module may send relevant information about the handshake success to the first SOC. The first SOC may instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on.
[0619] Alternatively, when the first SOC determines that no high level is detected within the preset time T01 based on the received level, the first SOC may determine that the handshake has failed, and may instruct the first protocol module to restart the charging protocol handshake. When the restarted charging protocol handshake is successful, the first SOC may instruct the first power management module to adjust the output voltage of the first electronic device 601 so that VBUS is powered on.
[0620] When the restarted charging protocol handshake fails, the first SOC may exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0621] Whether the restarted handshake protocol is successful can be determined by the first protocol module or by the first SOC. For specific details, reference can be made to the related contents of whether the handshake is successful.
[0622] It is understandable that after the second protocol module switches the states of the first signal line and the second signal line, it can also detect the level on the first signal line. When the second protocol module detects a high level on the first signal line within the preset time T02, the second protocol module can determine that the second electronic device 602 as a charging device and the first electronic device 601 as a power supply device have successfully shaken hands, and send relevant information about the successful handshake to the second SOC. After determining that the second electronic device 602 and the first electronic device 601 have successfully shaken hands, the second SOC can instruct the second power management module to detect the voltage on VBUS.
[0623] After the second power management module detects the voltage on VBUS, it can determine whether the voltage on VBUS meets the preset conditions within the preset time T03, and can send the judgment result (i.e., whether the voltage on VBUS meets the preset conditions or does not meet the preset conditions within the preset time T03) to the second SOC. After receiving the judgment result, the second SOC can determine whether the voltage on VBUS meets the preset conditions within the preset time T03 according to the judgment result. When the voltage on VBUS meets the preset conditions within the preset time T03, the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second electronic device 602 can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0624] Alternatively, after the second power management module detects the voltage on VBUS, the detected voltage can be sent to the second SOC. The second SOC can determine whether the voltage on VBUS meets the preset condition within the preset time T03. When the voltage on VBUS meets the preset condition within the preset time T03, the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second electronic device 602 can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0625] Alternatively, after the second protocol module determines that the second electronic device 602 has successfully shaken hands with the first electronic device 601, the voltage on VBUS can be detected. After the second protocol module detects the voltage on VBUS, it can determine whether the voltage on VBUS meets the preset conditions within the preset time T03. When the voltage on VBUS meets the preset conditions within the preset time T03, the second protocol module can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second protocol module can communicate with the first electronic device 601 through the charging protocol.
[0626] Alternatively, after the second protocol module detects the voltage on VBUS, the detected voltage can be sent to the second SOC. The second SOC can determine whether the voltage on VBUS meets the preset conditions within the preset time T03. When the voltage on VBUS meets the preset conditions within the preset time T03, the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second electronic device 602 can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0627] The preset condition may be determined according to the preset value B. For details, please refer to the description of the preset condition above.
[0628] Similarly, when the high level on the first signal line is not detected within the preset time T02 or the voltage on VBUS is not detected to meet the preset condition within the preset time T03 (i.e., the voltage on VBUS does not meet the preset condition within the preset time T03), the second protocol module or the second SOC can determine that the handshake fails. At this time, the second protocol module can restart the charging protocol handshake, or the second SOC can instruct the second protocol module to restart the charging protocol handshake. When the restarted charging protocol handshake is successful, and the voltage on VBUS is detected to meet the preset condition within the preset time T03 after the handshake is successful, the second protocol module or the second SOC can determine that the power supply connection between the second electronic device 602 and the first electronic device 601 is successful, that is, it is determined that the second electronic device 602 can communicate with the first electronic device 601 through the charging protocol. At this time, the second protocol module can communicate with the first electronic device 601 through the charging protocol, or the second SOC can instruct the second protocol module to communicate with the first electronic device 601 through the charging protocol.
[0629] When the restarted charging protocol handshake fails, the second SOC may exit charging, so that the charging process between the first electronic device 601 and the second electronic device 602 is terminated.
[0630] Whether the restarted handshake protocol is successful can be determined by the second protocol module or by the second SOC. For specific details, please refer to the above-mentioned contents related to whether the handshake is successful.
[0631] It should be understood that when the ACK B2 is not received, the first electronic device 601 can still function as a charging device and receive power provided by the second electronic device 602 .
[0632] In one possible implementation, Figure 6As shown in (b), the charging cable may also include a CC, that is, the first electronic device 601 and the second electronic device 602 may also be connected via a CC. When the first electronic device 601 or the second electronic device 602 detects a switching operation, the first electronic device 601 may switch the level state of the CC in the first electronic device 601, and the second electronic device 602 may also switch the level state of the CC in the second electronic device 602.
[0633] It is understandable that the first electronic device 601 and the second electronic device 602 may include a pin corresponding to CC (e.g., CC1). The first electronic device 601 can adjust the level state of CC in the first electronic device 601 by adjusting CC1 in the first electronic device 601. Similarly, the second electronic device 602 can adjust the level state of CC in the second electronic device 602 by adjusting CC1 in the second electronic device 602.
[0634] For example, initially, the first electronic device 601 may be a charging device, and the second electronic device 602 may be a power supply device. At this time, CC1 in the first electronic device 601 may be pulled down through a resistor Rd to generate a pull-down signal. CC1 in the second electronic device 602 may be pulled up through a resistor Rp to generate a pull-up signal. When a switching operation is detected, the first electronic device 601 may pull up CC1 of the first electronic device 601 through a resistor Rp to generate a pull-up signal. The second electronic device 602 may pull down CC1 of the second electronic device 602 through a resistor Rd to generate a pull-down signal.
[0635] In one example, when the first electronic device 601 and the second electronic device 602 are still connected via CC, the first electronic device 601 and the second electronic device 602 can still adjust the output voltage of the first electronic device 601 and the output voltage of the second electronic device 602 through relevant instructions received on the first signal line and the second signal line (see the above description for details), thereby adjusting the power roles during the charging process.
[0636] In another example, when the first electronic device 601 and the second electronic device 602 are still connected via CC, the first electronic device 601 can determine the charging state of the second electronic device 602 according to the level state of CC in the first electronic device 601, that is, the signal detected by the first electronic device 601 on CC. Similarly, the second electronic device 602 can also determine the charging state of the first electronic device 601 according to the level state of CC in the second electronic device 602, that is, the signal detected by the second electronic device 602 on CC. Therefore, the first electronic device 601 and the second electronic device 602 can adjust the output voltage according to their own charging state and the charging state of each other, thereby adjusting the power role in the charging process.
[0637] That is, in this embodiment, when it is necessary to switch the power role, that is, when the switching operation is detected, the first electronic device 601 and the second electronic device 602 can adjust the power role according to the charging protocol based on CC communication, that is, switch the charging state of the first electronic device 601 and the second electronic device 602, and adjust the power supply on VBUS according to the charging state of the first electronic device 601 and the second electronic device 602. At the same time, the first electronic device 601 can switch the state of the first signal line and the second signal line in the first electronic device 601 according to the relevant instructions transmitted by the first signal line and the second signal line. The second electronic device 602 can also switch the state of the first signal line and the second signal line in the second electronic device 602 according to the relevant instructions transmitted by the first signal line and the second signal line.
[0638] It should be understood that the first electronic device 601 determines the charging state of the second electronic device 602 according to the signal detected on the CC, and the second electronic device 602 determines the charging state of the first electronic device 601 according to the signal detected on the CC. Figures 1 to 3 The relevant description in will not be repeated here.
[0639] See also Fig.15 , Fig.15 A schematic flow chart of a method for switching power roles provided by another embodiment of the present application is shown. This embodiment is exemplified by taking the case where a switching operation is detected in the second electronic device 602 to switch the power roles.
[0640] like Fig.15 As shown, initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable, at which time the first electronic device 601 can be identified as a charging device, and the second electronic device 602 can be identified as a power supply device. Subsequently, the first electronic device 601 and the second electronic device 602 can initiate a charging protocol handshake. When the charging protocol handshake is successful, the first electronic device 601 and the second electronic device 602 can enter a normal charging process, that is, the second electronic device 602 can provide power to the first electronic device 601. It should be understood that when the charging protocol handshake fails, the first electronic device 601 and the second electronic device 602 can exit charging.
[0641] like Fig.15 As shown, in the process that the second electronic device 602 provides power to the first electronic device 601, when the user wants to trigger the switching of the power role on the second electronic device 602 side, the user can perform the switching operation in the second electronic device 602. That is, the second electronic device 602 can detect the switching operation in the second electronic device 602.
[0642] When the switching operation is detected, the second electronic device 602 can adjust the level state of CC to switch the role according to the switching operation, that is, switch the level state of CC in the second electronic device 602. The first electronic device 601 can adjust the level state of CC to switch the role according to the switching operation, that is, switch the level state of CC in the first electronic device 601, so as to adjust the charging state of the first electronic device 601 and the second electronic device 602, thereby adjusting the power role in the charging process, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS.
[0643] In addition, the second electronic device 602 may also send a switching instruction B to the first electronic device 601 .
[0644] It should be understood that when no switching operation is detected, the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601 .
[0645] The first electronic device 601 may determine whether the switching instruction B sent by the second electronic device 602 is received.
[0646] When receiving the switching instruction B, the first electronic device 601 may first determine whether the first electronic device 601 meets the switching condition B. When the first electronic device 601 meets the switching condition B, the first electronic device 601 may send ACK B1 and the approval instruction B to the second electronic device 602. When the first electronic device 601 does not meet the switching condition B, the first electronic device 601 may send a rejection instruction B to the second electronic device 602. At this time, the first electronic device 601 can still serve as a charging device and receive the power provided by the second electronic device 602.
[0647] It should be understood that when the first electronic device 601 does not receive the switching instruction B, the first electronic device 601 can still serve as a charging device and receive power provided by the second electronic device 602 .
[0648] The second electronic device 602 may determine whether the ACK B1 and the approval instruction B returned by the first electronic device 601 are received.
[0649] When receiving ACK B1 and the consent instruction B returned by the first electronic device 601, the second electronic device 602 can return ACK B2 to the first electronic device 601 to confirm receipt of the consent instruction B. When ACK B1 and the consent instruction B are not received, the second electronic device 602 can still serve as a power supply device to provide power to the first electronic device 601.
[0650] The second electronic device 602 may switch the states of the first signal line and the second signal line in the second electronic device 602 after a preset time T22 of returning the ACK B2 to the first electronic device 601 .
[0651] The first electronic device 601 may determine whether ACK B2 returned by the second electronic device 602 is received.
[0652] When receiving ACK B2, the first electronic device 601 can determine the time A when the second electronic device 602 switches the state of the first signal line and the second signal line in the second electronic device 602, and can switch the state of the first signal line and the second signal line in the first electronic device 601 after a preset time T32 of time A.
[0653] Subsequently, after determining that the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device have successfully handshaked, and the second electronic device 602 detects that the voltage on VBUS meets the preset conditions within the preset time T03, the first electronic device 601 and the second electronic device 602 can be charged through the charging protocol.
[0654] The specific contents of determining whether the handshake between the first electronic device 601 as a power supply device and the second electronic device 602 as a charging device is successful and whether the voltage on VBUS meets the preset conditions can be referred to. Fig. 9 The specific description in will not be repeated here.
[0655] It should be noted that, when the ACK B2 is not received, the first electronic device 601 can still serve as a charging device and receive power provided by the second electronic device 602 .
[0656] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0657] Corresponding to the power role switching method described in the above embodiment, the embodiment of the present application further provides a power role switching device, and each module of the device can correspond to each step of implementing the power role switching method.
[0658] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0659] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0660] The present application also provides an electronic device, the electronic device comprising at least one memory, at least one processor, and a computer program stored in the at least one memory and executable on the at least one processor, wherein when the processor executes the computer program, the electronic device implements the steps in any of the above-mentioned method embodiments. Exemplarily, the structure of the electronic device can be as follows: Figure 4 shown.
[0661] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program. When the computer program is executed by a computer, the computer implements the steps in any of the above-mentioned power role switching method embodiments.
[0662] An embodiment of the present application provides a computer program product. When the computer program product is executed on an electronic device, the electronic device implements the steps in any of the above-mentioned power role switching method embodiments.
[0663] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may at least include: any entity or device that can carry the computer program code to the device / electronic device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, a computer-readable storage medium cannot be an electric carrier signal and a telecommunication signal.
[0664] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0665] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0666] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0667] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0668] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for switching power roles, characterized in that: Applied to a first electronic device, initially, the first electronic device is a charging device for receiving electric energy provided by a second electronic device, the first electronic device and the second electronic device both have charging functions and power supply functions, the first electronic device is connected to the second electronic device via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device, the method comprising: The first electronic device receives a first operation, where the first operation is used to switch a power source role during charging; According to the first operation, the first electronic device sends a first instruction to the second electronic device, where the first instruction is used to instruct the second electronic device to switch to a charging device; According to the first operation, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device to switch the first electronic device to a power supply device.
2. The method according to claim 1, characterized in that The first electronic device sending a first instruction to the second electronic device includes: The first electronic device determines whether the first electronic device meets a switching condition; When the first electronic device meets the switching condition, the first electronic device sends the first instruction to the second electronic device.
3. The method according to claim 2, characterized in that The method further comprises: The first electronic device receives a second instruction, where the second instruction is used to agree to switch the power role, and the second instruction is sent by the second electronic device to the first electronic device after receiving the first instruction.
4. The method according to claim 3, characterized in that The first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device, including: After receiving the second instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
5. The method according to claim 3, characterized in that: After the first electronic device receives the second instruction, the method further includes: The first electronic device sends a third instruction to the second electronic device, where the third instruction is used to confirm receipt of the second instruction.
6. The method according to claim 5, characterized in that The first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device, including: After a second preset time after the first electronic device sends the third instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
7. The method according to any one of claims 1 to 6, characterized in that After the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, the method further includes: The first electronic device detects a level on the second signal line; When a high level is detected on the second signal line within a third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device is successful; or, When the high level on the second signal line is not detected within the third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device fails, and restarts the charging protocol handshake.
8. The method according to claim 7, characterized in that The first electronic device adjusting the output voltage of the first electronic device includes: After determining that the handshake between the first electronic device and the second electronic device is successful for a fourth preset time, the first electronic device adjusts the output voltage of the first electronic device.
9. The method according to any one of claims 1 to 8, characterized in that The first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, including: The first electronic device sets the first signal line to a pull-up state, and sets the second signal line to a high-impedance state.
10. The method according to any one of claims 1 to 9, characterized in that The first electronic device and the second electronic device are also connected via a CC signal line; After the first electronic device receives the first operation, the method further includes: According to the first operation, the first electronic device adjusts a level state of the CC signal line in the first electronic device.
11. The method according to claim 10, characterized in that The first electronic device adjusting the output voltage of the first electronic device includes: The first electronic device adjusts the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
12. The method according to any one of claims 1 to 11, characterized in that The first electronic device adjusting the output voltage of the first electronic device includes: The first electronic device adjusts the output voltage of the first electronic device to a first preset value.
13. A method for switching power roles, characterized in that: Applied to a second electronic device, initially, the second electronic device is a power supply device for providing power to a first electronic device, the first electronic device and the second electronic device both have charging and power supply functions, the second electronic device is connected to the first electronic device via a first signal line and a second signal line, the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device, the method comprising: The second electronic device receives a first instruction, the first instruction is used to instruct the second electronic device to switch to a charging device, the first instruction is sent by the first electronic device to the second electronic device when the first electronic device receives a first operation, and the first operation is used to switch the power source role during the charging process; The second electronic device adjusts the output voltage of the second electronic device according to the first instruction, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, so as to switch the second electronic device to a charging device.
14. The method according to claim 13, characterized in that After the second electronic device receives the first instruction, the method further includes: After receiving the first instruction, the second electronic device sends a second instruction to the first electronic device, where the second instruction is used to agree to switch the power role.
15. The method according to claim 14, characterized in that The second electronic device adjusts the output voltage of the second electronic device according to the first instruction, adjusts the first signal line so that the second electronic device receives data sent by the first electronic device, and adjusts the second signal line so that the second electronic device sends data to the first electronic device, including: After sending the second instruction, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
16. The method according to claim 14 or 15, characterized in that After the second electronic device sends the second instruction to the first electronic device, the method further includes: The second electronic device receives a third instruction, where the third instruction is sent by the first electronic device to the second electronic device after the first electronic device receives the second instruction, and the third instruction is used to confirm receipt of the second instruction.
17. The method according to claim 16, characterized in that The second electronic device adjusts the output voltage of the second electronic device according to the first instruction, adjusts the first signal line so that the second electronic device receives data sent by the first electronic device, and adjusts the second signal line so that the second electronic device sends data to the first electronic device, including: After receiving the third instruction for a first preset time, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
18. The method according to any one of claims 13 to 17, characterized in that The second electronic device adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including: The second electronic device sets the first signal line to a high impedance state, and sets the second signal line to a pull-up state.
19. The method according to any one of claims 13 to 18, characterized in that The second electronic device adjusting the output voltage of the second electronic device includes: The second electronic device adjusts the output voltage of the second electronic device to a second preset value.
20. The method according to claim 19, characterized in that After the second electronic device adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, the method further includes: The second electronic device detects the level on the first signal line; When a high level is detected on the first signal line within a third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device is successful; or, When the high level on the first signal line is not detected within the third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device fails, and restarts the charging protocol handshake.
21. The method according to claim 20, characterized in that The first electronic device and the second electronic device are also connected via a VBUS power line; The method further comprises: After determining that the second electronic device and the first electronic device have successfully shaken hands, the second electronic device detects whether the voltage on the VBUS power line meets a preset condition, where the preset condition is determined according to the second preset value; When it is detected within a fifth preset time that the voltage on the VBUS power line meets the preset condition, the second electronic device receives the electric energy provided by the first electronic device through a charging protocol; When it is not detected within the fifth preset time that the voltage on the VBUS satisfies the preset condition, the second electronic device restarts the charging protocol handshake.
22. The method according to any one of claims 13 to 21, characterized in that The second electronic device is further connected to the first electronic device via a CC signal line; The method further comprises: The second electronic device adjusts the level state of the CC signal line in the second electronic device according to the first instruction.
23. The method according to claim 22, characterized in that The second electronic device adjusting the output voltage of the second electronic device includes: The second electronic device adjusts the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
24. A power role switching system, characterized in that: The system includes a first electronic device and a second electronic device, both of which have a charging function and a power supply function. Initially, the first electronic device is a charging device, and the second electronic device is a power supply device. The first electronic device and the second electronic device are connected via a first signal line and a second signal line. The first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device. The first electronic device is used to perform the steps in the power role switching method according to any one of claims 1 to 12; The second electronic device is used to execute the steps in the power role switching method according to any one of claims 13 to 23.
25. A method for switching a power role, characterized in that: Applied to a second electronic device, initially, the second electronic device is a power supply device for providing power to a first electronic device, the first electronic device and the second electronic device both have charging and power supply functions, the second electronic device is connected to the first electronic device via a first signal line and a second signal line, the first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device, the method comprising: The second electronic device receives a first operation, where the first operation is used to switch a power source role during charging; According to the first operation, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device; According to the first operation, the second electronic device sends a first instruction to the first electronic device, where the first instruction is used to switch the first electronic device to a power supply device.
26. The method according to claim 25, characterized in that The method further comprises: The second electronic device receives a second instruction, where the second instruction is used to agree to switch the power role. The second instruction is sent to the second electronic device by the first electronic device after receiving the first instruction and determining that the first electronic device meets the switching condition.
27. The method according to claim 26, characterized in that The second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including: After receiving the second instruction, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
28. The method according to claim 26, characterized in that After the second electronic device receives the second instruction, the method further includes: The second electronic device sends a third instruction to the first electronic device, where the third instruction is used to confirm receipt of the second instruction.
29. The method according to claim 28, characterized in that The second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including: After a first preset time of sending the third instruction, the second electronic device adjusts the output voltage of the second electronic device, adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device.
30. The method according to any one of claims 25 to 29, characterized in that The second electronic device adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, including: The second electronic device sets the first signal line to a high impedance state, and sets the second signal line to a pull-up state.
31. The method according to any one of claims 25 to 30, characterized in that The second electronic device adjusting the output voltage of the second electronic device includes: The second electronic device adjusts the output voltage of the second electronic device to a second preset value.
32. The method according to claim 31, characterized in that After the second electronic device adjusts the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjusts the second signal line to be a signal line for the second electronic device to send data to the first electronic device, the method further includes: The second electronic device detects the level on the first signal line; When a high level is detected on the first signal line within a third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device is successful; or, When the high level on the first signal line is not detected within the third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device fails, and restarts the charging protocol handshake.
33. The method according to claim 32, characterized in that The first electronic device and the second electronic device are also connected via a VBUS power line; The method further comprises: After determining that the second electronic device and the first electronic device have successfully shaken hands, the second electronic device detects whether the voltage on the VBUS power line meets a preset condition, where the preset condition is determined according to the second preset value; When it is detected within a fifth preset time that the voltage on the VBUS power line meets the preset condition, the second electronic device is charged from the first electronic device through a charging protocol; When it is not detected within the fifth preset time that the power on the VBUS power line meets the preset condition, the second electronic device restarts the charging protocol handshake.
34. The method according to any one of claims 25 to 33, characterized in that The second electronic device is further connected to the first electronic device via a CC signal line; After the second electronic device receives the first operation, the method further includes: According to the first operation, the second electronic device switches a level state of the CC signal line in the second electronic device.
35. The method according to claim 34, characterized in that The second electronic device adjusting the output voltage of the second electronic device includes: The second electronic device adjusts the output voltage of the second electronic device according to the level state of the CC signal line in the second electronic device.
36. A method for switching a power role, characterized in that: Applied to a first electronic device, initially, the first electronic device is a charging device for receiving electric energy provided by a second electronic device, the first electronic device and the second electronic device both have charging functions and power supply functions, the first electronic device is connected to the second electronic device via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device, the method comprising: The first electronic device receives a first instruction, the first instruction is used to instruct the first electronic device to switch to a power supply device, the first instruction is sent by the second electronic device to the first electronic device after receiving a first operation, and the first operation is used to switch the power source role during charging; According to the first instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device to switch the first electronic device to a power supply device.
37. The method according to claim 36, characterized in that After the first electronic device receives the first instruction, the method further includes: The first electronic device determines whether the first electronic device meets a switching condition; When the first electronic device meets the switching condition, the first electronic device sends a second instruction to the second electronic device, where the second instruction is used to agree to switch the power role.
38. The method according to claim 37, characterized in that The first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device according to the first instruction, including: After sending the second instruction, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
39. The method according to claim 37 or 38, characterized in that After the first electronic device sends the second instruction to the second electronic device, the method further includes: The first electronic device receives a third instruction, where the third instruction is sent by the second electronic device to the first electronic device after the second electronic device receives the second instruction, and the third instruction is used to confirm receipt of the second instruction.
40. The method according to claim 39, characterized in that The first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device according to the first instruction, including: After receiving the third instruction for a second preset time, the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, and adjusts the output voltage of the first electronic device.
41. The method according to any one of claims 36 to 40, characterized in that After the first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, the method further includes: The first electronic device detects a level on the second signal line; When a high level is detected on the second signal line within a third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device is successful; or, When the high level on the second signal line is not detected within the third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device fails, and restarts the charging protocol handshake.
42. The method according to claim 41, characterized in that The first electronic device adjusting the output voltage of the first electronic device includes: The first electronic device adjusts the output voltage of the first electronic device after determining that the handshake between the first electronic device and the second electronic device is successful for a third preset time.
43. The method according to any one of claims 36 to 42, characterized in that The first electronic device adjusts the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjusts the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device, including: The first electronic device sets the first signal line to a pull-up state, and sets the second signal line to a high-impedance state.
44. The method according to any one of claims 36 to 43, characterized in that The first electronic device and the second electronic device are also connected via a CC signal line; The method further comprises: The first electronic device adjusts the level state of the CC signal line in the first electronic device according to the first instruction.
45. The method according to claim 44, characterized in that The first electronic device adjusting the output voltage of the first electronic device includes: The first electronic device adjusts the output voltage of the first electronic device according to the level state of the CC signal line in the first electronic device.
46. The method according to any one of claims 36 to 45, characterized in that The first electronic device adjusting the output voltage of the first electronic device includes: The first electronic device adjusts the output voltage of the first electronic device to a first preset value.
47. A power role switching system, characterized in that: The system includes a first electronic device and a second electronic device, both of which have a charging function and a power supply function. Initially, the first electronic device is a charging device, and the second electronic device is a power supply device. The first electronic device and the second electronic device are connected via a first signal line and a second signal line. The first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device. The second electronic device is used to perform the steps in the power role switching method according to any one of claims 25 to 35; The first electronic device is used to execute the steps in the power role switching method described in any one of claims 36 to 46.
48. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the electronic device implements the power role switching method according to any one of claims 1 to 12, 13 to 23, 25 to 35, or 36 to 46.
49. A first electronic device, characterized in that: Initially, the first electronic device is a charging device, used to receive electric energy provided by the second electronic device, the first electronic device and the second electronic device both have charging function and power supply function, the first electronic device is connected to the second electronic device via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device; The first electronic device comprises: a system chip, a protocol module, a power management module and an input module; The input module is used to receive a first operation and send first information of the first operation to the system chip, wherein the first operation is used to switch the power source role during the charging process; The system chip is used to instruct the protocol module to send a first instruction to the second electronic device according to the first information of the first operation, wherein the first instruction is used to instruct the second electronic device to switch to a charging device; The protocol module is used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device; The system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device.
50. A second electronic device, characterized in that: Initially, the second electronic device is a power supply device, which is used to provide power to the first electronic device. Both the first electronic device and the second electronic device have charging and power supply functions. The second electronic device is connected to the first electronic device via a first signal line and a second signal line. The first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device. The second electronic device includes: a system chip, a protocol module and a power management module: The protocol module is used to receive a first instruction and send the first instruction to the system chip, the first instruction is used to instruct the second electronic device to switch to a charging device, the first instruction is sent by the first electronic device to the second electronic device when receiving a first operation, and the first operation is used to switch the power source role during the charging process; The system chip is used to instruct the power management module to adjust the output voltage of the second electronic device according to the first instruction; The protocol module is further used to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device according to the first instruction.
51. A second electronic device, characterized in that: Initially, the second electronic device is a power supply device, which is used to provide power to the first electronic device. Both the first electronic device and the second electronic device have charging and power supply functions. The second electronic device is connected to the first electronic device via a first signal line and a second signal line. The first signal line is a signal line for the second electronic device to send data to the first electronic device, and the second signal line is a signal line for the second electronic device to receive data sent by the first electronic device. The second electronic device comprises: a system chip, a protocol module, a power management module and an input module; The input module is used to receive a first operation and send first information of the first operation to the system chip, wherein the first operation is used to switch the power source role during the charging process; The system chip is used to instruct the power management module to adjust the output voltage of the second electronic device according to the first information of the first operation; The protocol module is further used to adjust the first signal line to be a signal line for the second electronic device to receive data sent by the first electronic device, and adjust the second signal line to be a signal line for the second electronic device to send data to the first electronic device according to the first information of the first operation; The system chip is further used to instruct the protocol module to send a first instruction to the first electronic device, where the first instruction is used to switch the first electronic device to a power supply device.
52. A first electronic device, characterized in that: Initially, the first electronic device is a charging device, used to receive electric energy provided by the second electronic device, the first electronic device and the second electronic device both have charging function and power supply function, the first electronic device is connected to the second electronic device via a first signal line and a second signal line, the first signal line is a signal line for the first electronic device to receive data sent by the second electronic device, and the second signal line is a signal line for the first electronic device to send data to the second electronic device; The first electronic device includes: a system chip, a protocol module and a power management module: The protocol module is used to receive a first instruction and send the first instruction to the system chip, the first instruction is used to instruct the first electronic device to switch to a power supply device, the first instruction is sent by the second electronic device to the first electronic device after receiving a first operation, and the first operation is used to switch the power source role during the charging process; The protocol module is further used to adjust the first signal line to be a signal line for the first electronic device to send data to the second electronic device, and adjust the second signal line to be a signal line for the first electronic device to receive data sent by the second electronic device according to the first instruction; The system chip is further used to instruct the power management module to adjust the output voltage of the first electronic device according to the first instruction.
Citation Information
Cited By
Power source role switching method and system, and electronic device
EP4661241A1
