I2C data writing method

By introducing I2C interface modules and functional modules into the I2C interface system, efficient transmission and response reliability of I2C data writing are achieved, and the problems of slow data writing speed and low response reliability in I2C transmission are solved. They are suitable for a variety of Application scenario.

CN119003416APending Publication Date: 2024-11-22NOREL SYSTEMS LIMITED
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411023364.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-29
Publication Date
2024-11-22

Smart Images

  • Figure CN119003416A_ABST
    Figure CN119003416A_ABST
Patent Text Reader

Abstract

The invention provides an I2C data writing method which is based on an I2C interface system comprising an I2C interface module and at least one functional module, and the I2C interface module is connected with an I2C main controller through an I2C clock line and an I2C data line; and the function module is connected with the I2C interface module. The method is suitable for application scenes with long transmission distance or large signal interference, and the I2C system for long-distance transmission is high in response speed and transmission speed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, in particular to the encoding, decoding and transmission of physical layer data, and more particularly to a data writing method for I2C transmission. Background Art

[0002] The I2C bus is a simple, bidirectional serial bus developed by Philips. Devices interconnected through the I2C bus are called I2C devices, and the interface of the I2C device to the I2C bus is called the I2C interface. The I2C bus has become a de facto international standard, and the design specifications of the I2C bus and its protocol (called the standard I2C specification) are usually based on the description of the document THE I2C-BUS SPECIFICATION VERSION 2.1 JANUARY 2000.

[0003] The I2C interface includes an I2C clock line (generally named SCL) and an I2C data line (generally named SDA). The I2C master controller connects to the I2C interface modules of one or more I2C slave devices through the I2C clock line and the I2C data line. The I2C master controller drives the I2C clock line, initiates an I2C write or read operation, and determines whether the data is sent successfully through the response bit. Bit errors on the bus due to signal interference and other reasons cannot be recognized by the I2C slave device.

[0004] The electrical characteristics of the I2C interface require that the devices involved in I2C communication share a common ground, otherwise transmission will fail. Therefore, I2C communication is not suitable for applications with long transmission distances or large signal interference. To solve this problem, a device for forwarding I2C data is usually added to the I2C bus, but the introduction of forwarding devices also presents new problems:

[0005] The I2C communication mechanism requires that the I2C slave device must reply with an acknowledge bit for each byte sent by the I2C master controller. When the acknowledge bit level is low, it is I2CACK, and when the acknowledge bit level is high, it is I2C NAK. In the prior art, each byte sent by the I2C master controller is transmitted to the module that ultimately receives the data (referred to as the functional module in the present invention), and the functional module generates an acknowledge bit and transmits it back to the I2C master controller. The response speed of the transmission system is slow, resulting in a slow transmission speed.

[0006] In addition, in the current transmission based on the I2C protocol, the response mechanism is based entirely or partially on the response bit of the I2C protocol. This single-bit response mechanism is sensitive to voltage noise on the signal line and has low reliability. Currently, there is a lack of a transmission solution that can efficiently perform I2C transmission and improve response reliability. Summary of the invention

[0007] In order to solve the problems of slow I2C data writing and low response reliability in the prior art, an object of the present invention is to provide an I2C data writing method, based on an I2C interface system, the I2C interface system includes an I2C interface module, and at least one functional module, the I2C interface module is connected to the I2C main controller through an I2C clock line and an I2C data line, and the functional module is connected to the I2C interface module, including:

[0008] The I2C master controller initiates an I2C write operation and sends a write command packet to the I2C interface module. After receiving the write command packet, the I2C interface module pulls down the I2C clock line level and sends the write command packet to the function module.

[0009] The functional module receives the write command packet and executes the write command. When the functional module completes the write command, it returns a write status packet to the I2C interface module.

[0010] When the I2C interface module receives the write status packet, the I2C interface module stops pulling down the I2C clock line level and returns an I2C ACK or I2C NAK to the I2C master controller.

[0011] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0012] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information of the write status packet to the I2C master controller.

[0013] Preferably, when the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives the write command packet.

[0014] Preferably, the write command packet further includes a write command packet verification code.

[0015] When the data received by the I2C interface module reaches the length of the write command packet and the write command packet check code is verified to be correct, the I2C interface module receives the write command packet.

[0016] Preferably, when the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information of a write status packet to the I2C master controller.

[0017] Then the I2C interface module continues to receive the I2C operation initiated by the I2C master controller.

[0018] Further, before the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives an I2C START signal or an I2C STOP signal, then the I2C interface module ends receiving the current write command packet, and the I2C interface module does not receive the write command packet.

[0019] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0020] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

[0021] Further, when the data received by the I2C interface module reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet.

[0022] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0023] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

[0024] Preferably, the I2C interface module includes a timeout timer,

[0025] When the I2C interface module does not receive the write status packet before the timeout, the I2C interface module stops pulling down the I2C clock line level after the timeout, and returns an I2C ACK or I2C NAK to the I2C master controller.

[0026] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0027] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

[0028] Another object of the present invention is to provide an I2C data writing method, based on an I2C interface system, the I2C interface system includes an I2C interface module, and at least one functional module, the I2C interface module is connected to an I2C master controller via an I2C clock line and an I2C data line, and the functional module is connected to the I2C interface module, including:

[0029] The I2C master controller initiates an I2C write operation and sends a write command packet to the I2C interface module. After receiving the write command packet, the I2C interface module sends the write command packet to the function module.

[0030] The functional module receives the write command packet and executes the write command. When the functional module completes the write command, it returns a write status packet to the I2C interface module.

[0031] After the I2C interface module receives the write command packet,

[0032] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, and the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module returns an I2C NAK to the I2C master controller,

[0033] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, and the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module returns status information of the write status packet to the I2C master controller.

[0034] Preferably, when the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives the write command packet.

[0035] Preferably, the write command packet further includes a write command packet verification code.

[0036] When the data received by the I2C interface module reaches the length of the write command packet and the write command packet check code is verified to be correct, the I2C interface module receives the write command packet.

[0037] Further, before the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives an I2C START signal or an I2C STOP signal, then the I2C interface module ends receiving the current write command packet, and the I2C interface module does not receive the write command packet.

[0038] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0039] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

[0040] Further, when the data received by the I2C interface module reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet.

[0041] If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0042] If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

[0043] Preferably, the I2C interface module includes a timeout timer,

[0044] When the I2C interface module does not receive a write status packet before the timeout, if the subsequent I2C operation initiated by the I2C master controller after the timeout is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller.

[0045] When the I2C interface module does not receive a write status packet before timeout, if the subsequent I2C operation initiated by the I2C master controller after timeout is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

[0046] Preferably, when the subsequent I2C operation initiated by the I2C master controller is an I2C write operation,

[0047] If the I2C interface module does not receive the write status packet returned by the functional module to the I2C interface module, the I2C interface module pulls down the I2C clock line level.

[0048] If the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module stops pulling down the I2C clock line level and returns an I2C NAK to the I2C master controller.

[0049] Preferably, when the subsequent I2C operation initiated by the I2C master controller is an I2C read operation,

[0050] If the I2C interface module does not receive the write status packet returned by the functional module to the I2C interface module, the I2C interface module pulls down the I2C clock line level.

[0051] If the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module stops pulling down the I2C clock line level and returns status information of the write status packet to the I2C master controller.

[0052] Another object of the present invention is to provide an I2C data writing method, based on an I2C interface system, the I2C interface system includes an I2C interface module, and at least one functional module, the I2C interface module is connected to an I2C master controller via an I2C clock line and an I2C data line, and the functional module is connected to the I2C interface module, characterized in that:

[0053] The I2C master controller initiates an I2C write operation to send the write command packet to the I2C interface module, and then the I2C master controller initiates a subsequent I2C read operation to read the status information.

[0054] After receiving the address byte of the subsequent I2C read operation, the I2C interface module pulls down the I2C clock line level and sends the received write command packet to the functional module.

[0055] The functional module receives the write command packet and executes the write command. When the functional module completes the write command, it returns a write status packet to the I2C interface module.

[0056] After the I2C interface module receives the write status packet, the I2C interface module stops pulling down the I2C clock line level and returns status information of the write status packet to the I2C master controller.

