Single-wire two-way communication method and system, electronic equipment and readable storage medium

By using packet comparison and CRC verification in a single-line bidirectional communication system, the complex problems of communication conflicts and baud rate matching are solved, stable and accurate data transmission is achieved, and the connection between the host and the slave is simplified.

CN119025463APending Publication Date: 2024-11-26SIRIP MICROELECTRONICS TECHNOLOGY (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411193282.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

In the prior art, single-line bidirectional communication systems have communication conflict problems, and baud rate matching is complex, making it difficult to achieve simple configuration and connection.

Method used

By using a single bus to communicate between the host and the slave, the host generates and sends data packets, and determines the communication conflict by comparing whether the received data packet is consistent with the sent data packet. If there is a conflict, the data will be resent. Packets until consistent; at the same time, CRC verification is used to enhance the anti-interference ability of communication and support automatic baud rate detection.

Benefits of technology

It effectively avoids communication conflicts, improves the stability and accuracy of data transmission, simplifies the connection between the host and the slave, is compatible with traditional UART communication protocols, and reduces chip size consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025463A_ABST
    Figure CN119025463A_ABST
Patent Text Reader

Abstract

The invention discloses a single-wire two-way communication method and system, electronic equipment and a readable storage medium. The method comprises the steps that a host generates a write-in data packet or a read data packet based on a data request and sends the write-in data packet or the read data packet; the host receives the data packet and compares whether the received data packet is consistent with the sent data packet; and the host judges whether the bus has a communication conflict based on the comparison result. The slave receives the write-in data packet, and writes the corresponding data into the target address based on the write-in data packet; the slave receives the read data packet and obtains target data based on the read data packet; generating a target data packet based on the target data, and sending the target data packet; the slave receives the data packet and compares whether the received data packet is consistent with the target data packet; and the slave machine judges whether the bus has a communication conflict based on the comparison result. According to the invention, self-verification is carried out through locally receiving the sent data, so that communication conflicts when the host and the slave simultaneously transmit the data on the line are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of integrated circuits, and in particular relates to a single-line bidirectional communication method, system, electronic equipment and a readable storage medium. Background Art

[0002] Many AFE (Analog Front End) chips require simple configuration by the host device (MCU or MPU) and have the simplest possible connection. Universal communication options such as UART, SPI and I2C can meet the configuration requirements, but they require at least two pins to connect to the host. In addition, UART is asynchronous communication, and there are baud rate matching problems in practical applications. In order to make the connection simpler, the existing technology provides some single-wire-based solutions, but these solutions have certain usage restrictions. For example, there is no communication conflict handling principle, or some require special logic circuits to be added to the host device, or require very complex software operations for the host to simulate communication, or require baud rate requirements instead of configurable.

[0003] Therefore, in view of the above technical problems, it is necessary to provide a single-line two-way communication method, system, electronic device and readable storage medium. Summary of the invention

[0004] The object of the present invention is to provide a single-line two-way communication method, system, electronic device and readable storage medium, which can solve the communication conflict problem of the single-line two-way communication system.

[0005] In order to achieve the above purpose, the technical solution provided by an embodiment of the present invention is as follows:

[0006] A single-line bidirectional communication method is applied to a single-line bidirectional communication system, wherein the single-line bidirectional communication system includes a host and a slave, and the host and the slave communicate via a single bus. The method includes:

[0007] The host generates a write data packet based on the write data request, and sends the write data packet through its sending end;

[0008] The host receives the data packet at its receiving end, and compares the received data packet with the written data packet to see whether they are consistent;

[0009] The host determines whether there is a communication conflict on the bus based on the comparison result.

[0010] In one or more embodiments of the present invention, when the comparison results are consistent, the host determines that there is no communication conflict on the bus; the method further includes:

[0011] When there is no communication conflict, the host enters a standby state;

[0012] and / or,

[0013] When the comparison results are inconsistent, the host determines that there is a communication conflict on the bus; the method further includes:

[0014] When there is a communication conflict, the host re-sends the write data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the write data packet.

[0015] In one or more embodiments of the present invention, the write data packet includes an address byte, a data byte and a CRC check byte; wherein,

[0016] The address byte includes a write command bit or a read command bit, and / or the address byte includes a dedicated address bit corresponding to the slave.

[0017] Another embodiment of the present invention provides a technical solution as follows:

[0018] A single-line bidirectional communication method is applied to a single-line bidirectional communication system, wherein the single-line bidirectional communication system includes a host and a slave, and the host and the slave communicate via a single bus. The method includes:

[0019] The host generates a read data packet based on the read data request, and sends the read data packet through its sending end;

[0020] The host receives the data packet at its receiving end, and compares the received data packet with the read data packet to see whether they are consistent;

[0021] The host determines whether there is a communication conflict on the bus based on the comparison result.

[0022] In one or more embodiments of the present invention, when the comparison results are consistent, the host determines that there is no communication conflict on the bus; the method further includes:

[0023] When there is no communication conflict, the host receives the target data packet sent by the slave and performs a CRC check;

[0024] and / or,

[0025] When the comparison results are inconsistent, the host determines that there is a communication conflict on the bus; the method further includes:

[0026] When there is a communication conflict, the host re-sends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet.

[0027] In one or more embodiments of the present invention, the method further comprises:

[0028] The host enters a standby state after the target data packet passes the CRC check;

[0029] and / or,

[0030] When the target data packet fails to pass the CRC check, the host resends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet;

[0031] and / or,

[0032] When the host times out when receiving the target data packet sent by the slave, it resends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet.

[0033] In one or more embodiments of the present invention, the read data packet includes an address byte, a data byte and a CRC check byte; wherein,

[0034] The address byte includes a write command bit or a read command bit;

[0035] and / or,

[0036] The target data packet includes an address byte, a data byte and a CRC check byte; wherein,

[0037] The address byte includes a write command bit or a read command bit; and / or, the address byte includes a dedicated address bit corresponding to the slave.

[0038] Another embodiment of the present invention provides a technical solution as follows:

[0039] A single-line bidirectional communication method is applied to a single-line bidirectional communication system, wherein the single-line bidirectional communication system includes a host and a slave, and the host and the slave communicate via a single bus. The method includes:

[0040] The slave receives a read data packet at its receiving end, and acquires target data at a target address based on the read data packet;

[0041] The slave generates a target data packet based on the target data, and sends the target data packet through its sending end;

[0042] The slave receives a data packet at its receiving end, and compares the received data packet with the target data packet to see whether they are consistent;

[0043] The slave determines whether there is a communication conflict on the bus based on the comparison result.

[0044] In one or more embodiments of the present invention, when the comparison results are consistent, the slave determines that there is no communication conflict on the bus; the method further includes:

[0045] When there is no communication conflict, the slave enters a standby state;

[0046] and / or,

[0047] When the comparison results of the slave are inconsistent, the slave determines that there is a communication conflict on the bus; the method further includes:

[0048] When there is a communication conflict, the slave machine re-receives the read data packet or the write data packet through its receiving end. If the slave machine receives the read data packet at its receiving end, it generates a target data packet based on the target data again, and determines whether there is a communication conflict on the bus based on the comparison result between the received data packet and the target data packet.

[0049] In one or more embodiments of the present invention, the method further comprises:

[0050] The slave determines the baud rate of the host based on the start bit of the write data packet or the start bit of the read data packet received by its receiving end;

[0051] The slave coordinates its own baud rate based on the baud rate of the master;

[0052] and / or,

[0053] The slave performs a CRC check on a write data packet or a read data packet received by its receiving end;

[0054] and / or,

[0055] The slave performs a dedicated address check on a write data packet or a read data packet received by its receiving end.

[0056] In one or more embodiments of the present invention, after the baud rate of the slave is consistent with the baud rate of the host, the slave enters a standby state.

[0057] In one or more embodiments of the present invention, the method further comprises:

[0058] When the written data packet fails to pass the CRC check, the slave enters a standby state;

[0059] and / or,

[0060] When the read data packet fails to pass the CRC check, the slave enters a standby state;

[0061] and / or,

[0062] After the write data packet passes the CRC check, the slave writes the data in the write data packet into the target address;

[0063] and / or,

[0064] After the read data packet passes the CRC check, the slave obtains target data at a target address based on the read data packet.

[0065] Another embodiment of the present invention provides a technical solution as follows:

[0066] A single-line bidirectional communication system, the single-line bidirectional communication system comprising a host and a slave, the host and the slave communicate via a single bus;

[0067] The host generates a write data packet based on the write data request, and sends the write data packet through its sending end;

[0068] The host receives the data packet at its receiving end, and compares the received data packet with the written data packet to see whether they are consistent;

[0069] The host determines whether there is a communication conflict on the bus based on the comparison result.

[0070] Another embodiment of the present invention provides a technical solution as follows:

[0071] A single-line bidirectional communication system, the single-line bidirectional communication system comprising a host and a slave, the host and the slave communicate via a single bus;

[0072] The slave receives a read data packet at its receiving end, and acquires target data at a target address based on the read data packet;

[0073] The slave generates a target data packet based on the target data, and sends the target data packet through its sending end;

[0074] The slave receives a data packet at its receiving end, and compares the received data packet with the target data packet to see whether they are consistent;

[0075] The slave determines whether there is a communication conflict on the bus based on the comparison result.

[0076] In one or more embodiments of the present invention, the host includes a transmitting end, a receiving end, a first chip, a first resistor and a first transistor; wherein,

[0077] The first chip is connected between a power supply voltage and a ground potential, and the first chip includes an asynchronous transceiver, a transmitting end of the asynchronous transceiver is connected to a transmitting end of a host, and a receiving end of the asynchronous transceiver is connected to a receiving end of the host;

[0078] The control end of the first transistor is connected to the transmitting end of the host, the first end of the first transistor is connected to the receiving end of the host, and the second end of the first transistor is connected to the ground potential;

[0079] A first end of the first resistor is connected to a power supply voltage, and a second end of the first resistor is connected to a first end of the first transistor and a first end of the bus; and / or,

[0080] The slave includes a second resistor, a second transistor, an asynchronous receiver-transmitter logic unit, a state control machine and a storage unit; wherein,

[0081] A first end of the second resistor is connected to an input voltage, and a second end of the second resistor is connected to a first end of the second transistor;

[0082] The second terminal of the second transistor is connected to the ground potential, and the control terminal of the second transistor is connected to the asynchronous receiver-transmitter logic unit;

[0083] The second end of the bus is connected to the first end of the second transistor, and the second end of the bus is directly or indirectly connected to the asynchronous receiver-transmitter logic unit, and the state control machine is connected to the asynchronous receiver-transmitter logic unit and the storage unit.

[0084] In one or more embodiments of the present invention, the single-wire bidirectional communication system includes at least two slaves communicating with the master.

[0085] In one or more embodiments of the present invention, the at least two slaves have corresponding dedicated addresses;

[0086] The slave stores the corresponding dedicated address via a register; and / or,

[0087] The slave device represents the corresponding dedicated address through the levels of at least two slave device pins.

[0088] Another embodiment of the present invention provides a technical solution as follows:

[0089] An electronic device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the single-line bidirectional communication method as described in any one of the embodiments when executing the program.

[0090] Another embodiment of the present invention provides a technical solution as follows:

[0091] A computer-readable storage medium carries computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the single-line bidirectional communication method described in any embodiment.

[0092] Compared with the prior art, the single-line bidirectional communication method, system, electronic device and readable storage medium of the present invention, when the host and the slave communicate data, perform data self-verification in a "self-sending and self-receiving" manner by verifying the consistency between the sent data and the received data, thereby avoiding communication conflicts when the host and the slave transmit data on the line at the same time;

[0093] The present invention supports automatic baud rate detection, ensures the stability and accuracy of data transmission, and can improve communication efficiency;

[0094] The present invention also effectively enhances the anti-interference ability of the single-line bidirectional communication between the host and the slave by performing CRC check on the data packet, thereby improving the reliability of data transmission;

[0095] The host of the present invention communicates with the slave through an asynchronous transceiver, has strong compatibility and is highly adaptable to the traditional UART communication protocol; the host and the slave adopt a line-and-logic connection method, and the circuit structure and connection method are simple; the slave structure of the present invention is simple, and the chip size consumption can be reduced. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0097] Figure 1 This is a flow chart of a single-line bidirectional communication method in Embodiment 1 of the present invention;

