Electricity meter initialization method and device, terminal equipment and storage medium

By loading the ADSP subsystem when the terminal device is turned on and obtaining the meter attributes, the problem of low data reliability after I2C error is solved in the initialization of the ADSP subsystem, and the robust initialization of the meter is achieved, improving user experience and data reliability.

CN119847615APending Publication Date: 2025-04-18GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411920375.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the ADSP subsystem initialization, if the meter I2C report an error, the initialization process is not performed during the subsequent I2C communication recovery, resulting in low reliability of obtaining the meter data and a security vulnerability.

Method used

When the terminal device is turned on, the ADSP subsystem is loaded to obtain the meter attributes, and the target access result is obtained from the meter chip through the central processor, including the I2C unreported error and the meter type code, or the I2C error is reported. The corresponding power meter is initialized based on the results to ensure that the user experience is improved in extreme cases.

Benefits of technology

The initialization of the power meter when the I2C error is reported or not is reported is realized, which improves the reliability of the power meter data, improves the user experience in extreme cases, and solves the security vulnerabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847615A_ABST
    Figure CN119847615A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a voltameter initialization method and device, terminal equipment and a storage medium, a user can initialize a driver corresponding to a voltameter under the conditions that the terminal equipment is started, multiple voltameter models are supported, and an I2C error is reported or the I2C does not report an error, so that the user experience of the user under an extreme condition is improved. The method provided by the embodiment of the invention comprises the following steps: loading an advanced digital signal processor (ADSP) subsystem under the condition of detecting that the terminal equipment is started up, and obtaining the attribute of a voltameter; under the condition that the voltameter attribute supports multiple voltameter models, a first target access result is obtained from a voltameter chip through a central processing unit, and the first target access result comprises an I2C unreported error and a first voltameter type code, or an I2C reported error and a second voltameter type code; the I2C report error is used for indicating an error when data exchange with a voltameter chip is carried out through an I2C communication protocol; and initializing the corresponding voltameter according to the first target access result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of charging, and in particular to a method, device, terminal equipment and storage medium for initializing a power meter. Background Art

[0002] In the initialization of the existing advanced digital signal processor (ADSP) subsystem, if the fuel gauge I2C reports an error, even if the I2C communication is restored later, the corresponding fuel gauge initialization process is not performed, and the reliability of obtaining relevant data of the fuel gauge is relatively low. For example, the voltage, temperature, power, current, etc. of the fuel gauge may be fixed false values. Summary of the invention

[0003] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for initializing a fuel gauge. When the user turns on the terminal device and supports multiple fuel gauge models, the driver of the corresponding fuel gauge can be initialized for an I2C error or no I2C error, thereby improving the user experience in extreme situations.

[0004] A first aspect of the present application provides a method for initializing a fuel meter, which may include: when it is detected that a terminal device is turned on, loading an advanced digital signal processor ADSP subsystem to obtain fuel meter properties; when the fuel meter properties support multiple fuel meter models, obtaining a first target access result from the fuel meter chip through a central processing unit, the first target access result including no I2C error and a first fuel meter type code, or an I2C error, the I2C error being used to indicate an error when exchanging data with the fuel meter chip through an I2C communication protocol; and initializing the corresponding fuel meter according to the first target access result.

[0005] A second aspect of the present application provides a device for initializing an electric meter, which may include:

[0006] The detection module is used to load the advanced digital signal processor ADSP subsystem to obtain the properties of the power meter when it is detected that the terminal device is turned on;

[0007] A processing module, used to obtain a first target access result from the fuel meter chip through a central processing unit when the fuel meter attribute supports multiple fuel meter models, the first target access result including no I2C error and a first fuel meter type code, or an I2C error, the I2C error is used to indicate an error when exchanging data with the fuel meter chip through the I2C communication protocol; and initialize the corresponding fuel meter according to the first target access result.

[0008] A third aspect of the present application provides a terminal device, which may include a memory and a processor, wherein the memory stores a computer program that can be executed on the processor, and when the terminal device executes the program, the method described in the first aspect of the present application is implemented.

[0009] A fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect of the present application.

[0010] Yet another aspect of an embodiment of the present application discloses a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the method described in the first aspect of the present application.

[0011] Another aspect of an embodiment of the present application discloses an application publishing platform, which is used to publish a computer program product. When the computer program product runs on a computer, the computer executes the method described in the first aspect of the present application.

[0012] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0013] In an embodiment of the present application, when it is detected that the terminal device is powered on, the advanced digital signal processor ADSP subsystem is loaded to obtain the fuel gauge attributes; when the fuel gauge attributes support multiple fuel gauge models, the first target access result is obtained from the fuel gauge chip through the central processor, and the first target access result includes I2C no error and the first fuel gauge type code, or I2C error, and the I2C error is used to indicate that an error occurred when exchanging data with the fuel gauge chip through the I2C communication protocol; the corresponding fuel gauge is initialized according to the first target access result. The present application can support scenarios with multiple fuel gauge models for the same project, and can initialize the driver of the corresponding fuel gauge when the terminal device is powered on, in the case of I2C error or I2C no error, thereby improving the reliability of fuel gauge-related data and enhancing the user experience in extreme situations. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments and the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application, and other drawings can be obtained based on these drawings.

[0015] Figure 1 A schematic diagram of a charging solution for terminal devices to realize super flash charging SVOOC;

[0016] Figure 2 A schematic diagram of an embodiment of a method for initializing an electric meter in an embodiment of the present application;

[0017] Figure 3 A schematic diagram of another embodiment of the method for initializing the electric meter in the embodiment of the present application;

[0018] Figure 4 A schematic diagram of a method for initializing an electric meter in an embodiment of the present application;

[0019] Figure 5 A schematic diagram of an embodiment of a device for initializing an electric meter in an embodiment of the present application;

[0020] Fig. 6A This is a schematic diagram of an embodiment of a terminal device in an embodiment of the present application;

[0021] Figure 6B This is another schematic diagram of a terminal device in an embodiment of the present application. DETAILED DESCRIPTION

[0022] The embodiments of the present application provide a method, apparatus, terminal device and storage medium for initializing a fuel gauge. When the user turns on the terminal device and supports multiple fuel gauge models, the driver of the corresponding fuel gauge can be initialized for an I2C error or no I2C error, thereby improving the user experience in extreme situations.

[0023] In order to make the technical personnel in the technical field better understand the scheme of the present application, the technical scheme in the embodiment of the present application will be described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, not all of the embodiments. Based on the embodiments in the present application, they should all fall within the scope of protection of the present application.

[0024] 1. A fuel gauge is a device used to monitor and measure battery power. It can predict battery capacity, health, and provide safety protection. The fuel gauge is an important part of the battery management system. It ensures safe use of the battery and optimizes battery performance by monitoring key battery parameters.