[0057] Preferably, when the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives the write command packet.

[0058] Preferably, the write command packet further includes a write command packet verification code.

[0059] When the data received by the I2C interface module reaches the length of the write command packet and the write command packet check code is verified to be correct, the I2C interface module receives the write command packet.

[0060] Further, before the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives an I2C START signal or an I2C STOP signal of a subsequent I2C read operation, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet.

[0061] The I2C interface module returns status information to the I2C master controller after receiving the address byte of a subsequent I2C read operation.

[0062] Further, when the data received by the I2C interface module reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet.

[0063] The I2C interface module returns status information to the I2C master controller after receiving the address byte of a subsequent I2C read operation.

[0064] Preferably, the I2C interface module includes a timeout timer,

[0065] When the I2C interface module does not receive the write status packet before the timeout, the I2C interface module returns status information to the I2C master controller after receiving the address byte of the subsequent I2C read operation after the timeout.

[0066] The method for efficiently writing I2C data provided by the present invention packages the data for transmission and writing, and returns the status information of the I2C data writing to the I2C main controller through the I2C read operation. The return of the status information does not depend on the single-bit I2C response bit, thereby improving reliability. The method is suitable for application scenarios with longer transmission links, and is also compatible with local applications with shorter transmission links, thereby providing an ideal solution for I2C transmission. BRIEF DESCRIPTION OF THE DRAWINGS

[0067] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0068] Figure 1 The schematic diagram of an I2C interface system for high-speed I2C long-distance transmission according to the present invention is schematically shown.

[0069] Figure 2 A timing diagram of an I2C write operation of the present invention is shown.

[0070] Figure 3 FIG. 1 shows a timing diagram of an I2C read operation of the present invention.

[0071] Figure 4 The timing diagram of the I2C continuous read and write operation of the present invention is shown;

[0072] Figure 5 The timing diagram of initiating an I2C write operation and sending a write command packet according to the present invention is shown.

[0073] Figure 6 The timing diagram of the present invention initiating an I2C write operation and sending a write command packet with a check code is shown.

[0074] Figure 7 The timing diagram of the present invention is shown when the subsequent I2C operation is an I2C write operation after the current I2C write operation sends a write command packet.

[0075] Figure 8 The timing diagram of the present invention is shown when the subsequent I2C operation is an I2C read operation after the current I2C write operation sends a write command packet.

[0076] Fig. 9 The timing diagram of initiating an I2C write operation, sending a write command packet, and returning a write status packet timeout in the working mode 1 of the data writing method of the present invention is shown.

[0077] Fig.10 The timing diagram shows that an I2C write operation is initiated to send a write command packet and the subsequent I2C operation is an I2C write operation in the working mode 2 of the data writing method of the present invention.

[0078] Fig.11 The timing diagram shows that an I2C write operation is initiated to send a write command packet and the subsequent I2C operation is an I2C read operation in the working mode 2 of the data writing method of the present invention.

[0079] Fig.12 The timing diagram shows that in the working mode 2 of the data writing method of the present invention, an I2C write operation is initiated to send a write command packet, and the subsequent I2C operations are always I2C write operations.

[0080] Fig.13 The timing diagram shows that an I2C write operation is initiated to send a write command packet in the working mode 2 of the data writing method of the present invention, and an I2C read operation occurs in the subsequent I2C operation.

[0081] Fig.14 The timing diagram of initiating an I2C write operation and sending a write command packet in the working mode 2 of the data writing method of the present invention and receiving the I2C write operation before receiving the returned write status packet is shown.

[0082] Fig.15The timing diagram of initiating an I2C write operation and sending a write command packet in the working mode 2 of the data writing method of the present invention and receiving an I2C read operation before receiving the status information of the returned write status packet is shown.

[0083] Fig.16 The timing diagram of initiating an I2C write operation, initiating a write command packet, and then initiating an I2C read operation in working mode 3 of the data writing method of the present invention is shown.

[0084] The meanings of the text symbols in the above drawings are as follows:

[0085] 100: I2C master controller; 200: I2C interface module; 300: functional module; 400: I2C data line (SDA); 500: I2C clock line (SCL);

[0086] S: indicates the I2C START signal. The corresponding I2C bus state is that when SCL is at a high level, SDA jumps from a high level to a low level.

[0087] P: indicates the I2C STOP signal. The corresponding I2C bus state is that when SCL is at a high level, SDA jumps from a low level to a high level.

[0088] Sr: The corresponding I2C bus state is the same as S;

[0089] Sr / P: The corresponding I2C bus status is Sr or P;

[0090] ADDR: I2C address;

[0091] R / W: indicates the read / write operation indication bit. When this bit is R, it indicates that the current operation is an I2C read operation. When this bit is W, it indicates that the current operation is an I2C write operation.

[0092] R: indicates the read operation indicator bit. The corresponding I2C bus state is that SDA is high during the period when SCL is high.

[0093] W: indicates the write operation indicator bit. The corresponding I2C bus state is that SDA is low while SCL is high.

[0094] BYTE: write operation data or read operation data, usually a multi-byte sequence. The content in the brackets behind it indicates the sequence number of the byte in the sequence. Write operation data is used to send write command packets or read command packets, and read operation data or status information is read through read operation data. The smaller sequence number is sent first;

[0095] A: Indicates I2C ACK. The corresponding I2C bus state is that SDA is always low while SCL is high.

[0096] N: indicates I2C NAK. The corresponding I2C bus state is that SDA is always high while SCL is high.

[0097] DATA: Contains the bytes of read data and a sequence of I2C ACK / I2C NAK between bytes;

[0098] STATUS: Bytes containing status information and a sequence of I2C ACK / I2C NAK between bytes;

[0099] A / N: The corresponding I2C bus state is that SDA is always high or always low during the period when SCL is high.

[0100] HOLD: SCL is a continuous low level;

[0101] CRC: write command packet check code or read command packet check code;

[0102] IDLE: The corresponding I2C bus status includes the following two possibilities:

[0103] (1) Both SCL and SDA are high level;

[0104] (2) SCL and SDA may have other level states, but the combination of these level states does not result in a legal I2C operation. When IDLE is about to end, SCL and SDA are both high. DETAILED DESCRIPTION

[0105] In order to make the above and other features and advantages of the present invention more clear, the present invention is further described below in conjunction with the accompanying drawings. It should be understood that the specific embodiments given herein are for the purpose of explaining to those skilled in the art and are only exemplary and not restrictive.

[0106] The clock line (SCL) and the I2C data line (SDA) are collectively called the I2C bus. The I2C bus has become a de facto international standard. The design specifications of the I2C bus and its protocol (called the standard I2C specification) are usually based on the description in the document THE I2C-BUSSPECIFICATION VERSION 2.1JANUARY 2000.

[0107] like Figure 1 As shown, according to an embodiment of the present invention, an I2C interface system for efficient I2C transmission is provided, including an I2C interface module 200 and at least one functional module 300.

[0108] The I2C interface module 200 is connected to the I2C master controller 100 via an I2C clock line 500 (SCL) and an I2C data line 400 (SDA), and the functional module 300 is connected to the I2C interface module 200. The I2C interface module 200 can be connected to multiple functional modules 300, such as functional module 1, functional module 2, ..., functional module N. In this embodiment, the I2C interface module 200 is connected to one functional module 300 as an example for description.

[0109] The present invention does not limit the connection method between the I2C interface module 200 and the functional module 300. The I2C interface module 200 can be connected to one or more functional modules 300 through one or more transmission lines. At the same time, the present invention does not limit the positions of the I2C interface module 200 and the functional module 300. The I2C interface module 200 and the functional module 300 can be located in the same integrated circuit chip, or in different integrated circuit chips on a PCB board, or the I2C interface module 200 and the functional module 300 can also be located in different system devices.

[0110] An I2C master controller 100 can be connected to one or more I2C interface modules 200 through the same I2C bus (clock line 500 and I2C data line 400), and transmit a byte sequence carrying information through an I2C read operation or an I2C write operation. In this embodiment, an I2C master controller 100 is connected to an I2C interface module 200 through the same I2C bus (clock line 500 and I2C data line 400) as an example for description.

