A Register Mapping-Based Method for Configuring Electronic Module Parameters

By tracking register bit changes during the wait-for-write-allowed state and combining the shortest time interval with the duration of the write-allowed state, the read timing is adjusted, thus resolving the inconsistency caused by register bit changes during electronic module parameter configuration and improving the accuracy and stability of the configuration.

CN123114376APending Publication Date: 2026-11-17SHANGHAI YUANBAN TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611380266.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-07
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

In the current electronic module parameter configuration process, there is a problem that the register bits change due to the operation of the electronic module while waiting for the write permission state, resulting in inconsistent configuration. Furthermore, directly writing or rereading the constructed register value may occupy the write permission state time, affecting the accuracy and stability of the configuration.

Method used

By repeatedly reading register values ​​while waiting for write permission, tracking changes in register bits with a value of 0 in the write mask, recording the change time and the shortest time interval, determining whether to directly write or reread the register value to be written, and adjusting the read time in combination with the shortest time interval and the duration of write permission to ensure consistency of register contents and time constraints.

Benefits of technology

It reduces the risk of old register values ​​overwriting non-configuration register bits, improves the accuracy and stability of parameter configuration, and balances register content consistency with time limits for allowed write states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114376A_ABST
    Figure CN123114376A_ABST
Patent Text Reader

Abstract

This invention discloses a register mapping-based electronic module parameter configuration method, relating to the field of electronic module parameter configuration technology. It addresses the problems of inconsistencies between the register value to be written and the actual register state caused by register bit changes during the wait-for-write-allowed state, and the possibility of missing the write-allowed state when reconstructing the register value to be written. The method involves: determining the register mapping version based on device identity and version information and forming the register value to be written; repeatedly reading the register value during the wait-for-write-allowed state and reconstructing the register value to be written based on changes in register bits with a write mask value of 0; determining whether to write directly or reconstruct the value before writing when the working state is write-allowed; performing register verification after writing and executing operations such as restoring configuration, saving configuration, or applying configuration based on the verification results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of electronic module parameter configuration technology, and more specifically, to a method for configuring electronic module parameters based on register mapping. Background Technology

[0002] Current electronic module parameter configurations typically rely on register definitions, converting parameters into corresponding register bit values ​​and writing them to the registers. When only some register bits need modification, to avoid altering other register bits, the original register values ​​are usually read first, and then the register write value is generated. Some registers are only writable under specific operating conditions, so there may be a waiting period between reading the register value and actually writing it. During this waiting period, the electronic module's own operation may change register bits that were not modified in this parameter configuration, causing the previously generated register write value to no longer match the actual register state. Direct writing may overwrite the register bit changes that occurred during the waiting period, and rereading and reconstructing the register write value after entering the write-allowed state may occupy the write-allowed state duration, resulting in the write-allowed state being exited by the time reconstruction is complete.

[0003] To address the above problems, this invention proposes a solution. Summary of the Invention

[0004] In order to overcome the above-mentioned defects of the prior art, embodiments of the present invention provide an electronic module parameter configuration method based on register mapping to solve the problems mentioned in the background art.

[0005] To achieve the above objectives, the present invention provides the following technical solution: In a preferred embodiment, it includes: For registers that need to wait for a write-allowed state, the register value is repeatedly read while the working state is not yet in a write-allowed state. The register value is the register value currently stored in the register that is read from the register. Compare the register bits whose write mask value is zero in the current and previous register values; when the value changes, replace the corresponding register bit in the register to be written value with the value read this time, and record the time of change. The register to be written value is the value of the register bit whose write mask value is zero. The shortest time interval between two adjacent changes is obtained based on the change time; when the working state is in the write-allowed state, the elapsed time from the most recent read register value to the current read working state is obtained; Based on the elapsed time and the shortest time interval, determine whether to perform the write using the register write value, or to reread the register value and reconstruct the register write value.

[0006] In a preferred embodiment, a parameter configuration request for the target electronic module is received, and the parameter name and parameter value of the requested parameter are read from the parameter configuration request; Read the device identity information and version information of the target electronic module, find the corresponding register mapping from the pre-saved register mapping according to the device identity information, compare the version information with the version conditions recorded in the register mapping, and select the register mapping version whose version conditions include the version information; In the register mapping version, the corresponding register definition is found according to the parameter name of the request parameter, and the register offset, register width, bit range, read / write permissions and version conditions corresponding to the request parameter are read. If it is confirmed that the bit field range does not exceed the register width, the read / write permission allows writing, and the version information meets the version conditions, the parameter value of the request parameter and its corresponding register offset, register width, bit field range, and read / write permission are retained.

[0007] In a preferred embodiment, the parameter values ​​of the request parameters are read, along with the corresponding register offset, register width, bit range, read / write permissions, and parameter value representation. The parameter value is processed according to the parameter value representation method to obtain the bit field value that the request parameter needs to be written within the bit field range, and the bit field value is moved to the corresponding register bit position according to the position of the bit field range in the corresponding register to obtain the encoded register value. Read the parameter value range and the dependency relationship between the parameters corresponding to the request parameters, compare the parameter value with the parameter value range, and check the related request parameters in the same parameter configuration request according to the dependency relationship between the parameters; The request parameters that pass the inspection are grouped according to the register offset, a write mask is generated according to the bit field range corresponding to each request parameter, and the encoded register values ​​corresponding to each request parameter are combined according to their respective bit field ranges to obtain the encoded value.