[0025] 2. I2C (Inter-Integrated Circuit) bus is a simple, bidirectional, two-wire synchronous serial bus. Only two wires are needed to transmit information between devices connected to the bus.

[0026] 3. SDA (Serial Data Line): SDA is a bidirectional data line of the I2C bus, responsible for transmitting data between devices. During the I2C communication process, the level change on the SDA line reflects the data transmission status. Data is transmitted bidirectionally between the master device and the slave device through the SDA line, which can be used as an output line to send data or as an input line to receive data.

[0027] 4. SCL (Serial Clock Line): SCL is the clock line of the I2C bus; it is used to synchronize data transmission on the SDA line. SCL is controlled by the master device and generates a clock signal to drive the slave device to transmit data at a predetermined rate. The frequency of the clock signal determines the data transmission rate. Common I2C communication rates include standard mode (100kHz) and fast mode (400kHz).

[0028] 5. The init function is usually an initialization function, which is called when the program or module starts executing and is used to set the initial state or configuration of the program.

[0029] 6. ADSP (Advanced Digital Signal Processor) is an advanced processor specially used for processing digital audio signals. ADSP is widely used in audio processing, speech recognition, audio encoding and decoding, and is particularly suitable for scenarios that require high-performance audio processing.

[0030] In a charging solution for terminal devices, the power management integrated circuit is ported from the kernel driver to the digital signal processor (DSP) subsystem. In a solution based on an advanced digital signal processor (ADSP) to implement SVOOC (SuperVOOC, super flash charging), such as Figure 1 shown.

[0031] The ADSP subsystem controls the power management integrated circuit to implement the general charging logic. ADSP exchanges charging status information and Universal Serial Bus (USB) related status information with the central processing unit (CPU) through the Generic Link (GLINK). The power management integrated circuit + VOOCPHY + fuel gauge are fully integrated in ADSP to achieve fast charging. Since the fast charging logic is in the ADSP subsystem, and the power-related information needs to be updated in time during the fast charging process, the fuel gauge must also be designed in the ADSP subsystem. At present, the circuit meter model used in the same project in ADSP is single, and there may be multiple fuel gauge suppliers in the same project in the future, referred to as one supply, two supplies, three supplies, etc., so it is necessary to accurately identify the fuel gauge type on the ADSP subsystem side and initialize the related drivers, and provide the correct parameter interface for the CPU to call. However, ADSP does not have a concept similar to the kernel driver device tree, and cannot directly use the kernel driver to identify the set to control the fuel gauge, thereby distinguishing the type of fuel gauge.

[0032] Moreover, the current software architecture has serious defects when the fuel gauge I2C reports an error during the initialization of the ADSP subsystem: (1) When an I2C error occurs during initialization, the init function is not reloaded when the I2C communication is restored, so the fuel gauge voltage, temperature, charge, and current are all fixed false values, and the reliability is not high. (2) The battery encryption is passed directly after the I2C error occurs, and even if the I2C communication is restored, it is not re-encrypted, which poses a security vulnerability. Therefore, it is necessary to design a fault-tolerant, robust, and universally recognized software architecture based on the characteristics of the ADSP subsystem.

[0033] In the embodiment of the present application, the terminal device can be a mobile phone, a tablet computer, a computer with wireless transceiver function, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal device in industrial control, a wireless terminal device in self driving, a wireless terminal device in remote medical, a wireless terminal device in a smart grid, a wireless terminal device in transportation safety, a wireless terminal device in a smart city, or a wireless terminal device in a smart home, etc.

[0034] As an example but not limitation, in the embodiments of the present application, the terminal device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.

[0035] The technical solution of the present application is further described below by way of embodiments. Figure 2 As shown, it is a schematic diagram of an embodiment of a method for initializing a power meter in an embodiment of the present application, which may include:

[0036] 201. When it is detected that the terminal device is powered on, the advanced digital signal processor ADSP subsystem is loaded to obtain the properties of the power meter.

[0037] Exemplarily, when it is detected that a terminal device, such as a mobile phone, is turned on, it is necessary to load an advanced digital signal processor ADSP subsystem to obtain the properties of the power meter.

[0038] In some possible implementations, loading the advanced digital signal processor ADSP subsystem when the terminal device is powered on and obtaining the fuel meter properties may include: loading the ADSP subsystem when detecting that the terminal device is powered on and obtaining the current project number, wherein the current project number includes supported fuel meter models; and initializing the configuration of corresponding fuel meter properties according to the current project number.

[0039] For example, when a terminal device, such as a mobile phone, is detected and turned on, the ADSP subsystem needs to be loaded. During the startup process, the ADSP subsystem will go through a unified function entry to initialize the fuel meter, and then obtain the current project number. The current project number includes the supported fuel meter models, and the corresponding fuel meter attributes are initialized and configured according to the supported fuel meter models.

[0040] For example: There are currently three types of fuel gauges, A, B, and C. Initially, all fuel gauge attributes are configured as false, that is, support_A = false, support_B = false, support_C = false, and support_Exclusive = false (Exclusive means mutually exclusive, that is, the current project has multiple mutually exclusive fuel gauge models. Mutual exclusion here means that the hardware is mutually exclusive, and the software can support multiple fuel gauge models).

[0041] If project P1 only supports fuel gauge model A, configure fuel gauge attribute support_A = true;

[0042] If project P1 only supports fuel gauge model B, configure fuel gauge attribute support_B = true;

[0043] If project P1 only supports fuel gauge model C, configure fuel gauge attribute support_C = true;

[0044] If project P1 supports fuel gauge types A and B, or B and C, or A, B and C, configure the fuel gauge attribute support_exclusive = true.

[0045] Optionally, you may not configure the fuel gauge attributes and use the default fuel gauge attributes.

[0046] 202. When the fuel meter attribute supports multiple fuel meter models, a first target access result is obtained from the fuel meter chip through a central processing unit, wherein the first target access result includes an I2C no error and a first fuel meter type code, or an I2C error, wherein the I2C error is used to indicate that an error occurs when exchanging data with the fuel meter chip through an I2C communication protocol.

[0047] After the fuel meter attributes are configured, the corresponding fuel meter attributes can be determined and the corresponding fuel meter can be initialized. Exemplarily, if the fuel meter attribute support_exclusive=true, it means that the current project supports multiple fuel meter models. When the fuel meter attribute supports multiple fuel meter models, the first target access result is obtained from the fuel meter chip through the central processor. Specifically, the central processor can use the I2C communication protocol to send an extended command to the fuel meter chip to access the device type (device_type), that is, which specific fuel meter type.