[0111] like Figure 2 As shown, the I2C write operation includes a write address byte and one or more write operation data bytes (BYTE(1), ..., BYTE(N), shaded). The write address byte is the first byte sent. The write address byte includes an I2C address (ADDR) and a write operation indication bit (W). According to the standard I2C specification, the write operation indication bit (W) is a low level.

[0112] In this embodiment, the write address byte and the write operation data byte are both 8 bits, wherein the write address byte includes a 7-bit I2C address (ADDR) and a 1-bit write operation indicator bit (W). The present invention does not limit the number of bits of the write address byte and the write operation data byte. In other embodiments, the write address byte and the write operation data byte can be other numbers of bits.

[0113] When the I2C master controller 100 initiates an I2C write operation, the I2C master controller 100 first drives the I2C clock line 500 and the I2C data line 400 according to the standard I2C specification to generate an I2C START signal (S), and then sends a write address byte. After receiving the write address byte, the I2C interface module 200 drives the I2C data line 400 to generate an acknowledgement bit. According to the standard I2C specification, the acknowledgement bit can be an I2C ACK (the I2C data line level is low) or an I2C NAK (the I2C data line level is high).

[0114] When the response bit of the write address byte is I2C ACK, the I2C master controller 100 can send one or more write operation data bytes, and the I2C interface module 200 drives the I2C data line 400 to generate an response bit after receiving each write operation data byte. The response bit of the write operation data byte can be I2C ACK (the I2C data line level is low) or I2C NAK (the I2C data line level is high).

[0115] According to the standard I2C specification, when sending a write address byte and one or more write operation data bytes, the I2C master controller 100 drives the I2C data line 400 to send the number of bits contained in the write address byte and the write operation data byte, and for each bit contained in the write address byte and the write operation data byte, the I2C master controller 100 drives the I2C clock line 500 to generate a clock pulse.

[0116] According to the standard I2C specification, the I2C master controller 100 also drives the I2C clock line 500 to generate a clock pulse corresponding to the response bit of the write address byte and the response bit of the write operation data byte. The I2C master controller 100 ends the current write operation by sending an I2C STOP signal (P) or an I2C START signal (S) defined in the standard I2C specification.

[0117] like Figure 3 As shown, the I2C read operation includes a read address byte and one or more read operation data bytes (BYTE(1), ..., BYTE(N), no shadow), the read address byte is the first byte sent by the I2C master controller 100, and the one or more read operation data bytes are sent by the I2C interface module 200. The read address byte includes an I2C address (ADDR) and a read operation indication bit (R). According to the standard I2C specification, the read operation indication bit (R) is a high level.

[0118] In this embodiment, the read address byte and the read operation data byte are both 8 bits, wherein the read address byte includes a 7-bit I2C address (ADDR) and a 1-bit read operation indicator bit (R). The present invention does not limit the number of bits of the read address byte and the read operation data byte. In other embodiments, the read address byte and the read operation data byte can be other numbers of bits.

[0119] When the I2C master controller 100 initiates an I2C read operation, the I2C master controller 100 first drives the I2C clock line 500 and the I2C data line 400 according to the standard I2C specification to generate an I2C START signal (S), and then sends a read address byte. After receiving the read address byte, the I2C interface module 200 drives the I2C data line 400 to generate an acknowledge bit. According to the standard I2C specification, the acknowledge bit can be an I2C ACK (the I2C data line level is low) or an I2C NAK (the I2C data line level is high).

[0120] When the response bit of the read address byte is I2C ACK, the I2C interface module 200 can return one or more read operation data bytes by driving the I2C data line 400. The I2C master controller 100 drives the I2C data line to generate an response bit after receiving each read operation data byte. The response bit of the read operation data byte can be I2C ACK (the I2C data line level is low) or I2C NAK (the I2C data line level is high).

[0121] According to the standard I2C specification, when the I2C master controller 100 sends a read address byte and the I2C interface module 20 returns one or more read operation data bytes, the I2C master controller 100 sends the number of bits contained in the read address byte by driving the I2C data line 400, and the I2C interface module 200 returns the bits contained in the read operation data byte by driving the I2C data line 400, and for each bit contained in the read address byte and the read operation data byte, the I2C master controller 100 drives the I2C clock line 500 to generate a clock pulse.

[0122] According to the standard I2C specification, the I2C master controller 100 also drives the I2C clock line 500 to generate a clock pulse corresponding to the response bit of the read address byte and the response bit of the read operation data byte. The I2C master controller 100 ends the current read operation by sending an I2C STOP signal (P) or an I2C START signal (S) defined in the standard I2C specification.

[0123] An I2C write operation or I2C read operation cycle is started by the I2C START signal (S), but there are two ways to end it. The first is to end it with the I2C STOP signal (P). The timing is as follows: Figure 2 and Figure 3 shown.

[0124] The second is to generate a new I2C START signal (S) and enter the next I2C write operation or I2C read operation. The timing is as follows: Figure 4 shown. Figure 4 The dotted line between the acknowledge bit (A / N) and the I2CSTART signal (Sr) (such lines in other figures) is because the timing diagram is too long to be described in the same row, so it is split into multiple rows to indicate that the two timing diagrams are connected.

[0125] Using any of the above-mentioned ending methods will not affect the data writing method of the present invention. For the convenience of description, the end of an I2C operation (I2C write operation or I2C read operation) is described in this embodiment with an I2CSTOP signal (P).

[0126] Working mode 1 of the data writing method.

[0127] According to an embodiment of the present invention, an I2C data writing method is provided, which uses the I2C interface system provided by the present invention to write data, including:

[0128] The I2C master controller 100 initiates an I2C write operation and sends a write command packet to the I2C interface module 200 ; after receiving the write command packet, the I2C interface module 200 pulls down the level of the I2C clock line 500 and sends the write command packet to the functional module 300 .

[0129] The functional module 300 receives the write command packet and executes the write command. When the functional module 300 completes the write command, it returns a write status packet to the I2C interface module 200 .

[0130] When the I2C interface module 200 receives the write status packet, the I2C interface module 200 stops pulling down the level of the I2C clock line 500 and returns an I2CACK or I2CNAK to the I2C master controller 100 .

[0131] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0132] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns status information of the write status packet to the I2C master controller 100 .

[0133] The write command packet of the present invention is sent through write operation data bytes (BYTE (1), ..., BYTE (N), shaded), and the write command packet includes a write command length field and a write command data field, or the write command packet only includes a write command data field.

[0134] The write command data field of the present invention includes a write command, and the write command packet is used to distinguish the read command packet.

[0135] The read command packet of the present invention is also sent through the write operation data bytes (BYTE (1), ..., BYTE (N), shaded).

[0136] For example, when the I2C master controller 100 initiates a write command packet, the I2C master controller 100 initiates an I2C write operation to send a write address byte and one or more write operation data bytes (BYTE(1), ..., BYTE(N), shaded) containing the write command packet to the I2C interface module 200. When the I2C master controller 100 initiates a read command packet, the I2C master controller 100 initiates an I2C write operation to send a write address byte and one or more write operation data bytes (BYTE(1), ..., BYTE(N), shaded) containing the read command packet to the I2C interface module 200.

[0137] The write command packet is used to implement data writing, and the read command packet is used to implement data reading. The present invention does not limit the method of reading data through the read command packet.

[0138] The I2C interface module 200 has a logic circuit of an I2C interface, and the I2C interface module 200 receives and responds to data from the I2C master controller 100. The I2C interface module 200 and the I2C master controller 100 are interconnected through an I2C bus (clock line 500 and I2C data line 400), and one I2C master controller 100 is connected to one or more I2C interface modules 200, and each I2C interface module 200 has a unique I2C address (ADDR) on the I2C bus (clock line 500 and I2C data line 400) where it is located. According to the standard I2C specification, each I2C write operation or I2C read operation except for the I2C write broadcast is only for one of the I2C addresses (ADDR), and the I2C interface module 100 using other I2C addresses does not participate in the I2C write operation or I2C read operation.

