Multi-target data writing method
By designing the interface system, the main controller sends a write command packet to the interface module, and the interface module sends it to multiple functional modules and summarizes status information, solving the problem that the existing interface protocol cannot achieve fast data transmission of multiple target devices and achieving high efficiency parallel data writing of multi-target devices.
Patent Information
- Application Number
- CN202411086909.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-11-29
AI Technical Summary
The existing I2C and SPI interface protocols cannot achieve fast and parallel multi-target device data transmission during data transmission, and a single interface can only support a single target device and cannot configure multi-target device selection.
Design an interface system, including a main controller, an interface module and multiple functional modules. The main controller sends a write command packet to the interface module, and the interface module sends it to one or more functional modules. The functional module executes commands and returns to the status Package, interface module summarizes status information and returns to the main controller to realize parallel data writing of multi-target devices.
The parallel data transmission of multi-target devices with fast data transmission speed is realized. A single I2C or SPI interface can support multi-target devices, and the selection of multi-target devices can be configured, which improves transmission efficiency and flexibility.
Smart Images

Figure CN119046201A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to an interface system and a multi-target data writing method. 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. 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-BUSSPECIFICATION VERSION 2.1JANUARY 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 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 each time the I2C master controller sends a byte, the I2C slave device must reply with an acknowledge bit. When the acknowledge bit level is low, it is I2C ACK, and when the acknowledge bit level is high, it is I2CNAK. 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] SPI (Serial Peripheral Interface) is a high-speed, full-duplex, synchronous communication bus, and only occupies four lines on the chip pins, saving the chip pins, while saving space and providing convenience for PCB layout. SPI usually has four signal lines, including SPI_CSN signal line, SPI_CK signal line, SPI_MOSI signal line and SPI_MISO signal line. The SPI master controller connects to the SPI interface module through these four signal lines. The SPI master controller is the SPI master device, and the SPI interface module is the SPI slave device. The SPI master controller drives the SPI_CSN signal line, SPI_CK signal line, and SPI_MOSI signal line. The SPI interface module receives the SPI_CSN signal line, SPI_CK signal line, and SPI_MOSI signal line. The SPI interface module drives the SPI_MISO signal line, and the SPI master controller receives the SPI_MISO signal line. The SPI interface module receives and samples the data driven by the SPI master controller on the SPI_MOSI signal line at the rising or falling edge of the SPI_CK signal line. The SPI master controller receives and samples the data driven by the SPI interface module on the SPI_MISO signal line at the rising or falling edge of the SPI_CK signal line. In the SPI protocol, the SPI master controller drives the SPI_CK signal line, and the SPI master controller generates a clock edge on the SPI_CK signal line. The SPI master controller and the SPI interface module sample the data on the SPI_MISO signal line and the SPI_MOSI signal line at the rising or falling edge of the clock on the SPI_CK signal line, thereby realizing bidirectional data transmission between the SPI master controller and the SPI interface module. The SPI_CSN signal line is a selection signal. In the SPI protocol, data transmission is performed only when the SPI_CSN signal line is low. One SPI master controller can be connected to multiple SPI interface modules, that is, one SPI master device can be connected to multiple SPI slave devices, wherein the SPI master controller and multiple SPI interface modules share the SPI_CK signal line, the SPI_MOSI signal line and the SPI_MISO signal line, but each SPI interface module has an independent SPI_CSN signal line input, when the SPI_CSN signal line of one SPI interface module is high, this SPI interface module does not drive the SPI_MISO signal line (the driver output of this SPI interface module connected to the SPI_MISO signal line is in Hi-Z state), and one SPI interface module drives the SPI_MISO signal line only when its SPI_CSN signal line is low. When one SPI master controller is connected to multiple SPI interface modules, at any time, only one SPI interface module has its SPI_CSN signal line low, thereby avoiding conflicts caused by multiple SPI interface modules driving the SPI_MISO signal line at the same time.
[0007] When an SPI master controller is only connected to one SPI interface module, this SPI interface module can drive the SPI_MISO signal line at any time without causing conflict. In this case, there may be no SPI_CSN signal line between the SPI master controller and the SPI interface module, that is, when an SPI master controller is only connected to one SPI interface module, the SPI master controller and the SPI interface module may be connected only through the SPI_CK signal line, the SPI_MOSI signal line and the SPI_MISO signal line.
[0008] When data is transmitted over a long distance, it is generally based on the mode of sending a command packet and then receiving a feedback packet. The feedback packet contains the status information of the execution command. When it is a read command, the feedback packet can also contain read data. In the existing SPI protocol, the data is transmitted bidirectionally between the SPI master controller and the SPI interface module by sampling the data on the SPI_MISO signal line and the SPI_MOSI signal line at the rising or falling edge of the clock on the SPI_CK signal line. However, this data transmission can be considered as a data stream transmission and is not suitable for data transmission over a long distance.
[0009] In the prior art, whether it is the existing I2C protocol or the SPI protocol, an I2C interface or SPI interface generally only supports data transmission to a single target device at a single time. Although I2C has the ability to broadcast, the broadcast is for all devices connected to the I2C bus, and the target device cannot be selected. At present, the market needs a method with fast data transmission speed, a single I2C interface or a single SPI interface can perform parallel data transmission to multiple target devices, and the selection of multiple target devices can be configured. Summary of the invention
[0010] The present invention proposes a method for parallel data transmission of multiple target devices with a fast data transmission speed and a single I2C interface or a single SPI interface, and the selection of multiple target devices can be configured. One object of the present invention is to provide a multi-target data writing method, based on an interface system, the interface system includes a main controller, an interface module, and multiple functional modules, the main controller is connected to the interface module, and the interface module is connected to the multiple functional modules, characterized in that
[0011] The main controller sends a write command packet to the interface module, and when the interface module receives the write command packet, the interface module sends the write command packet to one or more functional modules.
[0012] The function module that receives the write command packet executes one or more write commands contained in the write command packet and returns a write status packet to the interface module, including:
[0013] When the execution result of each write command contained in the write command packet is successful, the function module returns a write status packet with successful status information to the interface module.
[0014] When the execution result of at least one of the write commands included in the write command packet is failed, the function module returns a write status packet with status information indicating failure to the interface module.
[0015] The interface module receives a write status packet from each functional module that sends a write command packet, and returns status information of the write status packet to the main controller.
[0016] Preferably, the main controller is an I2C main controller, and the interface module is an I2C interface module.
[0017] The I2C master controller is connected to the I2C interface module via an I2C clock line and an I2C data line. 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 one or more functional modules.
[0018] The function module that receives the write command packet returns the write status packet to the I2C interface module. The I2C interface module receives the write status packet from each function module that sends the write command packet, and returns the status information of the write status packet to the I2C master controller.
[0019] Further, when the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of each write status packet is successful, the I2C interface module stops pulling down the I2C clock line level and returns an I2C ACK to the I2C master controller.
[0020] When the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of at least one write status packet is failure, the I2C interface module stops pulling down the I2C clock line level and returns an I2C NAK to the I2C master controller.
[0021] Further, when the I2C interface module receives the write status packet from each functional module that sends the write command 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.
[0022] 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.
[0023] Preferably, the main controller is an I2C main controller, and the interface module is an I2C interface module.
[0024] The I2C master controller is connected to the I2C interface module via an I2C clock line and an I2C data line, the I2C master controller initiates an I2C write operation to send the write command packet to the I2C interface module, and the I2C interface module sends the write command packet to one or more functional modules after receiving the write command packet.
[0025] The function module that receives the write command packet returns the write status packet to the I2C interface module.
[0026] After the I2C interface module receives the write command packet,
[0027] 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 from each functional module that sends a write command packet, the I2C interface module returns status information of the write status packet to the I2C master controller.
[0028] Further, the subsequent I2C operation initiated by the I2C master controller is an I2C write operation.
[0029] If the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of each write status packet is successful, the I2C interface module receives a subsequent I2C write operation initiated by the I2C master controller,
[0030] If the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of at least one write status packet is failure, the I2C interface module returns an I2C NAK to the I2C master controller.
[0031] Preferably, the main controller is an SPI main controller, the interface module is an SPI interface module, and the SPI main controller is connected to the SPI interface module via an SPI_CK signal line, an SPI_MOSI signal line, and an SPI_MISO signal line.
[0032] The SPI master controller generates a clock edge on the SPI_CK signal line, sends the write command packet to the SPI interface module through the SPI_MOSI signal line, the write command packet starts with a first identifier, and the SPI interface module sends the write command packet to one or more functional modules after receiving the write command packet from SPI_MOSI.
[0033] The function module receiving the write command packet returns the write status packet to the SPI interface module, the SPI interface module receives the write status packet from each function module that sends the write command packet, and returns the status information of the write status packet to the SPI master controller, including:
[0034] After the SPI interface module receives a write status packet from each functional module that sends a write command packet, when the SPI master controller generates a clock edge on SPI_CK, the SPI interface module sends a write feedback packet to the SPI master controller through the SPI_MISO signal line, wherein the write feedback packet starts with a second identifier and includes status information included in the write status packet.
[0035] Furthermore, the SPI master controller generates a clock edge on the SPI_CK signal line, reads the write feedback packet through the SPI_MISO signal line,
[0036] When the SPI interface module does not receive the write status packet from each functional module that sends a write command packet, the SPI interface module sends data that cannot be identified as the write feedback packet to the SPI master controller through the SPI_MISO signal line.
[0037] Furthermore, the SPI master controller generates a clock edge on the SPI_CK signal line, and sends the write command packet to the SPI interface module via the SPI_MOSI signal line.
[0038] Then the SPI master controller generates a clock edge on the SPI_CK signal line, reads the write feedback packet through the SPI_MISO signal line, and after the SPI interface module sends the write feedback packet through the SPI_MISO signal line, it can continue to receive subsequent command packets.
[0039] Furthermore, the write feedback packet is divided into a write success feedback packet and a write failure feedback packet.
[0040] The SPI master controller generates a clock edge on the SPI_CK signal line and reads the write feedback packet through the SPI_MISO signal line.
[0041] When the SPI interface module receives the write status packet from each functional module that sends the write command packet and the status information contained in each write status packet is successful, the SPI interface module sends the write success feedback packet through the SPI_MISO signal line, and the write success feedback packet starts with the third identifier.
[0042] When the SPI interface module receives the write status packet from each functional module that sends the write command packet and the status information contained in at least one write status packet is failure, the SPI interface module sends the write failure feedback packet through the SPI_MISO signal line, and the write failure feedback packet starts with a fourth identifier.
[0043] Preferably, the functional module receiving the write command packet is connected to a remote I2C slave device. After receiving the write command packet from the interface module, the functional module receiving the write command packet executes one or more write commands contained in the write command packet. The method for executing each write command is:
[0044] The function module sends I2C START to the remote I2C slave device, then the function module sends the remote I2C address byte to the remote I2C slave device, and then the function module sends a write command to the remote I2C slave device.
[0045] For each byte sent by the function module to the remote I2C slave device, the function module receives an I2C acknowledge bit sent by the remote I2C slave device and determines the execution result of the write command.
[0046] Furthermore, the functional module that receives the write command packet includes a remote I2C address register, and the I2C address included in the remote I2C address byte sent by the functional module that receives the write command packet to the remote I2C slave device is the remote I2C address stored in the remote I2C address register.
[0047] Furthermore, the write command packet includes a remote I2C address, and the I2C address included in the remote I2C address byte sent by the functional module that receives the write command packet to the remote I2C slave device is the remote I2C address included in the write command packet.
[0048] Furthermore, the functional module that receives the write command packet includes a remote I2C address register, and the functional module that receives the write command packet also includes a remote I2C address selection module. The I2C address included in the remote I2C address byte sent by the functional module that receives the write command packet to the remote I2C slave device is derived from the remote I2C address stored in the remote I2C address register or from the remote I2C address included in the write command packet according to the instruction of the remote I2C address selection module.
[0049] Another object of the present invention is to provide a multi-target data writing method, based on an interface system, the interface system includes an I2C main controller, an I2C interface module, and multiple functional modules, the I2C main controller is connected to the I2C interface module, and the I2C interface module is connected to the multiple functional modules, characterized in that:
[0050] The I2C master controller initiates an I2C write operation to send a 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.
[0051] 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 one or more functional modules.
[0052] The functional module that receives the write command packet executes one or more write commands contained in the write command packet and returns a write status packet to the I2C interface module, including:
[0053] When the execution result of each write command contained in the write command packet is successful, the functional module returns a write status packet with successful status information to the I2C interface module.
[0054] When at least one of the write commands included in the write command packet has an execution result of failure, the functional module returns a write status packet with status information of failure to the I2C interface module.
[0055] After the I2C interface module receives the write status packet from each functional module that sends the write command packet, the I2C interface module stops pulling down the I2C clock line level and returns the status information of the write status packet to the I2C master controller.
[0056] The invention provides a multi-target data writing method with fast data transmission speed. A single I2C interface or a single SPI interface can perform parallel data transmission on multiple target devices, and the selection of the multiple target devices can be configured. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] 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.
[0058] Figure 1 The structure block diagram of an interface system of the present invention is schematically shown.
[0059] Figure 2 A schematic diagram of the data structure of a write command packet of the present invention is shown.
[0060] Figure 3 The structure block diagram shows that the main controller of an interface system of the present invention is an I2C main controller and the interface module is an I2C interface module.
[0061] Figure 4A timing diagram of an I2C write operation of the present invention is shown.
[0062] Figure 5 FIG. 1 shows a timing diagram of an I2C read operation of the present invention.
[0063] Figure 6 The timing diagram of the I2C continuous read and write operation of the present invention is shown.
[0064] Figure 7 The timing diagram of the present invention initiating an I2C write operation and sending a write command packet (or a read command packet) is shown.
[0065] Figure 8 The following diagram shows a timing diagram of initiating an I2C write operation and sending a write command packet, and the status information of the write status packet is a success, and a timing diagram of the status information of the write status packet is a failure in one embodiment of the present invention.
[0066] Fig. 9 A timing diagram showing an embodiment of the present invention in which an I2C write operation is initiated to send a write command packet and the subsequent I2C operation is an I2C read operation.
[0067] Fig.10 A timing diagram showing another embodiment of the present invention in which an I2C write operation is initiated to send a write command packet and the subsequent I2C operation is an I2C read operation.
[0068] Fig.11 A timing diagram showing another embodiment of the present invention in which an I2C write operation is initiated to send a write command packet and the status information of the write status packet is successful.
[0069] Fig.12 A timing diagram showing another embodiment of the present invention in which an I2C write operation is initiated to send a write command packet and the status information of the write status packet is failure.
[0070] Fig.13 The structure block diagram shows that the main controller of an interface system of the present invention is an SPI main controller and the interface module is an SPI interface module.
[0071] Fig.14 The data structure diagram of the write command packet is shown when the main controller of the present invention is an SPI main controller and the interface module is an SPI interface module.
[0072] Fig.15 A timing diagram of a first embodiment of SPI data writing of the present invention is shown.
[0073] Fig.16 A timing diagram of a second embodiment of SPI data writing according to the present invention is shown.
[0074] Fig.17 A timing diagram showing a third embodiment of the SPI data writing of the present invention
[0075] Fig.18 A timing diagram of a fourth embodiment of SPI data writing according to the present invention is shown.
[0076] Fig.19 A timing diagram of a fifth embodiment of SPI data writing according to the present invention is shown.
[0077] Fig. 20 The structure block diagram schematically shows a functional module of an interface system of the present invention connected to a remote I2C slave device.
[0078] Fig.21 The schematic diagram shows a write status packet in which the function module of the present invention returns status information of success to the interface module.
[0079] Fig. 22 It shows that in one embodiment of the present invention, the function module returns a write status packet with status information of failure to the interface module.
[0080] Fig.23 It shows that in another embodiment of the present invention, the function module returns a write status packet with status information indicating failure to the interface module.
[0081] The meanings of the text symbols in the above drawings are as follows:
[0082] 100: main controller; 100a: I2C main controller; 100b: SPI main controller;
[0083] 200: interface module; 200a: I2C interface module; 200b: SPI interface module;
[0084] SDA: I2C data line; SCL: I2C clock line;
[0085] 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.
[0086] 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.
[0087] Sr: The corresponding I2C bus state is the same as S;
[0088] Sr / P: The corresponding I2C bus status is Sr or P;
[0089] ADDR: I2C address;
[0090] 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.
[0091] R: indicates the read operation indicator bit. The corresponding I2C bus state is that SDA is high during the period when SCL is high.
[0092] W: indicates the write operation indicator bit. The corresponding I2C bus state is that SDA is low while SCL is high.
[0093] 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;
[0094] A: Indicates I2C ACK. The corresponding I2C bus state is that SDA is always low while SCL is high.
[0095] N: indicates I2C NAK. The corresponding I2C bus state is that SDA is always high while SCL is high.
[0096] STATUS: Bytes containing status information and a sequence of I2C ACK / I2C NAK between bytes;
[0097] A / N: The corresponding I2C bus state is that SDA is always high or always low during the period when SCL is high.
[0098] HOLD: SCL is a continuous low level;
[0099] IDLE: The corresponding I2C bus status includes the following two possibilities:
[0100] (1) Both SCL and SDA are high level;
[0101] (2) SCL and SDA may have other level states, but the combination of these level states does not indicate a legal I2C operation. When IDLE is about to end, SCL and SDA are both high levels.
[0102] SPI_CK: SPI_CK signal line; SPI_MOSI: SPI_MOSI signal line; SPI_MISO: SPI_MISO signal line; SPI_CSN: SPI_CSN signal line. DETAILED DESCRIPTION
[0103] 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.
[0104] like Figure 1 As shown, according to an embodiment of the present invention, an interface system is provided, characterized in that the interface system includes a main controller 100, an interface module 200, and multiple functional modules 300. The main controller 100 is connected to the interface module 200, and the interface module 200 is connected to the multiple functional modules 300, and the serial numbers of the functional modules 300 are represented by 1 to N.
[0105] According to an embodiment of the present invention, a multi-target data writing method is provided, comprising:
[0106] The main controller 100 sends a write command packet to the interface module 200 . After receiving the write command packet, the interface module 200 sends the write command packet to one or more functional modules 300 .
[0107] like Figure 2 As shown, the write command packet of the present invention includes one or more write commands, and an exemplary write command packet includes write command 1, write command 2, ..., write command N.
[0108] The function module 300 that receives the write command packet executes one or more write commands contained in the write command packet and returns a write status packet to the interface module 200, including:
[0109] When the execution result of each write command included in the write command packet is successful, the function module 300 returns a write status packet containing status information indicating success to the interface module 200 .
[0110] When the execution result of at least one write command in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the interface module 200 .
[0111] The interface module 200 receives a write status packet from each of the function modules 300 that transmits a write command packet, and returns status information of the write status packet to the main controller 100 .
[0112] In one embodiment, the functional module 300 that receives the write command packet receives the write command packet and executes one or more write commands contained in the write command packet. When the execution result of a write command is failure, the functional module 300 stops executing subsequent write commands, and the functional module 300 returns a write status packet with status information of failure to the interface module 200.
[0113] When the interface module 200 receives the write command packet, it sends the write command packet to one or more functional modules 300. The one or more target functional modules 300 to which the interface module 200 sends the write command packet are configurable. In one embodiment, the main controller 100 may send the target functional module configuration information before sending the write command packet. The interface module 200 sends the write command packet to the one or more target functional modules 300 indicated by the target functional module configuration information according to the target functional module configuration information. In another embodiment, the main controller 100 may also include the target functional module configuration information in the write command packet and send it to the interface module 200. After receiving the write command packet, the interface module 200 sends the write command packet to the one or more target functional modules 300 indicated by the target functional module configuration information according to the target functional module configuration information.
[0114] The configuration of the target function module can be dynamic, that is, the target function module configuration information can be selected to be modified before sending the write command packet. When the target function module configuration information is included in the write command packet, the target function module configuration information in different write command packets can be different. The configuration of the target function module can also be static, that is, the target function module configuration information can be preset and not modified during system operation. The present invention does not limit the configuration means or method of the target function module, and the use of any configuration means or method is within the protection scope of the present invention. The present invention also does not limit whether the configuration of the target function module is dynamic or static.
[0115] In the present invention, the number of target functional modules indicated by the target functional module configuration information may be equal to or less than the number of functional modules 300 connected to the interface module 200, that is, the target functional modules indicated by the target functional module configuration information may be all functional modules 300 connected to the interface module 200, or may be a subset of all functional modules 300 connected to the interface module 200.
[0116] like Figure 3 As shown, in one embodiment, the main controller 100 is an I2C main controller 100a, and the interface module 200 is an I2C interface module 200a.
[0117] The I2C master controller 100a is connected to the I2C interface module 200a via the I2C clock line (SCL) and the I2C data line (SDA). The I2C master controller 100a initiates an I2C write operation and sends a write command packet to the I2C interface module 200a. After receiving the write command packet, the I2C interface module 200a pulls down the I2C clock line (SCL) level and sends the write command packet to one or more functional modules 300.
[0118] The function module 300 receiving the write command packet executes one or more write commands contained in the write command packet, and the function module 300 receiving the write command packet returns the write status packet to the I2C interface module 200a, and the I2C interface module 200a receives the write status packet from each function module 300 that sends the write command packet, and returns the status information of the write status packet to the I2C main controller 100a, including:
[0119] When the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of each write status packet is success, the I2C interface module 200a stops pulling down the I2C clock line (SCL) level and returns an I2C ACK to the I2C master controller 100a.
[0120] When the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of at least one write status packet is failure, the I2C interface module 200a stops pulling down the I2C clock line (SCL) level and returns an I2C NAK to the I2C master controller 100a.
[0121] like Figure 4 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.
[0122] 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.
[0123] When the I2C master controller 100a initiates an I2C write operation, the I2C master controller 100a first drives the I2C clock line (SCL) and the I2C data line (SDA) according to the standard I2C specification, generates an I2C START signal (S), and then sends a write address byte. After receiving the write address byte, the I2C interface module 200a drives the I2C data line (SDA) and generates 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).
[0124] When the response bit of the write address byte is I2C ACK, the I2C master controller 100a can send one or more write operation data bytes. The I2C interface module 200a drives the I2C data line (SDA) to generate an response bit after receiving each write operation data byte. The response bit of the write operation data byte can be I2CACK (the I2C data line level is low) or I2C NAK (the I2C data line level is high).
[0125] According to the standard I2C specification, when sending a write address byte and one or more write operation data bytes, the I2C master controller 100a sends the number of bits contained in the write address byte and the write operation data byte by driving the I2C data line (SDA), and for each bit contained in the write address byte and the write operation data byte, the I2C master controller 100a drives the I2C clock line (SCL) to generate a clock pulse.
[0126] According to the standard I2C specification, the I2C master controller 100a also drives the I2C clock line (SCL) 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 100a ends the current write operation by sending an I2C STOP signal (P) or an I2C START signal (S) defined by the standard I2C specification.
[0127] like Figure 5 As shown, the I2C read operation includes a read address byte and one or more read operation data bytes (BYTE(1), ..., BYTE(N), no shading). The read address byte is the first byte sent by the I2C master controller 100a, and one or more read operation data bytes are sent by the I2C interface module 200a. 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.
[0128] 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.
[0129] When the I2C master controller 100a initiates an I2C read operation, the I2C master controller 100a first drives the I2C clock line and the I2C data line 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 200a drives the I2C data line to generate an acknowledge bit. According to the standard I2C specification, the acknowledge bit can be I2CACK (the I2C data line level is low) or I2C NAK (the I2C data line level is high).
[0130] When the response bit of the read address byte is I2C ACK, the I2C interface module 200a can return one or more read operation data bytes by driving the I2C data line. The I2C master controller 100a 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 I2CNAK (the I2C data line level is high).
[0131] According to the standard I2C specification, when the I2C master controller 100a sends a read address byte and the I2C interface module 200a returns one or more read operation data bytes, the I2C master controller 100a sends the number of bits contained in the read address byte by driving the I2C data line, and the I2C interface module 200a returns the bits contained in the read operation data byte by driving the I2C data line, and for each bit contained in the read address byte and the read operation data byte, the I2C master controller 100a drives the I2C clock line to generate a clock pulse.
[0132] According to the standard I2C specification, the I2C master controller 100a also drives the I2C clock line 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 100a ends the current read operation by sending an I2C STOP signal (P) or an I2C START signal (S) defined in the standard I2C specification.
[0133] 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 shown in Figure 4 and Figure 5 shown.
[0134] 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 6 shown. Figure 6The dashed line between the acknowledge bit (A / N) and the I2C START signal (Sr) (such lines in other figures) is because the timing diagram is too long to be described in one row, so it is split into multiple rows to indicate that the two timing diagrams are connected.
[0135] Using any of the above-mentioned ending methods will not affect the multi-target 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 I2C STOP signal (P).
[0136] The write command packet of the present invention is sent through the write operation data bytes (BYTE (1), ..., BYTE (N), shaded), such as Figure 2 As shown, four write command packet embodiments are given:
[0137] The write command packet may only include write command 1, write command 2, ..., write command N.
[0138] The write command packet may also include a write command packet length field and write command 1, write command 2, ..., write command N.
[0139] The write command packet may also include a remote I2C address and a write command 1, a write command 2, ..., a write command N.
[0140] The write command packet may also include a write command packet length field, a remote I2C address, and a write command 1, a write command 2, ..., a write command N.
[0141] The write command packet can also contain the target function module configuration information (not in Figure 2 ) is used to indicate one or more target functional modules 300.
[0142] It should be noted that the present invention does not limit the format of the write command packet, that is, the format of the write command packet in the present invention is not limited to Figure 2 In the four write command packet embodiments shown, the I2C master controller 100a and the I2C interface module 200a may agree on other write command packet formats.
[0143] The write command packet of the present invention is used to distinguish the read command packet. 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.
[0144] For example, when the I2C master controller 100a initiates a write command packet, the I2C master controller 100a 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 200a.
[0145] The I2C interface module 200a has a logic circuit of the I2C interface, and the I2C interface module 200a receives and responds to data from the I2C main controller 100a. The I2C interface module 200a is interconnected with the I2C main controller 100a through the I2C bus (I2C clock line and I2C data line), and one I2C main controller 100a is connected to one or more I2C interface modules 200a, and each I2C interface module 200a has a unique I2C address (ADDR) on the I2C bus (I2C clock line and I2C data line) where it is located. According to the standard I2C specification, each I2C write operation or I2C read operation except the I2C write broadcast is only for one of the I2C addresses (ADDR), and the I2C interface module 200a using other I2C addresses does not participate in the I2C write operation or I2C read operation.
[0146] like Figure 7 As shown, in a specific embodiment, the I2C interface module 200a 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 100a initiates an I2C write operation to sequentially write 0x06, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, a total of 7 bytes of write operation data to the I2C interface module 200a, and the 7 bytes of write operation data include 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 200a, and 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, and the value of the byte is the binary number 10100000, that is, the hexadecimal number 0xA0.
[0147] In this example, the format of the write command packet can be as follows: Figure 2 The four write command packet embodiments shown may also be other write command packet formats agreed upon between the I2C master controller 100a and the I2C interface module 200a.
[0148] In the present invention, the I2C interface module 200a receiving the write command packet means that the write operation data received by the I2C interface module 200a includes a complete write command packet. Figure 7 In the illustrated embodiment, the write operation data of 7 bytes in length, 0x06, 0x11, 0x21, 0x31, 0x41, 0x51, and 0x61, comprises a complete write command packet.
[0149] The I2C interface module 200a receives the last bit of the 0x61 byte, and the I2C interface module 200a receives the write command packet.
[0150] like Figure 2 As shown, the write command packet may include a write command packet length field. The I2C interface module 200a may determine whether the received write operation data includes a complete write command packet based on the write command packet length field (or part of the write command packet length field) according to the agreement between the I2C main controller 100a and the I2C main controller 100a. Figure 2 As shown, the write command packet may not include the write command packet length field. In this case, the I2C interface module 200a can determine whether the received write operation data includes a complete write command packet based on the agreement between it and the I2C main controller 100a (this agreement is not based on the write command packet length field).
[0151] Figure 7 In the illustrated embodiment, the I2C interface module 200a receives the last bit of the 0x61 byte, the I2C interface module 200a receives the write command packet, and then the I2C interface module 200a pulls down the I2C clock line level, the I2C bus is in the HOLD state (continuous low level state), and the I2C interface module 200a sends the write command packet to one or more functional modules 300. The functional module 300 that receives the write command packet receives the write command packet and executes one or more write commands contained in the write command packet, namely, write command 1, write command 2, ..., write command N, and then returns a write status packet to the I2C interface module 200a, including:
[0152] When the execution result of each write command included in the write command packet is successful, the function module 300 returns a write status packet with status information of success to the I2C interface module 200a;
[0153] When the execution result of at least one write command in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the I2C interface module 200a.
[0154] In the present invention, when the I2C interface module 200a 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.
[0155] According to an embodiment of the present invention, when the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of each write status packet is successful, the I2C interface module 200a stops pulling down the I2C clock line level and returns I2CACK to the I2C master controller 100a.
[0156] When the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of at least one write status packet is failure, the I2C interface module 200a stops pulling down the I2C clock line level and returns an I2C NAK to the I2C master controller 100a.
[0157] 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.
[0158] like Figure 8 As shown, examples are given to describe the situation when the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of each write status packet is success, and the situation when the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of at least one write status packet is failure.
[0159] The I2C master controller 100a 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 100a is a subsequent I2C operation (relative to the I2C operation with a sequence number of m).
[0160] Figure 8 In one embodiment shown, the I2C master controller 100a sends a write command packet through an I2C write operation with a sequence number of m, and the I2C interface module 200a pulls down the I2C clock line level after receiving the write command packet (after receiving BYTE (N)).
[0161] At the first moment, the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of each write status packet is success. The I2C interface module 200a stops pulling down the I2C clock line level and terminates the HOLD state (terminates the continuous low level state).
[0162] At moment ②, the I2C interface module 200a returns an I2C ACK to the I2C master controller 100a, and the I2C master controller 100a terminates the I2C operation with sequence number m (I2C write operation) and initiates the I2C operation with sequence number m+1 (subsequent I2C operation), and the subsequent I2C operation is an I2C write operation or an I2C read operation.
[0163] After the I2C interface module 200a returns I2C ACK in the I2C operation with sequence number m, it continues to receive the subsequent I2C operation initiated by the I2C master controller 100a (referring to returning I2C ACK after receiving the read address byte or the write address byte in the I2C operation with sequence number m+1 and continuing the I2C operation with sequence number m+1). If the subsequent I2C operation is an I2C write operation, the I2C interface module 200a returns I2C ACK after receiving the write address byte and continues to receive the write operation byte. If the subsequent I2C operation is an I2C read operation, the I2C interface module 200a returns I2C ACK after receiving the read address byte and continues to return the status information (STATUS) of the write status packet (in this example, the part of the subsequent I2C operation after the read address byte or the write address byte is not in the Figure 8 (displayed in the figure).
[0164] Figure 8 In another embodiment shown, the I2C master controller 100a sends a write command packet through an I2C write operation with a sequence number of m, and the I2C interface module 200a pulls down the I2C clock line level after receiving the write command packet (after receiving BYTE (N)).
[0165] At the first moment, the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of at least one write status packet is failure. The I2C interface module 200a stops pulling down the I2C clock line level and terminates the HOLD state (terminates the continuous low level state).
[0166] At time ②, the I2C interface module 200a returns an I2C NAK to the I2C master controller 100a, and the I2C master controller 100a terminates the I2C operation (I2C write operation) with sequence number m.
[0167] After the I2C interface module 200a returns I2C NAK in the I2C operation with sequence number m, if the I2C master controller 100a initiates a subsequent I2C operation and the subsequent I2C operation is an I2C write operation, after the I2C interface module 200a receives the write address byte, the I2C interface module 200a returns I2C NAK to the I2C master controller 100a, so that the subsequent I2C operation (I2C write operation) is terminated. After the I2C interface module 200a returns an I2C NAK in the I2C operation with sequence number m, if the I2C master controller 100a initiates a subsequent I2C operation and the subsequent I2C operation is an I2C read operation, after the I2C interface module 200a receives the read address byte, the I2C interface module 200a returns an I2C ACK to the I2C master controller 100a and continues to return the status information (STATUS) of the write status packet. After completing the subsequent I2C operation (I2C read operation), the I2C interface module 200a can continue to receive subsequent I2C operations initiated by the I2C master controller 100a (the subsequent I2C operation part in this example is not included in the I2C read operation). Figure 8 (displayed in the figure).
[0168] In the present invention, the status information (STATUS) may be the success or failure information contained in the write status packet, or may include other information contained in the write status packet. In one embodiment, the status information (STATUS) may include the success or failure information contained in each write status packet received by the I2C interface module 200a. After receiving the status information, the I2C main controller 100a may learn the execution status of each functional module 300 receiving the write command packet on the write command packet according to the status information, and then perform subsequent processing according to the execution status. Figure 8 In the illustrated embodiment, when the I2C interface module 200a receives a write status packet from each functional module 300 to which the write command packet is sent, the I2C interface module 200a stops pulling down the I2C clock line level, and returns an I2C ACK (when the status information of each write status packet is success) or an I2CNAK (when the status information of at least one write status packet is failure) to the I2C master controller 100a. If the I2C master controller 100a initiates a subsequent I2C operation and the subsequent I2C operation is an I2C read operation, after the I2C interface module 200a receives the read address byte, the I2C interface module 200a returns an I2C ACK to the I2C master controller 100a and continues to return the status information (STATUS) of the write status packet.
[0169] like Fig. 9In the illustrated embodiment, the I2C master controller 100a sends a write command packet through an I2C write operation with a sequence number of m. After receiving the write command packet (after receiving BYTE (N)), the I2C interface module 200a pulls down the I2C clock line level. When the I2C interface module 200a receives a write status packet from each functional module 300 to which it sends a write command packet, it stops pulling down the I2C clock line level and returns an I2C ACK or I2C NAK to the I2C master controller 100a. In this example, the I2C master controller 100a and the I2C interface module 200a can agree on the specific meaning of I2C ACK or I2C NAK. After the I2C interface module 200a stops pulling down the I2C clock line level and returns an I2C ACK or I2C NAK to the I2C master controller 100a, if the I2C master controller 100a initiates a subsequent I2C operation and the subsequent I2C operation is an I2C write operation, after the I2C interface module 200a receives the write address byte, the I2C interface module 200a returns an I2C NAK to the I2C master controller 100a, thereby terminating the subsequent I2C operation (I2C write operation). If the I2C master controller 100a initiates a subsequent I2C operation and the subsequent I2C operation is an I2C read operation, after the I2C interface module 200a receives the read address byte, the I2C interface module 200a returns an I2C NAK to the I2C master controller 100a. ACK and continue to return the status information (STATUS) of the write status packet. After completing the subsequent I2C operation (I2C read operation), the I2C interface module 200a can continue to receive the subsequent I2C operation initiated by the I2C master controller 100a (in this example, the subsequent I2C operation is the I2C write operation part not in Fig. 9 (displayed in the figure).
[0170] According to an embodiment of the present invention, the I2C master controller 100a is connected to the I2C interface module 200a via the I2C clock line and the I2C data line. The I2C master controller 100a initiates an I2C write operation and sends a write command packet to the I2C interface module 200a. After receiving the write command packet, the I2C interface module 200a sends the write command packet to one or more functional modules 300.
[0171] The function module receiving the write command packet executes one or more write commands contained in the write command packet, namely, write command 1, write command 2, ..., write command N, and then returns a write status packet to the I2C interface module 200a, including:
[0172] When the execution result of each write command included in the write command packet is successful, the function module 300 returns a write status packet with status information of success to the I2C interface module 200a;
[0173] When the execution result of at least one write command in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the I2C interface module 200a.
[0174] In the present invention, when the I2C interface module 200a 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.
[0175] The function module 300 receiving the write command packet returns the write status packet to the I2C interface module 200a, and the I2C interface module 200a returns the status information of the write status packet to the I2C main controller 100a, including:
[0176] After the I2C interface module 200a receives the write command packet,
[0177] If the subsequent I2C operation initiated by the I2C master controller 100a is an I2C read operation, and the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet, the I2C interface module 200a returns status information of the write status packet to the I2C master controller 100a.
[0178] If the subsequent I2C operation initiated by the I2C master controller 100a is an I2C write operation, and the I2C interface module 200a receives a write status packet from each of the function modules 300 that sends a write command packet and the status information of each write status packet is successful, the I2C interface module 200a receives the subsequent I2C write operation initiated by the I2C master controller 100a;
[0179] If the subsequent I2C operation initiated by the I2C master controller 100a is an I2C write operation, and the I2C interface module 200a receives a write status packet from each functional module 300 that sends a write command packet and the status information of at least one write status packet is failure, the I2C interface module 200a returns an I2C NAK to the I2C master controller 100a.
[0180] like Fig.10 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100a is an I2C write operation, which sends a write command packet to the I2C interface module 200a. 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 200a returns an I2C ACK to the I2C master controller 100a.
[0181] After the I2C interface module 200a receives the Nth write operation data byte (BYTE(N)) (i.e., after the I2C interface module 200a receives the complete write command packet), the I2C interface module 200a may return an I2C ACK or an I2C NAK to the I2C master controller 100a, which is specifically selected by the agreement between the I2C master controller 100a and the I2C interface module 200a. The I2C master controller 100a and the I2C interface module 200a may agree that after the Nth write operation data byte (BYTE(N)), whether I2C ACK or I2C NAK indicates the successful reception of the Nth write operation data byte (i.e., the complete write command packet). It may also be agreed that the 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 200a returns I2CACK or I2C NAK to the I2C master controller 100a, it indicates the successful reception of the Nth write operation data byte (i.e., the complete write command packet).
[0182] After the I2C master controller 100a completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200a returns an I2C ACK or an I2C NAK to the I2C master controller 100a, the I2C master controller 100a 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).
[0183] When the I2C operation with sequence number m+1 (subsequent I2C operation) is an I2C read operation, if the I2C interface module 200a receives a write status packet (a corresponding write status packet during the I2C operation with sequence number m) from each functional module 300 to which it sends a write command packet, then after the I2C master controller 100a sends the read address byte, the I2C interface module 200a returns an I2C ACK to the I2C master controller 100a and returns the status information (STATUS) of the write status packet.
[0184] like Fig.11 and Fig.12 As shown, the I2C operation with sequence number m initiated by the I2C master controller 100a is an I2C write operation, which sends a write command packet to the I2C interface module 200a. 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 200a returns an I2C ACK to the I2C master controller 100a.
[0185] After the I2C interface module 200a receives the Nth write operation data byte (BYTE(N)) (ie, after the I2C interface module 200a receives the complete write command packet), the I2C interface module 200a may return an I2C ACK or an I2C NAK to the I2C master controller 100a.
[0186] After the I2C master controller 100a completes sending the Nth write operation data byte (BYTE(N)), regardless of whether the I2C interface module 200a returns I2C ACK or I2C NAK to the I2C master controller 100a, the I2C master controller 100a 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).
[0187] When the I2C operation with sequence number m+1 (subsequent I2C operation) is an I2C write operation, if the I2C interface module 200a receives a write status packet (a corresponding write status packet during the I2C operation with sequence number m) from each functional module 300 that sends a write command packet and the status information of each write status packet is successful, then after the I2C master controller 100a sends the write address byte, the I2C interface module 200a returns an I2C ACK to the I2C master controller 100a, and the I2C interface module 200a receives the write operation data byte sent by the I2C operation with sequence number m+1 (subsequent I2C operation / I2C write operation) initiated by the I2C master controller 100a, such as Fig.11 shown.
[0188] If the I2C interface module 200a receives a write status packet (a write status packet corresponding to the I2C operation process with sequence number m) from each functional module 300 that sends a write command packet and the status information of at least one write status packet is failure, then after the I2C master controller 100a sends the write address byte, the I2C interface module 200a returns I2CNAK to the I2C master controller 100a, and the master controller 100a terminates the initiation of the I2C operation m+1 (subsequent I2C operation / I2C write operation), such as Fig.12 shown.
[0189] like Fig.13 As shown, in one embodiment, the main controller 100 is a SPI main controller 100b, the interface module 200 is a SPI interface module 200b, and the SPI main controller 100b is connected to the SPI interface module 200b through the SPI_CK signal line, the SPI_MOSI signal line and the SPI_MISO signal line.
[0190] The SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line. The write command packet starts with a first identifier. After receiving the write command packet from SPI_MOSI, the SPI interface module 200b sends the write command packet to one or more functional modules 300.
[0191] The function module receiving the write command packet executes one or more write commands contained in the write command packet, namely, write command 1, write command 2, ..., write command N, and then returns a write status packet to the SPI interface module 200b, including:
[0192] When the execution result of each write command included in the write command packet is successful, the function module 300 returns a write status packet with status information of success to the SPI interface module 200b;
[0193] When the execution result of at least one write command in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the SPI interface module 200b.
[0194] In the present invention, when the SPI interface module 200b 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.
[0195] The function module 300 receiving the write command packet returns the write status packet to the SPI interface module 200b, and the SPI interface module 200b receives the write status packet from each function module 300 that sends the write command packet, and returns the status information of the write status packet to the SPI master controller 100b, including:
[0196] After the SPI interface module 200b receives the write status packet from each functional module 300 that sends the write command packet, when the SPI master controller 100b generates a clock edge on SPI_CK, the SPI interface module 200b sends a write feedback packet to the SPI master controller 100b through the SPI_MISO signal line. The write feedback packet starts with the second identifier and contains the status information contained in the write status packet.
[0197] like Fig.14 In the embodiment shown, when the main controller 100 is an SPI main controller 100b and the interface module 200 is an SPI interface module 200b, the data structure of the write command packet is described. Four examples of write command packets are given as examples in the embodiment:
[0198] The write command packet may include a first identifier and write command 1, write command 2, ..., write command N, and start with the first identifier.
[0199] The write command packet may also include a first identifier, a write command packet length field, and write command 1, write command 2, ..., write command N, and start with the first identifier.
[0200] The write command packet may also include a first identifier, a remote I2C address, a write command 1, a write command 2, ..., a write command N, and start with the first identifier.
[0201] The write command packet may also include a first identifier, a write command packet length field, a remote I2C address, a write command 1, a write command 2, ..., a write command N, and start with the first identifier.
[0202] The first identifier, write command packet length field (if any), remote I2C address (if any), write command 1, write command 2, ..., write command N included in the write command packet are composed of a binary bit sequence. The present invention does not limit the length of the binary bit sequence of the first identifier, write command packet length field (if any), remote I2C address (if any), write command 1, write command 2, ..., write command N.
[0203] It should be noted that the present invention does not limit the format of the write command packet, that is, the format of the write command packet in the present invention is not limited to Fig.14 Four write command packet embodiments are shown. The SPI master controller 100b and the SPI interface module 200b may agree on other write command packet formats.
[0204] In the present invention, the SPI interface module 200b receiving the write command packet means that the data received by the SPI interface module 200b from the SPI_MOSI signal line contains a complete write command packet, such as Fig.14 As shown, the write command packet may include a write command packet length field, and the SPI interface module 200b may determine whether the received data includes a complete write command packet based on the write command packet length field (or part of the write command packet length field) according to the agreement between the SPI master controller 100b and the SPI master controller 100b, such as Fig.14 As shown, the write command packet may not include the write command packet length field. In this case, the SPI interface module 200b determines whether the received data includes a complete write command packet based on the agreement between the SPI master controller 100b (this agreement is not based on the write command packet length field).
[0205] The SPI master controller 100b drives the SPI_CK signal line, and the SPI master controller 100b generates a clock edge on the SPI_CK signal line. The SPI master controller 100b samples the data on the SPI_MISO signal line by the rising edge or falling edge of the clock on the SPI_CK signal line, and the SPI interface module 200b samples the data on the SPI_MOSI signal line by the rising edge or falling edge of the clock on the SPI_CK signal line, so as to realize bidirectional transmission of data between the SPI master controller 100b and the SPI interface module 200b.
[0206] The present invention is not limited to sampling the data on the SPI_MISO signal line and the SPI_MOSI signal line at the rising edge or falling edge of the clock on the SPI_CK signal line. In the embodiments of the present invention described below, the data on the SPI_MISO signal line and the SPI_MOSI signal line are sampled at the rising edge of the clock on the SPI_CK signal line, that is, in the embodiments of the present invention described below, the rising edge of the clock on the SPI_CK signal line is the sampling clock edge. In other embodiments of the present invention, the data on the SPI_MISO signal line and the SPI_MOSI signal line may also be sampled at the falling edge of the clock on the SPI_CK signal line, that is, in these embodiments, the falling edge of the clock on the SPI_CK signal line is the sampling clock edge.
[0207] like Fig.15 As shown, the SPI master controller 100b generates a clock edge on the SPI_CK signal line and drives the SPI_MOSI signal line at the same time, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line. The write command packet includes N bytes, each byte is 8-bit binary data, the first byte is the first identifier, and the 8-bit binary data of the first byte is C 10 , C 11 …C 17 Indicates that the Nth byte of the write command packet is the last byte of the write command packet, and the 8-bit binary data of the Nth byte of the write command packet is in C N0 , C N1 …C N7 express.
[0208] The SPI interface module 200b samples the data on the SPI_MOSI signal line at the rising edge of the clock on the SPI_CK signal line, and receives a write command packet from the SPI_MOSI signal line. N7 After the SPI_MOSI signal line receives the complete write command packet, the SPI interface module 200b receives the write command packet.
[0209] After receiving the write command packet from the SPI_MOSI signal line, the SPI interface module 200b sends the write command packet to the functional module 300. In the present invention, when the SPI interface module 200b sends the write command packet to the functional module 300, the content in the write command packet can be modified, added or deleted, and the present invention does not limit or stipulate this.
[0210] The function module receiving the write command packet executes one or more write commands contained in the write command packet, namely, write command 1, write command 2, ..., write command N, and then returns a write status packet to the SPI interface module 200b, including:
[0211] When the execution result of each write command included in the write command packet is successful, the function module 300 returns a write status packet with status information of success to the SPI interface module 200b;
[0212] When the execution result of at least one write command in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the SPI interface module 200b.
[0213] At the first moment, the SPI interface module 200b receives the write status packet, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, the SPI interface module 200b drives the SPI_MISO signal line, and sends a write feedback packet through the SPI_MISO signal line. The SPI master controller 100b samples the data on the SPI_MISO signal line at the rising edge of the clock on the SPI_CK signal line, and reads the write feedback packet. The write feedback packet starts with a second identifier, and the write feedback packet contains the status information contained in the write status packet. The status information contained in the write status packet can be write success and write failure, or other status information. In one embodiment, the write feedback packet can respectively contain the success or failure information contained in each write status packet received by the SPI interface module 200b. After receiving the write feedback packet, the SPI master controller 100b can learn the execution status of the write command packet by each functional module 300 that receives the write command packet according to the write feedback packet, and then can perform subsequent processing according to the execution status.
[0214] The write feedback packet contains M bytes, each byte is 8 bits of binary data, the first byte is the second identifier, and the 8 bits of binary data of the first byte are A 10 , A 11 …A 17 Indicates that the Mth byte of the write feedback packet is the last byte of the write feedback packet, and the 8-bit binary data of the Mth byte of the write feedback packet is A M0 , A M1 …A M7 express.
[0215] For ease of understanding, Fig.15 In the illustrated embodiment and the following description of the present invention, each byte is described as 8-bit binary data, but the present invention is not limited to the number of bits of each byte, and each byte may also be other numbers of bits.
[0216] Fig.15 In the illustrated embodiment, the length of the first identifier and the second identifier is one byte, and the length of the write command packet and the write feedback packet is an integer multiple of bytes. For ease of understanding, in the following description of the present invention, the length of the first to fourth identifiers is one byte, and the length of the write command packet and the write feedback packet (including a write success feedback packet and a write failure feedback packet) is an integer multiple of bytes, but the present invention does not limit the length of the first to fourth identifiers to one byte, nor does it limit the length of the first to fourth identifiers to an integer multiple of bytes. The present invention also does not limit the length of the write command packet and the write feedback packet (including a write success feedback packet and a write failure feedback packet) to an integer multiple of bytes.
[0217] In the interval marked as "no clock edge", the SPI master controller 100b does not generate a sampling clock edge on the SPI_CK signal line. Fig.15 In the description of the subsequent embodiments of the present invention, the levels of the SPI_MOSI and SPI_MISO signal lines remain unchanged in the "no clock edge" interval. The present invention is not limited to the levels of the SPI_MOSI and SPI_MISO signal lines in the "no clock edge" interval. The levels of the SPI_MOSI and SPI_MISO signal lines can also change in the "no clock edge" interval, but because the sampling of data on the SPI_MOSI and SPI_MISO signal lines is only performed on the sampling clock edge of the SPI_CK signal line ( Fig.15 In the embodiment shown, the sub-sampling clock edge is the rising edge of the clock, and level changes on the SPI_MOSI and SPI_MISO signal lines in the "no clock edge" interval will not be sampled and received.
[0218] exist Fig.15 In the illustrated embodiment, the SPI master controller 100b generates a clock edge on the SPI_CK signal line and drives the SPI_MOSI signal line at the same time. When sending a write command packet through the SPI_MOSI signal line, the SPI interface module 200b has no write feedback packet to send. At this time, the SPI interface module 200b drives the SPI_MISO signal line to a high level. During this period, the SPI interface module 200b of the present invention can also drive the SPI_MISO signal line to a low level or a changing level. However, the SPI interface module 200b should ensure that the level value driven on the SPI_MISO signal line or the changing level value, if sampled by the SPI master controller 100b on the SPI_CK signal line at the sampling clock edge ( Fig.15In the embodiment shown, the sub-sampling clock edge is the rising edge of the clock and is not identified as the second identifier. Fig.15 Taking the illustrated embodiment as an example, since the SPI interface module 200b drives the SPI_MISO signal line to a high level (sampled as continuous binary bits 1) during this period, in order not to be identified as the second identifier, the value of the second identifier should not be 0xFF.
[0219] exist Fig.15 In the illustrated embodiment, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and the SPI interface module 200b drives the SPI_MISO signal line. When sending a write feedback packet through the SPI_MISO signal line, the SPI master controller 100b has no write command packet to send. At this time, the SPI master controller 100b drives the SPI_MOSI signal line to a high level. During this period, the SPI master controller 100b of the present invention can also drive the SPI_MOSI signal line to a low level or a changing level, but the SPI master controller 100b should ensure that the level value driven on the SPI_MOSI signal line or the changing level value, if sampled by the SPI interface module 200b on the sampling clock edge of the SPI_CK signal line ( Fig.15 In the embodiment shown, the sub-sampling clock edge is the rising edge of the clock and is not identified as the first identifier. Fig.15 Taking the illustrated embodiment as an example, since the SPI master controller 100b drives the SPI_MOSI signal line to a high level (sampled as continuous binary bits 1) during this period, in order not to be identified as the first identifier, the value of the first identifier should not be 0xFF.
[0220] In addition to the SPI_CK signal line, the SPI_MOSI signal line and the SPI_MISO signal line, the SPI interface module 200b can also be connected to the SPI master controller 100b through the SPI_CSN signal line. The SPI master controller 100b drives the SPI_CSN signal line, the SPI_CK signal line and the SPI_MOSI signal line, and the SPI interface module 200b receives the SPI_CSN signal line, the SPI_CK signal line and the SPI_MOSI signal line. The SPI interface module 200b drives the SPI_MISO signal line, and the SPI master controller 100b receives the SPI_MISO signal line. The SPI_CSN signal line is a selection signal. In the SPI protocol, data transmission is performed only when the SPI_CSN signal line is low. One SPI master controller 100b can be connected to multiple SPI interface modules 200b, wherein the SPI master controller 100b and multiple SPI interface modules 200b share the SPI_CK signal line, the SPI_MOSI signal line and the SPI_MISO signal line, but each SPI interface module 200b has an independent SPI_CSN signal line input, when the SPI_CSN signal line of one SPI interface module 200b is high, this SPI interface module 200b does not drive the SPI_MISO signal line (the driver output of this SPI interface module 200b connected to the SPI_MISO signal line is in Hi-Z state), and one SPI interface module 200b drives the SPI_MISO signal line only when its SPI_CSN signal line is low. When one SPI master controller 100b is connected to multiple SPI interface modules 200b, at any time, only one SPI interface module 200b has the SPI_CSN signal line low, thereby avoiding conflicts caused by multiple SPI interface modules 200b driving the SPI_MISO signal line at the same time.
[0221] When a SPI master controller 100b is connected to only one SPI interface module 200b, the SPI interface module 200b can drive the SPI_MISO signal line at any time without causing a conflict. In this case, there may be no SPI_CSN signal line between the SPI master controller 100b and the SPI interface module 200b. That is, when a SPI master controller 100b is connected to only one SPI interface module 200b, the SPI master controller 100b and the SPI interface module 200b may be connected only through the SPI_CK signal line, the SPI_MOSI signal line and the SPI_MISO signal line. Fig.15 This is the case in the description of the illustrated embodiment.
[0222] The description of the present invention only describes the case where there is no SPI_CSN signal line between the SPI master controller 100b and the SPI interface module 200b, but according to the description of the present invention, it is easy to expand to the case where there is a SPI_CSN signal line between the SPI master controller 100b and the SPI interface module 200b, and the description of the present invention will not repeat the case where there is a SPI_CSN signal line between the SPI master controller 100b and the SPI interface module 200b. Whether there is a SPI_CSN signal line between the SPI master controller 100b and the SPI interface module 200b, it is within the protection scope of the present invention.
[0223] According to an embodiment of the present invention, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, reads the write feedback packet through the SPI_MISO signal line,
[0224] When the SPI interface module 200b does not receive the write status packet, the SPI interface module 200b sends data that cannot be identified as a write feedback packet to the SPI master controller 100b through the SPI_MISO signal line.
[0225] by Fig.16 As shown in the figure as an example, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line. After receiving the write command packet from the SPI_MOSI signal line, the SPI interface module 200b sends the write command packet to one or more functional modules 300. The functional module 300 that receives the write command packet executes one or more write commands included in the write command packet, and then returns a write status packet to the SPI interface module 200b. At the third moment, the SPI interface module 200b receives the write status packet from each functional module 300 that sends the write command packet. Before the third moment when the SPI interface module 200b receives the write status packet from each functional module 300 that sends the write command packet, between the first moment and the second moment, the SPI master controller 100b generates a clock edge on the SPI_CK signal line. Fig.16 In the embodiment shown, the SPI interface module 200b drives the SPI_MISO signal line to a high level. During this period, the SPI interface module 200b can also drive the SPI_MISO signal line to a low level or a changing level. However, the SPI interface module 200b should ensure that the level value driven on the SPI_MISO signal line or the changing level value is sampled by the SPI master controller 100b at the sampling clock edge on the SPI_CK signal line ( Fig.16In the embodiment shown, the sampling clock edge is the rising edge of the clock), which is not recognized as the second identifier, that is, when the SPI interface module 200b does not receive the write status packet from each functional module 300 that sends a write command packet, if the SPI master controller 100b generates a clock edge on the SPI_CK signal line, the SPI interface module 200b sends data that cannot be recognized as a write feedback packet to the SPI master controller 100b through the SPI_MISO signal line. At the third moment, after the SPI interface module 200b receives the write status packet from each functional module 300 that sends a write command packet, the SPI master controller 100b generates a clock edge on the SPI_CK signal line and reads the write feedback packet from the SPI interface module 200b through the SPI_MISO signal line.
[0226] exist Fig.17 In the illustrated embodiment, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line. After receiving the write command packet from the SPI_MOSI signal line, the SPI interface module 200b sends the write command packet to one or more functional modules 300. The functional modules 300 that receive the write command packet execute one or more write commands included in the write command packet, and then return a write status packet to the SPI interface module 200b. At time ①, the SPI interface module 200b receives a write status packet from each functional module 300 to which it sends a write command packet, and the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and reads a write feedback packet from the SPI interface module 200b through the SPI_MISO signal line. At the second moment, the SPI master controller 100b completes reading the write feedback packet, the SPI interface module 200b completes sending the write feedback packet, and the SPI master controller 100b continues to generate a clock edge on the SPI_CK signal line. At this time, the SPI interface module 200b drives the SPI_MISO signal line to a high level. During this period, the SPI interface module 200b can also drive the SPI_MISO signal line to a low level or a changing level, but the SPI interface module 200b should ensure that the level value driven or the changing level value on the SPI_MISO signal line is sampled by the SPI master controller 100b on the sampling clock edge of the SPI_CK signal line ( Fig.17 In the illustrated embodiment, the sampling clock edge is a rising clock edge), which is not identified as a second identifier.
[0227] According to the embodiment of the present invention, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line.
[0228] Then the SPI master controller 100b generates a clock edge on the SPI_CK signal line and reads the write feedback packet through the SPI_MISO signal line. After the SPI interface module 200b sends the write feedback packet through the SPI_MISO signal line, it can continue to receive subsequent command packets (subsequent command packets include write command packets and read command packets).
[0229] In the present invention, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends the write command packet to the SPI interface module 200b through the SPI_MOSI signal line. After receiving the write command packet from the SPI_MOSI signal line, the SPI interface module 200b sends the write command packet to one or more functional modules 300. The functional modules 300 that receive the write command packet execute one or more write commands contained in the write command packet, and then return a write status packet to the SPI interface module 200b. Then, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends the write command packet to the SPI interface module 200b through the SPI_MISO signal line. The signal line reads the write feedback packet. Before the SPI master controller 100b reads the write feedback packet, if the SPI master controller 100b drives the SPI_MOSI signal line to send a command packet (including a write command packet and a read command packet), the SPI interface module 200b can choose not to receive the command packet sent by the SPI master controller 100b before reading the write feedback packet. After the SPI master controller 100b reads the write feedback packet, that is, after the SPI interface module 200b sends the write feedback packet through the SPI_MISO signal line, the SPI interface module 200b can continue to receive subsequent command packets (subsequent command packets include write command packets and read command packets).
[0230] According to an embodiment of the present invention, a write feedback packet can be divided into a write success feedback packet and a write failure feedback packet;
[0231] The SPI master controller 100b generates a clock edge on the SPI_CK signal line and reads the write feedback packet through the SPI_MISO signal line.
[0232] When the SPI interface module 200b receives a write status packet from each functional module 300 that sends a write command packet and the status information contained in each write status packet is success, the SPI interface module 200b sends a write success feedback packet through the SPI_MISO signal line, and the write success feedback packet starts with the third identifier.
[0233] When the SPI interface module 200b receives a write status packet from each functional module 300 that sends a write command packet and at least one write status packet contains status information of failure, the SPI interface module 200b sends a write failure feedback packet through the SPI_MISO signal line, and the write failure feedback packet starts with a fourth identifier.
[0234] like Fig.18 As shown, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line. After receiving the write command packet from the SPI_MOSI signal line, the SPI interface module 200b sends the write command packet to one or more functional modules 300. The functional module 300 that receives the write command packet executes one or more write commands contained in the write command packet, and then returns a write status packet to the SPI interface module 200b. At the first moment, the SPI interface module 200b receives a write status packet from each functional module 300 to which it sends the write command packet, and the status information contained in each write status packet is success. When the SPI master controller 100b generates a clock edge on the SPI_CK signal line and reads a write feedback packet from the SPI interface module 200b through the SPI_MISO signal line, the SPI interface module 200b drives the SPI_MISO signal line to send a write success feedback packet to the SPI master controller 100b through the SPI_MISO signal line. The write success feedback packet starts with a third identifier.
[0235] like Fig.19 As shown, the SPI master controller 100b generates a clock edge on the SPI_CK signal line, and sends a write command packet to the SPI interface module 200b through the SPI_MOSI signal line. After receiving the write command packet from the SPI_MOSI signal line, the SPI interface module 200b sends the write command packet to one or more functional modules 300. The functional module 300 that receives the write command packet executes one or more write commands contained in the write command packet, and then returns a write status packet to the SPI interface module 200b. At the first moment, the SPI interface module 200b receives a write status packet from each functional module 300 to which it sends the write command packet, and the status information contained in at least one write status packet is failure. When the SPI master controller 100b generates a clock edge on the SPI_CK signal line and reads a write feedback packet from the SPI interface module 200b through the SPI_MISO signal line, the SPI interface module 200b drives the SPI_MISO signal line to send a write failure feedback packet to the SPI master controller 100b through the SPI_MISO signal line. The write failure feedback packet starts with the fourth identifier.
[0236] In the present invention, the third identifier is different from the fourth identifier. When the SPI master controller 100b reads a write feedback packet, it can determine whether the read write success feedback packet or the write failure feedback packet is a write success feedback packet or a write failure feedback packet by whether the write feedback packet starts with the third identifier or the fourth identifier. Therefore, the write success feedback packet may only include the third identifier, and the write failure feedback packet may only include the fourth identifier, so that the SPI master controller 100b can distinguish whether the read write feedback packet is a write success feedback packet or a write failure feedback packet.
[0237] In addition to being an I2C master controller 100a and an SPI master controller 100b, the main controller 100 in the present invention can also be a master controller that complies with other interface protocols (for example, a master controller that complies with serial port UART protocol, CAN protocol, LIN protocol, etc.). In addition to being an I2C interface module 200a and an SPI interface module 200b, the interface module 200 in the present invention can also be an interface module that complies with other interface protocols (for example, an interface module that complies with serial port UART protocol, CAN protocol, LIN protocol, etc.). The use of a main controller that complies with other interface protocols and an interface module that complies with other interface protocols are also within the protection scope of the present invention.
[0238] According to an embodiment of the present invention, the main controller 100 (I2C main controller 100a or SPI main controller 100b or main controller conforming to other interface protocols) sends a write command packet to the interface module 200 (I2C interface module 200a or SPI interface module 200b or interface module conforming to other interface protocols). After the interface module 200 receives the write command packet, it sends the write command packet to one or more functional modules 300. The write command packet includes one or more write commands, such as Figure 2 and Fig.14 shown.
[0239] like Fig. 20 As shown, an embodiment of the present invention provides an interface system, characterized in that the interface system includes a main controller 100, an interface module 200, multiple functional modules 300, and a remote I2C slave device 400. The main controller 100 is connected to the interface module 200, the interface module 200 is connected to multiple functional modules 300, the serial numbers of the functional modules 300 are represented by 1 to N, and the functional modules 300 may or may not be connected to the remote I2C slave device 400.
[0240] like Fig. 20 The functional modules 300 shown are all connected to the remote I2C slave devices 400, and the functional modules 300 may not be connected to multiple remote I2C slave devices 400. The functional modules 300 may also be connected to multiple remote I2C slave devices 400.
[0241] In this example, the process in which the main controller 100 sends a write command packet, the interface module 200 receives the write command packet, and sends the write command packet to one or more functional modules 300 is similar to the process in which the main controller 100 sends a write command packet, the interface module 200 receives the write command packet, and sends the write command packet to one or more functional modules 300. Figure 1 The embodiments shown and the descriptions are the same and will not be repeated here.
[0242] In this example, the function module 300 that receives the write command packet is connected to the remote I2C slave device 400. After receiving the write command packet from the interface module 200, the function module 300 executes one or more write commands contained in the write command packet. The method for executing each write command is:
[0243] The functional module 300 sends an I2C START to the remote I2C slave device 400, and then the functional module 300 sends a remote I2C address byte to the remote I2C slave device 400, and then the functional module 300 sends a write command to the remote I2C slave device 400.
[0244] For each byte sent by the functional module 300 to the remote I2C slave device 400, the functional module 300 receives an I2C response bit sent by the remote I2C slave device 400 and determines the execution result of the write command.
[0245] After receiving the write command packet, the function module 300 executes one or more write commands contained in the write command packet and returns a write status packet to the interface module 200, including:
[0246] When the execution result of each write command included in the write command packet is successful, the function module 300 returns a write status packet containing status information indicating success to the interface module 200 .
[0247] When the execution result of at least one write command in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the interface module 200 .
[0248] The interface module 200 receives a write status packet from each of the function modules 300 that transmits a write command packet, and returns status information of the write status packet to the main controller 100 .
[0249] like Fig.21 As shown, for each write command (write command 1, write command 2, ..., write command N) included in the write command packet, the function module 300 first sends an I2C START to the remote I2C slave device 400, and then the function module 300 sends a remote I2C address byte to the remote I2C slave device 400, and then the function module 400 sends a write command to the remote I2C slave device 400. The remote I2C address byte consists of an I2C address (ADDR) and a write operation indication bit (W).
[0250] For a write command, the I2C response bit received after the function module 300 sends the remote I2C address byte is I2CACK, and the I2C response bit received after the function module 300 sends each byte of the write command is I2C ACK, and the result of the function module 300 executing this write command is success.
[0251] like Fig.21 As shown, when the execution result of each write command is successful, the function module 300 returns a write status packet with status information indicating success to the interface module 200 , and the interface module 200 returns the status information of the write status packet to the main controller 100 .
[0252] In other embodiments (not shown) Fig.21 ), the functional module 300 may also agree with the remote I2C slave device 400 that, for a write command, the I2C response bit received after the functional module 300 sends the remote I2C address byte is I2C ACK, and the I2C response bit received after the functional module 300 sends each byte of the write command except the last byte is I2CACK, and the I2C response bit received after the functional module 300 sends the last byte of the write command is I2C NAK, and the functional module 300 also considers that the result of executing this write command is successful.
[0253] When the execution result of a write command is failure, the function module 300 stops executing subsequent write commands, and returns a write status packet with failure status information to the interface module 200 , and the interface module 200 returns the status information of the write status packet to the main controller 100 .
[0254] like Fig. 22 As shown, after the function module 300 sends the remote I2C address byte (write command 1 address byte) to the remote I2C slave device 400, the I2C response bit received by the function module 300 from the remote I2C slave device 400 is NAK, and the execution result of the write command 1 is failure. The function module 300 stops executing subsequent write commands, and the function module 300 returns a write status packet with status information of failure to the interface module 200, and the interface module 200 returns the status information of the write status packet to the main controller 100.
[0255] like Fig.23As shown, another embodiment of write command execution failure is given. After the function module 300 sends the remote I2C address byte, the I2C response bit received is I2C ACK, and the I2C response bit received after the function module 300 sends each byte of write command 1 is I2C ACK. The result of the function module 300 executing write command 1 is success. Then for write command 2, the I2C response bit received after the function module 300 sends the remote I2C address byte is I2C ACK, but after the function module 300 sends write command 2 byte 1, the I2C response bit sent by the remote I2C slave device 400 received by the function module 300 is NAK, then the execution result of write command 2 is failure (in this embodiment, write command 2 byte 1 is not the last byte of write command 2, or write command 2 byte 1 is the last byte of write command 2, but the function module 300 and the remote I2C slave device 400 agree that the I2C response bit after sending each byte of a write command is I2C ACK. ACK is considered that the write command is executed successfully), so the execution result of at least one write command in the write command packet is failure, the functional module 300 returns a write status packet with status information of failure to the interface module 200, and the interface module 200 returns the status information of the write status packet to the main controller 100.
[0256] When at least one of the write commands included in the write command packet has an execution result of failure, the function module 300 returns a write status packet with failure status information to the interface module 200 , and the interface module 200 returns the status information of the write status packet to the main controller 100 .
[0257] In the present invention, the status information of the write status packet may respectively include the success or failure information contained in each write status packet received by the interface module 200. After receiving the status information, the main controller 100 can know the execution status of the write command packet by each functional module 300 that receives the write command packet based on the status information, and then perform subsequent processing based on the execution status.
[0258] Fig. 22 and Fig.23 In the illustrated embodiment, when the execution result of a write command is failure, the function module 300 stops executing subsequent write commands, and the function module 300 returns a write status packet with failure status information to the interface module 200, and the interface module 200 returns the status information of the write status packet to the main controller 100. In other embodiments, when the execution result of a write command is failure, the function module 300 may choose to continue to execute subsequent write commands included in the write command packet, but when the execution result of at least one write command included in the write command packet is failure, the function module 300 returns a write status packet with failure status information to the interface module 200, and the interface module 200 returns the status information of the write status packet to the main controller 100.
[0259] In a preferred embodiment, the functional module 300 includes a remote I2C address register, and the remote I2C address byte sent by the functional module 300 to the remote I2C slave device 400 includes an I2C address (eg, Fig.21 , Fig. 22 , Fig.23 ADDR) shown in FIG. 1 is the remote I2C address stored in the remote I2C address register.
[0260] In a preferred embodiment, the write command packet includes the remote I2C address (such as Figure 2 , Fig.14 The I2C address contained in the remote I2C address byte sent by the functional module 300 to the remote I2C slave device 400 is the remote I2C address contained in the write command packet.
[0261] Furthermore, the functional module 300 includes a remote I2C address register, and the functional module 300 also includes a remote I2C address selection module. The I2C address contained in the remote I2C address byte sent by the functional module 300 to the remote I2C slave device 400 is derived from the remote I2C address stored in the remote I2C address register or from the remote I2C address contained in the write command packet according to the instruction of the remote I2C address selection module.
[0262] In a preferred embodiment, the write command packet includes multiple write commands, each of which includes a remote I2C address. The remote I2C address byte sent by the functional module 300 to the remote I2C slave device is derived from the remote I2C address included in each write command.
[0263] like Figure 3 As shown, in another embodiment, the main controller 100 is an I2C main controller 100a, and the interface module 200 is an I2C interface module 200a. The I2C main controller 100a initiates an I2C write operation to send a write command packet to the I2C interface module 200a, and then the I2C main controller 100a initiates a subsequent I2C read operation to read the status information.
[0264] In this example, after the I2C master controller 100a initiates an I2C write operation to send a write command packet to the I2C interface module 200a, it must initiate a subsequent I2C read operation to read the status information.
[0265] After receiving the address byte of the subsequent I2C read operation, the I2C interface module 200a pulls down the I2C clock line level and sends the received write command packet to one or more functional modules 300.
[0266] The function module 300 that receives the write command packet executes one or more write commands contained in the write command packet and returns a write status packet to the I2C interface module 200a, including:
[0267] When the execution result of each write command included in the write command packet is successful, the functional module 300 returns a write status packet with status information indicating success to the I2C interface module 200a.
[0268] When at least one of the write commands included in the write command packet has an execution result of failure, the function module 300 returns a write status packet with status information indicating failure to the I2C interface module 200a.
[0269] After the I2C interface module 200a receives the write status packet from each functional module 300 that sends the write command packet, the I2C interface module 200a stops pulling down the I2C clock line level and returns the status information of the write status packet to the I2C master controller 100a.
[0270] 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. A multi-target data writing method, based on an interface system, the interface system comprises a main controller, an interface module, and a plurality of functional modules, the main controller is connected to the interface module, and the interface module is connected to the plurality of functional modules, It is characterized in that The main controller sends a write command packet to the interface module, and when the interface module receives the write command packet, the interface module sends the write command packet to one or more functional modules. The function module that receives the write command packet executes one or more write commands contained in the write command packet and returns a write status packet to the interface module, including: When the execution result of each write command contained in the write command packet is successful, the function module returns a write status packet with successful status information to the interface module. When the execution result of at least one of the write commands included in the write command packet is failed, the function module returns a write status packet with status information indicating failure to the interface module. The interface module receives a write status packet from each functional module that sends a write command packet, and returns status information of the write status packet to the main controller.
2. A multi-target data writing method according to claim 1, It is characterized in that The main controller is an I2C main controller, and the interface module is an I2C interface module. The I2C master controller is connected to the I2C interface module via an I2C clock line and an I2C data line. 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 one or more functional modules. The function module that receives the write command packet returns the write status packet to the I2C interface module. The I2C interface module receives the write status packet from each function module that sends the write command packet, and returns the status information of the write status packet to the I2C master controller.
3. A multi-target data writing method according to claim 2, It is characterized in that When the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of each write status packet is successful, the I2C interface module stops pulling down the I2C clock line level and returns an I2C ACK to the I2C master controller. When the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of at least one write status packet is failure, the I2C interface module stops pulling down the I2C clock line level and returns an I2C NAK to the I2C master controller.
4. A multi-target data writing method according to claim 2, It is characterized in that When the I2C interface module receives the write status packet from each functional module that sends the write command 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 read operation, the I2C interface module returns status information of the write status packet to the I2C master controller.
5. A multi-target data writing method according to claim 1, It is characterized in that The main controller is an I2C main controller, and the interface module is an I2C interface module. The I2C master controller is connected to the I2C interface module via an I2C clock line and an I2C data line, the I2C master controller initiates an I2C write operation to send the write command packet to the I2C interface module, and the I2C interface module sends the write command packet to one or more functional modules after receiving the write command packet. The function module that receives the write command packet returns the 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 read operation, and the I2C interface module receives the write status packet from each functional module that sends a write command packet, the I2C interface module returns status information of the write status packet to the I2C master controller.
6. A multi-target data writing method according to claim 5, It is characterized in that The subsequent I2C operation initiated by the I2C master controller is an I2C write operation. If the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of each write status packet is successful, the I2C interface module receives a subsequent I2C write operation initiated by the I2C master controller, If the I2C interface module receives the write status packet from each functional module that sends the write command packet and the status information of at least one write status packet is failure, the I2C interface module returns I2CNAK to the I2C master controller.
7. A multi-target data writing method according to claim 1, It is characterized in that The main controller is an SPI main controller, the interface module is an SPI interface module, and the SPI main controller is connected to the SPI interface module via an SPI_CK signal line, an SPI_MOSI signal line, and an SPI_MISO signal line. The SPI master controller generates a clock edge on the SPI_CK signal line, sends the write command packet to the SPI interface module through the SPI_MOSI signal line, the write command packet starts with a first identifier, and the SPI interface module sends the write command packet to one or more functional modules after receiving the write command packet from SPI_MOSI. The function module receiving the write command packet returns the write status packet to the SPI interface module, the SPI interface module receives the write status packet from each function module that sends the write command packet, and returns the status information of the write status packet to the SPI master controller, including: After the SPI interface module receives a write status packet from each functional module that sends a write command packet, when the SPI master controller generates a clock edge on SPI_CK, the SPI interface module sends a write feedback packet to the SPI master controller through the SPI_MISO signal line, wherein the write feedback packet starts with a second identifier and includes status information included in the write status packet.
8. A multi-target data writing method according to claim 7, It is characterized in that The SPI master controller generates a clock edge on the SPI_CK signal line and reads the write feedback packet through the SPI_MISO signal line. When the SPI interface module does not receive the write status packet from each functional module that sends a write command packet, the SPI interface module sends data that cannot be identified as the write feedback packet to the SPI master controller through the SPI_MISO signal line.
9. A multi-target data writing method according to claim 7, It is characterized in that The SPI master controller generates a clock edge on the SPI_CK signal line, and sends the write command packet to the SPI interface module via the SPI_MOSI signal line. Then the SPI master controller generates a clock edge on the SPI_CK signal line, reads the write feedback packet through the SPI_MISO signal line, and after the SPI interface module sends the write feedback packet through the SPI_MISO signal line, it can continue to receive subsequent command packets.
10. A multi-target data writing method according to claim 7, It is characterized in that The write feedback packet is divided into a write success feedback packet and a write failure feedback packet. The SPI master controller generates a clock edge on the SPI_CK signal line and reads the write feedback packet through the SPI_MISO signal line. When the SPI interface module receives the write status packet from each functional module that sends the write command packet and the status information contained in each write status packet is successful, the SPI interface module sends the write success feedback packet through the SPI_MISO signal line, and the write success feedback packet starts with the third identifier. When the SPI interface module receives the write status packet from each functional module that sends the write command packet and the status information contained in at least one write status packet is failure, the SPI interface module sends the write failure feedback packet through the SPI_MISO signal line, and the write failure feedback packet starts with a fourth identifier.
11. A multi-target data writing method according to claim 1, It is characterized in that The functional module that receives the write command packet is connected to a remote I2C slave device. After receiving the write command packet from the interface module, the functional module that receives the write command packet executes one or more write commands contained in the write command packet. The method for executing each write command is as follows: The function module sends I2C START to the remote I2C slave device, then the function module sends the remote I2C address byte to the remote I2C slave device, and then the function module sends a write command to the remote I2C slave device. For each byte sent by the function module to the remote I2C slave device, the function module receives an I2C acknowledge bit sent by the remote I2C slave device and determines the execution result of the write command.
12. A multi-target data writing method according to claim 11, It is characterized in that The functional module that receives the write command packet includes a remote I2C address register, and the I2C address included in the remote I2C address byte sent by the functional module that receives the write command packet to the remote I2C slave device is the remote I2C address stored in the remote I2C address register.
13. The multi-target data writing method according to claim 11, It is characterized in that The write command packet includes a remote I2C address, and the I2C address included in the remote I2C address byte sent by the functional module that receives the write command packet to the remote I2C slave device is the remote I2C address included in the write command packet.
14. A multi-target data writing method according to claim 13, It is characterized in that The functional module that receives the write command packet includes a remote I2C address register, and the functional module that receives the write command packet also includes a remote I2C address selection module. The I2C address included in the remote I2C address byte sent by the functional module that receives the write command packet to the remote I2C slave device is derived from the remote I2C address stored in the remote I2C address register or from the remote I2C address included in the write command packet according to the instruction of the remote I2C address selection module.
15. A multi-target data writing method, based on an interface system, the interface system comprising an I2C main controller, an I2C interface module, and multiple functional modules, the I2C main controller is connected to the I2C interface module, the I2C interface module is connected to the multiple functional modules, It is characterized in that The I2C master controller initiates an I2C write operation to send a 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 one or more functional modules. The functional module that receives the write command packet executes one or more write commands contained in the write command packet and returns a write status packet to the I2C interface module, including: When the execution result of each write command contained in the write command packet is successful, the functional module returns a write status packet with successful status information to the I2C interface module. When at least one of the write commands included in the write command packet has an execution result of failure, the functional module returns a write status packet with status information of failure to the I2C interface module. After the I2C interface module receives the write status packet from each functional module that sends the write command packet, the I2C interface module stops pulling down the I2C clock line level and returns the status information of the write status packet to the I2C master controller.
Citation Information
Cited By
Multi-target data writing method
WO2026031753A1