[0048] Optionally, because the fuel meter chip includes a device type (device_type) register, when the fuel meter attributes support multiple fuel meter models, the first target access result can also be obtained from the device type register through the central processing unit. Specifically, the central processing unit can use the I2C communication protocol to send an extended command to the device type register to access the device type (device_type), that is, which specific fuel meter type.

[0049] The first target access result is obtained from the fuel gauge chip through the central processor, and the first target access result includes I2C no error and the first fuel gauge type code, or I2C error. That is, when the first target access result includes I2C no error, it also carries the first fuel gauge type code obtained by the corresponding access, or the first target access result also includes I2C error.

[0050] 203. Initialize a corresponding power meter according to the first target access result.

[0051] In some possible implementations, the initializing the corresponding power meter according to the first target access result may include:

[0052] When the first target access result includes that I2C does not report an error, initializing the first fuel gauge according to the first fuel gauge type code; or,

[0053] In the case where the first target access result includes an I2C error, the second target access result is obtained from the fuel meter chip by the central processor, and the corresponding fuel meter is initialized according to the second target access result, and the second target access result includes I2C no error and a second fuel meter type code, or I2C error.

[0054] Exemplarily, the terminal device can initialize the corresponding fuel meter according to the I2C no error and the first fuel meter type code, or the terminal device can obtain the second target access result from the fuel meter chip through the central processor again according to the I2C error, and initialize the corresponding fuel meter according to the second target access result. It should be noted that data encryption will be performed during the initialization process of the fuel meter.

[0055] The initialization of the fuel gauge may include but is not limited to the following steps:

[0056] Hardware power supply: First, you need to ensure that the fuel gauge hardware board is properly powered. For a single-string fuel gauge, you can connect the positive and negative terminals of the battery to the BAT / REGIN and VSS pins of the fuel gauge. If a DC voltage source is used instead of a battery, the output voltage needs to be set to about 3.6V.

[0057] I2C interface initialization: The microcontroller needs to initialize its I2C interface, including turning on the I2C clock and the general-purpose input / output (GPIO) clock, setting the GPIO to open-drain multiplexed output mode, and configuring I2C communication parameters such as communication rate, host mode, etc.

[0058] Configure fuel gauge parameters: Use the host computer software to configure fuel gauge parameters, including battery cell power, voltage, etc.

[0059] Voltage and current calibration: perform voltage and current calibration to ensure the accuracy of the measurement. When calibrating the current, it is necessary to pay attention to the reduction multiple. For example, if the actual capacity is reduced by several times, the current should also be reduced by several times accordingly.

[0060] Self-learning: For some fuel gauges, a self-learning process may be required to adapt to the characteristics of the battery. This may include disconnecting the battery from the external output power supply and using an external small battery to power other parts that need power.

[0061] Enable the fuel gauge: Some fuel gauges have a chip enable (CE) pin, which needs to be connected to a high level (such as BAT+) to power the internal circuit.

[0062] Software emulation of I2C calls: In some cases, software emulation of I2C calls may be required to achieve control and data reading of the fuel gauge.

[0063] Checking communication connectivity: During the initialization process, it is necessary to check whether the I2C communication is connected to ensure that the fuel gauge can respond to the instructions of the microcontroller.

[0064] The above steps ensure that the fuel meter is properly initialized and ready to measure voltage, current, and power, which is critical to ensuring the accuracy and reliability of the fuel meter.

[0065] 204. When the fuel meter attribute supports a single fuel meter model, initialize the corresponding fuel meter.

[0066] For example, if the fuel meter attribute is: support_A=true, then the current project only supports fuel meter model A, and therefore supports the initialization of fuel meter A; for example, if the fuel meter attribute is: support_B=true, then the current project only supports fuel meter model B, and therefore supports the initialization of fuel meter B; for example, if the fuel meter attribute is: support_C=true, then the current project only supports fuel meter model C, and therefore supports the initialization of fuel meter C; if no attributes are configured, the default fuel meter model corresponding to the fuel meter initialization is run to support the default project.

[0067] For example: the terminal device determines whether the attribute of the power meter is support_A=true? If so, the power meter A is initialized; if not, the terminal device determines whether the attribute of the power meter is support_B=true? If so, the power meter B is initialized; if not, the terminal device determines whether the attribute of the power meter is support_C=true? If so, the power meter C is initialized; if not, the terminal device determines whether the attribute of the power meter is support_Exclusive=true? If so, it indicates that the current project supports multiple power meter models, and the central processor needs to obtain the first target access result from the power meter chip, that is, execute step 203, to identify which specific power meter model it is. If not, the default power meter model corresponding to the power meter initialization is run to support the default project.

[0068] It should be noted that, in the embodiment of the present application, step 204 is an optional step.

[0069] In an embodiment of the present application, when it is detected that the terminal device is powered on, the ADSP subsystem is loaded to obtain the fuel gauge attributes; when the fuel gauge attributes support multiple fuel gauge models, a first target access result is obtained from the fuel gauge chip through the central processor, the first target access result includes no I2C error and a first fuel gauge type code, or an I2C error, the I2C error is used to indicate an error when exchanging data with the fuel gauge chip through the I2C communication protocol; the corresponding fuel gauge is initialized according to the first target access result. The present application can support scenarios with multiple fuel gauge models for the same project, and can initialize the driver of the corresponding fuel gauge for the case of an I2C error or no I2C error when the terminal device is powered on, thereby improving the reliability of data related to the fuel gauge and enhancing the user experience in extreme situations.

[0070] like Figure 3 As shown, it is a schematic diagram of another embodiment of the method for initializing the electric meter in the embodiment of the present application, which may include:

[0071] 301. When it is detected that the terminal device is powered on, the ADSP subsystem is loaded to obtain the properties of the power meter.

[0072] 302. When the fuel meter attribute supports multiple fuel meter models, a first target access result is obtained from the fuel meter chip through a central processing unit, wherein the first target access result includes an I2C no error and a first fuel meter type code, or an I2C error, wherein the I2C error is used to indicate that an error occurs when exchanging data with the fuel meter chip through an I2C communication protocol.

[0073] It should be noted that steps 301-302 in the embodiment of the present application are similar to Figure 2 Steps 201-202 in the illustrated embodiment are similar and will not be described in detail here.

[0074] 303. When the first target access result includes that the I2C does not report an error, initialize the first fuel gauge according to the first fuel gauge type code.

[0075] In some possible implementations, when the first target access result includes that I2C has not reported an error, initializing the corresponding first fuel meter according to the first fuel meter type code may include: when the first target access result includes that I2C has not reported an error, and the I2C has not reported an error includes that the I2C communication is successful, and the read device type instruction is executed correctly, the terminal device obtains the corresponding first fuel meter attribute according to the first fuel meter type code; and initializes the first fuel meter corresponding to the first fuel meter attribute.