[0139] Combination Figure 5In a specific embodiment, the I2C interface module 200 has an I2C address of 0x50 with a length of 7 bits (corresponding to the write address byte 0xA0 or the binary value 1010000), and the I2C master controller 100 initiates an I2C write operation to sequentially write 7 bytes of write operation data, 0x06, 0x11, 0x21, 0x31, 0x41, 0x51, and 0x61, to the I2C interface module 200. The 7 bytes of write operation data contain a write command packet. The 0xA0 byte corresponds to the write address byte, and the upper 7 bits correspond to the I2C address (ADDR) of the I2C interface module 200. The lower 1 bit is the write operation indicator bit (W). The value of the write operation indicator bit (W) is 0, indicating that the current operation is a write operation. The value of this byte is the binary number 10100000, that is, the hexadecimal number 0xA0.

[0140] In this example, the write command packet includes a write command length field and a write command data field.

[0141] The 0x06 byte corresponds to the write command length field. In this embodiment, the write command length field is represented by 1 byte. In some embodiments, the write command packet may only include the write command data field but not the write command length field. In this case, the length of the write command packet is determined by preset conditions. In other embodiments, the write command length field may be represented by multiple bytes (an integer number of bytes) or a non-integer number of bytes.

[0142] Bytes 0x11, 0x21, 0x31, 0x41, 0x51, and 0x61 correspond to the write command data field. In this embodiment, the write command data field has a total of 6 bytes. In other embodiments, the write command data field can be other integer bytes or non-integer bytes. When the I2C interface module 200 receives the last bit of the 0x61 byte, that is, when the data received by the I2C interface module 200 reaches the write command packet length, the I2C interface module 200 receives the write command packet.

[0143] In the present invention, the data received by the I2C interface module 200 reaches the length of the write command packet, which means that the I2C interface module 200 receives all the data of the write command packet.

[0144] like Figure 5 In the illustrated embodiment, the value of the write command length field (0x06) is equal to the length of the write command data field, and the data received by the I2C interface module 200 reaches the write command packet length, indicating that the I2C interface module 200 receives all the data in the write command data field until the last byte of the write command data field, 0x61 byte.

[0145] In another embodiment of the present invention, the value of the write command length field may also be preset to be equal to the length of the write command packet (including the length occupied by the write command length field and the length of the write command data field).

[0146] The value of the write command length field can also be preset to include part or all of the following data fields: write address byte, write command length field, write command data field, write command packet check code (described below in this document), etc. The present invention does not limit the content included in the value of the write command length field. The preset definition of the content included in the value of the write command length field only needs to enable the I2C interface module 200 to receive all the data of the write command packet according to the preset definition.

[0147] In some embodiments of the present invention, the write command packet may not include a write command length field, but only include a write command data field. In this case, the length of the write command packet is determined by a preset condition.

[0148] Figure 5 In the illustrated embodiment, the I2C interface module 200 receives the last bit of 0x61 bytes, that is, the data received by the I2C interface module 200 reaches the length of the write command packet, the I2C interface module 200 receives the write command packet, the I2C interface module 200 pulls down the level of the I2C clock line 500, the I2C bus is in the HOLD state (continuous low level state), and the I2C interface module 200 sends the write command packet to the functional module 300. The functional module 300 receives the write command packet and executes the write command. When the functional module 300 completes the write command, it returns a write status packet to the I2C interface module 200.

[0149] In the present invention, when the I2C interface module 200 sends the write command packet to the functional module 300, the content in the write command packet may be modified, added or deleted, and the present invention does not limit or stipulate this.

[0150] When the I2C interface module 200 receives the write status packet, the I2C interface module 200 stops pulling down the level of the I2C clock line 500 , and returns an I2C ACK or an I2C NAK to the I2C master controller 100 .

[0151] The present invention does not limit or stipulate that after the I2C interface module 200 receives the write status packet and stops pulling down the level of the I2C clock line 500, it returns I2C ACK or I2C NAK to the I2C master controller 100. The I2C master controller 100 and the I2C interface module 200 can agree that after the I2C interface module 200 receives the write status packet and stops pulling down the level of the I2C clock line 500, it returns I2C ACK or I2C NAK to the I2C master controller 100. As an embodiment, the I2C interface module 200 may choose to stop pulling down the level of the I2C clock line 500 and return an I2C ACK to the I2C master controller 100 when the I2C interface module 200 receives a write status packet and the status information of the write status packet is success, and to stop pulling down the level of the I2C clock line 500 and return an I2C NAK to the I2C master controller 100 when the I2C interface module 200 receives a write status packet and the status information of the write status packet is failure.

[0152] In the following embodiment, the write command packet includes a write command length field and a write command data field. The length of the write command length field is still one byte, and the value of the write command length field is equal to the length of the write command data field.

[0153] According to an embodiment of the present invention, the write command packet further includes a write command packet check code. If the data received by the I2C interface module 200 reaches the write command packet length and the write command packet check code is verified to be correct, the I2C interface module 200 receives the write command packet.

[0154] like Figure 6 As shown, a one-byte write command packet check code (CRC) is added to the write command packet. The present invention does not limit the generation algorithm of the write command packet check code. In some embodiments, the length of the write command packet check code is not limited to one byte. In the following embodiments, a one-byte write command packet check code is used as an example, and is marked with the English abbreviation CRC of the cyclic redundancy check code.

[0155] The I2C master controller 100 initiates an I2C write operation. After receiving the write command length field (0x06), the I2C interface module 200 can determine that the I2C master controller 100 will subsequently write 6-byte write command data fields, namely 0x11, 0x21, 0x31, 0x41, 0x51, and 0x61, and a 1-byte write command packet check code (CRC).

[0156] After the I2C interface module 200 receives the write command length field (0x06), it counts the bytes of the received write command data field. After receiving the last byte of the write command data field, 0x61 bytes, 0x11, 0x21, 0x31, 0x41, 0x51, and 0x61, it calculates the write command packet check code (CRC). When the I2C interface module 200 receives the write command packet check code (CRC), it compares the received write command packet check code (CRC) with the calculated write command packet check code (CRC). If the two are consistent, the data received by the I2C interface module 200 reaches the write command packet length, and the write command packet check code is verified to be correct, and the I2C interface module 200 receives the write command packet.

[0157] The present invention does not limit the data on which the write command packet check code (CRC) calculation is based. For example, other data besides the write command data field can also be used to calculate the write command packet check code (CRC), including but not limited to the write address byte, the write command length field, etc.

[0158] like Figure 6 As shown, after the I2C interface module 200 receives the write command packet, the I2C interface module 200 pulls down the level of the I2C clock line 500, the I2C bus is in the HOLD state (continuous low level state), and the I2C interface module 200 sends the write command packet to the functional module 300. The functional module 300 receives the write command packet and executes the write command. When the functional module 300 completes the write command, it returns a write status packet to the I2C interface module 200. When the I2C interface module 200 receives the write status packet, the I2C interface module 200 stops pulling down the level of the I2C clock line 500, and returns an I2C ACK or an I2C NAK to the I2C master controller 100.

[0159] The subsequent I2C operation referred to in the present invention is relative to the previous I2C operation, and the I2C operation may be an I2C write operation or an I2C read operation.

[0160] For example, if Figure 7 As shown, the I2C master controller 100 initiates an I2C operation (I2C write operation) with a sequence number of m (m is a natural number), and the I2C operation with a sequence number of m+1 initiated by the I2C master controller 100 is a subsequent I2C operation (relative to the I2C operation with a sequence number of m).

[0161] like Figure 7As shown, after the I2C master controller 100 passes the I2C operation with sequence number m (I2C write operation sends a write command packet), if the I2C operation with sequence number m+1 (subsequent I2C operation) initiated by the I2C master controller 100 is an I2C write operation, after the I2C interface module 200 receives the write address byte, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100, thereby terminating the execution of the I2C operation with sequence number m+1 (subsequent I2C operation / I2C write operation).

[0162] like Figure 8 As shown, after the I2C master controller 100 initiates an I2C operation with a sequence number of m (an I2C write operation sends a write command packet), if the I2C operation with a sequence number of m+1 (a subsequent I2C operation) initiated by the I2C master controller 100 is an I2C read operation, after the I2C interface module 200 receives the read address byte, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100 and continues to return the status information (STATUS) of the write status packet, so that the I2C master controller 100 continues to execute the I2C operation with a sequence number of m+1 (a subsequent I2C operation / I2C read operation).