[0008] In a preferred embodiment, for registers whose read / write permissions indicate that reading is permitted, the register value currently stored in the register is read according to the register offset and register width, and the read register value is recorded as the original register value; The register bits outside the write mask in the original register value are retained, and the register bits indicated by the write mask are replaced with the encoded values ​​to obtain the register value to be written. For registers whose read / write permissions indicate that reading is not allowed but writing is allowed, when the current request parameters have determined all the register bits that are allowed to be written, the register value is constructed according to the bit field range of each request parameter, after combining and encoding the register value, and according to the fixed register bit values ​​specified in the register definition. The configuration order of the obtained register values ​​to be written is determined according to the dependency relationship between the parameters. For request parameters that have a sequential relationship, the register values ​​to be written corresponding to the request parameters configured earlier are arranged before the register values ​​to be written corresponding to the request parameters configured later.

[0009] In a preferred embodiment, the values ​​to be written in each register are read sequentially according to the configuration order, and the register offset and register width corresponding to the values ​​to be written in each register are read. According to the register access method specified by the target electronic module, the register to be written is determined by the register offset, and the length of the data to be written is determined according to the register width; When a register can only be written to in a specific working state, the write-allowed state corresponding to that register is read, and the working state is read according to the communication protocol specified by the target electronic module; when the working state is a write-allowed state, the write to that register is executed; The register offset, register width, and register write value are organized into the register write content specified in the communication protocol and sent to the target electronic module; the write status is read from the communication response returned by the target electronic module, and when the write status indicates that the current register write has been received, the next register write value is processed according to the configuration order.

[0010] In a preferred embodiment, during the repeated reading of the working status, each working status and the corresponding reading time are recorded. When the read working status changes from not being in a write-allowed state to being in a write-allowed state, record the moment when it enters the write-allowed state; when the read working status subsequently leaves the write-allowed state, record the moment when it leaves the write-allowed state. The duration of the write-allowed state is obtained based on the time of entering the write-allowed state and the time of leaving the write-allowed state; When a register bit with a value of 0 in the write mask changes more than twice, the time interval between two adjacent changes is obtained based on the time of each change, and the shortest time interval that has occurred is retained.

[0011] In a preferred embodiment, when the working state is in the write-enabled state, the time elapsed from the most recent read register value to the current read working state is obtained; If the elapsed time is less than the shortest time interval, the working status is read again; If the working state read again is still in the write-allowed state, and the duration of the recorded write-allowed state is not less than the time required to complete the register write and obtain the corresponding communication response according to the register width and communication protocol, then the register write value is used to perform the write. If the minimum time interval has not yet been obtained, the elapsed time has reached the minimum time interval, or the duration of the allowed write state is shorter than the time required to complete the register write and obtain the corresponding communication response, the register value is reread before writing, and the register value to be written is reconstructed based on the reread register value, the write mask, and the encoding value.

[0012] In a preferred embodiment, after reconstructing the register write value, the working state is read again; if the working state is still in the write-allowed state, the write is performed using the reconstructed register write value. If the working state has left the write-allowed state, the write operation will not be performed, and the working state and register value will continue to be read. When the previous working state is the same as the previous state before entering the write-allowed state, read the time interval between the previous working state and the write-allowed state recorded most recently, and read the actual time consumed in the most recent completion of register read and reconstruction of the register write-pending value; The time difference between the time interval and the actual time consumed is used to determine the moment when the register value is reread during the previous working state, so that the register value to be written is reconstructed before entering the write-allowed state.

[0013] In a preferred embodiment, when the reconstructing is completed and the register bit with a value of 0 in the write mask changes again before entering the write-allowed state, the time when the same previous working state occurs again will be shifted to the time when the write-allowed state occurs. If the working state is read and the write-enabled state is entered before the reconstruction is completed, the time to start rereading the register value will be brought forward the next time the same working state occurs. The time for advancing or shifting is determined according to the time difference between the completion time of this reconstruction and the actual time of entering the write-allowed state; Each time the time to start rereading the register value is determined, the previous corresponding record is replaced with the previous working state, write-enabled state, register bit change time, and reconstruction time of the actual record.

[0014] The technical effects and advantages of the electronic module parameter configuration method based on register mapping of the present invention are as follows: This invention tracks changes in register bits with a value of 0 in the write mask during the wait for the write-allowed state, ensuring that the register write-to-be-written value retains the actual changes generated during the operation of the target electronic module, reducing the risk of old register write-to-be-written values ​​overwriting non-configured register bits. Simultaneously, by combining the shortest time interval, elapsed time, and the duration of the write-allowed state, it determines whether to directly write or reread and reconstruct the register write-to-be-written value. Furthermore, it adjusts subsequent read times based on the relationship between the reconstruction completion time and the write-allowed state occurrence time, thus balancing register content consistency with the time constraint of the write-allowed state, improving the accuracy and stability of parameter configuration. Attached Figure Description

[0015] Figure 1 This is a schematic diagram illustrating the construction of register write values ​​in an electronic module parameter configuration method based on register mapping according to the present invention.

