Electricity meter communication method and electronic equipment

By keeping the communication lock busy when the fuel meter receives a repeat start signal, the problem of the fuel meter misinterpreting it as an end signal and causing a sleep mode is solved, thus enabling normal communication between the fuel meter and the host and improving the user experience.

CN121807758APending Publication Date: 2026-04-07HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-30
Publication Date
2026-04-07

AI Technical Summary

Technical Problem

When the fuel gauge receives a repeat start signal, it mistakenly identifies it as an end signal, causing the communication lock to be released and the system to switch to sleep mode, resulting in the inability to communicate normally.

Method used

When the fuel gauge receives a repeat start signal, it keeps the communication lock in a busy state, transmits data via the I2C bus, and controls the status flag of the communication lock through a counter to maintain the wake-up mode when necessary.

Benefits of technology

Ensure the battery level meter remains awake during communication to avoid sleep mode, guarantee normal communication, prevent incorrect display of battery information or prolonged inactivity, and improve user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121807758A_ABST
    Figure CN121807758A_ABST
Patent Text Reader

Abstract

The invention provides a voltameter communication method and electronic equipment, the method is applied to the electronic equipment, a voltameter is correspondingly provided with a communication lock, and the communication lock is used for enabling the voltameter to be in an awakening mode. The method comprises the following steps: in response to receiving a start signal, waking up a voltameter and enabling a communication lock to be in a busy state; and in response to the fact that the voltameter receives the repeated start signal and the read identification bit, keeping the communication lock in a busy state, and transmitting data stored in the voltameter to the host through the I2C bus. Wherein the repeated start signal is used for indicating the voltameter to prepare to receive data, and the read flag bit is used for reading data stored in the voltameter. By adopting the method, even if the voltameter mistakenly recognizes the repeated starting signal as the ending signal, the voltameter is still in the awakening state after receiving the repeated starting signal, so that normal communication of the voltameter is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the technical field of terminal, and in particular, to a battery gauge communication method and an electronic device. BACKGROUND

[0002] Some battery gauges may identify a repeated start signal sent by a host (such as a processor) as an end signal, which causes the battery gauge to mistakenly consider that an end signal is received when a repeated start signal is received, and thus incorrectly release a communication lock corresponding to an inter-integrated circuit (I2C) module in the battery gauge, causing the battery gauge to switch from a wake-up mode to a sleep mode, and thus resulting in the battery gauge being unable to normally communicate. SUMMARY

[0003] The present application provides a battery gauge communication method and an electronic device, which are used to avoid the battery gauge from being incorrectly switched to a sleep mode during communication, and thus ensure that the battery gauge normally communicates.

[0004] To achieve the above object, the present application adopts the following technical solutions:

[0005] In a first aspect, a battery gauge communication method is provided, which is applied to a battery gauge in an electronic device. The battery gauge is provided with a communication lock corresponding thereto, and the communication lock is used to realize that the battery gauge is in a wake-up mode. The method comprises the following steps: in response to receiving a start signal, the battery gauge is woken up and the communication lock is in a busy state; in response to the battery gauge receiving a repeated start signal and reading an identification bit, the communication lock is kept in the busy state, and data stored in the battery gauge is transmitted to a host through an I2C bus. The repeated start signal is used to indicate that the battery gauge is ready to receive data, and the identification bit is used to read the data stored in the battery gauge.

[0006] The battery gauge communication method provided by the present application can keep the communication lock of the battery gauge in the busy state during communication between the battery gauge and the host using the I2C standard protocol, even if the battery gauge identifies a received repeated start signal as an end signal. Since any module lock in the battery gauge being in the busy state can ensure that the battery gauge is in a wake-up state, keeping the communication lock of the battery gauge in the busy state can ensure that the battery gauge is in the wake-up mode, and thus the battery gauge can still transmit data to the host, i.e., the battery gauge can still normally communicate.

[0007] In a possible implementation manner of the first aspect, after the battery gauge is woken up and the communication lock is in the busy state, the above method can further comprise the following step: in response to the battery gauge receiving an end signal, the communication lock is kept in the busy state. The end signal is used to indicate that the battery gauge ends a data transmission process.

[0008] In the scheme, the power meter is still in the wake-up mode after receiving the end signal, that is, the power meter can still communicate normally.

[0009] In a possible implementation of the first aspect, the communication lock has a state flag bit. When the state flag bit is a first value, the communication lock is in a busy state; and when the state flag bit is a second value, the communication lock is in an idle state.

[0010] In the scheme, the communication lock can be a software communication lock, and the state of the communication lock can be set by setting the state flag bit of the communication lock, which is convenient and fast.

[0011] In a possible implementation of the first aspect, the electronic device further includes a counter. The method further includes: in response to the state flag bit of the communication lock being the first value, triggering the counter to start timing; and in response to the timing duration of the counter being a first duration, the first duration being less than the first preset duration, and a repeated start signal or an end signal being received within the first duration, maintaining the state flag bit of the communication lock as the first value.

[0012] In the scheme, when the communication lock is in the busy state, the counter can be triggered to time. If the power meter receives a repeated start signal or an end signal within the first duration, the power meter can continue to control the communication lock to be in the busy state, so that the power meter remains in the wake-up mode.

[0013] In a possible implementation of the first aspect, the method further includes: in response to maintaining the state flag bit of the communication lock as the first value, triggering the counter to restart timing; in response to the timing duration of the counter restarting timing being a second duration, the second duration being greater than a second preset duration, and a repeated start signal or an end signal not being received within the second duration, changing the state flag bit of the communication lock to the second value, and setting the power meter to a sleep mode.

[0014] In the scheme, when the communication lock remains in the busy state, the counter can be triggered to restart timing. If the power meter does not receive a repeated start signal or an end signal within the second duration, it indicates that the power meter has ended the current communication process. Therefore, the communication lock can be controlled to switch to the idle state by changing the state flag bit of the communication lock to the second value, and the power meter can be set to the sleep mode, thereby saving power consumption.

[0015] In a possible implementation of the first aspect, the electronic device further includes a processor, the processor being connected with the power meter, the power meter including an I2C module, the I2C module corresponding to the communication lock. After the power meter is woken up, the method further includes: the power meter in the wake-up mode controlling a function switch of the I2C module to be in a conduction state, and a clock of the I2C module being in a working state.

[0016] In a possible implementation of the first aspect, after the state flag bit of the communication lock is changed from the first value to the second value, the method further includes: based on the power meter switching from the wake-up mode to the sleep mode, triggering the power meter to control the function switch of the I2C module to be in the off state, the clock of the I2C module to be in the stop state, and the STA interrupt to be enabled. The STA interrupt is used to wake up the power meter.