[0076] Exemplarily, the I2C not reporting an error includes: the I2C communication is successful, and the read device type instruction is executed correctly; for example: the GAUGE_DEVICE_TYPE_ACCESS_OK identifier is returned.

[0077] If the GAUGE_DEVICE_TYPE_ACCESS_OK identifier is returned, it is considered that the I2C communication is successful, and the read device type (device type) instruction is executed correctly, and the read device type (device type) code will be mapped to the first fuel gauge attribute. For example: the first fuel gauge type code device type = 0x0001, then the first fuel gauge attribute is support_A = true; the first fuel gauge type code device_type = 0x0002, then the first fuel gauge attribute is support_B = true; the first fuel gauge type code device type = 0x0003, then the first fuel gauge attribute is support_C = true. The first fuel gauge type code can also be called the first fuel gauge model, or the first fuel gauge model number, which is not limited to the specific embodiments of the present application.

[0078] Then the terminal device initializes the first electricity meter corresponding to the first electricity meter attribute, for example:

[0079] If the first fuel gauge attribute support_A=true, then the first fuel gauge of model A is initialized; if the first fuel gauge attribute support_B=true, then the first fuel gauge of model B is initialized; if the first fuel gauge attribute support_C=true, then the first fuel gauge of model C is initialized.

[0080] It should be noted that although the terminal device can support multiple electricity meter models, there is only one electricity meter running at the same time, that is, the electricity meter corresponding to one electricity meter model is running at the same time. Therefore, there is no situation where the first electricity meter attribute support_exclusive=true.

[0081] 304. When the first target access result includes an I2C error, the second target access result is obtained from the fuel meter chip through the central processor, and the corresponding fuel meter is initialized according to the second target access result, wherein the second target access result includes no I2C error and a second fuel meter type code, or an I2C error.

[0082] In the case where the first target access result includes an I2C error, the terminal device can re-obtain a second target access result from the fuel meter chip through the central processor, and then initialize the corresponding fuel meter according to the second target access result, wherein the second target access result includes no I2C error and a second fuel meter type code, or an I2C error.

[0083] Exemplarily, the first target access result includes an I2C error, which may include any of the following:

[0084] (1) I2C communication failed;

[0085] This may be indicated by returning a first identifier, for example, the first identifier is a GAUGE_DEVICE_TYPE_ACCESS_I2C_FAIL identifier.

[0086] (2) I2C communication during the fuel gauge reset process;

[0087] This may be indicated by returning a second identifier, for example, the second identifier is a GAUGE_DEVICE_TYPE_ACCESS_RESET_FAIL identifier.

[0088] (3) I2C communication is successful and the read device type instruction is executed incorrectly;

[0089] This may be indicated by returning a third identifier, for example, the third identifier is a GAUGE_DEVICE_TYPE_ACCESS_NOT_MATCH identifier.

[0090] The following describes these three situations separately, as shown below:

[0091] (1) I2C error includes I2C communication failure

[0092] In some possible implementations, when the first target access result includes an I2C error, obtaining a second target access result from the fuel gauge chip by the central processor, and initializing the corresponding fuel gauge according to the second target access result may include:

[0093] When the first target access result includes an I2C error, and the I2C error includes an I2C communication failure, and when the timer is initialized, the fuel gauge is reset and the timer is started, and the number of times the fuel gauge is reset is counted. When the timer times out, the second target access result is obtained from the fuel gauge chip through the central processor, and polling is performed, wherein the duration of the fuel gauge reset is less than or equal to the duration corresponding to the timer;

[0094] When the number of times the fuel gauge is reset exceeds a preset number and each target access result includes an I2C error, determining that the fuel gauge chip is faulty; or,

[0095] When the number of times the fuel gauge is reset does not exceed a preset number and the corresponding target access result includes that the I2C does not report an error, the corresponding fuel gauge is initialized according to the fuel gauge type code included in the target access result.

[0096] If the GAUGE_DEVICE_TYPE_ACCESS_I2C_FAIL identifier is returned, it is considered that the I2C communication has failed. At this time, the terminal device will first determine whether the ADSP timer has been initialized? If not, the timer of the ADSP subsystem's fuel gauge is initialized. If the timer has been initialized, the timer is no longer initialized. The timer is used to poll the fuel gauge to see if the I2C communication is OK? When the timer is initialized, the fuel gauge is reset and the timer is turned on. At the same time, the number of fuel gauge resets is counted. After the timer times out, the central processor obtains the second target access result from the fuel gauge chip for polling.

[0097] If the second target access result includes that the I2C does not report an error, initializing the corresponding second fuel gauge according to the second fuel gauge type code;

[0098] If the second target access result includes an I2C error, the fuel gauge is reset again and the timer is started, the number of fuel gauge resets is updated, and when the timer times out, a third target access result is obtained from the fuel gauge chip through the central processor;

[0099] If the third target access result includes that the I2C does not report an error, the corresponding third fuel gauge is initialized according to the third fuel gauge type code.

[0100] Exemplarily, it is determined whether the number of times the fuel gauge is reset overflows, that is, whether it exceeds the preset number (for example, 10). Each time the fuel gauge is reset and the timer is started, after the timer times out, the central processor is used to send an extended command to the device type register using the I2C communication protocol, and the target access result is obtained from the device type register. If the target access result includes an I2C error, the fuel gauge is reset and the timer is started again. The central processor is used to send an extended command to the device type register using the I2C communication protocol, and the target access result is obtained from the device type register, so as to poll. The execution of the fuel gauge reset action includes pulling down SDA and SCL for a duration (for example, 2.5s), because the fuel gauge does not have the enable GPIO pin control function, and the fuel gauge can only be reset by pulling down SDA and SCL for a duration. It can be understood that the timer timer (for example, 5s), when the timer time is up, will trigger the handle function of the timer, and continue to access device_type in the handle function and perform corresponding processing. The handle function usually refers to a callback function or processing function of a specific function, which is used to handle specific events, requests or tasks.

[0101] If the fuel gauge is reset 10 times and the corresponding target access result is still an I2C error, that is, the fuel gauge has not yet restored normal communication, it indicates that the problem is not with the fuel gauge, but with the fuel gauge IC itself, that is, the fuel gauge IC is faulty.

[0102] If the number of times the fuel gauge is reset does not reach 10 times or reaches exactly 10 times, the corresponding target access result is that I2C does not report an error, and the corresponding fuel gauge is initialized according to the fuel gauge type code carried in the target access result.

[0103] In some possible implementations, when the second target access result includes that I2C has not reported an error, initializing the corresponding second fuel meter according to the second fuel meter type code may include: when the second target access result includes that I2C has not reported an error, and the I2C has not reported an error includes that the I2C communication is successful, and the read device type instruction is executed correctly, the terminal device obtains the corresponding second fuel meter attribute according to the second fuel meter type code; and initializes the second fuel meter corresponding to the second fuel meter attribute.