[0016] Figure 2 This is a schematic diagram illustrating the working state and register bit change time relationship of an electronic module parameter configuration method based on register mapping according to the present invention. Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] In this embodiment, the present invention discloses a method for configuring electronic module parameters based on register mapping, comprising: In step one, a parameter configuration request from the target electronic module is received, and the parameter name and value of the requested parameters are read from the request. A device information reading command is sent to the target electronic module according to the communication protocol specified by the target electronic module, and the device identity information and version information are read from the communication response returned by the target electronic module. When the device identity information and version information are stored in a register, the value of the corresponding register is read according to the identification register address predefined by the target electronic module, and the device identity information and version information are obtained by parsing according to the definition of the register. When the device identity information and version information are directly included in the communication response, the corresponding fields are read according to the communication response format specified by the target electronic module.

[0019] Based on the device identity information, a register mapping corresponding to the device identity information is searched from a pre-saved register mapping. The version information is then compared with the version conditions recorded in the register mapping, and a register mapping version whose version conditions include the version information is selected. The register mapping is pre-established according to the register definitions specified by the target electronic module; the content related to determining the register corresponding to the request parameter in this step includes parameter name, register offset, register width, bit range, read / write permissions, and version conditions. If no register mapping corresponding to the device identity information is found, or if no register mapping version matching the version information is found among the found register mappings, the parameter configuration is stopped.

[0020] In the selected register mapping version, the corresponding register definition is searched item by item according to the parameter name of each request parameter. The register offset, register width, bit range, read / write permissions, and version conditions corresponding to the request parameter are read from the found register definitions. The register bits contained in the corresponding register are determined based on the register width, and it is confirmed that the bit range does not exceed the register width. The read / write permissions are read to confirm that the bit field corresponding to the request parameter is writable. The currently read version information is compared with the version conditions corresponding to the request parameter to confirm that the request parameter can be configured in the target electronic module of the current version. If no corresponding register definition is found for any request parameter, or if the corresponding bit range, read / write permissions, or version conditions do not meet the above conditions, the configuration of the request parameter is stopped. If the above conditions are met, the parameter value of the request parameter and its corresponding register offset, register width, bit range, and read / write permissions are retained.

[0021] The read / write permissions are read from the register definition corresponding to the selected register mapping version, and are used to determine whether the register corresponding to the request parameter is allowed to be read and whether the bit field corresponding to the request parameter is allowed to be written. When the read / write permissions indicate that reading is allowed, the register value currently stored in the register is read according to the corresponding register offset and register width; when the read / write permissions indicate that reading is not allowed but writing is allowed, the register value currently stored in the register is not read.

[0022] For example, after receiving a parameter configuration request, the target electronic module reads the parameter name and value of each requested parameter from the request, and reads the device identity information and version information of the target electronic module according to the communication protocol. After finding the corresponding register mapping based on the device identity information, the version information is compared with the version conditions recorded in the register mapping, and the register mapping version containing the current version information is selected. Then, according to the parameter name of the requested parameter, the corresponding register definition is searched in the register mapping version, and the register offset, register width, bit field range, read / write permissions, and version conditions are read. If the bit field range does not exceed the register width, the read / write permissions allow writing, and the version information meets the version conditions, the parameter value of the requested parameter and the corresponding register offset, register width, bit field range, and read / write permissions are retained; if any condition is not met, the configuration of the corresponding requested parameter is stopped.

[0023] In step two, the parameter values ​​of the request parameters retained in step one, along with the corresponding register offsets, register widths, bit ranges, and read / write permissions, are read. The parameter value representation is then retrieved from the register definition corresponding to the selected register mapping version. This parameter value representation is the correspondence between the parameter values ​​specified by the target electronic module and the actual values ​​stored in the register bit ranges. This includes directly writing the value, converting the value according to a specified ratio and offset, or determining the value through enumeration. The parameter value is processed according to the parameter value representation corresponding to the current request parameter to obtain the bit range value that needs to be written within the specified bit range. Based on the position of the bit range in the corresponding register, the bit range value is moved to the corresponding register bit position to obtain the encoded register value.

[0024] After obtaining the encoded register value, the parameter value range and dependencies between parameters are read from the register definition corresponding to the register mapping version. The parameter value range refers to the minimum and maximum parameter values ​​allowed to be configured for this request parameter as specified by the target electronic module, or an enumerated set of values ​​that can be selected. The dependencies between parameters refer to the size, mutual exclusion, or sequential relationships that must be satisfied when two or more request parameters are configured simultaneously, as specified by the target electronic module. The parameter values ​​in the parameter configuration request are compared with the corresponding parameter value ranges, and related request parameters in the same parameter configuration request are checked according to the dependencies between parameters. If a parameter value exceeds the corresponding parameter value range, or if a related request parameter does not satisfy the corresponding dependency, the configuration of the corresponding request parameter is stopped, and parameter values ​​exceeding the range are not automatically adjusted.

[0025] For request parameters that pass the above checks, they are grouped according to register offsets. When two or more request parameters have the same register offset, the register bits they occupy in the same register are determined based on the bit field range corresponding to each request parameter; if the bit field ranges do not overlap, the encoded register values ​​corresponding to each request parameter are retained. When two or more bit field ranges contain the same register bits, the values ​​to be written to the same register bits of these request parameters are read; if the values ​​to be written are the same, the same register bits are treated as a single write operation; if the values ​​to be written are different, the configuration of the conflicting request parameters is stopped, and the encoded register values ​​of the conflicting parameters are not used to construct the register write values ​​of the corresponding registers.