[0017] In a possible implementation of the first aspect, after the power meter is in the sleep mode, the method further includes: based on the power meter receiving a start signal, triggering the STA interrupt to wake up the power meter, and controlling the function switch of the I2C module to be in the on state and the clock of the I2C module to be in the working state again; and the power meter switching from the sleep mode to the wake-up mode.

[0018] In a possible implementation of the first aspect, the power meter further includes other modules in addition to the communication module, and each of the other modules corresponds to a module lock. The condition for the power meter switching from the wake-up mode to the sleep mode includes that the power meter determines that the state flag bits of the module locks corresponding to the other modules are all the second value.

[0019] In the second aspect, the present application provides an electronic device, including a memory and a power meter, and the power meter is connected with the memory. The memory stores computer program codes, and the computer program codes include instructions. When the power meter executes the instructions, the electronic device executes the method in the first aspect and any possible implementation manner thereof.

[0020] In the third aspect, a computer readable storage medium is provided, and the computer readable storage medium stores instructions. When the instructions are executed on the electronic device, the electronic device can execute the method in any one of the first aspect.

[0021] In the fourth aspect, a computer program product is provided, and the computer program product includes instructions. When the instructions are executed on the electronic device, the electronic device can execute the method in any one of the first aspect.

[0022] In the fifth aspect, a chip system is provided, and the chip system includes a processor for supporting the electronic device to implement the functions in the first aspect and any implementation manner thereof. In a possible design, the electronic device further includes an interface circuit, which can be used to receive signals from other devices (for example, a memory) or send signals to other devices (for example, a communication interface). The chip system can include a chip and can also include other discrete devices.

[0023] It can be understood that the electronic device provided in the second aspect, the computer readable storage medium provided in the third aspect, the computer program product provided in the fourth aspect, and the chip system provided in the fifth aspect can achieve the beneficial effects of the first aspect and any possible implementation manner thereof, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS

[0024] Figure 1 A timing diagram of an I2C bus signal provided for an embodiment of the present application;

[0025] Figure 2 A signal flow diagram of interaction between a host and a slave based on an I2C standard protocol provided for an embodiment of the present application;

[0026] Figure 3 A flow diagram of a power meter communication method between a power meter and a processor provided for an embodiment;

[0027] Figure 4 A display interface schematic diagram of a mobile phone provided for an embodiment of the present application;

[0028] Figure 5 A display interface schematic diagram of a mobile phone provided for an embodiment of the present application;

[0029] Figure 6 A hardware structure schematic diagram of an electronic device provided for an embodiment of the present application;

[0030] Figure 7 A power meter software architecture schematic diagram provided for an embodiment of the present application;

[0031] Figure 8 A flow schematic diagram of a power meter communication method provided for an embodiment of the present application;

[0032] Figure 9 A display interface schematic diagram of a mobile phone provided for an embodiment of the present application;

[0033] Figure 10 A display interface schematic diagram of a mobile phone provided for an embodiment of the present application;

[0034] Figure 11 A structure schematic diagram of a chip system provided for an embodiment of the present application. DETAILED DESCRIPTION

[0035] The terms "first", "second", and the like used in the embodiments of the present application are only used for the purpose of distinguishing the same type of features, and cannot be understood as indicating relative importance, quantity, order, and the like.

[0036] The terms "exemplary" or "for example" used in the embodiments of this application are used to indicate examples, illustrations, or descriptions. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a specific manner.

[0037] The terms "coupling" and "connection" used in the embodiments of this application should be interpreted broadly. For example, they can refer to a physical direct connection or an indirect connection achieved through electronic devices, such as a connection achieved through resistors, inductors, capacitors or other electronic devices.

[0038] First, let's introduce some concepts involved in this application:

[0039] 1. Fuel gauge: A device designed based on Faraday's law to obtain battery power information. This information may include parameters such as the battery's charge level. The battery's charge level may include the displayed charge level. Typically, battery-powered electronic devices are equipped with a fuel gauge. After obtaining the displayed battery charge level, the fuel gauge reports it to the host computer (such as a processor) within the electronic device. The host computer then reports it to the display module, which displays the battery charge level to the user, allowing the user to understand the battery's charge level.

[0040] 2. Inter-integrated circuit (I2C) standard protocol: This is a protocol that allows multiple slave devices to communicate with one or more masters. The master and slave devices can belong to the same device, or they can belong to different devices. This article uses the example of the master and slave devices belonging to the same device. The master is a module in a device used to send commands and data, controlling other modules on the I2C bus; the slave device cannot initiate communication, but can only receive commands and data sent by the master and execute corresponding operations. In the I2C standard protocol, the master and slave devices communicate through two lines: the serial clock line (SCL) and the serial data line (SDA).

[0041] During I2C protocol communication, the host can generate a start signal (start, S) and a stop signal (stop, P). The following section combines... Figure 1 The start and end signals will be explained. Figure 1 A timing diagram of an I2C bus signal according to an embodiment of this application is shown. For example, as shown... Figure 1As shown, when SCL is high, the transition from high to low on SDA will generate a start signal; when SCL is high, the transition from low to high on SDA will generate an end signal.

[0042] The start signal marks the beginning of a data transfer process. The master sends the start signal to notify all slave devices on the I2C bus that a data transfer is about to begin. Upon receiving the start signal, a slave device prepares to receive data from the master, or prepares to send data to the master.

[0043] The end signal marks the end of a data transmission process. The master sends an end signal to notify all slave devices on the I2C bus that the master will no longer send data to the slave devices, thus putting the I2C bus into an idle state.

[0044] In addition, during I2C protocol communication, the host will also generate a restart signal (Rs) to synchronize data with the slave. The restart signal means that instead of giving an end signal when communication ends, a start signal is given again within one clock cycle.

[0045] Figure 2 This document illustrates a signal flow diagram of a host and slave device interacting based on the I2C standard protocol, according to an embodiment of this application.

[0046] For example, such as Figure 2 As shown in Figure A, in a write command scenario, the master sends a start signal, along with the slave's address and write flag. After receiving the address from the master, the slave replies with an acknowledgment (ACK) signal. Upon receiving the acknowledgment signal, the master sends the data to be written byte by byte to the slave. During data transmission, when the slave receives a byte of data sent by the master, it replies with an acknowledgment signal. Upon receiving the acknowledgment signal, the master continues to send the next byte of data to the slave. Once the master has sent all data to the slave, it sends an end signal to notify the slave that the data transmission process is complete.

[0047] like Figure 2As shown in Figure B, in a read command scenario, the master sends a start signal, along with the slave's address and write flag. After receiving the address from the master, the slave replies with an acknowledgment signal. Upon receiving the acknowledgment signal, the master sends one byte of data, a repeat start signal, the slave's address, and the read flag to the slave. The slave, upon receiving the address from the master, replies with an acknowledgment signal. Next, the master receives the data sent by the slave. When the master wishes to stop receiving data from the slave, it sends a negative acknowledgement (NACK) signal and a stop signal to notify the slave that the data transmission process has ended.