[0104] Exemplarily, the second target access result includes I2C no error, which includes: I2C communication is successful, and the read device type instruction is executed correctly; it can be indicated by a fourth identifier, for example: the fourth identifier is a GAUGE_DEVICE_TYPE_ACCESS_OK identifier.

[0105] If the GAUGE_DEVICE_TYPE_ACCESS_OK identifier is returned, it is considered that the I2C communication is successful, and the read device type (device type) instruction is executed correctly, and the read device type (device type) code will be mapped to the second fuel gauge attribute. For example: the second fuel gauge type code device type = 0x0001, then the second fuel gauge attribute is support_A = true; the second fuel gauge type code device_type = 0x0002, then the second fuel gauge attribute is support_B = true; the second fuel gauge type code device type = 0x0003, then the second fuel gauge attribute is support_C = true. The second fuel gauge type code can also be called the second fuel gauge model, or the second fuel gauge model number, which is not limited in the specific embodiments of the present application.

[0106] The terminal device then initializes the second power meter corresponding to the second power meter attribute. For example: if the second power meter attribute support_A=true, then the second power meter of model A is initialized; if the second power meter attribute support_B=true, then the second power meter of model B is initialized; if the second power meter attribute support_C=true, then the second power meter of model C is initialized.

[0107] (2) I2C error reporting includes I2C communication during the fuel gauge reset process

[0108] In some possible implementations, when the first target access result includes an I2C error, obtaining a second target access result from the fuel meter chip through the central processor, and initializing the corresponding fuel meter according to the second target access result may include: when the first target access result includes an I2C error, and the I2C error includes I2C communication during the fuel meter reset process, and when a timer times out, obtaining a second target access result from the fuel meter chip through the central processor; and when the second target access result includes no I2C error, initializing the corresponding second fuel meter according to the second fuel meter type code.

[0109] For example, if GAUGE_DEVICE_TYPE_ACCESS_RESET_FAIL is returned, it is considered that I2C communication is performed during the reset process of the fuel gauge, that is, the fuel gauge chip is accessed by the central processor during the reset process of the fuel gauge, and then the process returns directly to continue polling judgment. When the timer times out, the central processor obtains the second target access result from the fuel gauge chip; when the second target access result includes that I2C does not report an error, the corresponding second fuel gauge is initialized according to the second fuel gauge type code.

[0110] (3) I2C errors include successful I2C communication and errors in executing the read device type command

[0111] In some possible implementations, when the first target access result includes an I2C error, obtaining a second target access result from the fuel gauge chip by the central processor, and initializing the corresponding fuel gauge according to the second target access result includes:

[0112] When the first target access result includes an I2C error, and the I2C error includes successful I2C communication and an error in executing a read device type instruction, and when the timer is initialized, the timer is started, and when the timer times out, the second target access result is obtained from the fuel meter chip through the central processor for polling; when the second target access result includes no I2C error, the corresponding fuel meter is initialized according to the second fuel meter type code.

[0113] Exemplarily, if the GAUGE_DEVICE_TYPE_ACCESS_NOT_MATCH identifier is returned, it is considered that the I2C communication is successful and the read device type instruction is executed incorrectly. At this time, the terminal device will first determine whether the ADSP timer has been initialized? If not, the timer of the ADSP subsystem's fuel gauge is initialized. If the timer has been initialized, the timer is no longer initialized. Is the timer used to poll the fuel gauge I2C communication OK? When the timer is initialized, the timer is started. After the timer times out, the second target access result is obtained from the fuel gauge chip through the central processor for polling.

[0114] If the second target access result includes an I2C error, the timer is started again. When the timer times out, the third target access result is obtained from the fuel meter chip through the central processor; if the third target access result includes no I2C error, the corresponding third fuel meter is initialized according to the third fuel meter type code.

[0115] Exemplarily, when the second target access result includes an I2C error, the timer is turned on again. After the timer times out, the central processor is used to send an extended command to the device type register using the I2C communication protocol, and the target access result is obtained from the device type register. If the target access result includes an I2C error, the timer is turned on again, and the central processor is used to send an extended command to the device type register using the I2C communication protocol, and the third target access result is obtained from the device type register, so as to poll. It can be understood that when the timer timer (for example, 5s) expires, the handle function of the timer will be triggered, and the device_type will continue to be accessed and corresponding processing will be performed in the handle function. The handle function usually refers to a callback function or processing function of a specific function, which is used to handle specific events, requests or tasks. If the corresponding third target access result is that I2C does not report an error, the corresponding fuel meter is initialized according to the fuel meter type code carried by the third target access result.

[0116] like Figure 4 As shown, it is a flowchart of the method for initializing the electricity meter in an embodiment of the present application.

[0117] When the terminal device is turned on, the ADSP subsystem will be loaded first. During the startup process, the ADSP subsystem will go through a unified function entry to initialize the power meter, then obtain the current project number, and initialize the corresponding power meter model configuration attributes according to the current project number; then determine the attributes of each power meter and initialize the corresponding power meter.

[0118] Determine whether the current project supports a single fuel gauge model based on the fuel gauge attributes. If the current project supports a single fuel gauge model, initialize the corresponding fuel gauge. If the current project supports multiple fuel gauge models, send an extended command through the CPU to access the device_type register to identify which fuel gauge model (device_type) it is, and obtain the first target access result.

[0119] There are four situations for the first target access result:

[0120] (1) I2C communication failure; this may be indicated by returning a first identifier, for example, the first identifier is a GAUGE_DEVICE_TYPE_ACCESS_I2C_FAIL identifier.

[0121] (2) The SDA and SCL of the I2C communication are being pulled low to reset the fuel gauge; this can be indicated by returning the second identifier, for example: the second identifier is

[0122] The GAUGE_DEVICE_TYPE_ACCESS_RESET_FAIL identifier.

[0123] (3) The I2C communication is successful and the read device type instruction is executed correctly; this can be indicated by returning a third identifier, for example: the third identifier is a GAUGE_DEVICE_TYPE_ACCESS_OK identifier.

[0124] (4) The I2C communication is successful but the read device type instruction is executed incorrectly; this may be indicated by returning a fourth identifier, for example, the fourth identifier is a GAUGE_DEVICE_TYPE_ACCESS_NOT_MATCH identifier.

[0125] Step 1: If the GAUGE_DEVICE_TYPE_ACCESS_OK identifier is returned, the I2C communication is successful and the read device type instruction is executed correctly. At this time, the read device_type will be demapped to obtain the supported fuel gauge attributes. For example, if device_type = 0x0001, support_A = true, if device_type = 0x0002, support_B = true, if device_type = 0x0003, support_C = true. If GAUGE_DEVICE_TYPE_ACCESS_OK is not returned, go to step 2.