[0026] A write mask is generated based on the bit range of each request parameter after the above processing. In this process, the register bits that need to be modified in the request parameters are set to 1, and the remaining register bits are set to 0. The encoded register values ​​corresponding to each request parameter are combined according to their respective bit ranges to obtain the encoded value. ,in Centered in the write mask The value indicated on the register bit is the value that needs to be written for the corresponding request parameter. For registers whose read / write permissions indicate that reading is allowed, the register value currently stored in the register is read according to the register offset and register width, using the communication protocol used to communicate with the target electronic module in step one, and the read register value is recorded as the original register value. The register value to be written is constructed using the following formula. : ; in, This refers to the register value to be written to in this operation. This is the original register value read from the target electronic module; This is a write mask generated based on the bit range corresponding to the parameters in this request. The encoded value is formed by combining the encoded register values ​​of each request parameter; This indicates a bitwise AND operation. This indicates a bitwise OR operation. This indicates a bitwise NOT operation. The register bits outside the write mask retain their original values, and the register bits indicated by the write mask are replaced with their encoded values. For example... Figure 1 As shown.

[0027] For example, when a register contains 8 register bits, and the current request parameter only modifies some of these register bits, first, the values ​​of the 8 register bits currently stored in the register are read according to the register offset and register width, and recorded as the original register values. Then, a write mask is generated based on the bit range corresponding to the request parameter, so that the register bits that need to be modified are set to 1, and the remaining register bits are set to 0. When constructing the register value to be written, the register bits with a value of 0 in the write mask continue to use the corresponding values ​​in the original register values, and the register bits with a value of 1 in the write mask use the corresponding values ​​in the encoded values, thus obtaining the complete register value to be written.

[0028] For example, if a request parameter corresponds to a register width comprising multiple register bits, and the bit field range of the request parameter only occupies a portion of these register bits, the parameter value is first processed according to the parameter value representation method corresponding to the request parameter to obtain the bit field value. Then, the bit field value is moved to the corresponding register bit position according to the bit field range to obtain the encoded register value. After confirming that the parameter value is within the corresponding parameter value range, and that related request parameters in the same parameter configuration request satisfy the dependency relationship between parameters, request parameters with the same register offset are grouped together. The register bits that need to be modified in the request parameter are set to 1 in the write mask, and the remaining register bits are set to 0. The encoded register values ​​corresponding to each request parameter are then combined according to their respective bit field ranges to form an encoded value. When two request parameters have the same register bit range but require different values ​​to be written, the configuration of the conflicting request parameters is stopped.

[0029] For registers whose read / write permissions indicate that reading is not allowed but writing is allowed, the original register value is not retrieved. When the current request parameters have determined all the register bits that are allowed to be written to, the register value is constructed by combining and encoding the bit field ranges corresponding to each request parameter, and constructing the register write value according to the fixed register bit values ​​specified in the register definition; when there are still register bits whose values ​​cannot be determined by the current request parameters or the register definition, the configuration of the request parameters corresponding to that register is stopped.

[0030] For example, for a register whose read / write permissions indicate that reading is not allowed but writing is allowed, the original register value is not read. When the current request parameters have determined all the register bits that are allowed to be written to, and the remaining register bits can be determined according to the fixed register bit values ​​specified in the register definition, the register value is constructed by combining the bit field ranges corresponding to each request parameter with the fixed register bit values; if there is a register bit whose value cannot be determined by the current request parameters or the register definition, the configuration of the request parameters corresponding to that register is stopped.

[0031] The configuration order of each register to be written is determined according to the dependency relationship between the parameters. For request parameters that have a priority relationship, the register to be written corresponding to the request parameter configured earlier is arranged before the register to be written corresponding to the request parameter configured later. For request parameters that do not have a priority relationship, the order of the corresponding register to be written is determined according to their arrangement order in the parameter configuration request.

[0032] In step three, the values ​​to be written in each register are read sequentially according to the configuration order determined in step two, and the register offset and register width corresponding to the value to be written are also read. Following the register access method specified by the target electronic module, the register to be written is determined using the register offset, and the data length to be written is determined based on the register width. If multiple request parameters in the same register have already been combined into a single value to be written in step two, the register is written only once, and the bit fields corresponding to each request parameter are not written separately.

[0033] When the selected register mapping version specifies that the current register can only be written to in a specific operating state, the write-allowed state corresponding to that register is read; the write-allowed state is the operating state specified by the target electronic module that allows write operations to be performed on the current register. The current operating state is read according to the communication protocol specified by the target electronic module, obtained from the corresponding field in the register or communication response specified by the target electronic module to represent the current operating state. The read current operating state is compared with the write-allowed state; if the current operating state is not a write-allowed state, no write is performed on the register, and the current operating state is read again according to the communication protocol; if the current operating state is a write-allowed state, the write operation on the register is performed. If the selected register mapping version does not specify that the current register must be in a specific operating state to be written to, the write operation on the register is performed directly.