[0048] 3. Module Locks of the Fuel Meter: The fuel meter includes multiple modules for performing different services. Each module performs different services, and each module corresponds to a module lock (for example, the module lock corresponding to the communication module in the fuel meter can be called a communication lock). The module lock corresponding to a module can be called the module lock of the module. When one module of the fuel meter is running, the module lock of that module is in a busy state, thus ensuring that the fuel meter is in wake-up mode. When a module stops running, the module lock of that module is in an idle state. When all module locks in the fuel meter are in an idle state, the fuel meter is in sleep mode.

[0049] It should be noted that the "busy state" here refers to the working state, while the "idle state" refers to the low-power state.

[0050] For example, a fuel gauge may include a communication module, such as an I2C module. The fuel gauge performs communication with a host (such as a processor) through the communication module, which may correspond to a communication lock. During communication with the host, the fuel gauge keeps its communication lock in a busy state.

[0051] 4. I2C Bus States: These include idle state, start signal, and stop signal. Idle state refers to the state where both SDA and SCL of the I2C bus are high, indicating that the I2C bus is not currently communicating. The start signal is generated when SDA transitions from high to low when SCL is high, indicating the start of a data transmission process. The stop signal is generated when SDA transitions from low to high when SCL is high, indicating the end of a data transmission process.

[0052] 5. Low-power switching scheme for the fuel gauge: When the fuel gauge determines that all module locks in the fuel gauge are in an idle state, the fuel gauge will switch to low-power mode. When an external interrupt occurs, the fuel gauge will exit low-power mode.

[0053] For example, external interrupts may include, but are not limited to: interrupts generated by general-purpose input / output ports, interrupts generated by the time module, start condition (STA) interrupts (i.e., interrupts triggered by a start signal), interrupts issued after an analog-to-digital converter completes a conversion, coulomb interrupts, and current wake-up interrupts.

[0054] 6. I2C design of the fuel gauge:

[0055] (1) When the fuel gauge enters low-power mode, it automatically shuts down the I2C module. Since the I2C module is disabled, the fuel gauge cannot receive the wake-up signal from the host, meaning communication between the fuel gauge and the host is interrupted. Consequently, the fuel gauge cannot communicate with the host and therefore cannot provide battery power information to the host. When the fuel gauge exits low-power mode, it automatically turns on the I2C module, restoring communication between the fuel gauge and the host.

[0056] It should be noted that the automatic shutdown and automatic opening of the I2C module by the aforementioned fuel gauge do not require software control, but are implemented by the fuel gauge's own hardware design.

[0057] (2) In low-power mode, the fuel gauge can enable the STA interrupt. The STA interrupt can respond to the start signal sent by the host, causing the fuel gauge to exit low-power mode (i.e., wake up the fuel gauge) and pass the start signal to the fuel gauge's I2C module. After receiving the start signal, the fuel gauge's I2C module can continue to communicate with the host, and thus continue to receive information sent by the host, such as address information.

[0058] (3) The fuel meter cannot distinguish between the end signal and the repeat start signal. When the fuel meter receives the repeat start signal sent by the host, it will identify the repeat start signal as the end signal.

[0059] In some examples, low-power mode can be called sleep mode, and non-low-power mode can be called wake-up mode. Therefore, exiting low-power mode can be understood as switching from sleep mode to wake-up mode; entering low-power mode can be understood as switching to sleep mode.

[0060] The following text combines Figure 3 This paper describes the communication process between the processor and the fuel gauge discussed in this paper.

[0061] Figure 3 A flowchart illustrating a method for communication between a fuel meter and a processor according to an embodiment is shown. Examples include... Figure 3 As shown, the fuel meter communication method may include:

[0062] S301, The processor sends a start signal to the fuel gauge.

[0063] As mentioned above, the start signal marks the beginning of a data transmission process.

[0064] S302, The fuel gauge receives a start signal and, in response to the start signal, activates the I2C module in the fuel gauge.

[0065] Since the start signal marks the beginning of a data transmission process, when the fuel gauge receives the start signal from the processor, it switches to wake-up mode and starts the I2C module in the fuel gauge to communicate with the processor through the I2C module.

[0066] S303, the power meter control communication lock is in a busy state.

[0067] The communication lock is the module lock corresponding to the fuel gauge's I2C module. When the I2C module is started, the communication lock being in a busy state ensures that the fuel gauge is in wake-up mode.

[0068] S304, data is transmitted between the fuel gauge and the processor.

[0069] Once the fuel gauge activates its I2C module and the control communication lock is in a busy state, the fuel gauge can communicate with the processor via I2C, enabling data transfer. This data transfer can refer to either the processor sending data to the fuel gauge, or the fuel gauge sending data to the processor. This data can include data written to the fuel gauge by the processor, or data read from the fuel gauge by the processor. It can also include I2C signals sent by the processor to the fuel gauge, such as end signals and repeat start signals.

[0070] S305, the fuel gauge receives data sent by the processor.

[0071] The fuel gauge can receive data sent by the processor through the I2C module in the fuel gauge.

[0072] S306. The fuel gauge determines whether the data sent by the processor includes an end signal.

[0073] S307. If the fuel gauge determines that the data sent by the processor includes an end signal, the fuel gauge will release the communication lock.

[0074] In both read and write command scenarios, if the fuel gauge receives data including an end signal, it will undoubtedly recognize it as such. However, in read command scenarios, as described in the fuel gauge's I2C design, if the fuel gauge receives data including a repeat start signal, it will also recognize the repeat start signal as an end signal. In other words, for the fuel gauge discussed in this paper, regardless of whether it receives an end signal or a repeat start signal, the fuel gauge will determine that it has received an end signal.

[0075] Since the end signal signifies the end of a data transmission process, when the fuel gauge receives the end signal, it determines that the communication has ended, meaning the fuel gauge's I2C module has completed its communication with the processor. Therefore, the fuel gauge will switch its I2C module to an idle state. Based on this, the fuel gauge will release the communication lock, meaning the communication lock will no longer be in a busy state.

[0076] It should be understood that if the fuel gauge determines that the received data does not include an end signal, such as if the received data is the address of the fuel gauge, the fuel gauge will continue to control the communication lock to be in a busy state (i.e., the fuel gauge continues to execute S303), thereby ensuring that the fuel gauge is in wake-up mode.

[0077] S308. When the fuel gauge meets the condition of switching from wake-up mode to sleep mode, the fuel gauge switches from wake-up mode to sleep mode.