[0098] Figure 2 A schematic diagram of a read data packet, a write data packet or a target data packet in a single-line bidirectional communication method according to an embodiment of the present invention;

[0099] Figure 3 is a flow chart of a single-line bidirectional communication method in Embodiment 2 of the present invention;

[0100] Figure 4 This is a host operating process diagram of the single-line bidirectional communication method in Example 2 of the present invention;

[0101] Figure 5 is a flow chart of a single-line bidirectional communication method in Embodiment 3 of the present invention;

[0102] Figure 6 FIG. 3 is a slave machine working flow chart of the single-line bidirectional communication method in Embodiment 3 of the present invention;

[0103] Figure 7 It is a schematic diagram of a single-line bidirectional communication system in Embodiment 4 of the present invention;

[0104] Figure 8 4 is a circuit structure diagram of a single-line bidirectional communication system in Embodiment 4 of the present invention;

[0105] Fig. 9 is a schematic diagram of a single-line bidirectional communication system in Embodiment 5 of the present invention;

[0106] Fig.10 FIG. 4 is a hardware structure diagram of an electronic device in one embodiment of the present invention. DETAILED DESCRIPTION

[0107] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0108] The term "coupled" or "connected" or "connected" in the specification includes both direct connection and indirect connection. Indirect connection is a connection through an intermediate medium, such as a connection through an electrically conductive medium, which may have parasitic inductance or parasitic capacitance; indirect connection may also include connection through other active or passive devices on the basis of achieving the same or similar functional purpose, such as connection through circuits or components such as switches and follower circuits. In addition, in the present invention, words such as "first" and "second" are mainly used to distinguish one technical feature from another technical feature, and do not necessarily require or imply that there is a certain actual relationship, quantity or order between these technical features.