[0163] The I2C master controller 100 continues to execute the I2C operation (subsequent I2C operation / I2C read operation) with sequence number m+1, and reads the status information (STATUS) of the write status packet.

[0164] After the I2C master controller 100 completes the I2C operation with sequence number m+1 (subsequent I2C operation / I2C read operation), it initiates the I2C operation with sequence number m+2.

[0165] After completing the I2C operation with sequence number m+1 (subsequent I2C operation / I2C read operation), the I2C interface module 200 continues to receive the I2C operation with sequence number m+2 initiated by the I2C master controller 100 (referring to the I2C interface module 200 returning I2C ACK after receiving the read address byte or the write address byte in the I2C operation with sequence number m+2 and continuing the I2C operation with sequence number m+2), repeats the above process, and the I2C master controller 100 continuously initiates I2C operations.

[0166] According to an embodiment of the present invention, when the I2C interface module 200 receives an I2C START signal or an I2C STOP signal before the data received by the I2C interface module 200 reaches the length of the write command packet, the I2C interface module 200 ends receiving the current write command packet, and the I2C interface module 200 does not receive the write command packet.

[0167] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0168] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns status information to the I2C master controller. In this example, the I2C interface module 200 does not receive a write command packet, so the I2C interface module 200 does not send a write command packet to the functional module 300 or receive a write status packet from the functional module 300. Therefore, the status information returned by the I2C interface module 200 to the I2C master controller 100 does not come from the write status packet. The present invention does not specify the status information returned by the I2C interface module 200 to the I2C master controller 100 in this example, but in some embodiments, the status information may include but is not limited to the fact that the I2C interface module 200 did not receive a write command packet.

[0169] For example, if Figure 7 and Figure 8 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation. The I2C master controller 100 sends a write command packet through the I2C write operation. In this example, the data received by the I2C interface module 200 in the I2C write operation with sequence number m does not reach the write command packet length. Before the data received by the I2C interface module 200 reaches the write command packet length, the I2C interface module 200 receives an I2C START signal or an I2C STOP signal, and the I2C interface module 200 ends the reception of the current write command packet. The I2C interface module 200 does not receive the write command packet.

[0170] After the I2C master controller 100 initiates an I2C operation (I2C write operation) with a sequence number of m, the I2C master controller 100 initiates an I2C operation (subsequent I2C operation) with a sequence number of m+1. The process of the I2C operation (subsequent I2C operation) with a sequence number of m+1 initiated by the I2C master controller 100 is the same as the processing method in the above text, and will not be repeated here.

[0171] According to an embodiment of the present invention, when the data received by the I2C interface module 200 reaches the write command packet length, but the write command packet check code verification is incorrect, the I2C interface module 200 ends the reception of the current write command packet, and the I2C interface module 200 does not receive the write command packet.

[0172] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0173] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns status information to the I2C master controller 100. In this example, the I2C interface module 200 does not receive a write command packet, so the I2C interface module 200 does not send a write command packet to the functional module 300 or receive a write status packet from the functional module 300. Therefore, the status information returned by the I2C interface module 200 to the I2C master controller 100 does not come from the write status packet. The present invention does not specify the status information returned by the I2C interface module 200 to the I2C master controller 100 in this example, but in some embodiments, the status information may include but is not limited to the fact that the I2C interface module 200 did not receive a write command packet.

[0174] For example, if Figure 7 and Figure 8 As shown, the I2C operation with serial number m initiated by the I2C master controller 100 is an I2C write operation. The I2C master controller 100 sends a write command packet through the I2C write operation. In this example, the data received by the I2C interface module 200 in the I2C write operation with serial number m reaches the write command packet length, but the write command packet check code verification is incorrect. The I2C interface module 200 ends the reception of the current write command packet, and the I2C interface module 200 does not receive the write command packet.

[0175] After the I2C master controller 100 initiates an I2C operation (I2C write operation) with a sequence number of m, the I2C master controller 100 initiates an I2C operation (subsequent I2C operation) with a sequence number of m+1. The process of the I2C operation (subsequent I2C operation) with a sequence number of m+1 initiated by the I2C master controller 100 is the same as the processing method in the above text, and will not be repeated here.

[0176] According to an embodiment of the present invention, the I2C interface module 200 includes a timeout timer.

[0177] The I2C master controller 100 sends a write command packet through an I2C write operation. After receiving the write command packet, the I2C interface module 200 sends the write command packet to the functional module 300. The I2C interface module 200 waits for the write status packet returned by the functional module 300 and the timeout timer counts.

[0178] When the I2C interface module 200 does not receive the write status packet before the timeout, the I2C interface module 200 stops pulling down the level of the I2C clock line 500 after the timeout, and returns an I2C ACK or an I2C NAK to the I2C master controller 100 .

[0179] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0180] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns status information to the I2C master controller 100. In this example, the I2C interface module 200 does not receive the write status packet, so the status information returned by the I2C interface module 200 to the I2C master controller 100 does not come from the write status packet. The present invention does not specify the status information returned by the I2C interface module 200 to the I2C master controller 100 in this example, but in some embodiments, the status information may include but is not limited to the fact that the I2C interface module 200 did not receive the write status packet before timeout.

[0181] For example, if Fig. 9 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation. The I2C master controller 100 sends a write command packet through the I2C write operation. After receiving the write command packet (after receiving BYTE(N)), the I2C interface module 200 pulls down the level of the I2C clock line 500 at the first moment. The I2C interface module 200 waits for the write status packet returned by the functional module 300 to the I2C interface module 200 and the timeout timer counts.

[0182] When the timing times out at the second moment, the I2C interface module 200 does not receive the write status packet before the timeout. After the timeout, the I2C interface module 200 stops pulling down the I2C clock line 500 level, terminates the HOLD state (terminates the continuous low level state), and returns an I2C ACK or an I2C NAK to the I2C master controller 100.

[0183] For example, if Figure 7 and Figure 8 As shown, the I2C master controller 100 initiates an I2C operation (I2C write operation) with a sequence number of m (in this example, the I2C write operation with a sequence number of m is as shown in FIG. Fig. 9 As shown, the I2C master controller 100 initiates an I2C operation with a sequence number of m+1 (subsequent I2C operation). The process of the I2C operation with a sequence number of m+1 (subsequent I2C operation) initiated by the I2C master controller 100 is the same as the processing method above, which will not be repeated here.

[0184] Working mode 2 of the data writing method.

[0185] According to an embodiment of the present invention, an I2C data writing method is provided, which uses the I2C interface system provided by the present invention to write data, including:

[0186] The I2C master controller 100 initiates an I2C write operation and sends a write command packet to the I2C interface module 200 . After receiving the write command packet, the I2C interface module 200 sends the write command packet to the functional module 300 .

[0187] The functional module 300 receives the write command packet and executes the write command. When the functional module 300 completes the write command, it returns a write status packet to the I2C interface module 200 .

[0188] After the I2C interface module 200 receives the write command packet,

[0189] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, and the I2C interface module 200 receives the write status packet returned by the function module 300 to the I2C interface module 200 , the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0190] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, and the I2C interface module 200 receives the write status packet returned by the function module 300 to the I2C interface module 200, the I2C interface module 200 returns the status information of the write status packet to the I2C master controller 100.

[0191] like Fig.10 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation, which sends a write command packet to the I2C interface module 200. For the first N-1 write operation data bytes (BYTE(1), ..., BYTE(N-1)), after each write operation data byte is sent, the I2C interface module 200 returns I2CACK to the I2C master controller 100.

[0192] After the I2C interface module 200 receives the Nth write operation data byte (BYTE(N)) (i.e., after the I2C interface module 200 receives the complete write command packet), the I2C interface module 200 may return I2CACK or I2CNAK to the I2C master controller 100. The selection is made specifically by the agreement between the I2C master controller 100 and the I2C interface module 200. The I2C master controller 100 and the I2C interface module 200 may agree that after the Nth write operation data byte (BYTE(N)), whether I2CACK or I2CNAK indicates that the Nth write operation data byte (i.e., the complete write command packet) is successfully received. It may also be agreed that I2C NAK indicates that the Nth write operation data byte (BYTE(N)) is not successfully received (i.e., the complete write command packet is not successfully received). In the following description of the present invention, after the Nth write operation data byte (BYTE(N)), whether the I2C interface module 200 returns I2CACK to the I2C master controller 100, ACK or I2CNAK both indicate the successful receipt of the Nth write operation data byte (i.e., the complete write command packet).