[0078] In S307, after receiving the end signal, the fuel gauge switches the I2C module of the fuel gauge to the idle state. If other modules in the fuel gauge besides the I2C module are also in the idle state, that is, all modules in the fuel gauge are in the idle state, the condition for the fuel gauge to switch to sleep mode is met. Therefore, the fuel gauge will switch from wake-up mode to sleep mode.

[0079] S309, the fuel gauge's I2C module is off.

[0080] In sleep mode, the fuel gauge can disable the I2C module to reduce power consumption.

[0081] S310, the fuel gauge enables STA interrupt.

[0082] When the fuel gauge is in sleep mode, it can enable the STA interrupt so that it can exit sleep mode in response to the start signal sent by the host.

[0083] S311, The processor sends a start signal to the fuel gauge.

[0084] When the processor needs to begin the next data transfer process with the fuel gauge, the processor can send a start signal to the fuel gauge again.

[0085] S312, the fuel meter receives the start signal.

[0086] S313, the STA interrupt in the fuel meter is activated by the start signal to wake up the fuel meter.

[0087] As can be seen from the nature of the STA interrupt, the STA interrupt can wake up the fuel gauge in response to the start signal sent by the processor (i.e., the host), even if the fuel gauge exits sleep mode.

[0088] S314, the fuel gauge restarts the I2C module.

[0089] After the fuel gauge is woken up, it can send a start signal to its I2C module, thereby restarting the I2C module. Once the I2C module is started, the fuel gauge will continue to execute step S303 as described above.

[0090] In summary, when the fuel gauge receives a start signal from the host, it indicates that a data transmission process has begun. The fuel gauge can communicate with the host through its I2C module and keep the communication lock in a busy state. When the fuel gauge receives a stop signal from the host, it indicates that a data transmission process has ended, meaning the fuel gauge's I2C module has completed its communication with the host and will be idle. At this point, if other modules in the fuel gauge besides the I2C module are also idle, the conditions for the fuel gauge to switch to sleep mode are met. Therefore, the fuel gauge will switch to sleep mode and will no longer communicate with the host.

[0091] When all modules in the fuel gauge except the I2C module are idle, upon receiving a repeat start signal from the host, the fuel gauge may mistakenly interpret the repeat start signal as an end signal, thus releasing the communication lock (even if the communication lock is idle) and switching the fuel gauge to sleep mode. At this point, if the host does not send a start signal to the fuel gauge (i.e., no start signal triggers the STA interrupt in the fuel gauge), it cannot wake up the fuel gauge (i.e., it cannot exit sleep mode). Therefore, the fuel gauge cannot respond to read commands, preventing the host from reading data from the fuel gauge and thus from obtaining the displayed battery level. This can lead to issues such as fluctuating battery level (e.g., displayed battery level changes) or the battery level remaining unchanged for extended periods, negatively impacting the user experience.

[0092] Of course, in other scenarios, when the fuel gauge in an electronic device enters sleep mode, it can also cause abnormal communication between the fuel gauge and the host device, resulting in the host device being unable to obtain the battery power information in a timely manner, thus affecting the user's experience of using the electronic device.

[0093] The electronic devices discussed in this article can be referred to as terminals, user equipment (UE), mobile stations (MS), mobile terminals (MT), etc. These devices include batteries, fuel gauges, and processors, with the fuel gauge connected to the battery and processor. Electronic devices can be mobile phones, smart TVs, wearable devices, tablets, computers with wireless transceiver capabilities, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, or wireless terminals in smart homes, etc.

[0094] For ease of understanding, the following text uses a mobile phone as an example of an electronic device, combined with... Figure 4 and Figure 5 This section describes how electronic devices experience sudden fluctuations in battery level and prolonged periods of stable battery level.

[0095] Figure 4 This diagram illustrates one of the display interfaces of a mobile phone provided in an embodiment.

[0096] In one embodiment, such as Figure 4 As shown in A, mobile phone 100 displays a first interface 410. The first interface 410 includes a first time point 411 and a first battery level icon 412. The first battery level icon 412 is used to display that the battery level of mobile phone 100 at the first time point 8:00 is 90%. If the battery gauge inside the phone is in sleep mode and cannot communicate with the processor inside the phone at the first time point, the processor cannot continue to obtain the battery level displayed by the battery gauge. If the battery gauge inside the phone switches from sleep mode to wake-up mode at a second time point, the processor can continue to obtain the battery level displayed by the battery gauge, thus allowing mobile phone 100 to display the battery level as shown in the image. Figure 4 The second interface 420, shown as B in the diagram, includes a second time 421 and a second battery icon 422. The second battery icon 422 is used to display that the battery level of the mobile phone 100 is 84% ​​at the second time of 8:03.

[0097] Therefore, it can be seen that the displayed battery level of the phone jumped from 90% to 84%, which is a change of 6%. Because the fuel gauge was unable to communicate with the processor for an extended period, it could not promptly report the latest displayed battery level to the phone's display module. When communication between the fuel gauge and the processor resumed, the difference between the displayed battery level reported by the fuel gauge and the previous display level was significant, resulting in a noticeable jump in battery level for the user and a poor user experience.

[0098] Figure 5 This is a second schematic diagram of the display interface of a mobile phone provided in one embodiment.

[0099] In one embodiment, such as Figure 5 As shown in A, mobile phone 100 displays a third interface 510. The third interface 510 includes a third time point 511, a third battery icon 512, and a first display screen 513. The third battery icon 512 displays that the battery level of mobile phone 100 at the third time point 9:55 is 60%. The first display screen 513 displays the first video played by mobile phone 100 at the third time point 9:55. If the battery indicator inside the phone remains in sleep mode and cannot communicate with the processor while the phone is playing the video, the processor cannot obtain the battery level from the battery indicator during this sleep mode period. If the battery indicator inside the phone is still in sleep mode and not communicating with the processor, the phone displays as shown in the image. Figure 5 The fourth interface 520 is shown as B in the diagram. The fourth interface 520 includes a fourth time point 521, a fourth battery level icon 522, and a second display screen 523. The fourth battery level icon 522 displays that the battery level of the phone 100 is 60% at the fourth time point 10:00. The second display screen 523 displays a second video played by the phone 100 at the fourth time point 10:00. The phone 100 continuously plays the video during the period between the third and fourth times.

[0100] Therefore, it can be seen that while the phone 100 continuously plays videos, the displayed battery level remains at 60%, meaning the displayed battery level remains constant for an extended period. However, during this time, the phone 100 is in a discharge scenario because it is continuously playing videos, so the battery percentage is constantly decreasing. The displayed battery level changes with the battery percentage, so the actual displayed battery level should also be continuously decreasing. However, because the processor cannot communicate with the fuel gauge, the fuel gauge cannot report the latest displayed battery level to the phone's display module, causing the displayed battery level to remain unchanged for an extended period. If the displayed battery level remains unchanged for more than a preset time, the phone will automatically shut down to prevent over-discharge and other issues, thus protecting the battery. This results in users experiencing the phone automatically shutting down when the battery is high, leading to a poor user experience.