[0109] Embodiment 1:

[0110] like Figure 1 As shown, a single-line bidirectional communication method in this embodiment is applied to a single-line bidirectional communication system. The single-line bidirectional communication system includes a host and a slave. The host and the slave communicate through a single bus. The method includes the following steps.

[0111] In step S11, the host generates a write data packet based on the write data request, and sends the write data packet through its sending end. It can be understood that before step S11, the host will also be initialized and enter a standby state.

[0112] In step S12, the host receives the data packet at its receiving end, and compares the received data packet with the written data packet to see whether they are consistent.

[0113] In step S13, the host determines whether there is a communication conflict on the bus based on the comparison result.

[0114] Step S13 specifically includes:

[0115] When the comparison results are consistent, the host determines that there is no communication conflict on the bus, and when there is no communication conflict, the host enters a standby state.

[0116] When the comparison results are inconsistent, the host determines that there is a communication conflict on the bus. Further, when there is a communication conflict, the host re-sends the write data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result of the data packet received by its receiving end and the write data packet, until the host ends the loop state and enters the standby state when the comparison results are consistent.

[0117] like Figure 2 As shown, the write data packet in this embodiment includes address byte byte 1, data byte byte 2 and CRC check byte byte 3. Further, CRC check byte byte 3 includes CRC check information. Address byte byte 1 includes write command bit or read command bit r / w, and address bit addr.

[0118] The write command bit or read command bit r / w is used to indicate whether the data packet is a write data packet or a read input packet. In this embodiment, the host generates a write data packet based on a write data request, so the write command bit or read command bit r / w in this embodiment can extract a "write command". The address bit addr is used to indicate that the slave needs to write the data in the data byte byte2 to the address after receiving the data packet.