[0034] For example, after reading a register value to be written according to the configuration order, the register offset and register width corresponding to that value are read simultaneously. The register offset determines the register to be written to, and the register width determines the length of the data to be written. When the selected register mapping version specifies that the register can only be written to in a write-allowed state, the working status is repeatedly read according to the communication protocol. If the working status is not a write-allowed state, reading continues. If the working status is a write-allowed state, the register offset, register width, and register value to be written are organized into the register write content specified in the communication protocol and sent to the target electronic module. After the target electronic module returns a communication response, the write status is read from the communication response. When the write status indicates that the current register write has been received, the next register value to be written is processed according to the configuration order.

[0035] It should be noted that the register write value is constructed by reading the original register value from the target electronic module. However, some registers can only be written to when the current operating state enters the write-enabled state. Therefore, there may be a waiting process between obtaining the original register value and actually being able to write. During this waiting process, the target electronic module's own operation may change register bits that are not part of the write mask in the same register, so that the current value of the register when entering the write-enabled state is different from the original register value obtained when constructing the register write value. At this time, directly writing the previously constructed register write value may overwrite the register bit changes that occurred during the waiting process. Rereading the register and reconstructing the register write value will occupy the duration of the write-enabled state, so that when the reconstruction is completed, the current operating state may have already left the write-enabled state.

[0036] Therefore, in this embodiment, for the current register whose read / write permission indicates read permission but requires waiting for write permission, during the period when the current working state is not yet in the write permission state, after each read of the current working state according to the communication protocol, the register value currently stored in the register is read according to the register offset and register width corresponding to the current register, and the time of this register read is recorded using the same timing benchmark. The register value read this time is compared with the register value read previously, where only register bits with a value of 0 in the write mask are compared; when the value of the register bit changes, the corresponding register bit in the register to be written value is replaced with the value read this time, while the register bits with a value of 1 in the write mask still use the encoded value obtained in step two, and the time of change is recorded. The above process is repeated when reading the current register again, so that the register to be written value formed during the waiting period is reconstructed as the register bits generated by the target electronic module outside the write mask change.

[0037] In this embodiment, the change time is recorded according to the current register read time when the value of a register bit changes. The register value read this time is compared with the register bits with a mask value of 0 written in the previous register read. If the value of one or more corresponding register bits in the current read is different from the previous read, the time of this register read is recorded as the change time. After recording two or more consecutive change times, the time interval between two adjacent change times is compared, and the shortest time interval that has occurred is retained.

[0038] For example, when continuously reading the current register value before the working state is in a write-enabled state, the register bits with a value of 0 in the write mask remain unchanged after the first read. If a change is found in the corresponding register bit during a subsequent read, the time of that read is recorded as a change moment. If another change is found after further reads, a second change moment is recorded, and the time interval between the two changes is recorded. As register bit changes continue, the time intervals between adjacent change moments are recorded, and the shortest time interval is retained from the already recorded intervals.

[0039] During the repeated reading of the current working state, the current working state and its corresponding reading time are recorded each time. When the read current working state changes from a state that is not allowed to be written to a state that is allowed to be written, the time when entering the allowed writing state is recorded, and the last working state read before entering the allowed writing state is taken as the previous working state; when the current working state is subsequently read to leave the allowed writing state, the time when leaving the allowed writing state is recorded. Based on the continuously recorded times, the time interval between the last time the previous working state was read and the entry into the allowed writing state, and the duration between entering and leaving the allowed writing state are obtained respectively. For cases where register bits with a value of 0 in the write mask change more than twice during the waiting period, the time interval between two adjacent changes is obtained based on the time of each change, and the shortest time interval that has occurred is retained.

[0040] If the duration of the write-allowed state has not been recorded, the write operation is not performed based on the duration of the write-allowed state. Instead, the current register value is read again before the write operation is performed, and the register value to be written is reconstructed based on the reread register value, write mask, and encoding value. After the reconstruction is completed, the current working state is read again, and the write operation is performed based on the reread current working state.

[0041] When the current working state is read again and found to be in a write-enabled state, the elapsed time between the last read of the current register value and the current read of the current working state is obtained. If the shortest time interval between two consecutive changes of register bits with a value of 0 in the write mask has been obtained, and the elapsed time is less than this shortest time interval, the current working state is read again. If the current working state read again is still in a write-enabled state, and the recorded duration of the write-enabled state is not less than the time required to complete the register write according to the register width and communication protocol and obtain the corresponding communication response, the current register write value is used to perform the write. If the above conditions for using the current register write value to perform the write are not yet met, the current register value is read again before performing the write, and the register write value is reconstructed based on the reread register value, write mask, and encoding value. The time from issuing this register read instruction to completing the reconstruction of the register write value is recorded by the same timing reference, such as... Figure 2 As shown.

[0042] The time required to complete the register write and obtain the corresponding communication response is determined according to the register width of the current register and the communication protocol specified by the target electronic module. The data length of the register write content is determined based on the register width, and the time required to complete the register write and obtain the corresponding communication response is determined according to the register write content transmission process and the process of obtaining the corresponding communication response as specified in the communication protocol; when the communication protocol specifies a response waiting time, the time to obtain the corresponding communication response shall not exceed the response waiting time.