[0101] Therefore, embodiments of this application provide a fuel gauge communication method and an electronic device. Specifically, in response to receiving a start signal, the fuel gauge is awakened and the communication lock is in a busy state. Furthermore, in response to receiving a repeat start signal and a read flag, the fuel gauge maintains the communication lock in a busy state and transmits the data stored in the fuel gauge to the host via the I2C bus. The repeat start signal is used to indicate that the fuel gauge is ready to receive data, and the read flag is used to read the data stored in the fuel gauge.

[0102] When the communication lock is in a busy state, if the fuel gauge receives a repeat start signal and a read flag, it will keep the communication lock in a busy state. Since the fuel gauge will not enter sleep mode as long as one module lock is in a busy state, even if the fuel gauge identifies the repeat start signal as an end signal, it will not enter sleep mode. Therefore, there is no problem of the fuel gauge being unable to be woken up, thus ensuring normal communication of the fuel gauge.

[0103] Figure 6 A schematic diagram of the hardware structure of an electronic device according to an embodiment of this application is shown. The following description, in conjunction with... Figure 6 The hardware structure of electronic devices will be introduced.

[0104] Take a mobile phone as an example. Figure 6 As shown, the electronic device 600 may include: a processor 610, a memory 620, a display screen 630, a sensor module 640, a power management module 650, a fuel gauge 651, a battery 660, a charging management module 670, a universal serial bus (USB) interface 680, a camera 690, an audio module 691, a communication module 692, and an antenna, etc.

[0105] Processor 610 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, audio data signal processor (ADSP), and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors. The controller may be the central nervous system and command center of electronic device 600. The controller can generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.

[0106] In this embodiment, the processor 610 can act as a host to communicate with the fuel gauge. The processor 610 can send start signals, end signals, and repeat start signals to the fuel gauge. The descriptions of the start signals, end signals, and repeat start signals are as described above and will not be repeated here.

[0107] The memory 620 can be used to store computer executable program code, which includes instructions. The processor 610 executes various functional applications and data processing of the electronic device by running the instructions stored in the memory 620. The memory 620 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, interface display, etc.). The data storage area may store data created during the use of the electronic device (such as notification messages). Furthermore, the memory 620 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0108] Electronic device 600 implements display functions through a GPU, a display screen 630, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 630 and the application processor. The GPU performs mathematical and geometric calculations and is used for graphics rendering. Processor 610 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0109] The display screen 630 is used to display images, videos, etc. The display screen 630 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 Mini-LED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc.

[0110] In this embodiment, the display screen 630 can display a UI interface, which may include battery icons (such as the first battery icon, second battery icon, etc. mentioned herein) to help users understand the battery level of the electronic device. Of course, the UI interface can also display content such as screen images.

[0111] The sensor module 640 may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and bone conduction sensors, etc.

[0112] The charging management module 670 receives charging input from the charger. In some wired charging embodiments, the charging management module 670 receives charging input from the wired charger via USB interface 680. In some wireless charging embodiments, the charging management module 670 receives wireless charging input via the wireless charging coil of the electronic device 600. While charging the battery 660, the charging management module 670 can also supply power to the electronic device via the power management module 650.

[0113] The power management module 650 receives input from the battery 660 and / or the charging management module 670 to power the processor 610, memory 620, display 630, etc.

[0114] In some embodiments, the fuel gauge 651 may be integrated into the power management module 650; in other embodiments, the fuel gauge 651 and the power management module 650 may be two separate modules. Figure 4 The example shown is an integrated power meter 651 within a power management module 650.

[0115] In this embodiment, the software logic of the fuel gauge has been improved. Specifically, when the fuel gauge communicates with the host and the communication lock is in a busy state, the fuel gauge receives a repeat start signal and a read flag bit sent by the host. The fuel gauge will keep the communication lock in a busy state, keeping the fuel gauge in wake-up mode, so that the fuel gauge and the processor can communicate normally, and then transmit the data stored in the fuel gauge to the processor through the I2C bus.

[0116] Camera 690 is used to capture still images or videos. Audio module 691 is used to convert digital audio information into analog audio signals for output, convert analog audio input into digital audio signals, and encode and decode audio signals. Communication module 692 can provide solutions for wireless communication applications such as wireless local area networks (WLAN) and Bluetooth (BT) applied to electronic device 600.

[0117] It is understood that the structure illustrated in this embodiment does not constitute a specific limitation on the electronic device 600. In other embodiments, the electronic device 600 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0118] Generally, the implementation of the fuel gauge wake-up function in electronic devices requires both hardware support and software cooperation. The software system of the fuel gauge in an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application's embodiment uses a layered architecture based on Android. For example, combined with Figure 7 The software architecture of the fuel gauge in the electronic device involved in the embodiments of this application is described.

[0119] Figure 7 A schematic diagram of a fuel meter software architecture provided in an embodiment of this application is shown. Figure 7 As shown, the fuel gauge in an electronic device can include, from top to bottom, an application layer, an application framework layer, and a kernel layer.

[0120] The application layer can include communication commands. These communication commands can include read and write commands via I2C signals. The communication commands are the same for different models of fuel meters.

[0121] The application framework layer provides an application programming interface (API) for applications in the application layer. This allows applications in the application layer to communicate with the corresponding fuel meter driver in the kernel layer through the API.

[0122] Different models of fuel gauges have different API interfaces, so the application framework layer can include at least one API interface, with different API interfaces corresponding to different models of fuel gauges.

[0123] The kernel layer includes the I2C bus standard protocol, fuel gauge driver, and fuel gauge wake-up module. The fuel gauge driver can be used to operate the fuel gauge, for example, to monitor relevant battery data and status. Different fuel gauge models require different fuel gauge drivers; therefore, the kernel layer can include at least one fuel gauge driver, with different drivers corresponding to different fuel gauge models.

[0124] The fuel meter wake-up module is used to: trigger fuel meter communication and ensure that the fuel meter's communication lock is busy when the fuel meter driver determines that the fuel meter has been woken up.

[0125] The fuel gauge wake-up module is also used to: when it is determined that the fuel gauge has received a repeat start signal and a read flag, keep the communication lock in a busy state so that the fuel gauge continues to be in wake-up mode, thereby enabling the fuel gauge to communicate normally. In this way, the fuel gauge can transmit the data stored in the fuel gauge to the host via the I2C bus.