[0119] Furthermore, if the single-line bidirectional communication system includes at least two slaves communicating with the host, the address byte byte1 also includes a dedicated address bit corresponding to the slave, and the dedicated address bit is used to represent the dedicated address of the target slave of the write data packet. It can be understood that when at least two slaves communicate with the host, the host sends the write data packet to all slaves communicating with it, and the slave determines whether the write data packet is required by itself through its own dedicated address, that is, if the dedicated address bit of the address byte byte1 of the write data packet is consistent with the dedicated address corresponding to the slave, then the write data packet passes the dedicated address check, and the slave can perform operations such as extracting commands on the write data packet.

[0120] Embodiment 2:

[0121] like Figure 3 As shown, a single-line bidirectional communication method in this embodiment is applied to a single-line bidirectional communication system. The single-line bidirectional communication system includes a host and a slave. The host and the slave communicate through a single bus. The method includes the following steps.

[0122] In step S21, the host generates a read data packet based on the read data request, and sends the read data packet through its sending end. It can be understood that before step S21, the host will also be initialized and enter a standby state.

[0123] In step S22, the host receives the data packet at its receiving end and compares the received data packet with the read data packet to see if they are consistent;

[0124] In step S23, the host determines whether there is a communication conflict on the bus based on the comparison result.

[0125] Step S23 specifically includes:

[0126] When the comparison results are consistent, the host determines that there is no communication conflict on the bus. Further, when there is no communication conflict, when the host times out when receiving the target data packet sent by the slave, the host resends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result of the data packet received by its receiving end and the read data packet.

[0127] That is, if the host does not receive the target data packet sent by the slave within the set time, the host will loop and execute "the host sends a read data packet through its transmitting end, the host receives the data packet at its receiving end, and compares the received data packet with the read data packet to see if they are consistent", until the host receives the target data packet sent by the slave within the set time, the above loop is terminated, and the target data packet sent by the slave is subjected to CRC check.

[0128] When the comparison results of the host are inconsistent, it is determined that there is a communication conflict on the bus. When there is a communication conflict, the host re-sends the read data packet through its transmitting end, and again determines whether there is a communication conflict on the bus based on the comparison result of the data packet received by its receiving end with the read data packet, until the host ends the loop state and enters the standby state when the comparison results are consistent.

[0129] Furthermore, the host enters a standby state after the target data packet passes the CRC check. When the target data packet fails the CRC check, the host resends the read data packet through its transmitting end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet.

[0130] like Figure 2As shown, the write data packet and the target data packet in this embodiment both include the address byte byte1, the data byte byte2 and the CRC check byte byte3. Furthermore, the address byte byte1 includes a write command bit or a read command bit r / w, and an address bit addr. Among them, the write command bit or the read command bit r / w is used to indicate whether the data packet is a write data packet or a read input packet. In this embodiment, the host generates a read data packet based on a read data request, so the "read command" can be extracted from the write command bit or the read command bit r / w in this embodiment. The address bit addr is used to indicate that after receiving the data packet, the slave needs to write the data in the data byte byte2 to the address, or the slave needs to obtain the target data in the address represented by the address bit addr.

[0131] Furthermore, if the single-line bidirectional communication system includes at least two slaves communicating with the host, the address byte byte1 also includes a dedicated address bit corresponding to the slave, and the dedicated address bit is used to represent the dedicated address of the target slave of the write data packet. It can be understood that when at least two slaves communicate with the host, the host sends the write data packet to all slaves communicating with it, and the slave determines whether the write data packet is required by itself through its own dedicated address, that is, if the dedicated address bit of the address byte byte1 of the write data packet is consistent with the dedicated address corresponding to the slave, then the write data packet passes the dedicated address check, and the slave can perform operations such as extracting commands on the write data packet.

[0132] In this embodiment, the CRC check is implemented by the CRC check byte byte 3 in the target data packet. The CRC check byte byte 3 contains the CRC check information.

[0133] like Figure 4 A single-line two-way communication method is shown, wherein the working process of the host includes the single-line two-way communication method in embodiments 1 and 2.

[0134] Embodiment 3:

[0135] like Figure 5 As shown, a single-line bidirectional communication method in this embodiment is applied to a single-line bidirectional communication system. The single-line bidirectional communication system includes a host and a slave. The host and the slave communicate through a single bus. The method includes the following steps.

[0136] In step 31, the slave receives a read data packet at its receiving end, and obtains target data at the target address based on the read data packet. It is understandable that if the receiving end of the slave receives a write data packet, the slave writes the data of the write data packet into the address corresponding to the write based on the command of the write data packet, and enters the standby state.

[0137] In step 32, the slave generates a target data packet based on the target data, and sends the target data packet through its sending end.

[0138] In step 33, the slave receives the data packet at its receiving end, and compares the received data packet with the target data packet to see whether they are consistent.

[0139] In step 34, the slave determines whether there is a communication conflict on the bus based on the comparison result.

[0140] Step 34 specifically includes:

[0141] When the comparison results of the slave are consistent, it is determined that there is no communication conflict on the bus. When there is no communication conflict, the slave enters the standby state.

[0142] When the comparison results of the slave are inconsistent, it is determined that there is a communication conflict on the bus, and the slave returns to the state after power-on. That is, when there is a communication conflict, the slave receives the read data packet or the write data packet again through its receiving end. If the slave receives the read data packet at its receiving end, it obtains the target data at the target address based on the read data packet again, generates a target data packet based on the target data and sends the target data packet through its sending end, receives the data packet at its receiving end, and determines whether there is a communication conflict on the bus based on the comparison result of the received data packet and the target data packet.