[0126] Step 2: If the GAUGE_DEVICE_TYPE_ACCESS_I2C_FAIL identifier is returned, it will first determine whether the fuel gauge timer of the ADSP subsystem has been initialized? If not, the fuel gauge timer of the ADSP subsystem is initialized. The timer is used to poll whether the fuel gauge I2C communication is OK? If the timer has been initialized, the timer will not be initialized. Then the fuel gauge is reset and the timer is turned on, and the total number of fuel gauge resets is counted. After the timer times out, the extended command is sent again to access the second target access result. If the second target access result includes that I2C has not reported an error, the corresponding fuel gauge is initialized according to the fuel gauge type code carried by the second target access result. If the second target access result includes an I2C error, it is determined whether the total number of fuel gauge resets exceeds the preset number, and polls in sequence. If there are 10 consecutive errors, the fuel gauge will be reset each time, and it has been reset 10 times. If the fuel gauge I2C communication has not restored normal communication, it indicates that it is not a fuel gauge problem. The failure of I2C communication may be a problem with the fuel gauge IC itself.

[0127] Step 3: If the return value is the GAUGE_DEVICE_TYPE_ACCESS_RESET_FAIL identifier, it indicates that I2C communication is performed during the fuel gauge reset process. In this case, the function returns directly and continues to perform polling judgment.

[0128] Step 4: If the GAUGE_DEVICE_TYPE_ACCESS_NOT_MATCH identifier is returned, similarly determine whether the ADSP fuel gauge timer has been initialized. If not, initialize it. If the timer has been initialized, do not initialize the timer again. Is the timer used to poll the fuel gauge I2C communication OK? When the timer is initialized, start the timer. After the timer times out, obtain the second target access result from the fuel gauge chip through the central processor for polling.

[0129] In an embodiment of the present application, when it is detected that the terminal device is powered on, the ADSP subsystem is loaded to obtain the fuel gauge attributes; when the fuel gauge attributes support multiple fuel gauge models, the first target access result is obtained from the fuel gauge chip through the central processor, and the first target access result includes I2C no error and the first fuel gauge type code, or, I2C error, and the I2C error is used to indicate an error when exchanging data with the fuel gauge chip through the I2C communication protocol; when the first target access result includes I2C no error, the corresponding first fuel gauge is initialized according to the first fuel gauge type code; when the first target access result includes I2C error, the second target access result is obtained from the fuel gauge chip through the central processor, and the corresponding fuel gauge is initialized according to the second target access result, and the second target access result includes I2C no error and the second fuel gauge type code, or, I2C error. A software design scheme based on ADSP charging and power IC type identification is designed in the present application. For a single-meter project, the meter model is fixed by the current project number; for a multi-meter project and when the meter I2C does not report an error during power-on initialization, the meter initialization entry is accessed through the I2C extension command to obtain the meter type code to determine which meter to initialize; for a multi-meter project and when the meter I2C reports an error during power-on initialization, a timer mechanism is integrated according to the characteristics of the ADSP subsystem to reset the meter and poll the meter type in real time. When access is successful, the corresponding meter type is initialized and parameters are provided. In summary, the technical solution of this application can adapt to loading various types of meter in the project and can also tolerate I2C errors, with strong compatibility.

[0130] The technical solution of the present application can adapt to the situation where there are multiple power meter models in the same project. It will load the corresponding driver initialization and provide the correct parameters to the CPU. In the case of an I2C error when the terminal device is turned on, a fault-tolerant mechanism is designed for the ADSP subsystem so that when I2C restores communication, that is, when I2C does not report an error, the driver of the corresponding power meter can be initialized, thereby improving the user experience in extreme situations.

[0131] It should be noted that for the ADSP charging solution, different batteries can be replaced, and the fuel gauge SDA and / or SCL lines can be pulled down during the power-on phase of the terminal device, and restored after power-on. Then, the I2C waveform can be used to check whether the access command codes of different batteries are the same. If they are the same, it indicates that the fault-tolerance mechanism in this application is not supported.

[0132] like Figure 5 As shown, it is a schematic diagram of an embodiment of a device for initializing a power meter in an embodiment of the present application, which may include:

[0133] The detection module 501 is used to load the advanced digital signal processor ADSP subsystem and obtain the properties of the power meter when detecting that the terminal device is turned on;

[0134] Processing module 502 is used to obtain a first target access result from the fuel meter chip through a central processing unit when the fuel meter attribute supports multiple fuel meter models. The first target access result includes no I2C error and a first fuel meter type code, or an I2C error, and the I2C error is used to indicate that an error occurs when exchanging data with the fuel meter chip through the I2C communication protocol; and initialize the corresponding fuel meter according to the first target access result.

[0135] In some possible implementations, the processing module 502 is specifically configured to initialize the first electric meter according to the first electric meter type code when the first target access result includes that the I2C does not report an error; or,

[0136] The processing module 502 is specifically used to obtain a second target access result from the fuel meter chip through the central processor when the first target access result includes an I2C error, and initialize the corresponding fuel meter according to the second target access result, wherein the second target access result includes no I2C error and a second fuel meter type code, or an I2C error.

[0137] In some possible implementations, the processing module 502 is specifically used to obtain the corresponding first fuel meter type according to the first fuel meter type code when the first target access result includes that I2C does not report an error, and the I2C does not report an error includes that I2C communication is successful, and the read device type instruction is executed correctly; and initialize the first fuel meter corresponding to the first fuel meter type.

[0138] In some possible implementations, the processing module 502 is specifically configured to, when the first target access result includes an I2C error, and the I2C error includes an I2C communication failure, and when the timer is initialized, reset the fuel gauge and start the timer, count the number of times the fuel gauge is reset, and when the timer times out, obtain the second target access result from the fuel gauge chip through the central processor, and poll in this way, wherein the duration of the fuel gauge reset is less than or equal to the duration corresponding to the timer;

[0139] The processing module 502 is specifically configured to determine that the fuel gauge chip is faulty when the number of times the fuel gauge is reset exceeds a preset number and each target access result includes an I2C error; or,

[0140] The processing module 502 is specifically configured to initialize the corresponding fuel gauge according to the fuel gauge type code included in the target access result when the number of times the fuel gauge is reset does not exceed a preset number and the corresponding target access result includes that the I2C does not report an error.

[0141] In some possible implementations, the processing module 502 is specifically used to obtain a second target access result from the fuel meter chip through the central processor when the first target access result includes an I2C error, and the I2C error includes I2C communication during the fuel meter reset process, and when the timer times out; and when the second target access result includes no I2C error, initialize the corresponding second fuel meter according to the second fuel meter type code.