[0126] The fuel gauge wake-up module is also used to: after the fuel gauge is woken up and the communication lock is in a busy state, in response to the fuel gauge receiving an end signal, keep the communication lock in a busy state, thereby ensuring that the fuel gauge can still communicate normally.

[0127] The fuel gauge wake-up module is also used to: trigger a counter to start timing when the communication lock is in a busy state. If the counter's timing duration is a first duration, which is less than a first preset duration, and a repeat start or end signal is received within the first duration, the communication lock remains in a busy state. Alternatively, if the counter's timing duration is a second duration, which is longer than a second preset duration, and no repeat start or end signal is received within the second duration, the communication lock is switched from a busy state to an idle state, and the fuel gauge is set to sleep mode.

[0128] The following text takes relevant modules in electronic devices (such as processors and fuel gauges) as the main execution entities, combined with... Figure 8 and Figure 9 The present application will introduce the fuel meter communication method provided in the embodiments.

[0129] Figure 8This illustration shows one of the flowcharts of a fuel meter communication method provided in an embodiment of this application. Figure 8 As shown, the method may include:

[0130] S801, the processor sends a start signal to the fuel gauge.

[0131] The start signal marks the beginning of a data transmission process.

[0132] S802, the fuel gauge receives a start signal and is woken up in response to the start signal.

[0133] Since the start signal marks the beginning of a data transmission process, the fuel gauge will switch to wake-up mode after receiving the start signal from the processor.

[0134] In one embodiment, after the fuel gauge is woken up, it activates the I2C module in the fuel gauge to communicate with the processor via the I2C module. For example, activating the I2C module may include: controlling the function switch of the I2C module to be in a conducting state, and controlling the clock of the I2C module to be in an active state.

[0135] S803, the power meter control communication lock is in a busy state.

[0136] The communication lock is the module lock corresponding to the fuel gauge's I2C module. When the I2C module starts, keeping the communication lock in a busy state ensures the fuel gauge remains in wake-up mode. The communication lock can be a hardware lock or a software lock; this article focuses on a software communication lock. The following section uses a software communication lock as an example to illustrate how to keep the communication lock in a busy state:

[0137] In one embodiment, the communication lock described herein has a status flag bit. By changing the status flag bit, the communication lock can be controlled to be in a busy state or an idle state. Specifically, when the status flag bit of the communication lock is a first value (e.g., 1), the communication lock can be in a busy state; when the status flag bit of the communication lock is a second value (e.g., 0), the communication lock can be in an idle state.

[0138] S804: The power meter starts timing after the communication lock is in a busy state.

[0139] In one embodiment, the electronic device may further include a counter. When the communication lock is in a busy state, i.e., when the status flag of the communication lock is a first value, the fuel gauge can trigger the counter to start timing to obtain the duration of the communication lock being in a busy state.

[0140] In one example, when the status flag of the communication lock is at the first value, the fuel gauge can send a timing command to the timer to instruct the timer to start counting. Each time the timer completes a counting cycle, it sends a count to the fuel gauge so that the fuel gauge can promptly obtain the duration the communication lock has been in a busy state.

[0141] For example, taking a counting cycle of 250ms as an example, when the count is 3, the power meter can determine that the communication lock has been in a busy state for 750ms; when the count is 4, the power meter can determine that the communication lock has been in a busy state for 1000ms.

[0142] S805, data is transferred between the processor and the fuel gauge.

[0143] When the I2C module is started and the communication lock is in a busy state, the processor can communicate with the fuel gauge via I2C. Therefore, the processor can transmit data to the fuel gauge through the I2C bus, and the fuel gauge can also transmit data to the processor through the I2C bus.

[0144] It should be understood that S804 and S805 can be executed simultaneously.

[0145] S806: The fuel gauge determines whether an I2C signal has been received within the first duration after the timing starts. If an I2C signal is received, proceed to S807; otherwise, if no I2C signal is received, proceed to S809-S816.

[0146] S807. If the fuel gauge determines that it receives an I2C signal within the first duration after the start of timing, the fuel gauge control communication lock remains in a busy state.

[0147] The first duration can be less than the first preset duration. The first preset duration can be set according to the situation. The I2C signal can include: repeat start signal, end signal, data, etc.

[0148] In one embodiment, taking the case where the fuel gauge receives an end signal within a preset time after the communication lock has been in a busy state as an example, since the end signal signifies the end of a data transmission process, the fuel gauge would normally control the communication lock to switch from a busy state to an idle state after receiving the end signal. However, in this step, the fuel gauge will still control the communication lock to remain in a busy state after receiving the end signal. In this way, the fuel gauge is still in wake-up mode, enabling the fuel gauge to communicate normally, that is, the fuel gauge can transmit the data stored in the fuel gauge to the processor via the I2C bus.

[0149] In another embodiment, taking the case where the fuel gauge receives a repeat start signal within a preset time after the communication lock is in a busy state as an example, although the fuel gauge will identify the repeat start signal as an end signal, in this step, the fuel gauge will still control the communication lock to remain in a busy state after identifying the end signal. This avoids the fuel gauge switching directly from wake-up mode to sleep mode after receiving the repeat start signal, thus preventing the fuel gauge from being unable to wake up and causing a communication failure between the fuel gauge and the processor. In this way, the fuel gauge remains in wake-up mode, enabling normal communication; that is, the fuel gauge can transmit the data stored in the fuel gauge to the processor via the I2C bus.

[0150] In one embodiment, the first duration can be less than a first preset duration. That is, within the first preset duration, if the fuel meter receives a repeat start signal or end signal, the fuel meter can keep the communication lock in a busy state by maintaining the status flag bit of the communication lock at a first value. The first preset duration can be set according to specific circumstances.

[0151] In one embodiment, assuming a counting cycle of 250ms and a first preset duration of 1000ms, when the count reaches 4, the communication lock has been in a busy state for the first preset duration. When the I2C clock frequency is 400kHz and the data communication time per frame exceeds 5ms, a count of 4 (i.e., a preset duration of 1000ms) can reduce the probability of data transmission failure when multiple frames of data are transmitted concurrently between the host and the fuel gauge.

[0152] S808: The fuel meter restarts timing from the point where the control communication lock is in a busy state.

[0153] When the fuel gauge keeps the communication lock in a busy state, the fuel gauge can clear the previous count and recalculate the duration of the communication lock being busy. After the fuel gauge re-acquires the duration of the communication lock being busy, the fuel gauge will continue to execute S805-S806 as described above.

[0154] In one embodiment, when the status flag of the communication lock remains at a first value, the fuel gauge can trigger the timer to restart. For example, when the status flag of the communication lock remains at the first value, the fuel gauge can resend the timing command to the timer to restart the timing.