[0143] like Figure 6 As shown, the slave in this embodiment first performs a power-on operation, and the slave receives a write data packet or a read data packet from the host through its own receiving end, and determines the baud rate of the host. Specifically, the slave determines the baud rate of the host based on the start bit of the write data packet or the start bit of the read data packet received by it. If the start bit received by the slave is low, it means that the slave has received a data packet from the host and needs to determine its baud rate and coordinate its own baud rate.

[0144] like Figure 2 As shown, the write data packet, read data packet and target data packet in this embodiment all include address byte byte 1, data byte byte 2 and CRC check byte byte 3. Further, address byte byte 1 includes a write command bit or a read command bit r / w, and an address bit addr. The write command bit or the read command bit r / w is used to indicate whether the data packet is a write data packet or a read input packet.

[0145] The start bit of the address byte byte1 in this embodiment is 0, that is, a low level. The highest bit 8 bits of the address byte byte1 are 1, that is, a high level. It can be understood that after power-on, the slave will enter a state of continuous bit reception. Once the slave receives a low-level bit (that is, the start bit is 0), it indicates that the slave needs to perform baud rate detection, that is, obtain the host's bit rate based on the pulse width of the start bit startbit, and before the next low-level bit arrives, coordinate its own bit rate to make the slave's baud rate consistent with the host's baud rate.

[0146] like Figure 6 As shown, further, after the baud rate of the slave is consistent with the baud rate of the host, the slave enters the standby state and continues to receive new bytes until a complete write data packet or a read data packet is received. Therefore, it can be understood that when the slave determines that there is a communication conflict on the bus, the slave returns to the state after power-on in order to continue to receive new bytes and perform baud rate matching until a new complete read data packet or a new complete write data packet is received.

[0147] The slave performs a CRC check on the received write data packet or read data packet. In this embodiment, the CRC check is implemented by the CRC check byte byte3 in the target data packet. The CRC check byte byte3 contains the CRC check information.

[0148] It is understandable that if the check fails, the slave enters the standby state. After the write data packet passes the CRC check, the slave writes the data in the write data packet to the target address, and after the read data packet passes the CRC check, the slave obtains the target data at the target address based on the read data packet.

[0149] Specifically, if the data packet received by the slave is a write data packet, the write command bit or the read command bit r / w of the address byte byte1 should be extracted as the write command, and the slave writes the data in the write data packet to the corresponding target address and then enters the standby state. Conversely, if the data packet received by the slave is a read data packet, the write command bit or the read command bit r / w of the address byte byte1 should be extracted as the read command, and the slave executes the above steps 31 to 34.

[0150] Furthermore, if the single-line bidirectional communication system includes at least two slaves communicating with the host, after receiving a new byte until a complete write data packet or read data packet is received, the slave also needs to perform a dedicated address check on the write data packet or read data packet received by its receiving end.

[0151] Specifically, the address byte byte1 also includes a dedicated address bit corresponding to the slave, and the dedicated address bit is used to represent the dedicated address of the target slave of the write data packet or the read data packet. It can be understood that when at least two slaves communicate with the host, the host sends the write data packet or the read data packet to all the slaves communicating with it, and the slave determines whether the write data packet or the read data packet is required by itself through its own dedicated address.

[0152] When the dedicated address in the write data packet of the slave is inconsistent with the dedicated address of the slave itself, it is determined that the write data packet has not passed the dedicated address check. When the dedicated address in the read data packet of the slave is inconsistent with the dedicated address of the slave itself, it is determined that the read data packet has not passed the dedicated address check. If the dedicated address bit of the address byte byte1 of the write data packet is consistent with the dedicated address corresponding to the slave, or the dedicated address bit of the address byte byte1 of the read data packet is consistent with the dedicated address corresponding to the slave, then the write data packet or the read data packet has passed the dedicated address check, and the slave can perform operations such as extracting commands on the write data packet.

[0153] like Figure 2 As shown, the write data packet, read data packet and target data packet in this embodiment all include address byte byte1, data byte byte2 and CRC check byte byte3. Further, address byte byte1 includes write command bit or read command bit r / w, and address bit addr. Among them, the write command bit or read command bit r / w is used to indicate whether the data packet is a write data packet or a read input packet. In this implementation, the host reads data request to generate a read data packet, so the write command bit or read command bit r / w in this embodiment represents "read". The address bit addr is used to indicate that after receiving the data packet, the slave needs to write the data in the data byte byte2 to the address, or obtain the target data in the address represented by the address bit addr.

[0154] Furthermore, if the single-line bidirectional communication system includes at least two slaves communicating with the host, the address byte byte1 also includes a dedicated address bit corresponding to the slave, and the dedicated address bit is used to represent the dedicated address of the target slave of the write data packet. It can be understood that when at least two slaves communicate with the host, the host sends the write data packet to all slaves communicating with it, and the slave determines whether the write data packet is required by itself through its own dedicated address, that is, if the dedicated address bit of the address byte byte1 of the write data packet is consistent with the dedicated address corresponding to the slave, then the write data packet passes the dedicated address check, and the slave can perform operations such as extracting commands on the write data packet.

[0155] Embodiment 4:

[0156] like Figure 7 As shown, a single-line bidirectional communication system in this embodiment includes a host 41 and a slave 42. The host 41 and the slave 42 communicate through a single bus.