[0142] In some possible implementations, the processing module 502 is specifically used to start the timer when the first target access result includes an I2C error, and the I2C error includes successful I2C communication and an error in executing a read device type instruction, and when the timer is initialized, obtain the second target access result from the fuel meter chip through the central processor for polling when the timer times out; and initialize the corresponding fuel meter according to the second fuel meter type code when the second target access result includes no I2C error.

[0143] In some possible implementations, the detection module 501 is specifically configured to load the ADSP subsystem and obtain a current project number when detecting that the terminal device is powered on, wherein the current project number includes a supported electricity meter model;

[0144] The processing module 502 is specifically configured to initialize and configure corresponding electric meter attributes according to the current project number.

[0145] In some possible implementations, the processing module 502 is further configured to initialize the corresponding fuel meter when the fuel meter attribute supports a single fuel meter model.

[0146] Fig. 6A As shown, it is a schematic diagram of an embodiment of a terminal device in an embodiment of the present application, which may include: Figure 5 The fuel gauge is shown initialized by the device.

[0147] like Figure 6B FIG. 1 is a schematic diagram of another embodiment of a terminal device in an embodiment of the present application. Figure 6B A detailed introduction to the various components of the mobile phone in the terminal device:

[0148] The RF circuit 610 can be used for receiving and sending signals during the process of sending and receiving information or making calls. In particular, after receiving the downlink information of the base station, it is sent to the processor 680 for processing; in addition, the designed uplink data is sent to the base station. Generally, the RF circuit 610 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (Low Noise Amplifier, LNA), a duplexer, etc. In addition, the RF circuit 610 can also communicate with the network and other devices through wireless communication. The above-mentioned wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile communication (Global System of Mobile communication, GSM), General Packet Radio Service (General Packet Radio Service, GPRS), Code Division Multiple Access (Code Division Multiple Access, CDMA), Wideband Code Division Multiple Access (Wideband Code Division Multiple Access, WCDMA), Long Term Evolution (Long Term Evolution, LTE), email, Short Messaging Service (SMS), etc.

[0149] The memory 620 can be used to store software programs and modules. The processor 680 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 620. The memory 620 can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 620 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0150] The input unit 630 can be used to receive input digital or character information, and to generate key signal input related to the user settings and function control of the mobile phone. Specifically, the input unit 630 may include a touch panel 631 and other input devices 632. The touch panel 631, also known as a touch screen, can collect the user's touch operation on or near it (such as the user's operation on the touch panel 631 or near the touch panel 631 using any suitable object or accessory such as a finger, stylus, etc.), and drive the corresponding connection device according to a pre-set program. Optionally, the touch panel 631 may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 680, and can receive and execute commands sent by the processor 680. In addition, the touch panel 631 can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 631, the input unit 630 may also include other input devices 632. Specifically, the other input devices 632 may include but are not limited to one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, etc.

[0151] The display unit 640 can be used to display information input by the user or information provided to the user and various menus of the mobile phone. The display unit 640 may include a display panel 641. Optionally, the display panel 641 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 631 may cover the display panel 641. When the touch panel 631 detects a touch operation on or near it, it is transmitted to the processor 680 to determine the type of touch event. Subsequently, the processor 680 provides a corresponding visual output on the display panel 641 according to the type of touch event. Although in Figure 6B In the embodiment, the touch panel 631 and the display panel 641 are used as two independent components to realize the input and output functions of the mobile phone, but in some embodiments, the touch panel 631 and the display panel 641 can be integrated to realize the input and output functions of the mobile phone.

[0152] The mobile phone may also include at least one sensor 650, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 641 according to the brightness of the ambient light, and the proximity sensor may turn off the display panel 641 and / or the backlight when the mobile phone is moved to the ear. As a type of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in all directions (generally three axes), and can detect the magnitude and direction of gravity when stationary. It can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc.; as for other sensors that can be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be repeated here.

[0153] The audio circuit 660, the speaker 661, and the microphone 662 can provide an audio interface between the user and the mobile phone. The audio circuit 660 can transmit the received audio data to the speaker 661 after converting the received audio data into an electrical signal, which is converted into a sound signal for output; on the other hand, the microphone 662 converts the collected sound signal into an electrical signal, which is received by the audio circuit 660 and converted into audio data, and then the audio data is output to the processor 680 for processing, and then sent to another mobile phone through the RF circuit 610, or the audio data is output to the memory 620 for further processing.

[0154] Wi-Fi is a short-range wireless transmission technology. The mobile phone can help users send and receive emails, browse web pages and access streaming media through the Wi-Fi module 670, which provides users with wireless broadband Internet access. Figure 6BA Wi-Fi module 670 is shown, but it is understandable that it is not an essential component of the mobile phone and can be omitted as needed without changing the essence of the invention.

[0155] The processor 680 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs and / or modules stored in the memory 620, and calling data stored in the memory 620, it executes various functions of the mobile phone and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 680 may include one or more processing units; preferably, the processor 680 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 680.

[0156] The mobile phone also includes a power supply 690 (such as a battery) for supplying power to various components. Preferably, the power supply can be logically connected to the processor 680 through a power management system, so that the power management system can manage charging, discharging, power consumption and other functions.

[0157] Although not shown, the mobile phone may also include a camera, a Bluetooth module, etc., which will not be described in detail here.

[0158] In an embodiment of the present application, the processor 680 is used to load the advanced digital signal processor ADSP subsystem to obtain the fuel meter properties when it is detected that the terminal device is turned on; when the fuel meter properties support multiple fuel meter models, obtain the first target access result from the fuel meter chip through the central processor, the first target access result includes no I2C error and a first fuel meter type code, or an I2C error, the I2C error is used to indicate an error when exchanging data with the fuel meter chip through the I2C communication protocol; initialize the corresponding fuel meter according to the first target access result.

[0159] In some possible implementations, the processor 680 is specifically configured to initialize the first fuel gauge according to the first fuel gauge type code when the first target access result includes that the I2C does not report an error; or

[0160] Processor 680 is specifically used to obtain a second target access result from the fuel meter chip through the central processor when the first target access result includes an I2C error, and initialize the corresponding fuel meter according to the second target access result, wherein the second target access result includes no I2C error and a second fuel meter type code, or an I2C error.

[0161] In some possible implementations, the processor 680 is specifically used to obtain the corresponding first fuel meter type according to the first fuel meter type code when the first target access result includes that I2C does not report an error, and the I2C does not report an error includes that I2C communication is successful, and the read device type instruction is executed correctly; and initialize the first fuel meter corresponding to the first fuel meter type.

[0162] In some possible implementations, the processor 680 is specifically configured to, when the first target access result includes an I2C error, and the I2C error includes an I2C communication failure, and when the timer is initialized, reset the fuel gauge and start the timer, count the number of times the fuel gauge is reset, and when the timer times out, obtain the second target access result from the fuel gauge chip through the central processor, and poll in this way, wherein the duration of the fuel gauge reset is less than or equal to the duration corresponding to the timer;