[0193] After the I2C master controller 100 completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200 returns an I2C ACK or an I2C NAK to the I2C master controller 100, the I2C master controller 100 terminates the I2C operation with sequence number m (I2C write operation) and may choose to initiate an I2C operation with sequence number m+1 (subsequent I2C operation).

[0194] When the I2C operation with sequence number m+1 (subsequent I2C operation) is an I2C write operation, if the I2C interface module 200 receives the write status packet returned by the functional module 300 to the I2C interface module 200 (the corresponding write status packet during the I2C operation with sequence number m), then after the I2C main controller 100 sends the write address byte, the I2C interface module 200 returns an I2C NAK to the I2C main controller 100, and the main controller 100 terminates initiating the I2C operation m+1 (subsequent I2C operation / I2C write operation).

[0195] According to an embodiment of the present invention, when the data received by the I2C interface module 200 reaches the length of the write command packet, the I2C interface module 200 receives the write command packet. Specifically, the process of determining whether the I2C interface module 200 receives the write command packet is the same as the determination process in the working mode 1 of the data writing method, and will not be repeated here.

[0196] According to an embodiment of the present invention, the write command packet further includes a write command packet check code. When the data received by the I2C interface module 200 reaches the write command packet length, and the write command packet check code is verified to be correct, the I2C interface module 200 receives the write command packet. Specifically, the process of determining whether the I2C interface module 200 receives the write command packet is the same as the determination process in the working mode 1 of the data writing method, and will not be repeated here.

[0197] According to an embodiment of the present invention, when the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, after the I2C interface module 200 receives the write status packet returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 returns the status information of the write status packet to the I2C master controller 100.

[0198] like Fig.11 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation, which sends a write command packet to the I2C interface module 200. For the first N-1 write operation data bytes (BYTE(1), ..., BYTE(N-1)), after each write operation data byte is sent, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100.

[0199] After the I2C interface module 200 receives the Nth write operation data byte (BYTE(N)) (ie, after the I2C interface module 200 receives a complete write command packet), the I2C interface module 200 may return an I2C ACK or an I2C NAK to the I2C master controller 100 .

[0200] After the I2C master controller 100 completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200 returns an I2C ACK or an I2C NAK to the I2C master controller 100, the I2C master controller 100 terminates the I2C operation with sequence number m (I2C write operation) and may choose to initiate an I2C operation with sequence number m+1 (subsequent I2C operation).

[0201] When the I2C operation with sequence number m+1 (subsequent I2C operation) is an I2C read operation, if the I2C interface module 200 receives the write status packet (the status packet corresponding to the I2C operation process with sequence number m) returned by the functional module 300 to the I2C interface module 200, then after the I2C master controller 100 sends the read address byte, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100 and returns the status information (STATUS) of the write status packet (the status packet corresponding to the I2C operation process with sequence number m).

[0202] According to an embodiment of the present invention, when the I2C interface module 200 receives an I2C START signal or an I2C STOP signal before the data received by the I2C interface module 200 reaches the length of the write command packet, the I2C interface module 200 ends receiving the current write command packet, and the I2C interface module 200 does not receive the write command packet.

[0203] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0204] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns status information to the I2C master controller 100 .

[0205] The process after the I2C master controller 100 initiates the subsequent I2C read operation is the same as the processing method in the working mode 1 of the data writing method, and will not be repeated here.

[0206] According to an embodiment of the present invention, when the data received by the I2C interface module 200 reaches the write command packet length, but the write command packet check code verification is incorrect, the I2C interface module 200 ends the reception of the current write command packet, and the I2C interface module 200 does not receive the write command packet.

[0207] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0208] If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns status information to the I2C master controller 100 .

[0209] The process after the I2C master controller 100 initiates the subsequent I2C read operation is the same as the processing method in the working mode 1 of the data writing method, and will not be repeated here.

[0210] According to an embodiment of the present invention, the I2C interface module 200 includes a timeout timer.

[0211] The I2C master controller 100 sends a write command packet through an I2C write operation. After receiving the write command packet, the I2C interface module 200 sends the write command packet to the functional module 300. The I2C interface module 200 waits for the write status packet returned by the functional module 300 and the timeout timer counts.

[0212] When the I2C interface module 200 does not receive the write status packet before the timeout, if the subsequent I2C operation initiated by the I2C master controller 100 after the timeout is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100 .

[0213] When the I2C interface module 200 does not receive the write status packet before the timeout, if the subsequent I2C operation initiated by the I2C master controller 100 after the timeout is an I2C read operation, the I2C interface module 200 returns status information to the I2C master controller 100 .

[0214] The process after the I2C master controller 100 initiates the subsequent I2C read operation is the same as the processing method in the working mode 1 of the data writing method, and will not be repeated here.

[0215] According to an embodiment of the present invention, when the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100. If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 continues to return an I2C NAK to the I2C master controller 100. If the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, the I2C interface module 200 returns the status information of the write status packet to the I2C master controller 100, and the I2C interface module 200 continues to receive subsequent I2C operations initiated by the I2C master controller 100 after the I2C read operation.

[0216] like Fig.12 and Fig.13 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation, which sends a write command packet to the I2C interface module 200. For the first N-1 write operation data bytes (BYTE(1), ..., BYTE(N-1)), after each write operation data byte is sent, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100.

[0217] After the I2C interface module 200 receives the Nth write operation data byte (BYTE(N)) (ie, after the I2C interface module 200 receives a complete write command packet), the I2C interface module 200 may return an I2C ACK or an I2C NAK to the I2C master controller 100 .

[0218] After the I2C master controller 100 completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200 returns an I2C ACK or an I2C NAK to the I2C master controller 100, the I2C master controller 100 terminates the I2C operation with sequence number m (I2C write operation) and may choose to initiate an I2C operation with sequence number m+1 (subsequent I2C operation).

[0219] When the I2C operation with sequence number m+1 (subsequent I2C operation) is an I2C write operation, after the I2C master controller 100 sends the write address byte, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100, and the master controller 100 terminates initiating the I2C operation (subsequent I2C operation / I2C write operation) with sequence number m+1, and the I2C master controller 100 can choose to initiate the I2C operation (subsequent I2C operation) with sequence number m+2.

[0220] If the I2C operation (subsequent I2C operation) with sequence number m+2 initiated by the I2C master controller 100 is an I2C write operation, the I2C interface module 200 returns an I2C NAK to the I2C master controller 100, and the master controller 100 terminates the I2C operation (subsequent I2C operation / I2C write operation) initiated m+2, such as Fig.12 shown.

[0221] If the I2C operation (subsequent I2C operation) with sequence number m+2 initiated by the I2C master controller 100 is an I2C read operation, after the I2C interface module 200 receives the read address byte, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100, and returns the status information (STATUS) of the write status packet (the status packet corresponding to the I2C operation process with sequence number m) to the I2C master controller 100. After the I2C operation (subsequent I2C operation / I2C read operation) with sequence number m+2, the I2C interface module 200 continues to receive the I2C operation (subsequent I2C operation) with sequence number m+3 initiated by the I2C master controller 100 (referring to the I2C interface module 200 returning an I2C ACK and continuing the I2C operation with sequence number m+3 after receiving the read address byte or the write address byte in the I2C operation with sequence number m+3), such as Fig.13 shown.

[0222] According to an embodiment of the present invention, when the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, if the I2C interface module 200 does not receive the write status packet returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 pulls down the level of the I2C clock line 500.

[0223] If the I2C interface module 200 receives the write status packet returned by the function module 300 to the I2C interface module 200 , the I2C interface module 200 stops pulling down the level of the I2C clock line 500 and returns an I2C NAK to the I2C master controller 100 .

[0224] like Fig.14 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation, which sends a write command packet to the I2C interface module 200. For the first N-1 write operation data bytes (BYTE(1), ..., BYTE(N-1)), after each write operation data byte is sent, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100.