[0157] The host 41 in this embodiment generates a write data packet based on a write data request and sends the write data packet through its transmitting end; the host 41 receives the data packet at its receiving end and compares the received data packet with the write data packet to see if they are consistent; the host 41 determines whether there is a communication conflict on the bus based on the comparison result.

[0158] The slave 42 in this embodiment receives a read data packet at its receiving end, and obtains target data at the target address based on the read data packet; the slave 42 generates a target data packet based on the target data, and sends the target data packet through its transmitting end; the slave 42 receives a data packet at its receiving end, and compares the received data packet with the target data packet to see if they are consistent; the slave 42 determines whether there is a communication conflict on the bus based on the comparison result.

[0159] like Figure 8 As shown, the host in this embodiment includes a transmitting end, a receiving end, a first chip, a first resistor R1 and a first transistor M1.

[0160] The first chip is connected between the power supply voltage VCC and the ground potential, and includes an asynchronous transceiver UART, a transmitting end TXD of the asynchronous transceiver is connected to a transmitting end of the host 41, and a receiving end RXD of the asynchronous transceiver is connected to a receiving end of the host 41. The first chip in this embodiment may be an MCU or an MPU.

[0161] The control end of the first transistor M1 is connected to the transmitting end of the host 41, the first end of the first transistor M1 is connected to the receiving end of the host 41, and the second end of the first transistor M1 is connected to the ground potential. Optionally, the first end of the first transistor M1 is a source, the second end is a drain, and the control end is a gate.

[0162] A first end of the first resistor R1 is connected to the power supply voltage VCC, and a second end of the first resistor R1 is connected to a first end of the first transistor M1 and a first end of the bus.

[0163] like Figure 8 As shown, the slave in this embodiment includes a second resistor R2, a second transistor M2, an asynchronous receiver-transmitter logic unit, a state control machine and a storage unit. Optionally, the slave in this embodiment is an AFE (analog front end) chip.

[0164] The first end of the second resistor R2 is connected to the input voltage VDD, and the second end of the second resistor R2 is connected to the first end of the second transistor M2. The second end of the second transistor M2 is connected to the ground potential, and the control end of the second transistor M2 is connected to the asynchronous receiver-transmitter logic unit. Optionally, the first end of the second transistor M2 is a source, the second end is a drain, and the control end is a gate.

[0165] The second end of the bus is connected to the first end of the second transistor M2, and the second end of the bus is directly connected to the asynchronous receiver-transmitter logic unit, or the second end of the bus is connected to the buffer Buffer, and the buffer Buffer is connected to the asynchronous receiver-transmitter logic unit. The state control machine is connected to the asynchronous receiver-transmitter logic unit and the storage unit.

[0166] The asynchronous transceiver logic unit in this embodiment is used to implement data serialization: converting parallel data into serial data for transmission through a single communication line. The asynchronous transceiver logic unit is also used to implement data deserialization: receiving serial data and converting it back into parallel data for use by the AFE chip or external devices. The asynchronous transceiver logic unit follows the UART communication protocol.

[0167] The state controller in this embodiment is used to manage and control various functions and states inside the slave, so that the slave can implement the single-line bidirectional communication method in embodiment 1, 2 or 3.

[0168] Furthermore, the storage unit in this embodiment may be an electrically erasable programmable read only memory (EEPROM), or the storage unit may be a register map.

[0169] Embodiment 5:

[0170] like Fig. 9 As shown, a single-line bidirectional communication system in this embodiment is different from Embodiment 4 in that: the single-line bidirectional communication system includes at least two slaves communicating with the host.

[0171] At least two slaves have corresponding private addresses. That is, each slave is assigned a different private address. When at least two slaves communicate with the host, the host sends a write data packet or a read data packet to all slaves communicating with it. The slave determines whether the write data packet or the read data packet is required by itself through its own private address. That is, if the private address bit of the address byte byte1 of the write data packet or the read data packet is consistent with the private address corresponding to the slave, then the write data packet or the read data packet passes the private address check, and the slave can perform operations such as extracting commands on the write data packet.

[0172] Furthermore, the slave in this embodiment stores the corresponding dedicated address through a register. Or the slave in this embodiment represents the corresponding dedicated address through the level of at least two slave pins, that is, when designing the board-level PCB, several pins of the slave are set to different high and low levels, such as the first pin is low and the second pin is high. Its dedicated address can be understood as 01. If the dedicated address bit of the address byte byte1 of the write data packet or the read data packet is 01, the write data packet or the read data packet passes the dedicated address check, and the slave can perform operations such as extracting commands on the write data packet. On the contrary, if the dedicated address bit of the address byte byte1 of the write data packet or the read data packet is 00 or 11, etc., it means that the dedicated address check of the data packet has not passed, and the data packet is not required by this slave.

[0173] like Figure 2 As shown, the write data packet, read data packet and target data packet in this embodiment all include address byte byte1, data byte byte2 and CRC check byte byte3. Furthermore, address byte byte1 includes write command bit or read command bit r / w, and address bit addr. Among them, the write command bit or read command bit r / w is used to indicate whether the data packet is a write data packet or a read input packet, and the address bit addr is used to indicate that the slave needs to write the data in data byte byte2 to the address after receiving the data packet, or the slave needs to obtain the target data in the address represented by address bit addr. Address byte byte1 also includes a dedicated address bit corresponding to the slave, and the dedicated address bit is used to indicate the dedicated address of the target slave of the write data packet.