[0163] The processor 680 is specifically configured to determine that the fuel gauge chip is faulty when the number of times the fuel gauge is reset exceeds a preset number and each target access result includes an I2C error; or,

[0164] The processor 680 is specifically configured to initialize the corresponding fuel meter according to the fuel meter type code included in the target access result when the number of times the fuel meter is reset does not exceed a preset number and the corresponding target access result includes that the I2C does not report an error.

[0165] In some possible implementations, the processor 680 is specifically used to obtain a second target access result from the fuel meter chip through the central processor when the first target access result includes an I2C error, and the I2C error includes I2C communication during the fuel meter reset process, and when the timer times out; and when the second target access result includes no I2C error, initialize the corresponding second fuel meter according to the second fuel meter type code.

[0166] In some possible implementations, the processor 680 is specifically used to start the timer when the first target access result includes an I2C error, and the I2C error includes successful I2C communication and an error in executing a read device type instruction, and when the timer is initialized, obtain the second target access result from the fuel meter chip through the central processor for polling when the timer times out; and initialize the corresponding fuel meter according to the second fuel meter type code when the second target access result includes no I2C error.

[0167] In some possible implementations, the processor 680 is specifically used to load the ADSP subsystem and obtain the current project number when detecting that the terminal device is turned on, wherein the current project number includes supported power meter models; and initialize the configuration of corresponding power meter attributes according to the current project number.

[0168] In some possible implementations, the processor 680 is further configured to initialize the corresponding fuel meter when the fuel meter attribute supports a single fuel meter model.

[0169] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a DVD), or a semiconductor medium (eg, a solid state disk (SSD)).

[0170] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0171] In the several embodiments provided in the present 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 only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0172] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0173] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0174] 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 technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer,

[0175] The server, or network device, etc.) executes all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.

[0176] As described above, the above 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. However, 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 embodiments of the present application.

Claims

1. A method for initializing an electric meter, characterized in that: include: When it is detected that the terminal device is powered on, the advanced digital signal processor ADSP subsystem is loaded to obtain the properties of the power meter; In the case where the fuel gauge attribute supports multiple fuel gauge models, a first target access result is obtained from the fuel gauge chip through a central processor, wherein the first target access result includes an I2C no error and a first fuel gauge type code, or an I2C error, wherein the I2C error is used to indicate an error when exchanging data with the fuel gauge chip through an I2C communication protocol; The corresponding electricity meter is initialized according to the first target access result.

2. The method according to claim 1, characterized in that Initializing the corresponding power meter according to the first target access result includes: When the first target access result includes that I2C does not report an error, initializing the first fuel gauge according to the first fuel gauge type code; or, In the case where the first target access result includes an I2C error, the second target access result is obtained from the fuel meter chip by the central processor, and the corresponding fuel meter is initialized according to the second target access result, and the second target access result includes I2C no error and a second fuel meter type code, or I2C error.

3. The method according to claim 2, characterized in that When the first target access result includes that the I2C does not report an error, initializing the first fuel gauge according to the first fuel gauge type code includes: When the first target access result includes that the I2C does not report an error, and the I2C does not report an error includes that the I2C communication is successful, and the read device type instruction is executed correctly, obtaining a corresponding first fuel gauge attribute according to the first fuel gauge type code; Initialize a first electricity meter corresponding to the first electricity meter attribute.

4. The method according to claim 2 or 3, characterized in that: In the case where the first target access result includes an I2C error, obtaining a second target access result from the fuel gauge chip by the central processor, and initializing the corresponding fuel gauge according to the second target access result, including: When the first target access result includes an I2C error, and the I2C error includes an I2C communication failure, and when the timer is initialized, the fuel gauge is reset and the timer is started, and the number of times the fuel gauge is reset is counted. When the timer times out, the second target access result is obtained from the fuel gauge chip through the central processor, and polling is performed, wherein the duration of the fuel gauge reset is less than or equal to the duration corresponding to the timer; If the number of times the fuel gauge is reset exceeds a preset number and each target access result includes an I2C error, determining that the fuel gauge chip is faulty; or, When the number of times the fuel gauge is reset does not exceed a preset number and the corresponding target access result includes that the I2C does not report an error, the corresponding fuel gauge is initialized according to the fuel gauge type code included in the target access result.

5. The method according to claim 2 or 3, characterized in that: In the case where the first target access result includes an I2C error, obtaining a second target access result from the fuel gauge chip by the central processor, and initializing the corresponding fuel gauge according to the second target access result, including: When the first target access result includes an I2C error, and the I2C error includes I2C communication during a fuel gauge reset, and when a timer times out, obtaining a second target access result from the fuel gauge chip through the central processor; When the second target access result includes that the I2C does not report an error, the corresponding second fuel gauge is initialized according to the second fuel gauge type code.

6. The method according to claim 2 or 3, characterized in that: In the case where the first target access result includes an I2C error, obtaining a second target access result from the fuel gauge chip by the central processor, and initializing the corresponding fuel gauge according to the second target access result, including: When the first target access result includes an I2C error, and the I2C error includes an I2C communication success and a read device type instruction execution error, and when the timer is initialized, start the timer, and when the timer times out, obtain the second target access result from the fuel gauge chip through the central processor, thereby polling; When the second target access result includes that the I2C does not report an error, the corresponding fuel gauge is initialized according to the second fuel gauge type code.

7. The method according to any one of claims 1 to 3, characterized in that The method of loading the advanced digital signal processor ADSP subsystem when the terminal device is powered on and obtaining the properties of the electric meter includes: When it is detected that the terminal device is powered on, the ADSP subsystem is loaded to obtain the current project number, where the current project number includes the supported electricity meter models; Initialize and configure corresponding fuel gauge attributes according to the current project number.

8. The method according to any one of claims 1 to 3, characterized in that The method further comprises: When the fuel gauge attribute supports a single fuel gauge model, the corresponding fuel gauge is initialized.

9. A device for initializing an electric meter, characterized in that: include: The detection module is used to load the advanced digital signal processor ADSP subsystem to obtain the properties of the power meter when it is detected that the terminal device is turned on; A processing module, used to obtain a first target access result from the fuel meter chip through a central processing unit when the fuel meter attribute supports multiple fuel meter models, the first target access result including no I2C error and a first fuel meter type code, or an I2C error, the I2C error is used to indicate an error when exchanging data with the fuel meter chip through the I2C communication protocol; and initialize the corresponding fuel meter according to the first target access result.

10. A terminal device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the terminal device executes the program, the method according to any one of claims 1 to 8 is implemented.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Fault detection method, cabin area control system and vehicle

    CN121143284A