[0225] After the I2C interface module 200 receives the Nth write operation data byte (BYTE(N)) (ie, after the I2C interface module 200 receives a complete write command packet), the I2C interface module 200 may return an I2C ACK or an I2C NAK to the I2C master controller 100 .

[0226] After the I2C master controller 100 completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200 returns an I2C ACK or an I2C NAK to the I2C master controller 100, the I2C master controller 100 terminates the I2C operation with sequence number m (I2C write operation) and may choose to initiate an I2C operation with sequence number m+1 (subsequent I2C operation).

[0227] When the I2C operation (subsequent I2C operation) with sequence number m+1 initiated by the I2C master controller 100 is an I2C write operation, if the I2C interface module 200 does not receive the write status packet returned by the functional module 300 to the I2C interface module 200 (the write status packet corresponding to the I2C operation process with sequence number m), then after receiving the write address byte, the I2C interface module 200 pulls down the I2C clock line level, suspends the process of the I2C operation with sequence number m+1, and continues to wait for receiving the write status packet.

[0228] If the I2C interface module 200 receives a write status packet (a write status packet corresponding to the I2C operation process with sequence number m) returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 stops pulling down the level of the I2C clock line 500 and returns an I2C NAK to the I2C main controller 100, and the main controller 100 terminates initiating the I2C operation of m+1 (subsequent I2C operation / I2C write operation).

[0229] According to other embodiments of the present invention, when the subsequent I2C operation initiated by the I2C master controller 100 is an I2C write operation, if the I2C interface module 200 does not receive the write status packet returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 may choose to return an I2C NAK to the I2C master controller 100 instead of Fig.14 As shown, after the I2C clock line 500 level is pulled down, the device waits for receiving a write status packet.

[0230] According to an embodiment of the present invention, when the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, if the I2C interface module 200 does not receive the write status packet returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 pulls down the I2C clock line level.

[0231] If the I2C interface module 200 receives the write status packet returned by the function module 300 to the I2C interface module 200 , the I2C interface module 200 stops pulling down the I2C clock line level and returns the status information of the write status packet to the I2C master controller 100 .

[0232] like Fig.15As shown, when the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation and sends a write command packet to the I2C interface module 200, and the I2C operation with sequence number m+1 initiated by the I2C master controller 100 is an I2C read operation, if the I2C interface module 200 does not receive the write status packet returned by the functional module 300 to the I2C interface module 200 (the write status packet corresponding to the I2C operation process with sequence number m), the I2C interface module 200 pulls down the I2C clock line level, suspends the process of the I2C operation with sequence number m+1, and continues to wait for receiving the write status packet.

[0233] If the I2C interface module 200 receives a write status packet (a write status packet corresponding to the I2C operation process with sequence number m) returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 stops pulling down the I2C clock line level, returns an I2C ACK to the I2C master controller 100, and returns status information (STATUS) of the write status packet to the I2C master controller 100.

[0234] According to other embodiments of the present invention, when the subsequent I2C operation initiated by the I2C master controller 100 is an I2C read operation, if the I2C interface module 200 does not receive the write status packet returned by the functional module 300 to the I2C interface module 200, the I2C interface module 200 may choose to return an I2C NAK to the I2C master controller 100 instead of Fig.15 As shown, after the I2C clock line 500 level is pulled down, the device waits for receiving a write status packet.

[0235] Working mode three of the data writing method.

[0236] According to an embodiment of the present invention, an I2C data writing method is provided, which uses the I2C interface system provided by the present invention to write data, including:

[0237] The I2C master controller 100 initiates an I2C write operation to send a write command packet to the I2C interface module 200 , and then the I2C master controller 100 initiates a subsequent I2C read operation to read the status information.

[0238] After receiving the address byte of the subsequent I2C read operation, the I2C interface module 200 pulls down the level of the I2C clock line 500 and sends the received write command packet to the functional module 300 .

[0239] The functional module 300 receives the write command packet and executes the write command. When the functional module 300 completes the write command, it returns a write status packet to the I2C interface module 200 .

[0240] After the I2C interface module 200 receives the write status packet, the I2C interface module 200 stops pulling down the level of the I2C clock line 500 and returns the status information of the write status packet to the I2C master controller 100 .

[0241] like Fig.16 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100 is an I2C write operation, which sends a write command packet to the I2C interface module 200. For the first N-1 write operation data bytes (BYTE(1), ..., BYTE(N-1)), after each write operation data byte is sent, the I2C interface module 200 returns an I2C ACK to the I2C master controller 100.

[0242] After the I2C interface module 200 receives the Nth write operation data byte (BYTE(N)) (i.e., after the I2C interface module 200 receives the complete write command packet), the I2C interface module 200 may return an I2C ACK or an I2C NAK to the I2C master controller 100. The selection is made specifically by the agreement between the I2C master controller 100 and the I2C interface module 200. The I2C master controller 100 and the I2C interface module 200 may agree that after the Nth write operation data byte (BYTE(N)), whether I2C ACK or I2C NAK indicates that the Nth write operation data byte (i.e., the complete write command packet) has been successfully received. It may also be agreed that I2C NAK indicates that the Nth write operation data byte (BYTE(N)) has not been successfully received (i.e., the complete write command packet has not been successfully received). In the following description of the present invention, after the Nth write operation data byte (BYTE(N)), whether the I2C interface module 200 returns an I2C ACK to the I2C master controller 100, ACK or I2C NAK both indicate the successful receipt of the Nth write operation data byte (i.e., the complete write command packet).

[0243] After the I2C master controller 100 completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200 returns an I2C ACK or an I2C NAK to the I2C master controller 100, the I2C master controller 100 terminates the I2C operation with sequence number m (I2C write operation) and initiates an I2C read operation with sequence number m+1 (subsequent I2C read operation).

[0244] According to an embodiment of the present invention, when the data received by the I2C interface module 200 reaches the length of the write command packet, the I2C interface module 200 receives the write command packet. Specifically, the process of determining whether the I2C interface module 200 receives the write command packet is the same as the determination process in the working mode 1 of the data writing method, and will not be repeated here.

[0245] According to an embodiment of the present invention, the write command packet further includes a write command packet check code. When the data received by the I2C interface module 200 reaches the write command packet length, and the write command packet check code is verified to be correct, the I2C interface module 200 receives the write command packet. Specifically, the process of determining whether the I2C interface module 200 receives the write command packet is the same as the determination process in the working mode 1 of the data writing method, and will not be repeated here.

[0246] At the first moment, after receiving the address byte of the subsequent I2C read operation, the I2C interface module 200 pulls down the level of the I2C clock line 500, and sends the received write command packet to the functional module 300. The functional module 300 receives the write command packet and executes the write command. When the functional module 300 completes the write command, it returns a write status packet to the I2C interface module 200.

[0247] At the second moment, after the I2C interface module 200 receives the write status packet, the I2C interface module 200 stops pulling down the level of the I2C clock line 500 and returns the status information of the write status packet to the I2C master controller 100 .

[0248] exist Fig.16 In the illustrated embodiment, after the I2C interface module 200 stops pulling down the level of the I2C clock line 500, it first returns an I2C ACK to the I2C master controller 100 and continues to return status information (STATUS) of the write status packet.

[0249] In other embodiments, the I2C interface module 200 may choose to return an I2C ACK to the I2C master controller 100 and continue to return the status information (STATUS) of the write status packet when the status information of the write status packet is successful, and return an I2C NAK to the I2C master controller 100 when the status information of the write status packet is failed.

[0250] According to an embodiment of the present invention, before the data received by the I2C interface module 200 reaches the length of the write command packet, the I2C interface module 200 receives the I2C START signal or the I2C STOP signal of the subsequent I2C read operation, then the I2C interface module 200 ends the reception of the current write command packet, the I2C interface module 200 does not receive the write command packet, and the I2C interface module returns the status information to the I2C master controller after receiving the address byte of the subsequent I2C read operation. The present invention does not specify the status information returned by the I2C interface module 200 to the I2C master controller 100 in this example, but in some embodiments the status information may include but is not limited to the fact that the I2C interface module 200 does not receive the write command packet.