[0174] Fig.10 FIG. 1 shows a hardware structure diagram of an electronic device according to an embodiment of the present specification. Figure 5 As shown, the electronic device 50 may include at least one processor 51, a memory 52 (e.g., a non-volatile memory), a memory 53, and a communication interface 54, and the at least one processor 51, the memory 52, the memory 53, and the communication interface 54 are connected together via a bus 55. At least one processor 51 executes at least one computer-readable instruction stored or encoded in the memory 52.

[0175] It should be understood that the computer executable instructions stored in the memory 52, when executed, cause at least one processor 51 to perform the above combined operations in various embodiments of the present specification. Figures 1 to 6 Describes the various operations and functions.

[0176] In the embodiments of the present specification, the electronic device 50 may include, but is not limited to: a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile electronic device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable electronic device, a consumer electronic device, and the like.

[0177] According to one embodiment, a program product such as a machine-readable medium is provided. The machine-readable medium may have instructions (i.e., the above-mentioned elements implemented in the form of software), which, when executed by a machine, causes the machine to perform the above-mentioned combination of various embodiments of this specification. Figures 1 to 6 Specifically, a system or device equipped with a readable storage medium may be provided, on which a software program code implementing the functions of any of the above-mentioned embodiments is stored, and a computer or processor of the system or device reads and executes the instructions stored in the readable storage medium.

[0178] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification.

[0179] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.

[0180] Those skilled in the art should understand that the various embodiments disclosed above can be modified and altered in various ways without departing from the essence of the invention. Therefore, the protection scope of this specification should be defined by the appended claims.

[0181] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be determined as needed. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical client, or some units may be implemented by multiple physical clients, or some components in multiple independent devices may be implemented together.

[0182] In the above embodiments, the hardware unit or module can be realized by mechanical or electrical means. For example, a hardware unit, module or processor can include permanent dedicated circuit or logic (such as special processor, FPGA or ASIC) to complete the corresponding operation. The hardware unit or processor can also include programmable logic or circuit (such as general-purpose processor or other programmable processor), which can be temporarily set by software to complete the corresponding operation. Specific implementation (mechanical method or dedicated permanent circuit or temporary circuit) can be determined based on cost and time consideration.

[0183] The specific embodiments described above in conjunction with the accompanying drawings describe exemplary embodiments, but do not represent all embodiments that can be implemented or fall within the scope of protection of the claims. The term "exemplary" used throughout this specification means "used as an example, instance or illustration" and does not mean "preferred" or "having advantages" over other embodiments. For the purpose of providing an understanding of the described technology, the specific embodiments include specific details. However, these technologies can be implemented without these specific details. In some instances, in order to avoid making the concepts of the described embodiments difficult to understand, well-known structures and devices are shown in block diagram form.

[0184] The above description of the present disclosure is provided to enable any person of ordinary skill in the art to implement or use the present disclosure. Various modifications to the present disclosure will be apparent to those of ordinary skill in the art, and the general principles corresponding to the present disclosure may be applied to other variations without departing from the scope of protection of the present disclosure. Therefore, the present disclosure is not limited to the examples and designs described herein, but is consistent with the widest range of principles and novel features disclosed herein.

Claims

1. A single-line bidirectional communication method, applied to a single-line bidirectional communication system, wherein the single-line bidirectional communication system comprises a host and a slave, wherein the host and the slave communicate via a single bus, It is characterized in that The method comprises: The host generates a write data packet based on the write data request, and sends the write data packet through its sending end; The host receives the data packet at its receiving end, and compares the received data packet with the written data packet to see whether they are consistent; The host determines whether there is a communication conflict on the bus based on the comparison result.

2. The single-line bidirectional communication method according to claim 1, It is characterized in that When the comparison results are consistent, the host determines that there is no communication conflict on the bus; the method also includes: When there is no communication conflict, the host enters a standby state; and / or, When the comparison results are inconsistent, the host determines that there is a communication conflict on the bus; the method further includes: When there is a communication conflict, the host re-sends the write data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the write data packet.

3. The single-line bidirectional communication method according to claim 1 or 2, It is characterized in that The write data packet includes an address byte, a data byte and a CRC check byte; wherein, The address byte includes a write command bit or a read command bit, and / or the address byte includes a dedicated address bit corresponding to the slave.

4. A single-line bidirectional communication method, applied to a single-line bidirectional communication system, the single-line bidirectional communication system comprising a host and a slave, the host and the slave communicating via a single bus, It is characterized in that The method comprises: The host generates a read data packet based on the read data request, and sends the read data packet through its sending end; The host receives the data packet at its receiving end, and compares the received data packet with the read data packet to see whether they are consistent; The host determines whether there is a communication conflict on the bus based on the comparison result.

5. The single-line bidirectional communication method according to claim 4, It is characterized in that When the comparison results are consistent, the host determines that there is no communication conflict on the bus; the method also includes: When there is no communication conflict, the host receives the target data packet sent by the slave and performs a CRC check; and / or, When the comparison results are inconsistent, the host determines that there is a communication conflict on the bus; the method further includes: When there is a communication conflict, the host re-sends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet.

6. The single-line bidirectional communication method according to claim 5, It is characterized in that The method further comprises: The host enters a standby state after the target data packet passes the CRC check; and / or, When the target data packet fails to pass the CRC check, the host resends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet; and / or, When the host times out when receiving the target data packet sent by the slave, it resends the read data packet through its sending end, and again determines whether there is a communication conflict on the bus based on the comparison result between the data packet received by its receiving end and the read data packet.