[0155] In one embodiment, if the fuel gauge receives an I2C signal within the second duration after the timing restarts, the fuel gauge can continue to keep the communication lock in a busy state, that is, continue to keep the communication lock status flag bit at the first value. The second duration is longer than a second preset duration.

[0156] For example, the second duration can be greater than the first duration, the first duration can be equal to the second duration, or the second duration can be less than the first duration. The second preset duration can be equal to the first preset duration, the second preset duration can be less than the first preset duration, or the second preset duration can be greater than the first preset duration. For example, the first preset duration and the second preset duration can be 750ms-1000ms.

[0157] S809. If the fuel gauge determines that it has not received an I2C signal within the first duration after the start of timing, the fuel gauge controls the communication lock to switch from the busy state to the idle state.

[0158] If the fuel gauge determines that it has not received an I2C signal within the first duration after the start of timing, it indicates that the communication between the fuel gauge and the processor has ended. The fuel gauge can then control the communication lock to switch from a busy state to an idle state, that is, the fuel gauge releases the busy state of the communication lock.

[0159] In one embodiment, if the fuel gauge does not receive an I2C signal during the second period after the timing restarts, the fuel gauge can control the communication lock to switch from a busy state to an idle state, that is, change the status flag of the communication lock to a second value.

[0160] S810. When the fuel gauge determines that the conditions for switching from wake-up mode to sleep mode are met, the fuel gauge switches from wake-up mode to sleep mode.

[0161] The conditions for the fuel gauge to switch from wake-up mode to sleep mode may include: the module lock corresponding to each module in the fuel gauge is in an idle state.

[0162] In S809 above, the fuel gauge has already controlled the communication lock to switch from a busy state to an idle state. Therefore, if the module locks corresponding to other modules in the fuel gauge are all in an idle state, the fuel gauge can determine that it meets the conditions for switching from wake-up mode to sleep mode. Switching from wake-up mode to sleep mode can reduce the power consumption of the fuel gauge.

[0163] In one embodiment, the fuel gauge can periodically acquire the status of each module lock in the fuel gauge, so that the fuel gauge can determine whether to switch to wake-up mode or sleep mode based on the status of each module lock.

[0164] For example, other module locks of the fuel gauge in this article can also be software module locks. Therefore, when the status flag of a module lock is determined to be a first value, the fuel gauge can determine that the module lock is in a busy state; when the status flag of a module lock is determined to be a second value, the fuel gauge can determine that the module lock is in an idle state.

[0165] Based on this, when the fuel gauge determines that the status flags of all module locks in the fuel gauge are all at the second value, the fuel gauge can determine that all module locks are in an idle state. At this time, the fuel gauge can switch to sleep mode.

[0166] S811, the fuel gauge disables the I2C module.

[0167] In sleep mode, the fuel gauge can disable the I2C module to reduce power consumption.

[0168] In one embodiment, turning off the I2C module with the fuel gauge may include: the fuel gauge controlling the function switch of the I2C module to be in the on state, and controlling the clock of the I2C module to be in the working state.

[0169] S812, the fuel gauge enables STA interrupt.

[0170] When the fuel gauge is in sleep mode, it can enable the STA interrupt so that it can exit sleep mode in response to the start signal sent by the host.

[0171] S813, the processor sends a start signal to the fuel gauge.

[0172] When the processor needs to begin the next data transfer process with the fuel gauge, the processor can send a start signal to the fuel gauge again.

[0173] S814, the fuel meter receives the start signal.

[0174] S815, the STA interrupt in the fuel meter wakes up the fuel meter in response to the start signal.

[0175] As can be seen from the nature of the STA interrupt, the STA interrupt can wake up the fuel gauge in response to the start signal sent by the processor (i.e., the host), even if the fuel gauge switches from sleep mode to wake-up mode.

[0176] S816, the fuel gauge restarts the I2C module.

[0177] After the fuel gauge is woken up, it can send a start signal to its I2C module, thereby restarting the I2C module. Once the I2C module is started, the fuel gauge will continue to execute step S803 as described above.

[0178] In summary, in this embodiment, during the communication between the fuel gauge and the processor, within a preset time period after the fuel gauge's communication lock is in a busy state, the fuel gauge receives a repeat start signal sent by the processor, and the fuel gauge controls the communication lock to remain in a busy state. Since the fuel gauge will not enter sleep mode as long as any module lock in the fuel gauge is in a busy state, it will not enter sleep mode within this preset time period. Therefore, there is no problem of the fuel gauge being unable to be woken up within this preset time period, thus ensuring normal communication between the fuel gauge and the processor.

[0179] In addition, when the fuel gauge keeps the communication lock busy due to receiving a repeat start signal from the processor, the fuel gauge will reacquire the duration of the communication lock being busy, so that when the fuel gauge receives a repeat start signal from the processor in the next preset duration, it can continue to keep the communication lock busy, thereby keeping the fuel gauge in wake-up mode and ensuring normal communication between the fuel gauge and the processor.

[0180] Figure 9 This illustration shows one of the interface diagrams of a mobile phone provided in an embodiment of this application.

[0181] In one embodiment, such as Figure 9 As shown in A, mobile phone 100 displays the fifth interface 910. The fifth interface 910 includes a fifth time marker 911 and a fifth battery icon 912. The fifth battery icon 912 displays that the battery level of mobile phone 100 is 50% at the fifth time marker 10:00. At the fifth time marker, the battery gauge inside the phone is in wake-up mode, allowing it to communicate with the phone's internal processor. Therefore, the processor can obtain the displayed battery level through the battery gauge. At the sixth time marker, the battery gauge remains in wake-up mode, continuing to communicate with the phone's internal processor. This means that during the period from the fifth time marker to the sixth time marker, the processor can promptly obtain the latest displayed battery level from the battery gauge, thus allowing mobile phone 100 to display the battery level as shown in the image. Figure 9 The sixth interface 920, shown as B in the diagram, includes a sixth time marker 921 and a sixth battery icon 922. The sixth battery icon 922 displays that the battery level of the phone 100 is 49% at the sixth time marker 10:03.

[0182] and Figure 4 Compared to the illustrated embodiment, after adopting the battery meter communication method provided in this application embodiment, during the time period from the fifth time 10:00 to the sixth time 10:03 (i.e., within the same time period), since the battery meter and the processor communicate normally, the battery meter can report the battery information to the display module in a timely manner through the processor. Therefore, the battery level displayed on the mobile phone 100 changes from 50% to 49% during this time period without producing a significant battery jump, thereby improving the user experience.

[0183] Figure 10 This is a second schematic diagram of a mobile phone interface provided in an embodiment of this application.

