Power role switching method and system and electronic equipment
Patent Information
- Application Number
- CN202480003451.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-06-30
- Filing Date
- 2024-02-28
- Publication Date
- 2025-03-04
AI Technical Summary
During the charging process between two dual-character devices, how to accurately switch the power role has become an urgent problem. It is difficult for the existing technology to achieve efficient switching of power roles, affecting the user experience.
In the signal line connection between the first electronic device and the second electronic device, the function and output voltage of the signal line are adjusted according to the user's operation, and the power role is switched, so that the first electronic device or the second electronic device can be switched from the first electronic device or the second electronic device. Switch the charging device to a power supply device or vice versa.
Accurate power role switching during charging of dual-character devices, improves user experience and ensures the accuracy and usability of power role switching between devices.
Smart Images

Figure CN119563268A_ABST
Abstract
Description
Power role switching method, system and electronic device
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on June 30, 2023, with application number 202310809719.9 and application name “Power role switching method, system and electronic device”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application belongs to the field of terminal technology, and in particular relates to a method, system and electronic device for switching power roles. Background Art
[0003] With the rapid development of electronic devices and charging technology, electronic devices such as mobile phones, laptops, tablets, and smart screens can now function as dual-role devices, offering both charging and power supply functions. These dual-role devices can act as both power supply devices (i.e., power source roles) to provide power to other electronic devices, and also as charging devices to receive power from power source roles, significantly improving the user experience. However, when two dual-role devices are charging, switching power source roles becomes a pressing issue.
[0004] Summary of the Invention
[0005] The embodiments of the present application provide a power role switching method, system, and electronic device, which can accurately switch power roles during the charging process of two electronic devices that are both dual-role devices, thereby improving user experience.
[0006] In a first aspect, an embodiment of the present application provides a method for switching power roles, 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 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 includes:
[0007] The first electronic device receives a first operation, where the first operation is used to switch a power source role during charging;
[0008] 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;
[0009] 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.
[0010] In the power role switching method provided above, during the charging process of two electronic devices both being dual-role devices, the power roles can be accurately switched according to the first operation detected in the first electronic device, thereby improving user experience.
[0011] The first operation may be a switching operation, and the first instruction may be a switching instruction.
[0012] Exemplarily, the first electronic device sending a first instruction to the second electronic device includes:
[0013] determining, by the first electronic device, whether the first electronic device satisfies a switching condition;
[0014] When the first electronic device meets the switching condition, the first electronic device sends the first instruction to the second electronic device.
[0015] 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.
[0016] In one example, the method further includes:
[0017] The first electronic device receives a second instruction, where the second instruction is used to agree to switch the power role. The second instruction is sent by the second electronic device to the first electronic device after receiving the first instruction.
[0018] The second instruction may be an instruction for approving the switching of the power role.
[0019] Optionally, the first electronic device adjusting the first signal line to be a signal line for transmitting data from the first electronic device to the second electronic device, adjusting the second signal line to be a signal line for receiving data transmitted by the second electronic device by the first electronic device, and adjusting the output voltage of the first electronic device includes:
[0020] 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.
[0021] In another example, after the first electronic device receives the second instruction, the method further includes:
[0022] 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.
[0023] The third instruction may be an ACK for confirming receipt of the approval instruction.
[0024] Optionally, the first electronic device adjusting the first signal line to be a signal line for transmitting data from the first electronic device to the second electronic device, adjusting the second signal line to be a signal line for receiving data transmitted by the second electronic device by the first electronic device, and adjusting the output voltage of the first electronic device includes:
[0025] After a second preset time has passed since the first electronic device sent 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.
[0026] In one 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:
[0027] The first electronic device detects the electrical level on the second signal line;
[0028] 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
[0029] When a high level is not detected on the second signal line within the third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device has failed, and restarts the charging protocol handshake.
[0030] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0031] 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.
[0032] In the power role switching method provided by this implementation, after determining that the handshake between the first electronic device and the second electronic device is successful 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.
[0033] Exemplarily, the first electronic device adjusting the first signal line to be a signal line for transmitting data from the first electronic device to the second electronic device, and adjusting the second signal line to be a signal line for receiving data transmitted by the second electronic device by the first electronic device, includes:
[0034] 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.
[0035] In a possible implementation, the first electronic device and the second electronic device are further connected via a CC signal line;
[0036] After the first electronic device receives the first operation, the method further includes:
[0037] According to the first operation, the first electronic device adjusts a level state of the CC signal line in the first electronic device.
[0038] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0039] The first electronic device adjusts an output voltage of the first electronic device according to a level state of the CC signal line in the first electronic device.
[0040] Exemplarily, the first electronic device adjusting the output voltage of the first electronic device includes:
[0041] The first electronic device adjusts the output voltage of the first electronic device to a first preset value.
[0042] 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 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 device includes:
[0043] An input module, configured to receive a first operation for switching a power source role during charging;
[0044] 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;
[0045] an adjustment module, configured to adjust, according to the first operation, the first signal line to become a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to become 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.
[0046] Exemplarily, the sending module is further configured to determine whether the first electronic device meets a switching condition; and when the first electronic device meets the switching condition, send the first instruction to the second electronic device.
[0047] In one example, the apparatus further comprises:
[0048] 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.
[0049] 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.
[0050] 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.
[0051] 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.
[0052] In a possible implementation, the apparatus further includes:
[0053] a detection module, configured 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, determine 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, determine that the handshake between the first electronic device and the second electronic device has failed, and restart the charging protocol handshake.
[0054] 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.
[0055] Exemplarily, the adjustment module is further configured to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0056] In a possible implementation, the first electronic device and the second electronic device are further connected via a CC signal line;
[0057] The adjustment module is further configured to adjust a level state of the CC signal line in the first electronic device according to the first operation.
[0058] Optionally, the adjustment module is further configured to adjust the output voltage of the first electronic device according to a level state of the CC signal line in the first electronic device.
[0059] Exemplarily, the adjustment module is further configured to adjust the output voltage of the first electronic device to a first preset value.
[0060] In a third aspect, an embodiment of the present application provides a method for switching power roles, 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 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 includes:
[0061] The second electronic device receives a first instruction, the first instruction being used to instruct the second electronic device to switch to a charging device, the first instruction being sent by the first electronic device to the second electronic device upon receiving a first operation, the first operation being used to switch the power source role during the charging process;
[0062] 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 into a charging device.
[0063] In one example, after the second electronic device receives the first instruction, the method further includes:
[0064] 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.
[0065] Optionally, the second electronic device adjusting the output voltage of the second electronic device according to the first instruction, 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:
[0066] 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.
[0067] In another example, after the second electronic device sends the second instruction to the first electronic device, the method further includes:
[0068] 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.
[0069] Optionally, the second electronic device adjusting the output voltage of the second electronic device according to the first instruction, 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] 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.
[0071] 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:
[0072] 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.
[0073] Exemplarily, the second electronic device adjusting the output voltage of the second electronic device includes:
[0074] The second electronic device adjusts the output voltage of the second electronic device to a second preset value.
[0075] 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:
[0076] The second electronic device detects the electrical level on the first signal line;
[0077] 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
[0078] When a high level is not detected on the first signal line within the third preset time, the second electronic device determines that the handshake between the second electronic device and the first electronic device has failed, and restarts the charging protocol handshake.
[0079] In a possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0080] The method further comprises:
[0081] After determining that the second electronic device has successfully shaken hands with the first electronic device, 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;
[0082] 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 power provided by the first electronic device through a charging protocol;
[0083] When it is not detected within the fifth preset time that the voltage on the VBUS meets the preset condition, the second electronic device restarts the charging protocol handshake.
[0084] In another possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0085] The method further comprises:
[0086] The second electronic device adjusts the level state of the CC signal line in the second electronic device according to the first instruction.
[0087] Optionally, the second electronic device adjusting the output voltage of the second electronic device includes:
[0088] 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.
[0089] 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 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 device includes:
[0090] 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, the first instruction being sent by the first electronic device to the second electronic device upon receiving a first operation, wherein the first operation is used to switch the power source role during the charging process;
[0091] an adjustment module, configured 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 into a charging device.
[0092] In one example, the apparatus further comprises:
[0093] The sending module is 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.
[0094] 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.
[0095] 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.
[0096] 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.
[0097] Exemplarily, the adjustment module is further configured to set the first signal line to a high-impedance state, and set the second signal line to a pull-up state.
[0098] Exemplarily, the adjustment module is further configured to adjust the output voltage of the second electronic device to a second preset value.
[0099] In one example, the apparatus further comprises:
[0100] 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 handshake between the second electronic device and the first electronic device is successful; or when a high level is not detected on the first signal line within the third preset time, it is determined that the handshake between the second electronic device and the first electronic device has failed, and the charging protocol handshake is restarted.
[0101] In a possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0102] The device further comprises:
[0103] The 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, where 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 the 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.
[0104] In another possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0105] 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.
[0106] Optionally, the adjustment module is further configured to adjust the output voltage of the second electronic device according to a level state of the CC signal line in the second electronic device.
[0107] In a fifth aspect, an embodiment of the present application provides a power role switching system, the system including a first electronic device and a second electronic device, wherein the first electronic device and the second electronic device both have charging and power supply functions, wherein initially, the first electronic device is a charging device and the second electronic device is a power supply device, and the first electronic device and the second electronic device are connected 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;
[0108] The first electronic device is configured to execute the steps in the power role switching method described in any one of the first aspects above;
[0109] 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.
[0110] In a sixth aspect, an embodiment of the present application provides a method for switching power roles, 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 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 includes:
[0111] The second electronic device receives a first operation, where the first operation is used to switch a power source role during charging;
[0112] According to the first operation, the second electronic device adjusts the output voltage of the second electronic device, 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;
[0113] 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.
[0114] In one example, the method further includes:
[0115] 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 when the first electronic device determines that the first electronic device meets the switching condition after receiving the first instruction.
[0116] 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:
[0117] 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.
[0118] In another example, after the second electronic device receives the second instruction, the method further includes:
[0119] 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.
[0120] 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:
[0121] After a first preset time has passed since the second electronic device sent 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.
[0122] 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:
[0123] 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.
[0124] Exemplarily, the second electronic device adjusting the output voltage of the second electronic device includes:
[0125] The second electronic device adjusts the output voltage of the second electronic device to a second preset value.
[0126] 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:
[0127] The second electronic device detects the electrical level on the first signal line;
[0128] 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
[0129] 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 has failed, and restarts the charging protocol handshake.
[0130] In another possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0131] The method further comprises:
[0132] After determining that the second electronic device has successfully shaken hands with the first electronic device, 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;
[0133] 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 the charging protocol;
[0134] 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.
[0135] In a possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0136] After the second electronic device receives the first operation, the method further includes:
[0137] According to the first operation, the second electronic device switches the level state of the CC signal line in the second electronic device.
[0138] Optionally, the second electronic device adjusting the output voltage of the second electronic device includes:
[0139] 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.
[0140] 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 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 device includes:
[0141] An input module, configured to receive a first operation for switching a power source role during charging;
[0142] an adjustment module, configured to adjust, according to the first operation, an output voltage of the second electronic device, adjust the first signal line so that the second electronic device receives data sent by the first electronic device, and adjust the second signal line so that the second electronic device sends data to the first electronic device;
[0143] The sending module is configured 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 into a power supply device.
[0144] In one example, the apparatus further comprises:
[0145] 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 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.
[0146] 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.
[0147] 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.
[0148] 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.
[0149] Exemplarily, the adjustment module is further configured to set the first signal line to a high-impedance state, and set the second signal line to a pull-up state.
[0150] Exemplarily, the adjustment module is further configured to adjust the output voltage of the second electronic device to a second preset value.
[0151] In a possible implementation, the apparatus further includes:
[0152] 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 handshake between the second electronic device and the first electronic device is successful; or when a high level is not detected on the first signal line within the third preset time, it is determined that the handshake between the second electronic device and the first electronic device has failed, and the charging protocol handshake is restarted.
[0153] In another possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0154] The device further comprises:
[0155] The 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, where 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 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, restart the charging protocol handshake.
[0156] In a possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0157] The adjustment module is further configured to switch the level state of the CC signal line in the second electronic device according to the first operation.
[0158] Optionally, the adjustment module is further configured to adjust the output voltage of the second electronic device according to a level state of the CC signal line in the second electronic device.
[0159] In an eighth aspect, an embodiment of the present application provides a method for switching power roles, 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 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 includes:
[0160] The first electronic device receives a first instruction, the first instruction being used to instruct the first electronic device to switch to a power supply device, the first instruction being sent by the second electronic device to the first electronic device after receiving a first operation, the first operation being used to switch the power source role during the charging process;
[0161] 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.
[0162] In one example, after the first electronic device receives the first instruction, the method further includes:
[0163] determining, by the first electronic device, whether the first electronic device satisfies a switching condition;
[0164] 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.
[0165] Optionally, the first electronic device adjusting, according to the first instruction, the first signal line to serve as a signal line for the first electronic device to send data to the second electronic device, adjusting the second signal line to serve as 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 includes:
[0166] 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.
[0167] In one example, after the first electronic device sends the second instruction to the second electronic device, the method further includes:
[0168] 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.
[0169] Optionally, the first electronic device adjusting, according to the first instruction, the first signal line to serve as a signal line for the first electronic device to send data to the second electronic device, adjusting the second signal line to serve as 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 includes:
[0170] After a second preset time from receiving 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.
[0171] 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:
[0172] The first electronic device detects the electrical level on the second signal line;
[0173] 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
[0174] When a high level is not detected on the second signal line within the third preset time, the first electronic device determines that the handshake between the first electronic device and the second electronic device has failed, and restarts the charging protocol handshake.
[0175] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0176] 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.
[0177] Exemplarily, the first electronic device adjusting the first signal line to be a signal line for transmitting data from the first electronic device to the second electronic device, and adjusting the second signal line to be a signal line for receiving data transmitted by the second electronic device by the first electronic device, includes:
[0178] 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.
[0179] In a possible implementation, the first electronic device and the second electronic device are further connected via a CC signal line;
[0180] The method further comprises:
[0181] The first electronic device adjusts the level state of the CC signal line in the first electronic device according to the first instruction.
[0182] Optionally, the first electronic device adjusting the output voltage of the first electronic device includes:
[0183] The first electronic device adjusts an output voltage of the first electronic device according to a level state of the CC signal line in the first electronic device.
[0184] Exemplarily, the first electronic device adjusting the output voltage of the first electronic device includes:
[0185] The first electronic device adjusts the output voltage of the first electronic device to a first preset value.
[0186] 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 and power supply functions. 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 device includes:
[0187] 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, the first instruction being 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 the charging process;
[0188] an adjustment module, configured to adjust, according to the first instruction, the first signal line to become a signal line for the first electronic device to send data to the second electronic device, adjust the second signal line to become 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.
[0189] In one example, the apparatus further comprises:
[0190] 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, where the second instruction is used to agree to switch the power role.
[0191] 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.
[0192] 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.
[0193] 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.
[0194] In one example, the apparatus further comprises:
[0195] The 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.
[0196] 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.
[0197] Exemplarily, the adjustment module is further configured to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0198] In a possible implementation, the first electronic device and the second electronic device are further connected via a CC signal line;
[0199] 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.
[0200] Optionally, the adjustment module is further configured to adjust the output voltage of the first electronic device according to a level state of the CC signal line in the first electronic device.
[0201] Exemplarily, the adjustment module is further configured to adjust the output voltage of the first electronic device to a first preset value.
[0202] In a tenth aspect, an embodiment of the present application provides a power role switching system, the system including 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 being a signal line for the second electronic device to send data to the first electronic device, and the second signal line being a signal line for the second electronic device to receive data sent by the first electronic device;
[0203] The second electronic device is configured to perform the steps in the power role switching method described in any one of the sixth aspects above;
[0204] The first electronic device is used to execute the steps in the power role switching method described in any one of the eighth aspects.
[0205] In an eleventh aspect, an embodiment of the present application provides a first electronic device. Initially, the first electronic device is a charging device configured to receive power provided by a second electronic device. Both the first electronic device and the second electronic device have charging and power supply functions. 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.
[0206] The first electronic device includes: a system chip, a protocol module, a power management module and an input module;
[0207] The input module is configured to receive a first operation and send first information of the first operation to the system chip, wherein the first operation is configured to switch the power source role during the charging process;
[0208] The system chip is configured to instruct the protocol module to send a first instruction to the second electronic device according to the first information of the first operation, where the first instruction is configured to instruct the second electronic device to switch to a charging device;
[0209] The protocol module is configured 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;
[0210] The system chip is further configured to instruct the power management module to adjust the output voltage of the first electronic device.
[0211] Exemplarily, the system chip is further configured to determine whether the first electronic device meets a switching condition; and when the first electronic device meets the switching condition, instruct the protocol module to send the first instruction to the second electronic device.
[0212] 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.
[0213] 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. Or,
[0214] 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.
[0215] The system chip is further configured to instruct the power management module to adjust the output voltage of the first electronic device.
[0216] In another example, the protocol module is further configured to send a third instruction to the second electronic device, wherein the third instruction is configured to confirm receipt of the second instruction. Or,
[0217] 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.
[0218] Optionally, the protocol module is further configured 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 has passed since the third instruction was sent. Alternatively,
[0219] 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.
[0220] Optionally, the system chip is further configured to instruct the power management module 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.
[0221] Exemplarily, the protocol module is further configured to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0222] In a possible implementation, the first electronic device and the second electronic device are further connected via a CC signal line;
[0223] The protocol module is further configured to adjust a level state of the CC signal line in the first electronic device according to the first operation.
[0224] Optionally, the system chip is further configured 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.
[0225] Exemplarily, the system chip is further configured to instruct the power management module to adjust the output voltage of the first electronic device to a first preset value.
[0226] In a twelfth aspect, an embodiment of the present application provides a second electronic device. Initially, the second electronic device is a power supply device configured to provide power to a 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.
[0227] The second electronic device includes: a system chip, a protocol module and a power management module:
[0228] The protocol module is configured to receive a first instruction and send the first instruction to the system chip, wherein the first instruction is used to instruct the second electronic device to switch to a charging device, and the first instruction is sent by the first electronic device to the second electronic device upon receiving a first operation, wherein the first operation is used to switch the power source role during the charging process;
[0229] The system chip is configured to instruct the power management module to adjust the output voltage of the second electronic device according to the first instruction;
[0230] The protocol module is further configured to adjust, according to the first instruction, 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.
[0231] In one example, the protocol module is further configured to send a second instruction to the first electronic device after receiving the first instruction, where the second instruction is configured to agree to switch the power role.
[0232] Optionally, the system chip is also used to, after sending the second instruction, 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.
[0233] 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.
[0234] 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.
[0235] 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 first preset time of the third 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.
[0236] 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 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.
[0237] Exemplarily, the protocol module is further configured to set the first signal line to a high-impedance state, and set the second signal line to a pull-up state.
[0238] Exemplarily, the system chip is further configured to instruct the power management module to adjust the output voltage of the second electronic device to a second preset value.
[0239] In one example, 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.
[0240] In a possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0241] The system chip is further used to, after determining that the second electronic device has successfully handshaked with the first electronic device, instruct the power management module to detect whether the voltage on the VBUS power line meets a preset condition, where the preset condition is determined based on 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 power 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.
[0242] In another possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0243] The protocol module is further configured to adjust the level state of the CC signal line in the second electronic device according to the first instruction.
[0244] Optionally, the system chip is further configured 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.
[0245] In a thirteenth aspect, an embodiment of the present application provides a second electronic device. Initially, the second electronic device is a power supply device configured to provide power to a 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.
[0246] The second electronic device includes: a system chip, a protocol module, a power management module and an input module;
[0247] The input module is configured to receive a first operation and send first information of the first operation to the system chip, wherein the first operation is configured to switch the power source role during the charging process;
[0248] The system chip is configured 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;
[0249] The protocol module is configured 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;
[0250] The system chip is further configured 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 configured to switch the first electronic device to a power supply device.
[0251] In one example, the protocol module is also used to receive a second instruction, which is used to agree to switch the power role. The second instruction is sent to the second electronic device after the first electronic device receives the first instruction and determines that the first electronic device meets the switching conditions.
[0252] Optionally, the system chip is also used to, after receiving the second instruction, 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.
[0253] 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.
[0254] 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.
[0255] Exemplarily, the protocol module is further configured to set the first signal line to a high-impedance state, and set the second signal line to a pull-up state.
[0256] Exemplarily, the system chip is further configured to adjust the output voltage of the second electronic device to a second preset value.
[0257] 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 handshake between the second electronic device and the first electronic device is successful; or, when a high level is not detected on the first signal line within the third preset time, it is determined that the handshake between the second electronic device and the first electronic device has failed, and the charging protocol handshake is restarted.
[0258] In another possible implementation, the first electronic device and the second electronic device are further connected via a VBUS power line;
[0259] The system chip is further used to, after determining that the second electronic device has successfully handshaked with the first electronic device, instruct the power management module to detect whether the voltage on the VBUS power line meets a preset condition, where the preset condition is determined based on 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.
[0260] In a possible implementation, the second electronic device is further connected to the first electronic device via a CC signal line;
[0261] 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.
[0262] Optionally, the system chip is further configured 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.
[0263] In a fourteenth aspect, an embodiment of the present application provides a first electronic device. Initially, the first electronic device is a charging device configured to receive power provided by a second electronic device. Both the first electronic device and the second electronic device have charging 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.
[0264] The first electronic device includes: a system chip, a protocol module and a power management module:
[0265] The protocol module is configured to receive a first instruction and send the first instruction to the system chip, wherein the first instruction is used to instruct the first electronic device to switch to a power supply device, and 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 the charging process;
[0266] The protocol module is further configured to, according to the first instruction, adjust the first signal line to be a signal line for the first electronic device to transmit 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 transmitted by the second electronic device;
[0267] The system chip is further configured to instruct the power management module to adjust the output voltage of the first electronic device according to the first instruction.
[0268] In one example, the system chip is further 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.
[0269] Optionally, the system chip is further 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.
[0270] 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.
[0271] 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.
[0272] The system communication chip is further configured to, after a second preset time period from receiving the third instruction, instruct the power management module to adjust the output voltage of the first electronic device.
[0273] In one example, 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.
[0274] Optionally, the system chip is further configured to instruct the power management module 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.
[0275] Exemplarily, the protocol module is further configured to set the first signal line to a pull-up state, and set the second signal line to a high-impedance state.
[0276] In a possible implementation, the first electronic device and the second electronic device are further connected via a CC signal line;
[0277] The protocol module is further configured to adjust a level state of the CC signal line in the first electronic device according to the first instruction.
[0278] Optionally, the system chip is further configured 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.
[0279] Exemplarily, the system chip is further configured to instruct the power management module to adjust the output voltage of the first electronic device to a first preset value.
[0280] 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 runnable on the processor. When the processor executes the computer program, the electronic device implements the power role switching method described in any one of the first, third, sixth, or eighth aspects above.
[0281] In the sixteenth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a computer, the computer implements the power role switching method described in any one of the first, third, sixth or eighth aspects above.
[0282] In the seventeenth aspect, an embodiment of the present application provides a computer program product, which, when running on an electronic device, enables the electronic device to execute the power role switching method described in any one of the first, third, sixth or eighth aspects above. BRIEF DESCRIPTION OF THE DRAWINGS
[0283] Figures 1 to 3 are schematic diagrams of charging a dual-role device;
[0284] FIG4 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;
[0285] FIG5 is a schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;
[0286] FIG6 is a first schematic diagram of a power role switching system provided in an embodiment of the present application;
[0287] FIG7 is a schematic diagram of an application scenario provided in an embodiment of the present application;
[0288] FIG8 is a second schematic diagram of an application scenario provided by an embodiment of the present application;
[0289] FIG9 is a schematic flowchart of a method for switching power roles provided in accordance with an embodiment of the present application;
[0290] FIG10 is a schematic diagram of signal switching in power role switching according to an embodiment of the present application;
[0291] FIG11 is a second schematic flow chart of a method for switching power roles provided in accordance with an embodiment of the present application;
[0292] FIG12 shows a second schematic diagram of a power role switching system provided in an embodiment of the present application;
[0293] FIG13 is a schematic flow chart of a method for switching power roles provided in another embodiment of the present application;
[0294] FIG14 is a schematic diagram of signal switching in power role switching provided by another embodiment of the present application;
[0295] FIG15 is a schematic flowchart of a method for switching power roles provided in yet another embodiment of the present application. DETAILED DESCRIPTION
[0296] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or collections thereof.
[0297] It will also be understood that the term "and / or" used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0298] As used in this specification and the appended claims, the term "if" can be interpreted as "when" or "upon" 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 "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.
[0299] 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.
[0300] References to "one embodiment" or "some embodiments" in this specification mean that a particular feature, structure, or characteristic described in conjunction with that embodiment is included in one or more embodiments of the present application. Thus, phrases such as "in one embodiment," "in some embodiments," "in other embodiments," and "in other embodiments" appearing in various places in this specification do not necessarily refer to the same embodiment, but rather mean "one or more but not all embodiments," unless otherwise specifically emphasized. The terms "including," "comprising," "having," and variations thereof all mean "including but not limited to," unless otherwise specifically emphasized.
[0301] In addition, the “plurality” mentioned in the embodiments of the present application should be interpreted as two or more.
[0302] The steps involved in the power role switching method provided in the embodiments of the present application are only examples. Not all steps are required, nor are all information or messages required. They can be added or reduced as needed during use. In the embodiments 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.
[0303] 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. Ordinary technicians in this field will know 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.
[0304] 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 role) 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, when mobile phone A is 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.
[0305] It should be understood that a power supply device (also referred to as a Source) is a device that can provide electrical energy. For example, the power supply device can be connected to a charging device via a charging cable, thereby providing electrical energy to the charging device.
[0306] A 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 a power supply device via a charging cable, thereby receiving electrical energy provided by the power supply device.
[0307] Charging can refer to an electronic device acting as a charging device, receiving electrical energy from a power supply device. Powering can refer to an electronic device acting as a power supply device, providing electrical energy to a charging device. For example, for electronic device A and electronic device B, when electronic device A acts as a charging device, receiving electrical energy from electronic device B, the process of electronic device A receiving electrical energy can be understood as charging, and the process of electronic device B providing electrical energy can be understood as powering.
[0308] Refer to Figures 1 to 3, which illustrate schematic diagrams of charging a dual-role device. When dual-role devices (e.g., 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.
[0309] It is understood that a USB Type-C cable can include a signal line CC, a power line VBUS, and a ground line GND. Electronic device A and electronic device B can each include two CC pins, for example, CC1 and CC2. One of the CC pins (e.g., CC1 or CC2) can be used to connect the charging device to the power supply device. That is, electronic devices A and B can transmit signals and other information through the CC connected to the CC1 pin.
[0310] It should be understood that in Figures 1 to 3, the power supply device can be represented as Source and the charging device can be represented as Sink. Electronic device A and electronic device B can both include a voltage converter, a current detection module, and a Sink or Source identification module (represented as Sink or Source in Figures 1 to 3). The voltage converter can be used to control the voltage during the charging process, etc. 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.
[0311] Among them, when charging has 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.
[0312] After electronic device A is connected to electronic device B, electronic device A and electronic device B may be randomly identified as power supply devices or charging devices initially.
[0313] As shown in Figure 1(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 via resistor Rp to generate a pull-up signal. CC1 of electronic device B can be pulled down via 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.
[0314] As shown in (b) of FIG1 , when electronic device A detects a pull-down signal from electronic device B on CC, electronic device A may switch the state from “power supply device-unconnected” to “power supply device-waiting for connection”.
[0315] 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-not connected" to "charging device-waiting for connection".
[0316] 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.
[0317] 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.
[0318] 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.
[0319] 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 role according to the switching operation.
[0320] In one example, a user may input a switching operation in electronic device B. Assuming 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, then, as shown in FIG2(a), electronic device B may pull up CC1 of electronic device B through resistor Rp to generate a pull-up signal. Simultaneously, as shown in FIG2(b), electronic device B may switch electronic device B from the "charging device - waiting for connection" state to the "attempting power supply" state.
[0321] After electronic device B switches from the "Charging Device - Waiting for Connection" state to the "Trying to Power Supply" state, that is, after CC1 of electronic device B is pulled up through resistor Rp to generate a pull-up signal, electronic device A will no longer detect the pull-down signal of electronic device B. At this time, as shown in Figure 2 (a), electronic device A can pull CC1 of electronic device A down through resistor Rd to generate a pull-down signal. At the same time, as shown in Figure 2 (b), electronic device A can switch from the "Power Supply Device - Connected" state to the "Charging Device - Not Connected" state and adjust the output voltage of electronic device A to shut down the VBUS power supply.
[0322] Electronic device A in the "charging device - not connected" state can still detect the pull-up signal of electronic device B on CC. Therefore, as shown in (b) in Figure 2, 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.
[0323] 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. Therefore, as shown in (b) in Figure 2, 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.
[0324] 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, as shown in (b) in Figure 2, electronic device A can switch electronic device A from the "charging device - waiting for connection" state to the "charging device - connected" state.
[0325] 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.
[0326] 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 - waiting for connection" state. At this time, as shown in (a) of Figure 2, electronic device A may pull down CC1 of electronic device A through resistor Rd to generate a pull-down signal. At the same time, as shown in Figure 3, electronic device A may switch electronic device A from the "power supply device - waiting for connection" state to the "attempting charging" state.
[0327] After electronic device A switches from the "power supply device - waiting for connection" state to the "attempting to charge" state, that is, after CC1 of electronic device A is pulled down through resistor Rd to generate a pull-down signal, electronic device B will no longer detect the pull-up signal of electronic device A. Therefore, as shown in Figure 2 (a), electronic device B can pull CC1 of electronic device B up through resistor Rp to generate a pull-up signal. At the same time, as shown in Figure 3, electronic device B can switch from the "charging device - waiting for connection" state to the "power supply device - not connected" state.
[0328] Electronic device B in the "power supply device-not connected" state can still detect the pull-down signal of electronic device A on CC. Therefore, as shown in Figure 3, electronic device B can continue to switch electronic device B from the "power supply device-not connected" state to the "power supply device-waiting for connection" state.
[0329] As shown in Figure 3, 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, into a charging device, and switching electronic device B, which originally receives power, into a power supply device, thereby realizing the switching of power roles.
[0330] As shown in FIG3 , after electronic device A detects that VBUS has power, the electronic device A can be switched from the “attempting to charge” state to the “charging device-connected” state.
[0331] As can be seen from the above description, when an electronic device uses a charging protocol that communicates over a single signal line (i.e., CC), the electronic device can switch the power role based on the CC's connection status, that is, the pull-up signal and pull-down signal detected on the CC. However, this switching method is only applicable to charging protocols based on single signal line communication. When an electronic device uses a charging protocol based on full-duplex communication over two signal lines, how to switch the power role remains an urgent problem to be solved.
[0332] To address the above-mentioned issues, 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, each of which has charging and power supply functions. Initially, the first electronic device is a charging device and the second electronic device is a power supply device. The first and second electronic devices 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, and the second signal line is a signal line for the first electronic device to send data. The first signal line can also 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 switching power roles is required, a user can perform a first operation on the first electronic device. After receiving the first operation, the first electronic device can send a first instruction to the second electronic device, instructing the second electronic device to switch to the 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, thereby switching the second electronic device to the 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 the 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, thereby improving the user experience and having strong ease of use and practicality.
[0333] 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, an in-vehicle 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.
[0334] The following first introduces the electronic device (ie, the first electronic device or the second electronic device) involved in the embodiments of the present application. Please refer to FIG4 , which shows a schematic structural diagram of an electronic device 400 .
[0335] 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. 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.
[0336] It should be understood that the structure illustrated in the embodiments 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, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0337] 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 processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0338] 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.
[0339] Processor 410 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 410 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 410. If processor 410 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 410 latency, and thus improves system efficiency.
[0340] In some embodiments, the processor 410 may include one or more interfaces. The interfaces 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.
[0341] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, processor 410 may include multiple I2C busses. Processor 410 may be coupled to touch sensor 470E, a charger, and the like via different I2C bus interfaces. For example, processor 410 may be coupled to touch sensor 470E via an I2C interface, enabling communication between processor 410 and touch sensor 470E via the I2C bus interface, thereby enabling touch functionality of electronic device 400.
[0342] 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 via the UART interface to implement 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 via the DSI interface to implement the display function of the electronic device 400.
[0343] The GPIO interface can be configured through software. The GPIO interface can be configured as a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 410 to the display 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.
[0344] USB interface 430 is an interface that complies with USB standards and specifications, and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. USB interface 430 can be used to connect a charger to charge electronic device 400, or to transfer data between electronic device 400 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices, such as AR devices.
[0345] It is understood that the interface connection relationship between the modules illustrated in the embodiment of the present application is merely an illustrative 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 a different interface connection method from the above embodiment, or a combination of multiple interface connection methods.
[0346] The charging management module 440 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 440 can receive charging input from the wired charger via the USB interface 430. In some wireless charging embodiments, the charging management module 440 can receive wireless charging input via the wireless charging coil of the electronic device 400. While charging the battery 442, the charging management module 440 can also provide power to the electronic device via the power management module 441.
[0347] 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 provides power to the processor 410, the internal memory 421, the display 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 count, and battery health status (leakage, impedance). In some other embodiments, the power management module 441 can also be provided in the processor 410. In other embodiments, the power management module 441 and the charging management module 440 can also be provided in the same device.
[0348] 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.
[0349] 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 antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0350] 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, 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.
[0351] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium- or 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 being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor displays images or videos via the display screen 490. In some embodiments, the modem processor may be a standalone device. In other embodiments, the modem processor may be independent of the processor 410 and provided in the same device as the mobile communication module 450 or other functional modules.
[0352] 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 that integrate at least one communication processing module. The wireless communication module 460 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 410. The wireless communication module 460 can also receive the signal to be sent from the processor 410, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0353] In some embodiments, antenna 1 of electronic device 400 is coupled to mobile communication module 450, and antenna 2 is coupled to wireless communication module 460, so that electronic device 400 can communicate with a network and other devices via 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).
[0354] Electronic device 400 implements display functionality through a GPU, display screen 490, and an application processor. The GPU is a microprocessor for image processing that connects display screen 490 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 410 may include one or more GPUs that execute program instructions to generate or modify display information.
[0355] Display screen 490 is used to display images, videos, and the like. 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 (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 400 may include one or N display screens 490, where N is a positive integer greater than one.
[0356] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 400 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0357] Video codecs are used to compress or decompress digital video. Electronic device 400 may support one or more video codecs. This allows electronic device 400 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.
[0358] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 400, such as image recognition, face recognition, voice recognition, and text comprehension.
[0359] 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 via the external memory interface 420 to implement data storage functions. For example, files such as videos can be stored in the external memory card.
[0360] 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.
[0361] Pressure sensor 470A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 470A can be located on display screen 490. There are many types of pressure sensors 470A, such as resistive, inductive, and capacitive. A capacitive pressure sensor can include at least two parallel plates made of conductive material. When force acts on pressure sensor 470A, the capacitance between the electrodes changes. Electronic device 400 determines the intensity of the pressure based on this change in capacitance. When a touch operation is applied to display screen 490, electronic device 400 detects the intensity of the touch operation using pressure sensor 470A. Electronic device 400 can also calculate the location of the touch based on the detection signal from pressure sensor 470A. In some embodiments, touch operations applied to the same touch location but with different touch intensities can correspond to different operation instructions. For example, when a touch operation with an intensity less than a first pressure threshold is applied to a short message application icon, a command to view short messages is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to a short message application icon, a command to create a new short message is executed.
[0362] Gyro sensor 470B can be used to determine the motion posture of electronic device 400. In some embodiments, gyro sensor 470B can be used to determine the angular velocity of electronic device 400 around three axes (i.e., x, y, and z axes). Gyro sensor 470B can be used for navigation and somatosensory gaming scenes.
[0363] Accelerometer 470C can detect the magnitude of acceleration of electronic device 400 in all directions (generally three axes). When electronic device 400 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the electronic device's posture, enabling applications such as switching between landscape and portrait modes and pedometers.
[0364] 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 implement 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 prevent the electronic device 400 from shutting down abnormally due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 400 boosts the output voltage of the battery 442 to prevent abnormal shutdown due to low temperature.
[0365] Touch sensor 470E, also known as a "touch device," can be disposed on display screen 490. Touch sensor 470E and display screen 490 form a touch screen, also known as a "touch screen." Touch sensor 470E is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to an application processor to determine the type of touch event. Visual output related to the touch operations can be provided via display screen 490. In other embodiments, touch sensor 470E can also be disposed on the surface of electronic device 400, at a location different from that of display screen 490.
[0366] Keys 480 include a power button, a volume button, and the like. Keys 480 may be mechanical keys or touch-sensitive keys. Electronic device 400 may receive key inputs and generate key signal inputs related to user settings and function control of electronic device 400.
[0367] The software system of the electronic device 400 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a microservice architecture, or a cloud architecture. For example, the software system of the electronic device 400 can 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 illustrate the software structure of the electronic device 400.
[0368] FIG5 is a software structure block diagram of the electronic device 400 according to an embodiment of the present application.
[0369] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.
[0370] The application layer can include a series of application packages.
[0371] As shown in FIG5 , the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, and short message.
[0372] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions.
[0373] As shown in FIG5 , the application framework layer may include a window manager, a content provider, a view system, a telephony manager, a resource manager, a notification manager, and the like.
[0374] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.
[0375] 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.
[0376] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.
[0377] The phone manager is used to provide communication functions of the electronic device 400, such as management of call status (including answering, hanging up, etc.).
[0378] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0379] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.
[0380] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.
[0381] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.
[0382] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.
[0383] The system library can 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.
[0384] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.
[0385] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0386] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0387] A 2D graphics engine is a drawing engine for 2D drawings.
[0388] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.
[0389] The following will exemplarily illustrate a method for switching power roles provided in an embodiment of the present application with reference to the accompanying drawings and specific application scenarios.
[0390] Please refer to FIG. 6 , which shows a first schematic diagram of a power role switching system provided in an embodiment of the present application.
[0391] As shown in (a) of Figure 6, the system may include a first electronic device 601 and a second electronic device 602. 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, in some application scenarios, the first electronic device 601 may serve as a charging device and receive electrical energy provided by other power supply devices. For example, the first electronic device 601 may serve as a charging device, the second electronic device 602 may serve as a power supply device, and the first electronic device 601 may receive electrical energy provided by the second electronic device 602. In other application scenarios, the first electronic device 601 may serve as a power supply device and provide electrical energy to other electronic devices. For example, the first electronic device 601 may serve as a power supply device, the second electronic device 602 may serve as a charging device, and the second electronic device 602 may receive electrical energy provided by the first electronic device 601, that is, the first electronic device 601 may provide electrical energy to the second electronic device 602.
[0392] 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 (i.e., Data+, D+), and the other signal line (hereinafter referred to as the second signal line) may be a negative data line (i.e., Data-, D-).
[0393] It should be understood that for a power supply device, the positive data line can be a signal line for sending data (i.e., Transmitter, TX), and the negative data line can be a signal line for receiving data (i.e., Receiver, RX). For a charging device, the positive data line can be RX, and the negative data line can be TX.
[0394] 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 can be TX and the second signal line can be RX. For the second electronic device 602, the first signal line can be RX and the second signal line can be TX. That is, when the first electronic device 601 provides power to the second electronic device 602, the first electronic device 601 can send data to the second electronic device 602 via the first signal line and receive data sent by the second electronic device 602 via the second signal line. The second electronic device 602 can receive data sent by the first electronic device 601 via the first signal line and send data to the first electronic device 601 via the second signal line.
[0395] For example, as shown in (a) of Figure 6, 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 via the first signal line and can send data to the second electronic device 602 via the second signal line. The second electronic device 602 can send data to the first electronic device 601 via the first signal line and can receive data sent by the first electronic device 601 via the second signal line.
[0396] It should be noted that, as shown in (a) of Figure 6, the charging cable may further include VBUS and GND, etc. During the charging process, the first electronic device 601 and the second electronic device 602 can 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 can provide power to the second electronic device 602 via VBUS. For example, as shown in (a) of Figure 6, 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 via VBUS.
[0397] 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.
[0398] 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 actual scenarios.
[0399] For example, as shown in FIG6( b ), the charging cable may further include a charging cable. 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 charging cable. 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 charging cable.
[0400] For example, as shown in (c) of Figure 6, 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.
[0401] It should be understood that, in addition to the above signal lines, the charging cable may also include other signal lines for other functions. In FIG6 , the first electronic device 601 is used as a charging device, and the second electronic device 602 is used as a power supply device for exemplary description.
[0402] The following description will be given by taking as an example the case where the first electronic device 601 is initially identified as a charging device and the second electronic device 602 is initially identified as a power supply device.
[0403] 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 confirming the receipt of the ping instruction is received. When the first electronic device 601 receives an ACK returned by the second electronic device 602 confirming 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.
[0404] For example, when the second electronic device 602 provides power to the first electronic device 601 through a charging protocol, if the user wants to switch the power roles during the charging process, that is, 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 that the first electronic device 601 can provide power to the second electronic device 602, 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. Alternatively, 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 the second electronic device 602 to a charging device.
[0405] It should be noted that the embodiment of the present application does not impose any restrictions on the specific type of 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.
[0406] 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 .
[0407] For example, during the charging process, the first electronic device 601 may display a power role switching button on the display interface of the first electronic device 601. When the user wants to switch the power role during the charging process, the user can touch the switching button on the first electronic device 601 to switch the power role.
[0408] For example, during the charging process, the second electronic device 602 may display a power role switching button on 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 on the second electronic device 602 to switch the power role.
[0409] Please refer to Figure 7, which shows a schematic diagram of an application scenario provided by an embodiment of the present application. This application scenario is exemplified 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.
[0410] As shown in (a) of Figure 7, 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 a prompt message indicating whether to switch the power role. For example, the prompt message may be "The current device is a charging device, do you want to switch to a power supply device?" At the same time, the first switching prompt interface 701 may also display a "Yes" button 7011 and a "No" button 7012. The "Yes" button 7011 is used to trigger the switching of the power role, and the "No" button 7012 is used to refuse the switching of the power role.
[0411] 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.
[0412] As shown in FIG7(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 on the display interface of the second electronic device 602. The second switching prompt interface 702 may display a prompt message indicating whether to switch the power role. For example, the prompt message may be "The current device is a power supply device. Do you want to switch to a power supply device?". At the same time, the second switching prompt interface 702 may also display a "Yes" button 7021 and a "No" button 7022. The "Yes" button 7021 is used to trigger the switching of the power role, and the "No" button 7022 is used to refuse the switching of the power role.
[0413] When the user wants to switch the power role during charging, 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 the 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 7022 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.
[0414] 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 .
[0415] For example, during charging, the user can simultaneously press the "battery +" button and the power button of the first electronic device 601 to switch the power role. For example, during charging, the user can simultaneously press the "battery +" button and the power button of the second electronic device 602 to switch the power role.
[0416] Optionally, the switching operation may be an operation of performing a specific gesture in the first electronic device 601, or an operation of performing a specific gesture in the second electronic device 602. For example, the specific gesture may be touching the display interface with two or three fingers, or may be single-clicking or double-clicking the display interface with two finger joints, and so on.
[0417] For example, during the charging process, the user can use two or three fingers to touch the display interface of the first electronic device 601 to switch the power role. For example, during the charging process, the user can use two knuckles to single-click or double-click the display interface of the first electronic device 601 to switch the power role. For example, during the charging process, the user can use two or three fingers to touch the display interface of the second electronic device 602 to switch the power role. For example, during the charging process, the user can use two knuckles to single-click or double-click the display interface of the second electronic device 602 to switch the power role.
[0418] As can be seen from the above, the user can perform a switching operation on 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 based on the switching operation detected by the first electronic device 601. Alternatively, the user can perform a switching operation on 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 based on the switching operation detected by the second electronic device 602.
[0419] The following will be explained separately: 1. The first electronic device 601 triggers the switching of the power role during the charging process according to the switching operation detected by the first electronic device 601; 2. The second electronic device 602 triggers the switching of the power role during the charging process according to the switching operation detected by the second electronic device 602.
[0420] 1. The first electronic device 601 triggers the switching of the power source role during the charging process according to the switching operation detected by the first electronic device 601
[0421] 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 is providing power to the first electronic device 601, when the user wants to trigger a power role switch on the first electronic device 601, the user can perform a switching operation on the first electronic device 601, for example, by clicking the "Yes" button 7011 shown in (a) of Figure 7. After detecting the switching operation, the first electronic device 601 determines that the power role needs to be switched during the charging process.
[0422] 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 switching instruction A to the second electronic device 602 via the second signal line. Switching instruction A is used to request that the second electronic device 602 be switched to a charging device to implement the switching of the power source role during the charging process.
[0423] After the second electronic device 602 receives the switching instruction A, it can adjust the output voltage of the second electronic device 602. 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.
[0424] In addition, the second electronic device 602 may further switch the states of the first signal line and the second signal line in the second electronic device 602, that is, swap the 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.
[0425] It should be understood that after the first electronic device 601 detects the switching operation, it may also switch the states of the first signal line and the second signal line in the first electronic device 601, that is, swap the RX and TX of the first electronic device 601. 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 states of the first signal line and the second signal line in the first electronic device 601 are switched, the first signal line may be TX and the second signal line may be RX.
[0426] 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.
[0427] It should be noted that the embodiments of the present application do not impose any restrictions on the specific values of preset value A and preset value B, which can be determined based on actual scenarios. For example, preset value A can be determined to be 0V based on actual scenarios. For example, preset value B can be determined to be any value such as 5V, 10V, or 20V based on actual scenarios.
[0428] 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 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) 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 electrical energy to the second electronic device 602 through VBUS.
[0429] 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, it can adjust the output voltage of the first electronic device 601 to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, ensuring effective switching of power roles.
[0430] When the first electronic device 601 does not detect a high level on the second signal line within a preset time T01, the charging handshake protocol may be restarted. If the restarted charging handshake protocol succeeds, the first electronic device 601 may adjust the output voltage of the first electronic device 601 to power on VBUS. If the restarted charging handshake protocol fails, the first electronic device 601 may exit charging, terminating the charging process between the first electronic device 601 and the second electronic device 602.
[0431] 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 the charging device, and the first electronic device 601, as the power supply device, have successfully shaken hands. After the second electronic device 602 determines that the second electronic device 602, as the charging device, and the first electronic device 601, as the power supply device, have successfully shaken hands, the second electronic device 602 can detect whether the voltage on VBUS meets a preset condition. When the second electronic device 602 detects that the voltage on VBUS meets the preset condition within a preset time (hereinafter referred to as the preset time T03), the second electronic device 602 can determine that the power supply of the second electronic device 602 and the first electronic device 601 are successfully connected and can communicate 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.
[0432] The preset condition can be determined based on the preset value B. The specific method for determining the preset condition can be determined based on the actual scenario, and the embodiment of the present application does not impose any specific restrictions on this. Optionally, a voltage range can be determined based on the preset value B, and the preset condition can be that the voltage is within the voltage range.
[0433] 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.
[0434] 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.
[0435] 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.
[0436] 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.
[0437] If the restarted charging protocol handshake succeeds and the voltage on VBUS is detected to meet a preset condition within a preset time T03 after the handshake succeeds, 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 using the charging protocol. At this time, the second electronic device 602 can receive power provided by the first electronic device 601 through the charging protocol. If 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.
[0438] It should be noted that the above description of the first electronic device 601 or the second electronic device 602 exiting charging when the restarted charging protocol handshake fails is only for illustrative purposes and should not be construed as limiting 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 based on actual scenarios.
[0439] It should be noted that the values of the preset times 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 thereto. 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.
[0440] Optionally, switching the states of the first signal line and the second signal line in the first electronic device 601 may involve setting the first signal line in the first electronic device 601 to a pull-up state and setting the second signal line in the first electronic device 601 to a high-impedance state. Switching the states of the first signal line and the second signal line in the second electronic device 602 may involve setting the first signal line in the second electronic device 602 to a high-impedance state and setting the second signal line to a pull-up state.
[0441] Please refer to FIG8 , which shows a second schematic diagram of an application scenario provided in an embodiment of the present application.
[0442] As shown in FIG8(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 point, the second electronic device 602 can adjust its output voltage to power up VBUS, thereby enabling the second electronic device 602 to provide power to the first electronic device 601 via VBUS.
[0443] 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 RX and TX of the first electronic device 601, as shown in (b) in Figure 8. After the switching, for the first electronic device 601, the first signal line can be TX and the second signal line can be RX.
[0444] 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, as shown in (b) in Figure 8. After switching, for the second electronic device 602, the first signal line can be RX and the second signal line can be TX.
[0445] As shown in (b) of FIG8 , the second electronic device 602 may further adjust the output voltage of the second electronic device 602 so that the second electronic device 602 stops supplying power, thereby stopping the second electronic device 602 from providing power to the first electronic device 601 through VBUS.
[0446] 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.
[0447] In another example, after the first electronic device 601 detects the 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.
[0448] It should be noted that the switching condition A can be determined based on the actual scenario, and the present embodiment does not impose any restrictions on this. For example, the switching condition A can be determined based on the actual scenario to include at least one of power level, battery temperature, cable impedance, voltage and current accuracy, and port leakage current.
[0449] For example, 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 preset power level A may be expressed as a percentage of the battery capacity. For example, 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 meets switching condition A.
[0450] 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 Celsius. 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 Celsius, the first electronic device 601 may determine that the first electronic device 601 meets the switching condition A.
[0451] 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 meets the switching condition A.
[0452] 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 receipt of the switching instruction A and an approval instruction (hereinafter referred to as approval instruction A) to the first electronic device 601. In other words, the second electronic device 602 can send ACK A1 and approval instruction A to the first electronic device 601 via the first signal line (i.e., the TX of the second electronic device 602).
[0453] For example, 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 to power off VBUS, so that the second electronic device 602 stops supplying power, thereby causing the second electronic device 602 to no longer provide power to the first electronic device 601 via 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.
[0454] 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.
[0455] For example, after receiving ACK A1 and the approval instruction A returned by the second electronic device 602, the first electronic device 601 may return an ACK (hereinafter referred to as ACK A2) to the second electronic device 602 confirming receipt of the approval 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).
[0456] After receiving the ACK A2 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 down VBUS, thereby stopping the second electronic device 602 from supplying power, and thus preventing the second electronic device 602 from providing power to the first electronic device 601 via 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.
[0457] Alternatively, since the second electronic device 602 needs time to parse ACK A2 to determine whether it is indeed necessary to switch the power role, in order to ensure accurate switching of the power role, after receiving ACK A2, 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 status of the first signal line and the second signal line in the second electronic device 602.
[0458] 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.
[0459] 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 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 is adjusted so that VBUS is powered on, thereby allowing the first electronic device 601 to provide electrical energy to the second electronic device 602 through VBUS.
[0460] Optionally, after the first electronic device 601 returns ACK A2 to the second electronic device 602, it can determine the time (for example, 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 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, to effectively ensure the accuracy of the power role switching.
[0461] For example, 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 a preset time T31 of time A. Subsequently, after a preset time T1 that determines that the first electronic device 601, serving as a power supply device, and the second electronic device 602, serving as a charging device, have successfully shaken hands, the first electronic device 601 may adjust the output voltage of the first electronic device 601 to power on VBUS, thereby enabling the first electronic device 601 to provide power to the second electronic device 602 via VBUS, thereby reducing power supply conflicts on VBUS.
[0462] It should be noted that the values of the preset time T21 and the preset time T31 can be determined based on the actual scenario, and the embodiments of the present application do not limit this. For example, the preset time T21 can be set to any value such as 2ms, 5ms, or 10ms based on the actual scenario. For example, the preset time T31 can be set to any value such as 3ms, 5ms, or 10ms based on the actual scenario.
[0463] 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 the switching instruction A to the second electronic device 602. At this time, the first electronic device 601 will not switch the status 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.
[0464] Optionally, the control instructions (e.g., ping instructions, ACK, handover instructions, and consent instructions) 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 message header may be 2 bytes long, the control instruction may be 1 byte long, and the CRC may be 1 byte long.
[0465] Optionally, the relevant content of the control instructions (such as ping instructions, ACK, handover instructions, and consent instructions) sent between the first electronic device 601 and the second electronic device 602 can be as shown in Table 1. The numbers of the control instructions in Table 1 are only for illustrative purposes 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.
[0466] Table 1
[0467] 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 message header may be 2 bytes long, the command may be 1 byte long, the data length may be 1 byte long, the data may be 1 to 59 bytes long, and the CRC may be 1 byte long.
[0468] For example, the relevant content of the data message (e.g., a rejection instruction, etc.) sent between the first electronic device 601 and the second electronic device 602 can be shown in Table 2. The numbers of the data messages in Table 2 are for illustrative purposes only and should not be construed as limiting the embodiments of the present application. In the embodiments of the present application, the numbers of the data messages can also be set to other values according to actual needs.
[0469] Table 2
[0470] Please refer to Figure 9, which shows a schematic flowchart of a method for switching power roles provided by an embodiment of the present application. This embodiment is illustrative of the method for switching power roles by detecting a switching operation in the first electronic device 601.
[0471] As shown in Figure 9, initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable. At this 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 the 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] As shown in Figure 9, when a first electronic device 601 is receiving power from a second electronic device 602, if a user wishes to trigger a power role switch on the first electronic device 601, the user may perform a switching operation on the first electronic device 601. Specifically, the first electronic device 601 may detect the switching operation in the first electronic device 601. Upon detecting the switching operation, the first electronic device 601 may first determine whether the first electronic device 601 satisfies a switching condition A. If the first electronic device 601 satisfies the switching condition A, the first electronic device 601 may send a switching instruction A to the second electronic device 602. If no switching operation is detected, or if the first electronic device 601 does not meet the switching condition A, the first electronic device 601 may still function as a charging device and receive power from 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 the 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 consent instruction A returned by the second electronic device 602 are received.
[0476] When receiving ACK A1 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. If neither ACK A1 nor the consent instruction A is received, the first electronic device 601 can still function as a charging device and receive power provided by the second electronic device 602.
[0477] The second electronic device 602 may determine whether the 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, it can determine the time A when the second electronic device 602 switches the states of the first signal line and the second signal line in the second electronic device 602. The first electronic device 601 can first switch the states of the first signal line and the second signal line in the first electronic device 601 after a preset time T31 of time A. 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 for a preset time T1, the first electronic device 601 can adjust the output voltage of the first electronic device 601 to power on VBUS, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via 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 determine 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 a 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 to indicate a successful handshake, the first electronic device 601 can adjust the output voltage of the first electronic device 601 to power on VBUS, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via VBUS.
[0481] It should be understood that if a high level is not detected on the second signal line within the preset time T01, the first electronic device 601 may determine that the handshake has failed. In this case, the first electronic device 601 may restart the charging protocol handshake. If the restarted charging protocol handshake is successful, the first electronic device 601 may adjust the output voltage of the first electronic device 601 to power up VBUS, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via 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 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 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 the charging device, has successfully shaken hands with the first electronic device 601, as the power supply device. 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 determines that the second electronic device 602 can communicate the charging protocol with the first electronic device 601, 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. 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 via the charging protocol. At this time, the second electronic device 602 can receive the power provided by the first electronic device 601 via 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 the above description of the first electronic device 601 or the second electronic device 602 exiting charging when the restarted charging protocol handshake fails is only for illustrative purposes and should not be construed as limiting 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 based on actual scenarios.
[0488] Please refer to Figure 10, which shows a schematic diagram of signal switching in power role switching provided by an embodiment of the present application. Figure 10 uses the power role switching shown in Figure 9 as an example for exemplary description.
[0489] As shown in (a) and (b) of Figure 10, initially, during the charging process in which 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 may be RX and the second signal line may be TX; for the second electronic device 602, the first signal line may be TX and the second signal line may be RX.
[0490] When the first electronic device 601 detects the switching operation, the first electronic device 601 can determine whether the first electronic device 601 meets the switching condition A. As shown in (a) of Figure 10, 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 via the second signal line.
[0491] After receiving the switching instruction A, the second electronic device 602 may send an ACK A1 and an approval instruction A to the first electronic device 601 through the first signal line.
[0492] The first electronic device 601 receives the ACK A1 and the consent instruction A and may send an ACK A2 to the second electronic device 602 via the second signal line.
[0493] As shown in (a) and (b) of Figure 10, after the second electronic device 602 receives ACK A2, it can adjust the output voltage of the second electronic device 602 after the preset time T21, so that VBUS is powered off, so that the second electronic device 602 stops being powered, and the TX and RX of the second electronic device 602 can be exchanged.
[0494] As shown in (b) of Figure 10, the first electronic device 601 can exchange the TX and RX of the first electronic device 601 after the preset time T31 of the second electronic device 602 switching 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 to power on VBUS after the preset time T1 of determining that the first electronic device 601 as the power supply device and the second electronic device 602 as the charging device have successfully shaken hands. It should be understood that Figure 10 (b) is an example of an example in which the first electronic device 601 detects a high level on the second signal line after the first electronic device 601 exchanges the TX and RX of the first electronic device 601, thereby determining that the first electronic device 601 and the second electronic device 602 have successfully shaken hands.
[0495] As shown in (a) of FIG10 , after exchanging the TX and RX signals 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 a 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 handshake between the second electronic device 602 and the first electronic device 601 is successful. After determining that the handshake between the second electronic device 602 and the first electronic device 601 is successful, the second electronic device 602 can detect whether the voltage on VBUS meets a preset condition. When the voltage on VBUS is detected to meet 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 the charging protocol with the first electronic device 601, so that the second electronic device 602 can receive the power provided by the first electronic device 601 through the charging protocol.
[0496] As shown in (b) of Figure 10, after the power role is switched, for the first electronic device 601, the first signal line can be TX and the second signal line can be RX. For the second electronic device 602, the first signal line can be RX and the second signal line can be TX. At the same time, the power supply on VBUS can also change as shown in (b) of Figure 10. That is, as shown in (b) of Figure 10, initially, the second electronic device 602 can provide power to the first electronic device 601 via VBUS. After the switch is completed, the first electronic device 601 can provide power to the second electronic device 602 via VBUS.
[0497] Please refer to Figure 11, which shows a schematic flowchart 2 of a method for switching power roles provided by an embodiment of the present application. This embodiment is illustrative of the method of switching power roles by detecting a switching operation in the first electronic device 601.
[0498] Initially, the first electronic device 601 and the second electronic device 602 may be connected via a charging cable. At this point, 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 instruction, 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 instruction.
[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 power provided by the second electronic device 602 through the charging protocol.
[0501] When the first electronic device 601 receives power from the second electronic device 602 , and the user wants to trigger switching of the power role on the first electronic device 601 , the user can perform a switching operation on the first electronic device 601 .
[0502] As shown in FIG. 11 , 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, it can determine the time A when the second electronic device 602 switches the states of the first signal line and the second signal line in the second electronic device 602. The first electronic device 601 can first switch the states of the first signal line and the second signal line in the first electronic device 601 after a preset time T31 of time A. 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 for a preset time T1, the first electronic device 601 can adjust the output voltage of the first electronic device 601 to power on VBUS, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via 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 determine 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 a 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 to indicate a successful handshake, the first electronic device 601 can adjust the output voltage of the first electronic device 601 to power on VBUS, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via 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 instruction, 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 instruction.
[0510] After the second electronic device 602 receives ACK1, the second electronic device 602 and the first electronic device 601 may be charged using the charging protocol. That is, the first electronic device 601 may provide power to the second electronic device 602 using the charging protocol.
[0511] Please refer to FIG. 12 , which shows a second schematic diagram of a power role switching system provided in an embodiment of the present application.
[0512] As shown in Figure 12, the first electronic device 601 and the second electronic device 602 may each 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. 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 via 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. The 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 switching of power roles will be exemplarily described below with reference to the system shown in FIG. 12 and detecting a switching operation on the first electronic device 601 .
[0515] Initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable. At this 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 the 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] When the first electronic device 601 receives power from the second electronic device 602, if the user wants to trigger a power role switch on the first electronic device 601, the user can perform the switching operation on 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 on 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 power roles. 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 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 serve 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 approval 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 approval 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 the ACK A1 and the consent instruction A returned by the second electronic device 602 have been received.
[0523] Upon receiving ACK A1 and the approval 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 approval instruction A, or the first SOC may instruct the first protocol module to return ACK A2 to the second electronic device 602. If ACK A1 and the approval 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 function as a charging device and receive 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, whether ACK A2 is received or not) 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 further 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 states 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 states of the first signal line and the second signal line in the second electronic device 602 may be determined, and the states of the first signal line and the second signal line in the first electronic device 601 may be switched after a preset time T31 of time A. Alternatively, after the first protocol module returns ACK A2, the first SOC may determine the time A at which the second electronic device 602 switches the states of the first signal line and the second signal line in the second electronic device 602, and may instruct the first protocol module to switch the states of the first signal line and the second signal line in the first electronic device 601 after a preset time T31 of time A.
[0530] 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, thereby enabling the first electronic device 601 to 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, it can detect the voltage level on the second signal line (i.e., the RX of the first electronic device 601). When the first protocol module detects a high voltage 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 send relevant information about 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, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via VBUS.
[0532] Alternatively, after the first protocol module switches the states of the first signal line and the second signal line, it can detect the level on the second signal line and send the detected level 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. After the preset time T1 of determining that the handshake is successful, 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, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via 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 may determine that the handshake has failed. In this case, 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. After the first SOC determines that the handshake is successful, it may 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 a 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, please refer to the above-mentioned content on 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 voltage level on the first signal line (i.e., the RX of the second electronic device 602). When the second protocol module detects a high voltage level on the first signal line within the preset time T02, the second protocol module can determine that the second electronic device 602, which is a charging device, and the first electronic device 601, which is 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 based on 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using 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 using the charging protocol.
[0539] Alternatively, after detecting the voltage on VBUS, the second power management module can send the detected voltage to the second SOC. The second SOC can determine whether the voltage on VBUS meets a preset condition within a 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using 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 using the charging protocol.
[0540] Alternatively, after the second protocol module determines that the handshake between the second electronic device 602 and the first electronic device 601 is successful, it can detect the voltage on VBUS. After detecting the voltage on VBUS, the second protocol module can determine whether the voltage on VBUS meets a preset condition within a preset time T03. If the voltage on VBUS meets the preset condition 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using the charging protocol. At this time, the second protocol module communicates with the first electronic device 601 using the charging protocol.
[0541] Alternatively, after the second protocol module detects the voltage on VBUS, it can send the detected voltage to the second SOC. The second SOC can determine whether the voltage on VBUS meets a preset condition within a 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using the charging protocol. At this time, the second SOC can instruct the second protocol module to communicate with the first electronic device 601 using 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 a high level is not detected on the first signal line within the preset time T02, or when 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 may determine that the handshake has failed. In this case, the second protocol module may restart the charging protocol handshake, or the second SOC may 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 may 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 using the charging protocol. In this case, the second protocol module may communicate with the first electronic device 601 using the charging protocol, or the second SOC may instruct the second protocol module to communicate with the first electronic device 601 using 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 the second SOC. For specific details, please refer to the above-mentioned content on whether the handshake is successful.
[0546] 2. The second electronic device 602 triggers switching of the power source role during charging 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 side, the user can perform the switching operation in the second electronic device 602, for example, click the "Yes" button 7021 shown in (b) of Figure 7. After the second electronic device 602 detects the switching operation, it can determine 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 switching instruction B to the first electronic device 601 through the first signal line. 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, it can adjust the output voltage of the second electronic device 602. 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, swap the 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 receiving the switching instruction B, the first electronic device 601 may switch the states of the first signal line and the second signal line in the first electronic device 601, that is, swap the RX and TX of the first electronic device 601. 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 switching the states of the first signal line and the second signal line in the first electronic device 601, the first signal line may be TX and the second signal line may 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, thereby enabling the first electronic device 601 to provide power to the second electronic device 602 via 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 the preset time T1, it can adjust the output voltage of the first electronic device 601 to power on VBUS, so that the first electronic device 601 can provide power to the second electronic device 602 through VBUS, ensuring effective switching of power roles.
[0554] When the first electronic device 601 does not detect a high level on the second signal line within a preset time T01, the charging handshake protocol may be restarted. If the restarted charging handshake protocol succeeds, the first electronic device 601 may adjust the output voltage of the first electronic device 601 to power on VBUS. If the restarted charging handshake protocol fails, the first electronic device 601 may exit charging, terminating the charging process between the first electronic device 601 and the second electronic device 602.
[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 carried out, 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 can be determined based on the preset value B. The specific method for determining the preset condition can be determined based on the actual scenario, and the embodiment of the present application does not impose any specific restrictions on this. Optionally, a voltage range can be determined based on the preset value B, and the preset condition can be that the voltage is within the voltage range.
[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 understood that switching condition B can be determined based on the actual scenario, and the present embodiment does not impose any restrictions on this. For example, switching condition B can be determined based on the actual scenario to include at least one of power level, battery temperature, cable impedance, voltage and current accuracy, and port leakage current.
[0563] For example, 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 preset power level B may be expressed as a percentage of the battery capacity. For example, 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 meets 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 Celsius. 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 Celsius, 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 meets the switching condition B.
[0566] When the first electronic device 601 satisfies the switching condition B, the first electronic device 601 may send an ACK (hereinafter referred to as ACK B1) to confirm receipt of the switching instruction B, and an approval instruction (hereinafter referred to as approval instruction B) to the second electronic device 602. That is, the first electronic device 601 may send the ACK B1 and the approval instruction B to the second electronic device via the second signal line (ie, TX in the first electronic device 601).
[0567] For example, 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 down VBUS, 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 via 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] For example, after receiving the ACK B1 and the approval 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 confirming receipt of the approval 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 down 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 states 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 the preset time of returning ACK B2 (hereinafter referred to as the preset time T22) to stop power supply and switch the status 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, it can switch the states of the first signal line and the second signal line in the first electronic device 601, and 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.
[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, it 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.
[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 at which the second electronic device 602 switches the states 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 states 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 the preset time T32), 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, to effectively ensure the accuracy of the power role switching.
[0575] For example, 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 a preset time T32 of time A. Subsequently, after a preset time T1 that determines that the first electronic device 601, serving as a power supply device, and the second electronic device 602, serving as a charging device, have successfully shaken hands, the first electronic device 601 may adjust the output voltage of the first electronic device 601 to power on VBUS, thereby enabling the first electronic device 601 to provide power to the second electronic device 602 via 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 determined based on the actual scenario, and the embodiments of the present application do not limit this. For example, the preset time T22 can be set to any value such as 2ms, 5ms, or 10ms based on the actual scenario. For example, the preset time T32 can be set to any value such as 3ms, 5ms, or 10ms based on 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 serve as a charging device and the second electronic device 602 can still serve 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 as 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 as or different.
[0579] Please refer to Figure 13, which shows a schematic flow chart of a method for switching power roles provided by another embodiment of the present application. This embodiment is illustrative of the method for switching power roles by detecting a switching operation in the second electronic device 602.
[0580] As shown in Figure 13, initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable. At this 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 the 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] As shown in Figure 13, when a user wishes to trigger a power role switch on the second electronic device 602 while the second electronic device 602 is providing power to the first electronic device 601, the user can perform a switching operation on the second electronic device 602. Specifically, the second electronic device 602 can detect the switching operation on 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 function 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 an ACK B1 and an 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. In this case, the first electronic device 601 can still function as a charging device and receive 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 consent 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. If neither ACK B1 nor the consent instruction B is received, the second electronic device 602 can still function 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 the 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 the 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 at which the second electronic device 602 switches the states of the first signal line and the second signal line in the second electronic device 602, and can first switch the states of the first signal line and the second signal line in the first electronic device 601 after a preset time T32 of time A. 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 for a preset time T1, the first electronic device 601 can adjust the output voltage of the first electronic device 601 so that VBUS is powered on, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via VBUS.
[0590] 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 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, thereby determining 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] Among them, 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 second electronic device 602 detects whether the voltage on VBUS meets the preset conditions can be referred to the specific description in Figure 9, which 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] Please refer to Figure 14, which shows a schematic diagram of signal switching in power role switching provided by another embodiment of the present application. Figure 14 takes the power role switching shown in Figure 13 as an example for illustrative description.
[0594] As shown in FIG14 , initially, during the charging process in which 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 may be RX and the second signal line may be TX; and for the second electronic device 602, the first signal line may be TX and the second signal line may 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 it 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 via the second signal line.
[0597] The second electronic device 602 receives the ACK B1 and the consent 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 of the second electronic device 602 sending 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] As shown in FIG14 , after exchanging the TX and RX signals 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 a 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 handshake between the second electronic device 602 and the first electronic device 601 is successful. After determining that the handshake between the second electronic device 602 and the first electronic device 601 is successful, the second electronic device 602 can detect whether the voltage on VBUS meets a preset condition. When 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, i.e., that the second electronic device 602 can communicate the charging protocol with the first electronic device 601, thereby allowing the second electronic device 602 to receive power provided by the first electronic device 601 through the charging protocol.
[0600] It should be noted that, during the power role switching, changes in the first signal line, changes in the second signal line, and changes in the power supply on VBUS can be seen in (b) of FIG10 , and will not be described in detail here.
[0601] The switching of power roles will be exemplarily described below with reference to the system shown in FIG. 12 and detecting a switching operation on the second electronic device 602 .
[0602] Initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable. At this 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 the 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] During the process of the second electronic device 602 providing power to the first electronic device 601, when the user wants to trigger a power role switch on the second electronic device 602, the user can perform the switching operation on 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 on 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 to switch power roles. If the user operation is determined to be a switching operation, the second SOC can instruct the second protocol module to send a switching instruction B to the first electronic device 601. If 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 function as a power supply device to provide power to the first electronic device 601.
[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., the switching instruction B is received or the switching instruction B is not received) 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] Upon receiving the switching instruction B sent by the second electronic device 602, the first SOC may 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 may instruct the first protocol module to send an ACK B1 and an approval instruction B to the second electronic device 602. If the first electronic device 601 does not meet the switching condition B, the first SOC may instruct the first protocol module to send a rejection instruction B to the second electronic device 602. In this case, the first electronic device 601 may still function as a charging device and receive 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 function 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 it has received ACK B1 and the consent instruction B returned by the first electronic device 601.
[0611] When receiving ACK B1 and the approval 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 approval 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 approval 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 can 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 can switch the states of the first signal line and the second signal line in the second electronic device 602. Alternatively, the second SOC can 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.
[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 has been received, and may send the parsing result (i.e., whether the ACK B2 has been received or not received) to the first SOC. Alternatively, after the first protocol module receives the ACK B2, it may send the ACK B2 to the first SOC. After receiving the ACK B2, the first SOC may parse the ACK B2 to determine whether the ACK B2 returned by the second electronic device 602 has been received.
[0614] Upon receiving the ACK B2 returned by the second electronic device 602, the first protocol module may determine the time A at which the second electronic device 602 switches the states of the first signal line and the second signal line in the second electronic device 602, and may switch the states of the first signal line and the second signal line in the first electronic device 601 after a preset time T32 of time A. Alternatively, the first SOC may determine the time A at which the second electronic device 602 switches the states of the first signal line and the second signal line in the second electronic device 602, and may instruct the first protocol management module to switch the states of the first signal line and the second signal line in the first electronic device 601 after a preset time T32 of time A.
[0615] Subsequently, after determining that the first electronic device 601 serving as a power supply device and the second electronic device 602 serving 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, thereby enabling the first electronic device 601 to provide power to the second electronic device 602 through VBUS.
[0616] That is, after the first protocol module switches the states of the first and second signal lines, it can detect the voltage level on the second signal line. When the first protocol module detects a high voltage level on the second signal line within a 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 transmit information related to the successful handshake to the first SOC. After determining that the handshake is successful within the preset time T1, the first SOC can instruct the first power management module to adjust the output voltage of the first electronic device 601 to power on VBUS, thereby enabling the first electronic device 601 to provide power to the second electronic device 602 via VBUS.
[0617] Alternatively, after the first protocol module switches the states of the first signal line and the second signal line, it can detect the level on the second signal line and send the detected level 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. After the preset time T1 of determining that the handshake is successful, 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, thereby allowing the first electronic device 601 to provide power to the second electronic device 602 via 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. In this case, 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 a 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, please refer to the above-mentioned content on whether the handshake is successful.
[0622] It is understood that after the second protocol module switches the states of the first and second signal lines, it can also detect the voltage level on the first signal line. When the second protocol module detects a high voltage level on the first signal line within the preset time T02, the second protocol module can determine that the second electronic device 602, acting as the charging device, and the first electronic device 601, acting as the 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 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 based on 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using 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 using the charging protocol.
[0624] Alternatively, after detecting the voltage on VBUS, the second power management module can send the detected voltage to the second SOC. The second SOC can determine whether the voltage on VBUS meets a preset condition within a preset time T03. If 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, that the second electronic device 602 can communicate with the first electronic device 601 using 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 using the charging protocol.
[0625] Alternatively, after the second protocol module determines that the handshake between the second electronic device 602 and the first electronic device 601 is successful, it can detect the voltage on VBUS. After detecting the voltage on VBUS, the second protocol module can determine whether the voltage on VBUS meets a preset condition within a preset time T03. If the voltage on VBUS meets the preset condition 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using the charging protocol. At this time, the second protocol module can communicate with the first electronic device 601 using the charging protocol.
[0626] Alternatively, after the second protocol module detects the voltage on VBUS, it can send the detected voltage to the second SOC. The second SOC can determine whether the voltage on VBUS meets a preset condition within a 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 determines that the second electronic device 602 can communicate with the first electronic device 601 using 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 using 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 a high level is not detected on the first signal line within the preset time T02, or when 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 may determine that the handshake has failed. In this case, the second protocol module may restart the charging protocol handshake, or the second SOC may 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 may 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 using the charging protocol. In this case, the second protocol module may communicate with the first electronic device 601 using the charging protocol, or the second SOC may instruct the second protocol module to communicate with the first electronic device 601 using 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 the second SOC. For specific details, please refer to the above-mentioned content on 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, as shown in FIG6( b ), the charging cable may further include a CC, that is, the first electronic device 601 and the second electronic device 602 may further be connected via the 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 understood 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 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 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. In this case, CC1 in the first electronic device 601 may be pulled down via resistor Rd to generate a pull-down signal. CC1 in the second electronic device 602 may be pulled up via resistor Rp to generate a pull-up signal. Upon detecting a switching operation, the first electronic device 601 may pull up CC1 of the first electronic device 601 via resistor Rp to generate a pull-up signal. The second electronic device 602 may pull down CC1 of the second electronic device 602 via 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 supply 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 a CC, the first electronic device 601 can determine the charging status of the second electronic device 602 based on the level of the CC in the first electronic device 601, that is, the signal detected by the first electronic device 601 on the CC. Similarly, the second electronic device 602 can also determine the charging status of the first electronic device 601 based on the level of the CC in the second electronic device 602, that is, the signal detected by the second electronic device 602 on the CC. Therefore, the first electronic device 601 and the second electronic device 602 can adjust their output voltages based on their own charging status and the charging status of each other, thereby adjusting the power supply roles during the charging process.
[0637] That is, in this embodiment, when the power role needs to be switched, that is, when the switching operation is detected, the first electronic device 601 and the second electronic device 602 can respectively adjust the power role according to the charging protocol based on CC communication, that is, switch the charging status of the first electronic device 601 and the second electronic device 602, and adjust the power supply on VBUS according to the charging status of the first electronic device 601 and the second electronic device 602. At the same time, the first electronic device 601 can switch the status 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 status 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 specific content of the first electronic device 601 determining the charging status of the second electronic device 602 based on the signal detected on the CC, and the second electronic device 602 determining the charging status of the first electronic device 601 based on the signal detected on the CC can be referred to the relevant descriptions in Figures 1 to 3, and will not be repeated here.
[0639] Please refer to Figure 15, which shows a schematic flow chart of a method for switching power roles provided by another embodiment of the present application. This embodiment is illustrative of the method for switching power roles by detecting a switching operation in the second electronic device 602.
[0640] As shown in Figure 15, initially, the first electronic device 601 and the second electronic device 602 can be connected via a charging cable. At this 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 the 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] As shown in FIG15 , when the second electronic device 602 is providing power to the first electronic device 601, if the user wants to trigger a power role switch on the second electronic device 602, the user can perform a switching operation on the second electronic device 602. That is, the second electronic device 602 can detect the switching operation on the second electronic device 602.
[0642] When a switching operation is detected, the second electronic device 602 can adjust the power level of the CC to switch roles according to the switching operation, that is, switch the power level of the CC in the second electronic device 602. The first electronic device 601 can adjust the power level of the CC to switch roles according to the switching operation, that is, switch the power level of the CC in the first electronic device 601, so as to adjust the charging status of the first electronic device 601 and the second electronic device 602, thereby adjusting the power supply roles during the charging process, so that the first electronic device 601 can provide power to the second electronic device 602 via 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 an ACK B1 and an 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. In this case, the first electronic device 601 can still function as a charging device and receive 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 consent 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. If neither ACK B1 nor the consent instruction B is received, the second electronic device 602 can still function 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 from returning the ACK B2 to the first electronic device 601 .
[0651] The first electronic device 601 may determine whether the 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 states of the first signal line and the second signal line in the second electronic device 602, and can switch the states 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] Among them, the specific content 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 meets the preset conditions can be referred to the specific description in Figure 9, which 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 function 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 this application.
[0657] Corresponding to the power role switching method described in the above embodiment, an embodiment of the present application further provides a power role switching device, and each module of the device can correspond to each step of 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 this application. Their specific functions and technical effects can be found in the method embodiment section and will not be repeated here.
[0659] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and 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 into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of 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, and will not be repeated here.
[0660] The present application also provides an 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. When the processor executes the computer program, the electronic device implements the steps of any of the above-described method embodiments. For example, the structure of the electronic device may be as shown in FIG4 .
[0661] An embodiment of the present application further provides a computer-readable storage medium storing 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 run 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. The computer program can be stored in a computer-readable storage medium, and when the computer program is executed by the processor, it can implement the steps of the above-mentioned various method embodiments. Wherein, 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 or a telecommunication signal.
[0664] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0665] Those skilled 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 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 merely a logical function division. In actual implementation, there may be other division methods, 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 separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0668] The above-described embodiments 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, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application, and should all be included in the scope of protection 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 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 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 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 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 adjusts the output voltage of the first electronic device, comprising: 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, wherein the first instruction is used to instruct the second electronic device to switch to a charging device, and the first instruction is that the first electronic device sends a first instruction to the second electronic device when receiving the first operation. The first operation is sent by the sub-device, and 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.