[0251] According to an embodiment of the present invention, when the data received by the I2C interface module 200 reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module 200 ends the reception of the current write command packet, the I2C interface module 200 does not receive the write command packet, and the I2C interface module returns status information to the I2C master controller after receiving the address byte of the subsequent I2C read operation. The present invention does not specify the status information returned by the I2C interface module 200 to the I2C master controller 100 in this example, but in some embodiments the status information may include but is not limited to the fact that the I2C interface module 200 does not receive the write command packet.

[0252] According to an embodiment of the present invention, the I2C interface module 200 includes a timeout timer.

[0253] The I2C master controller 100 initiates an I2C write operation to send a write command packet to the I2C interface module 200 , and then the I2C master controller 100 initiates a subsequent I2C read operation to read the status information.

[0254] After receiving the address byte of the subsequent I2C read operation, the I2C interface module 200 pulls down the level of the I2C clock line 500 and sends the received write command packet to the functional module 300. The I2C interface module 200 waits for the write status packet returned by the functional module 300 and the timeout timer counts.

[0255] When the I2C interface module 200 does not receive the write status packet before the timeout, the I2C interface module stops pulling down the level of the I2C clock line 500 after the timeout, and returns the status information to the I2C master controller. The present invention does not specify the status information returned by the I2C interface module 200 to the I2C master controller 100 in this example, but in some embodiments, the status information may include but is not limited to the fact that the I2C interface module 200 did not receive the write status packet before the timeout.

[0256] Although the embodiments of the present invention have been shown and described above, it is to be understood that the above embodiments are exemplary and are not to be construed as limitations on the present invention. Any changes, modifications, substitutions and variations of the above embodiments made by a person skilled in the art within the scope of the present invention shall fall within the scope of protection of the present invention.

Claims

1. An I2C data writing method, based on an I2C interface system, wherein the I2C interface system comprises an I2C interface module and at least one functional module, wherein the I2C interface module is connected to an I2C master controller via an I2C clock line and an I2C data line, and the functional module is connected to the I2C interface module, characterized in that: The I2C master controller initiates an I2C write operation and sends a write command packet to the I2C interface module. After receiving the write command packet, the I2C interface module pulls down the I2C clock line level and sends the write command packet to the function module. The functional module receives the write command packet and executes the write command. When the functional module completes the write command, it returns a write status packet to the I2C interface module. When the I2C interface module receives the write status packet, the I2C interface module stops pulling down the I2C clock line level and returns an I2C ACK or I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information of the write status packet to the I2C master controller.

2. The I2C data writing method according to claim 1, characterized in that: When the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives the write command packet.

3. The I2C data writing method according to claim 1, characterized in that: The write command packet also includes a write command packet verification code, When the data received by the I2C interface module reaches the length of the write command packet and the write command packet check code is verified to be correct, the I2C interface module receives the write command packet.

4. The I2C data writing method according to claim 1, characterized in that: When the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information of a write status packet to the I2C master controller. Then the I2C interface module continues to receive the I2C operation initiated by the I2C master controller.

5. The I2C data writing method according to claim 2, characterized in that: When the I2C interface module receives an I2C START signal or an I2C STOP signal before the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module ends receiving the current write command packet, and the I2C interface module does not receive the write command packet. If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

6. The I2C data writing method according to claim 3, characterized in that: When the data received by the I2C interface module reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet. If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

7. The I2C data writing method according to claim 1, characterized in that: The I2C interface module includes a timeout timer, When the I2C interface module does not receive the write status packet before the timeout, the I2C interface module stops pulling down the I2C clock line level after the timeout, and returns an I2C ACK or I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

8. An I2C data writing method, based on an I2C interface system, the I2C interface system comprising an I2C interface module and at least one functional module, the I2C interface module is connected to an I2C master controller via an I2C clock line and an I2C data line, the functional module is connected to the I2C interface module, characterized in that: The I2C master controller initiates an I2C write operation and sends a write command packet to the I2C interface module. After receiving the write command packet, the I2C interface module sends the write command packet to the function module. The functional module receives the write command packet and executes the write command. When the functional module completes the write command, it returns a write status packet to the I2C interface module. After the I2C interface module receives the write command packet, If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, and the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module returns an I2C NAK to the I2C master controller, If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, and the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module returns status information of the write status packet to the I2C master controller.

9. The I2C data writing method according to claim 8, characterized in that: When the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives the write command packet.

10. The I2C data writing method according to claim 8, characterized in that: The write command packet also includes a write command packet verification code, When the data received by the I2C interface module reaches the length of the write command packet and the write command packet check code is verified to be correct, the I2C interface module receives the write command packet.

11. The I2C data writing method according to claim 9, characterized in that: When the I2C interface module receives an I2C START signal or an I2C STOP signal before the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module ends receiving the current write command packet, and the I2C interface module does not receive the write command packet. If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

12. The I2C data writing method according to claim 10, characterized in that: When the data received by the I2C interface module reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet. If the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. If the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

13. The I2C data writing method according to claim 8, characterized in that: The I2C interface module includes a timeout timer, When the I2C interface module does not receive a write status packet before the timeout, if the subsequent I2C operation initiated by the I2C master controller after the timeout is an I2C write operation, the I2C interface module returns an I2C NAK to the I2C master controller. When the I2C interface module does not receive a write status packet before timeout, if the subsequent I2C operation initiated by the I2C master controller after timeout is an I2C read operation, the I2C interface module returns status information to the I2C master controller.

14. The I2C data writing method according to claim 8, characterized in that: When the subsequent I2C operation initiated by the I2C master controller is an I2C write operation, If the I2C interface module does not receive the write status packet returned by the functional module to the I2C interface module, the I2C interface module pulls down the I2C clock line level. If the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module stops pulling down the I2C clock line level and returns an I2C NAK to the I2C master controller.

15. The I2C data writing method according to claim 8, characterized in that: When the subsequent I2C operation initiated by the I2C master controller is an I2C read operation, If the I2C interface module does not receive the write status packet returned by the functional module to the I2C interface module, the I2C interface module pulls down the I2C clock line level. If the I2C interface module receives the write status packet returned by the functional module to the I2C interface module, the I2C interface module stops pulling down the I2C clock line level and returns status information of the write status packet to the I2C master controller.

16. An I2C data writing method, based on an I2C interface system, the I2C interface system comprising an I2C interface module and at least one functional module, the I2C interface module is connected to an I2C master controller via an I2C clock line and an I2C data line, the functional module is connected to the I2C interface module, characterized in that: The I2C master controller initiates an I2C write operation to send the write command packet to the I2C interface module, and then the I2C master controller initiates a subsequent I2C read operation to read the status information. After receiving the address byte of the subsequent I2C read operation, the I2C interface module pulls down the I2C clock line level and sends the received write command packet to the functional module. The functional module receives the write command packet and executes the write command. When the functional module completes the write command, it returns a write status packet to the I2C interface module. After the I2C interface module receives the write status packet, the I2C interface module stops pulling down the I2C clock line level and returns status information of the write status packet to the I2C master controller.

17. The I2C data writing method according to claim 16, characterized in that: When the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives the write command packet.

18. The I2C data writing method according to claim 16, characterized in that: The write command packet also includes a write command packet verification code, When the data received by the I2C interface module reaches the length of the write command packet and the write command packet check code is verified to be correct, the I2C interface module receives the write command packet.

19. The I2C data writing method according to claim 17, characterized in that: Before the data received by the I2C interface module reaches the length of the write command packet, the I2C interface module receives an I2C START signal or an I2C STOP signal of a subsequent I2C read operation, then the I2C interface module ends receiving the current write command packet, and the I2C interface module does not receive the write command packet. The I2C interface module returns status information to the I2C master controller after receiving the address byte of a subsequent I2C read operation.

20. The I2C data writing method according to claim 18, characterized in that: When the data received by the I2C interface module reaches the length of the write command packet, but the write command packet check code verification is incorrect, the I2C interface module ends the reception of the current write command packet, and the I2C interface module does not receive the write command packet. The I2C interface module returns status information to the I2C master controller after receiving the address byte of a subsequent I2C read operation.

21. The I2C data writing method according to claim 16, characterized in that: The I2C interface module includes a timeout timer, When the I2C interface module does not receive the write status packet before the timeout, the I2C interface module returns status information to the I2C master controller after receiving the address byte of the subsequent I2C read operation after the timeout.