[0184] In one embodiment, such as Figure 10 As shown in A, mobile phone 100 displays the seventh interface 1010. The seventh interface 1010 includes the seventh time 1011, the seventh battery icon 1012, and the third display screen 1013. The seventh battery icon 1012 displays that the battery level of mobile phone 100 at the seventh time 10:30 is 40%. The third display screen 1013 displays the third video played by mobile phone 100 at the seventh time 10:30. During the continuous playback of the video, the internal battery gauge continuously communicates with the internal processor, enabling the processor to continuously obtain the battery level from the battery gauge, thus displaying the battery level as shown. Figure 10 The eighth interface 1020, shown as B in the diagram, includes an eighth time point 1021, an eighth battery icon 1022, and a fourth display screen 1023. The eighth battery icon 1022 displays the battery level of the phone 100 at 10:35 (the eighth time point) as 30%. The fourth display screen 1023 shows the fourth video played by the phone 100 at 10:35 (the eighth time point). During the period between the seventh and eighth times, the phone 100's battery level decreased due to continuous video playback.

[0185] and Figure 5 Compared to the illustrated embodiment, after adopting the battery meter communication method provided in this application embodiment, during the time period from 10:30 at the seventh time to 10:35 at the eighth time (i.e., within the same time period), since the battery meter and the processor communicate normally, the battery meter can report the battery information to the display module in a timely manner through the processor. Therefore, when the mobile phone 100 is continuously playing video, the displayed battery level of the mobile phone 100 drops from 40% to 30%, improving the user experience.

[0186] It should be understood that Figure 5 and Figure 10 In the embodiments shown, the mobile phones are not connected to an external power source, meaning that the mobile phones are in a discharge scenario.

[0187] Figure 11 A schematic diagram of the structure of a chip system provided in an embodiment of this application is shown.

[0188] In one embodiment, such as Figure 11As shown in the illustration, this application also provides a chip system. The chip system 1900 includes at least one processor 1901 and at least one interface circuit 1902. The at least one processor 1901 and the at least one interface circuit 1902 are interconnected via lines. The processor 1901 is used to support an electronic device in implementing the various steps in the above method embodiments, and the at least one interface circuit 1902 can be used to receive signals from other devices (e.g., memory) or to send signals to other devices (e.g., a communication interface). The chip system may include a chip and may also include other discrete devices.

[0189] This application also provides a computer storage medium including instructions that, when executed on the electronic device, cause the electronic device to perform the steps in the above method embodiments.

[0190] This application also provides a computer program product including instructions that, when executed on the electronic device, cause the electronic device to perform the steps in the method embodiments described above.

[0191] The technical effects of the chip system, computer storage medium, and computer program product are similar to those in the preceding method embodiments.

[0192] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply 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.

[0193] Those skilled in the art will recognize that the modules and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art 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.

[0194] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and modules described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0195] In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or modules may be electrical, mechanical, or other forms.

[0196] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located on one device or distributed across multiple devices. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0197] In addition, the functional modules in the various embodiments of this application can be integrated into one device, or each module can exist physically separately, or two or more modules can be integrated into one device.

[0198] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software programs, implementation can be entirely or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer storage medium or transmitted from one computer storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer storage medium can be any available medium accessible to a computer or a data storage device including one or more servers, data centers, etc., that can be integrated with the medium. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0199] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A communication method for a fuel meter, characterized in that, The method is applied to a fuel gauge in an electronic device, wherein the fuel gauge is equipped with a communication lock, the communication lock being used to put the fuel gauge into a wake-up mode; the method includes: In response to receiving a start signal, the fuel meter is activated and the communication lock is in a busy state; In response to the fuel gauge receiving a repeat start signal and a read flag, the communication lock remains in a busy state, and the data stored in the fuel gauge is transmitted to the host via the I2C bus; wherein, the repeat start signal is used to indicate that the fuel gauge is ready to receive data, and the read flag is used to read the data stored in the fuel gauge.

2. The method according to claim 1, characterized in that, After the fuel gauge is woken up and the communication lock is in a busy state, the method further includes: In response to the fuel meter receiving an end signal, the communication lock remains in a busy state; The termination signal is used to indicate that the fuel meter has ended a data transmission process.

3. The method according to claim 1 or 2, characterized in that, The communication lock has a status flag bit; When the status flag is the first value, the communication lock is in a busy state; When the status flag is the second value, the communication lock is in an idle state.

4. The method according to any one of claims 1-3, characterized in that, The electronic device further includes a counter; the method further includes: In response to the status flag of the communication lock being set to the first value, the counter is triggered to start timing; In response to the counter's timing duration being a first duration, which is less than a first preset duration, and the receiving of the repeat start signal or end signal within the first duration, the status flag of the communication lock is maintained at the first value.

5. The method according to claim 4, characterized in that, The method further includes: In response to keeping the status flag of the communication lock at the first value, the counter is triggered to restart. In response to the counter resetting the timing for a second duration, the second duration being longer than a second preset duration, and no repeat start signal or end signal being received within the second duration, the status flag of the communication lock is changed to the second value, and the power meter is set to sleep mode.

6. The method according to any one of claims 1-5, characterized in that, The electronic device further includes a processor connected to the fuel gauge, the fuel gauge including an I2C module corresponding to the communication lock; After the fuel gauge is activated, the method further includes: When the power meter is in wake-up mode, the function switch of the I2C module is turned on, and the clock of the I2C module is in working state.

7. The method according to claim 5 or 6, characterized in that, After the status flag of the communication lock is changed from a first value to a second value, the method further includes: Based on the switch of the fuel gauge from the wake-up mode to the sleep mode, the function switch of the I2C module controlled by the fuel gauge is turned off, the clock of the I2C module is stopped, and the STA interrupt is enabled; wherein, the STA interrupt is used to wake up the fuel gauge.

8. The method according to claim 7, characterized in that, After the fuel gauge enters the sleep mode, the method further includes: Based on the start signal received by the fuel gauge, the STA interrupt is triggered to wake up the fuel gauge, and the function switch of the I2C module is turned on again, and the clock of the I2C module is in working state; The power meter switches from the sleep mode to the wake-up mode.

9. The method according to claim 7 or 8, characterized in that, The fuel gauge also includes other modules besides the communication module, each of which corresponds to a module lock; the conditions for the fuel gauge to switch from the wake-up mode to the sleep mode include: The power meter determines that the status flag bits of the module locks corresponding to the other modules are all of the second value.

10. An electronic device, characterized in that, The device includes a memory and a fuel gauge, the fuel gauge being connected to the memory; the memory stores computer program code, the computer program code including instructions; when the fuel gauge executes the instructions, the electronic device performs the method as described in any one of claims 1-9.

11. A computer-readable storage medium, characterized in that, Includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-9.

12. A computer program product, characterized in that, Includes instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-9.