[0043] After reconstructing the register write value, the current working state is read again. If the current working state is still in the write-allowed state, and the recorded write-allowed state duration is not less than the time required to complete the register write and obtain the corresponding communication response according to the register width and communication protocol, the reconstructed register write value is used to perform the write. If the current working state has left the write-allowed state, or the above conditions for performing the write have not yet been met, the write is not performed, and the current working state and the current register value are read again. When the same previous working state as before entering the write-allowed state reappears, the time interval between the most recently recorded previous working state and the write-allowed state is read, and the actual time consumed in the most recent register read and register write value reconstruction is read. When the time interval is not shorter than the actual time consumed, the time difference between the time interval and the actual time consumed determines the moment when the current register value is reread during the previous working state, so that the register value to be written is reconstructed before entering the write-allowed state. When the time interval is shorter than the actual time consumed, the current register value is reread and the register value to be written is reconstructed after the same previous working state is read again. After reconstruction, the current working state is read again, and it is determined whether to perform this write operation based on the current working state read again. When the register bit with a value of 0 in the write mask changes again before entering the write-allowed state after this reconstruction, the moment when the same previous working state appears again will be moved to the moment when the write-allowed state appears. When the current working state is read and the write-allowed state is entered before the reconstruction is completed, the moment when the current register value is reread will be moved forward after the same previous working state appears again. The time of moving forward or shifting is determined according to the time difference between the moment when the reconstruction is completed and the moment when the write-allowed state is actually entered. Each time the read time is redefined, the previous corresponding record is replaced with the previous working state, write-enabled state, register bit change time, and reconstruction time of the actual record.

[0044] The previous working state, the duration of the write-allowed state, the time of register bit change, the shortest time interval, and the time consumed for reconstruction are all recorded in the current register respectively. When processing the next register to be written in the configuration order, the above contents recorded in the register corresponding to the register to be written are read, and the records corresponding to other registers are not used.

[0045] When the time to start rereading the current register value is moved towards the time when the write-allowed state appears, the re-determined time is no later than the actual time when the write-allowed state is entered; when the time to start rereading the current register value is advanced, the re-determined time is no earlier than the time when the same previous working state is read again. When the time determined according to the time difference exceeds the above range, the time that can be determined within the range is taken as the time to start rereading the current register value.

[0046] For example, while the current working state is not yet in a write-allowed state, the current working state and the current register value are repeatedly read according to the communication protocol, and the changes in register bits with a write mask value of 0 in the current register are recorded. After recording two or more change times, the time interval between two adjacent changes is obtained, and the shortest time interval is retained. When the current working state enters a write-allowed state, the elapsed time from the most recent read of the current register value to the current read of the current working state is obtained. If the elapsed time is less than the shortest time interval, and the current working state read again is still in a write-allowed state, and the duration of the already recorded write-allowed state is not less than the time required to complete the register write and obtain the corresponding communication response, the write operation is performed using the current register value to be written.

[0047] If the above conditions are not yet met, the current register value is reread before writing, and the register value to be written is reconstructed based on the reread register value, write mask, and encoding value. After reconstruction, the current working state is read again; if the current working state has left the write-allowed state, the write operation is not performed, and the current working state and current register value are read again. If the same previous working state as before entering the write-allowed state reappears, the time to start rereading the current register value is determined based on the time interval between the most recently recorded previous working state and the write-allowed state, as well as the actual time consumed in the most recent register read and register value reconstruction.

[0048] When a register bit with a value of 0 in the write mask changes again after reconstruction is completed, before entering the write-allowed state, the time when the same previous working state occurs again will be moved to the time when the write-allowed state appears. If the current working state is read and the write-allowed state is entered before reconstruction is completed, the time when the current register value is read again will be moved forward, and the previous record will be replaced according to the previous working state, write-allowed state, register bit change time, and reconstruction time.

[0049] After determining the register write value for the current register, the register offset, register width, and the currently determined register write value are organized into the register write content specified in the communication protocol used in step one for communicating with the target electronic module, and then sent to the target electronic module. The communication protocol specifies that when a write operation returns a communication response, the write status is read from the communication response returned by the target electronic module. If the write status indicates that the current register write has not been received, or if no communication response corresponding to the current register write is obtained within the response waiting time specified in the communication protocol, the writing of the remaining registers according to the configuration order is stopped. If the write status indicates that the current register write has been received, the next register write value is processed according to the configuration order. For registers whose read / write permissions indicate that reading is not allowed but writing is allowed, since the original register value was not used when constructing the register write value in step two, the above-mentioned repeated reading and reconstruction processing of register bits outside the write mask is not performed. After the current working state is in the write-allowed state, the corresponding register write value is written according to the communication protocol. If the communication protocol does not specify that when a write operation returns a communication response, the next register write value is processed according to the configuration order after the register write content is sent.

[0050] In step four, following the configuration order in step three, the written registers whose read / write permissions indicate read permission are read. Based on the register offset and register width corresponding to the register, the written register value is obtained according to the communication protocol specified by the target electronic module. The write mask generated for this register in step two is then read. and register write value The write mask is used to retain the written register value and the register bit actually configured in the current write value, respectively, and the retained values ​​are compared. If they are the same, it is determined that the register bit configured in the current write value in that register is consistent with the register bit to be written; if they are different, the verification of the remaining registers is stopped, and that register is determined as a register that failed the write verification. For registers that have already been written and whose read / write permissions indicate that reading is not allowed, the register read result is not used to determine the written content.