7. The single-line bidirectional communication method according to any one of claims 5 or 6, It is characterized in that The read data packet includes an address byte, a data byte and a CRC check byte; wherein, The address byte includes a write command bit or a read command bit; and / or, The target data packet includes an address byte, a data byte and a CRC check byte; wherein, The address byte includes a write command bit or a read command bit; and / or, the address byte includes a dedicated address bit corresponding to the slave.

8. A single-line bidirectional communication method, applied to a single-line bidirectional communication system, the single-line bidirectional communication system comprising a host and a slave, the host and the slave communicating via a single bus, It is characterized in that The method comprises: The slave receives a read data packet at its receiving end, and acquires target data at a target address based on the read data packet; The slave generates a target data packet based on the target data, and sends the target data packet through its sending end; The slave receives a data packet at its receiving end, and compares the received data packet with the target data packet to see whether they are consistent; The slave determines whether there is a communication conflict on the bus based on the comparison result.

9. The single-line bidirectional communication method according to claim 8, It is characterized in that When the comparison results are consistent, the slave determines that there is no communication conflict on the bus; the method further includes: When there is no communication conflict, the slave enters a standby state; and / or, When the comparison results of the slave are inconsistent, the slave determines that there is a communication conflict on the bus; the method further includes: When there is a communication conflict, the slave machine re-receives the read data packet or the write data packet through its receiving end. If the slave machine receives the read data packet at its receiving end, it generates a target data packet based on the target data again, and determines whether there is a communication conflict on the bus based on the comparison result between the received data packet and the target data packet.

10. The single-line bidirectional communication method according to claim 8, It is characterized in that The method further comprises: The slave determines the baud rate of the host based on the start bit of the write data packet or the start bit of the read data packet received by its receiving end; The slave coordinates its own baud rate based on the baud rate of the master; and / or, The slave performs a CRC check on a write data packet or a read data packet received by its receiving end; and / or, The slave performs a dedicated address check on a write data packet or a read data packet received by its receiving end.

11. The single-line bidirectional communication method according to claim 10, It is characterized in that The method further comprises: When the written data packet fails to pass the CRC check, the slave enters a standby state; and / or, When the read data packet fails to pass the CRC check, the slave enters a standby state; and / or, After the write data packet passes the CRC check, the slave writes the data in the write data packet into the target address; and / or, After the read data packet passes the CRC check, the slave obtains target data at a target address based on the read data packet.

12. A single-line two-way communication system, It is characterized in that The single-line bidirectional communication system comprises a host and a slave, and the host and the slave communicate via a single bus; The host generates a write data packet based on the write data request, and sends the write data packet through its sending end; The host receives the data packet at its receiving end, and compares the received data packet with the written data packet to see whether they are consistent; The host determines whether there is a communication conflict on the bus based on the comparison result.

13. A single-line two-way communication system, It is characterized in that The single-line bidirectional communication system comprises a host and a slave, and the host and the slave communicate via a single bus; The slave receives a read data packet at its receiving end, and acquires target data at a target address based on the read data packet; The slave generates a target data packet based on the target data, and sends the target data packet through its sending end; The slave receives a data packet at its receiving end, and compares the received data packet with the target data packet to see whether they are consistent; The slave determines whether there is a communication conflict on the bus based on the comparison result.

14. A single-line two-way communication system according to claim 12 or 13, It is characterized in that The host includes a transmitting end, a receiving end, a first chip, a first resistor and a first transistor; wherein, The first chip is connected between a power supply voltage and a ground potential, and the first chip includes an asynchronous transceiver, a transmitting end of the asynchronous transceiver is connected to a transmitting end of a host, and a receiving end of the asynchronous transceiver is connected to a receiving end of the host; The control end of the first transistor is connected to the transmitting end of the host, the first end of the first transistor is connected to the receiving end of the host, and the second end of the first transistor is connected to the ground potential; A first end of the first resistor is connected to a power supply voltage, and a second end of the first resistor is connected to a first end of the first transistor and a first end of the bus; and / or, The slave includes a second resistor, a second transistor, an asynchronous receiver-transmitter logic unit, a state control machine and a storage unit; wherein, A first end of the second resistor is connected to an input voltage, and a second end of the second resistor is connected to a first end of the second transistor; The second terminal of the second transistor is connected to the ground potential, and the control terminal of the second transistor is connected to the asynchronous receiver-transmitter logic unit; The second end of the bus is connected to the first end of the second transistor, and the second end of the bus is directly or indirectly connected to the asynchronous receiver-transmitter logic unit, and the state control machine is connected to the asynchronous receiver-transmitter logic unit and the storage unit.

15. The single-line bidirectional communication system according to claim 12 or 13, It is characterized in that The single-wire bidirectional communication system includes at least two slaves communicating with the master.

16. The single-line two-way communication system according to claim 15, It is characterized in that The at least two slaves have corresponding dedicated addresses; The slave stores the corresponding dedicated address via a register; and / or, The slave device represents the corresponding dedicated address through the levels of at least two slave device pins.

17. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, It is characterized in that When the processor executes the program, the single-wire bidirectional communication method according to any one of claims 1 to 11 is implemented.

18. A computer-readable storage medium, It is characterized in that The computer-readable storage medium carries computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the single-wire bidirectional communication method according to any one of claims 1 to 11.