[0051] For example, for a register that has already been written and whose read / write permissions indicate that reading is allowed, the written register value is reread according to the register offset and register width, and the write mask and register value to be written generated for that register in step two are read. The actual registered bits configured in this operation are retained in the written register value and the register value to be written in the register, respectively, using the write mask. If they are the same, it is determined that the configured register bits are consistent with the register value to be written. If they are different, the register is determined to be a register that failed the write verification, and the verification of the remaining registers is stopped.

[0052] When the target electronic module specifies a configuration check value for checking the overall configuration content, the register storing the configuration check value is read according to the selected register mapping version, and the calculation range and calculation method specified by the target electronic module for the configuration check value are read. The configuration check value is the value obtained by the target electronic module calculating the register values ​​within the specified range according to the specified calculation method. The register values ​​participating in the calculation after this parameter configuration are obtained according to the specified calculation range, and the corresponding configuration check value is obtained according to the specified calculation method. The calculated configuration check value is compared with the configuration check value read from the target electronic module; if the two are different, the execution of this parameter configuration is stopped. If the selected register mapping version specifies a corresponding configuration recovery operation, the configuration recovery operation is performed, and the configuration saving operation or configuration activation operation is not performed. If the target electronic module does not specify a configuration check value, this comparison is not performed.

[0053] For registers that fail the write verification, read the original register value obtained in step two before writing. According to the register offset and register width corresponding to the register, the original register value is converted using the communication protocol. Rewrite the corresponding register; when multiple registers that have already been written to have acquired the original register values. Then, restore these registers in the reverse order of the configuration in step three. For registers with read / write permissions indicating that reading is not allowed, and therefore the original register values ​​were not retrieved in step two. When the selected register mapping version specifies a corresponding recovery configuration operation, the recovery configuration operation shall be followed; when no corresponding recovery configuration operation is specified, the current parameter configuration shall be stopped, and the save configuration operation or the configuration effective operation shall not be performed.

[0054] The configuration recovery operation is the recovery operation specified for this parameter configuration in the selected register mapping version. When the selected register mapping version specifies a configuration recovery operation, the register offset, write value, and execution order corresponding to the configuration recovery operation are read, and the corresponding write value is written to the corresponding register according to the execution order and the communication protocol. After the configuration recovery operation is completed, the save configuration operation or configuration activation operation in this parameter configuration is not executed.

[0055] Once all allowed read-already written registers pass the comparison, and the comparison results of the configuration checksums (if specified by the target electronic module) are consistent, the save configuration operation or configuration activation operation specified for this parameter configuration in the selected register mapping version is read. The save configuration operation is the operation by which the target electronic module writes the configuration content in the current register into the non-volatile storage area specified by the target electronic module; the configuration activation operation is the operation by which the target electronic module puts the written configuration content into a usable state according to its specified control method. The save configuration operation or configuration activation operation is executed through the communication protocol according to the register offset, write value, and execution order specified by the selected register mapping version; if the selected register mapping version does not specify a save configuration operation or configuration activation operation, the corresponding operation is not executed.

[0056] After performing a save configuration operation or a configuration activation operation, the register representing the execution result of the save configuration operation or configuration activation operation is read according to the selected register mapping version, and the read register value is compared with the operation completion status specified in the register definition. If the read register value matches the operation completion status, the current parameter configuration ends; if the read register value does not match the operation completion status, the current parameter configuration stops; if the selected register mapping version specifies a corresponding restore configuration operation, the restore configuration operation is performed accordingly.

[0057] The above formulas are all dimensionless calculations. The formulas are derived from software simulations based on a large amount of collected data to obtain the most recent real-world results. The preset parameters in the formulas are set by those skilled in the art according to the actual situation.

[0058] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, in the form of a computer program product.

[0059] 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 inventive 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.

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

[0061] 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.

[0062] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A method for configuring electronic module parameters based on register mapping, characterized in that, include: For registers that need to wait for a write-allowed state, the register value is repeatedly read while the working state is not yet in a write-allowed state. The register value is the register value currently stored in the register that is read from the register. Compare the register bits whose write mask value is zero in the current and previous register values; when the value changes, replace the corresponding register bit in the register to be written value with the value read this time, and record the time of change. The register to be written value is the value of the register bit whose write mask value is zero. The shortest time interval between two adjacent changes is obtained based on the change time; when the working state is in the write-allowed state, the elapsed time from the most recent read register value to the current read working state is obtained; Based on the elapsed time and the shortest time interval, determine whether to perform the write using the register write value, or to reread the register value and reconstruct the register write value.

2. The electronic module parameter configuration method based on register mapping according to claim 1, characterized in that: Receive a parameter configuration request from the target electronic module, and read the parameter name and parameter value of the requested parameter from the parameter configuration request; Read the device identity information and version information of the target electronic module, find the corresponding register mapping from the pre-saved register mapping according to the device identity information, compare the version information with the version conditions recorded in the register mapping, and select the register mapping version whose version conditions include the version information; In the register mapping version, the corresponding register definition is found according to the parameter name of the request parameter, and the register offset, register width, bit range, read / write permissions and version conditions corresponding to the request parameter are read. If it is confirmed that the bit field range does not exceed the register width, the read / write permission allows writing, and the version information meets the version conditions, the parameter value of the request parameter and its corresponding register offset, register width, bit field range, and read / write permission are retained.

3. The electronic module parameter configuration method based on register mapping according to claim 2, characterized in that: Read the parameter values ​​of the request parameters, as well as the corresponding register offset, register width, bit range, read / write permissions, and parameter value representation. The parameter value is processed according to the parameter value representation method to obtain the bit field value that the request parameter needs to be written within the bit field range, and the bit field value is moved to the corresponding register bit position according to the position of the bit field range in the corresponding register to obtain the encoded register value. Read the parameter value range and the dependency relationship between the parameters corresponding to the request parameters, compare the parameter value with the parameter value range, and check the related request parameters in the same parameter configuration request according to the dependency relationship between the parameters; The request parameters that pass the inspection are grouped according to the register offset, a write mask is generated according to the bit field range corresponding to each request parameter, and the encoded register values ​​corresponding to each request parameter are combined according to their respective bit field ranges to obtain the encoded value.

4. The electronic module parameter configuration method based on register mapping according to claim 3, characterized in that: For registers whose read / write permissions indicate that reading is allowed, read the register value currently stored in the register according to the register offset and register width, and record the read register value as the original register value; The register bits outside the write mask in the original register value are retained, and the register bits indicated by the write mask are replaced with the encoded values ​​to obtain the register value to be written. For registers whose read / write permissions indicate that reading is not allowed but writing is allowed, when the current request parameters have determined all the register bits that are allowed to be written, the register value is constructed according to the bit field range of each request parameter, after combining and encoding the register value, and according to the fixed register bit values ​​specified in the register definition. The configuration order of the obtained register values ​​to be written is determined according to the dependency relationship between the parameters. For request parameters that have a sequential relationship, the register values ​​to be written corresponding to the request parameters configured earlier are arranged before the register values ​​to be written corresponding to the request parameters configured later.

5. The electronic module parameter configuration method based on register mapping according to claim 4, characterized in that: Read the values ​​to be written in each register sequentially according to the configuration order, and read the register offset and register width corresponding to the values ​​to be written in each register; According to the register access method specified by the target electronic module, the register to be written is determined by the register offset, and the length of the data to be written is determined according to the register width; When a register can only be written to in a specific working state, the write-allowed state corresponding to that register is read, and the working state is read according to the communication protocol specified by the target electronic module; when the working state is a write-allowed state, the write to that register is executed; The register offset, register width, and register write value are organized into the register write content specified in the communication protocol and sent to the target electronic module; the write status is read from the communication response returned by the target electronic module, and when the write status indicates that the current register write has been received, the next register write value is processed according to the configuration order.

6. The electronic module parameter configuration method based on register mapping according to claim 1, characterized in that: During the repeated reading of the working status, the working status and the corresponding reading time are recorded each time; When the read working status changes from not being in a write-allowed state to being in a write-allowed state, record the moment when it enters the write-allowed state; when the read working status subsequently leaves the write-allowed state, record the moment when it leaves the write-allowed state. The duration of the write-allowed state is obtained based on the time of entering the write-allowed state and the time of leaving the write-allowed state; When a register bit with a value of 0 in the write mask changes more than twice, the time interval between two adjacent changes is obtained based on the time of each change, and the shortest time interval that has occurred is retained.

7. The electronic module parameter configuration method based on register mapping according to claim 6, characterized in that: When the working state is in the write-enabled state, obtain the elapsed time from the last read register value to the current read working state; If the elapsed time is less than the shortest time interval, the working status is read again; If the working state read again is still in the write-allowed state, and the duration of the recorded write-allowed state is not less than the time required to complete the register write and obtain the corresponding communication response according to the register width and communication protocol, then the register write value is used to perform the write. If the minimum time interval has not yet been obtained, the elapsed time has reached the minimum time interval, or the duration of the allowed write state is shorter than the time required to complete the register write and obtain the corresponding communication response, the register value is reread before writing, and the register value to be written is reconstructed based on the reread register value, the write mask, and the encoding value.

8. The electronic module parameter configuration method based on register mapping according to claim 7, characterized in that: After reconstructing the register write value, read the working status again; if the working status is still in the write-allowed state, use the reconstructed register write value to perform the write operation. If the working state has left the write-allowed state, the write operation will not be performed, and the working state and register value will continue to be read. When the previous working state is the same as the previous state before entering the write-allowed state, read the time interval between the previous working state and the write-allowed state recorded most recently, and read the actual time consumed in the most recent completion of register read and reconstruction of the register write-pending value; The time difference between the time interval and the actual time consumed is used to determine the moment when the register value is reread during the previous working state, so that the register value to be written is reconstructed before entering the write-allowed state.

9. The electronic module parameter configuration method based on register mapping according to claim 8, characterized in that: Once this reconstruction is complete, if the register bit with a value of 0 in the write mask changes again before entering the write-allowed state, the time when the same previous working state occurs again will be shifted to the time when the write-allowed state occurs. If the working state is read and the write-enabled state is entered before the reconstruction is completed, the time to start rereading the register value will be brought forward the next time the same working state occurs. The time for advancing or shifting is determined according to the time difference between the completion time of this reconstruction and the actual time of entering the write-allowed state; Each time the time to start rereading the register value is determined, the previous corresponding record is replaced with the previous working state, write-enabled state, register bit change time, and reconstruction time of the actual record.