Unibus-based communication method and device, electronic equipment and readable storage medium
By using the level status after the response to determine the start time of the communication frame in the single-bus communication between embedded devices, the problem of low transmission efficiency is solved and efficient communication without setting the start bit is achieved.
Patent Information
- Application Number
- CN202410542697.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2024-08-23
Smart Images

Figure CN118535511A
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of communication technology, and in particular relates to a single bus-based communication method, device, electronic equipment and readable storage medium. Background Art
[0002] The emergence of embedded devices has greatly facilitated people's lives. Communication between embedded devices is an important task of embedded devices. Single bus communication is one of the important ways of communication between embedded devices. Single bus communication only requires a single bus to complete the data transmission between the embedded device host and the embedded device slave.
[0003] However, in the single bus communication process between embedded devices, the start bit needs to be transmitted before the valid data is transmitted. The start bit represents the clock signal to indicate the start of the valid data transmission, and the valid data transmission starts after the start bit is transmitted. Therefore, the start bit needs to be transmitted before each valid data transmission, which brings inconvenience to the data transmission between embedded devices and leads to low communication efficiency between embedded devices. Summary of the invention
[0004] The present invention provides a single bus communication method, device, electronic device and readable storage medium, so as to solve the problem that a start bit needs to be transmitted before each transmission of valid data during single bus communication, resulting in low efficiency.
[0005] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0006] In a first aspect, the present invention provides a single bus communication method, which is applied to a first device, wherein the first device is connected to a second device via a single bus, and the method comprises:
[0007] Based on the response corresponding to the start instruction, determining the level state of the single bus after transmitting the response;
[0008] A communication frame is sent to the second device based on a preset coding rule; wherein the first communication frame is used for the second device to parse data values and for the second device to obtain a clock signal; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response; when the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes two identical level states, it corresponds to the second data value.
[0009] In a second aspect, the present invention provides a single bus-based communication method, which is applied to a second device, wherein the first device is connected to the second device via a single bus, and the method comprises: receiving a communication frame sent by the first device; upon receiving the first communication frame, parsing the data value corresponding to the first communication frame and parsing the clock signal according to a preset decoding rule; upon parsing the clock signal, parsing subsequent communication frames based on the clock signal and the preset decoding rule.
[0010] In a third aspect, the present invention provides a single bus communication device, which is applied to a first device, wherein the first device is connected to a second device via a single bus, and the device comprises:
[0011] A response module, used for determining a level state of the single bus after transmitting the response based on the response corresponding to the start instruction;
[0012] A sending module, used for sending a communication frame to the second device based on a preset coding rule; wherein the first communication frame is used for the second device to parse a data value and for the second device to obtain a clock signal; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response; when the communication frame includes two different level states, it corresponds to a first data value; when the communication frame includes two identical level states, it corresponds to a second data value.
[0013] In a fourth aspect, the present invention provides a single bus communication device, which is applied to a second device, wherein the second device is connected to a first device via a single bus, and the device comprises:
[0014] A receiving module, used for receiving a communication frame sent by the first device;
[0015] A first parsing module is used to parse the data value corresponding to the first communication frame and the clock signal according to a preset decoding rule when the first communication frame is received;
[0016] The second parsing module is used to parse subsequent communication frames based on the clock signal and preset decoding rules when a clock signal is parsed.
[0017] In a fifth aspect, the present invention provides an electronic device, characterized in that it includes:
[0018] A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the single bus-based communication method as described in the first aspect or the single bus-based communication method as described in the second aspect is implemented.
[0019] In a sixth aspect, the present invention provides a readable storage medium, characterized in that it includes: when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the single bus-based communication method described in the first aspect or execute the single bus-based communication method described in the second aspect.
[0020] In an embodiment of the present invention, after a response, the first communication frame is sent starting from a level state different from the level state after the response is transmitted via a single bus, so that a level jump is generated after the response, and the start transmission time of the communication frame is determined by the level jump, and a clock signal is obtained. At the same time, when the communication frame includes two different level states, it corresponds to a first data value; when the communication frame includes two identical level states, it corresponds to a second data value, so that the first communication frame is used for the second device to parse the data value and for the second device to obtain the clock signal, thereby efficiently communicating. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 It is one of the flowcharts of a specific example provided by an embodiment of the present invention;
[0023] Figure 2 is a single bus communication system architecture diagram provided by an embodiment of the present invention;
[0024] Figure 3 This is a second flowchart of a specific example provided by an embodiment of the present invention;
[0025] Figure 4a-4e It is one of the timing diagrams provided by the embodiment of the present invention;
[0026] Figure 5 This is a flowchart of a specific example provided by an embodiment of the present invention;
[0027] Figure 6 This is a second timing diagram provided by an embodiment of the present invention;
[0028] Figures 7a-7d This is a third timing diagram provided by an embodiment of the present invention;
[0029] Figure 8a-8b This is a fourth flowchart of an example provided by an embodiment of the present invention;
[0030] Fig. 9 It is one of the single bus communication devices provided by the embodiment of the present invention;
[0031] Fig.10 This is a second single bus communication device provided by an embodiment of the present invention;
[0032] Fig.11 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are 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 are within the scope of protection of the present invention.
[0034] Figure 2 A single bus communication system architecture in an embodiment of the present invention Fig.11 .like Figure 2 As shown, the system may include a first device 20, a second device 30, and a single bus 40, and the first device and the second device are connected via the single bus.
[0035] In an embodiment of the present invention, the first device may be an embedded device, the second device may be an external device, or the second device may be an embedded device, the first device may be an external device, or both the first device and the second device may be embedded devices. The embedded device includes an MCU (Microcontroller Unit). The MCU is used to process instructions and data, and generate output signals. The I / O port is an interface of the microcontroller unit. The I / O port of the microcontroller unit is connected to an external device or other microcontroller units through a single bus. The I / O port can receive signals from external devices through the bus, and can also send signals to external devices. Therefore, the transmission of various data between the first device and the second device can be implemented based on a single bus, such as the write command, write end, read command, and read end in Figure 7, and the various data transmitted between the first device and the second device, including: write command, write end, read command, and read end, will cause the level of the single bus to change corresponding to the transmitted data, such as Figure 4a-4e As shown, Figure 4a-4e It is the timing diagram corresponding to the single bus when the first device and the second device transmit write command, write end, read command, read end and communication frame.
[0036] Figure 1 110 is a step flow chart of a single bus communication method provided by an embodiment of the present invention, such as Figure 1As shown, the method may include:
[0037] Step 101: Based on a response corresponding to a start instruction, determine a level state of the single bus after transmitting the response.
[0038] In the embodiment of the present invention, before determining the level state of the single bus after transmitting the acknowledgement response, an instruction may be sent to the first device or the second device to initialize the first device and the second device.
[0039] Optionally, an instruction is sent to the first device to instruct the first device to start initialization, and the first device is instructed to send an initialization signal to the second device via a single bus. When the second device replies with a response signal to the initialization signal, it indicates that the second device has completed initialization.
[0040] Optionally, an instruction is sent to the second device to instruct the second device to start initialization, and the second device is instructed to send an initialization signal Tstart to the first device via a single bus. When the first device replies with a response signal Tack to the initialization signal, it indicates that the first device has completed initialization. Figure 6 As shown, an initialization signal Tstart is sent, and after waiting for a waiting time Tde, a response signal Tack for the initialization signal is replied.
[0041] In the embodiment of the present invention, after completing the initialization of the first device and the second device, a start instruction may be transmitted. After the start instruction is transmitted, a response corresponding to the start instruction is transmitted, and the response indicates that the communication frame transmission is ready.
[0042] Since the response is transmitted through the single bus, the level state of the single bus will be affected by the response. If the response ends with a low level, the level state of the single bus will become a low level after the response is transmitted based on the single bus. If the response ends with a high level, the level state of the single bus will become a high level after the response is transmitted based on the single bus. Therefore, the level state of the single bus after the response is transmitted can be determined based on the response. If the response ends with a low level, the level state of the single bus after the response is transmitted is a low level. If the response ends with a high level, the level state of the single bus after the response is transmitted is a high level.
[0043] Step 102, sending a communication frame to the second device based on a preset coding rule; wherein the first communication frame is used for the second device to parse data values and for the second device to obtain a clock signal; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response; when the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes one level state, it corresponds to the second data value.
[0044] In an embodiment of the present invention, when sending a communication frame, the communication frame can be sent in different level states according to the data value corresponding to the communication frame and a preset coding rule. When the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes one level state, it corresponds to the second data value.
[0045] like Figure 4a As shown, in Figure 4a The first data value is logic 0, and the second data value is logic 1, wherein the logic 0 of a communication frame corresponds to a level state on the bus including a high level and a low level, and the logic 1 of a communication frame corresponds to a level state on the bus of a high level or a low level.
[0046] In the embodiment of the present invention, the periods of the communication frames are the same or different.
[0047] In the embodiment of the present invention, the communication frame is transmitted via a single bus. Therefore, when the communication frame is sent to the second device based on the preset coding rule, the level state on the single bus will be affected by the communication frame. Since the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response, when the first device sends the first communication frame, the level state of the single bus changes, resulting in a level jump, and the communication frame transmission start time can be clarified according to the level jump after the response.
[0048] like Figure 4a As shown, in Figure 4a In the embodiment, after the response, the level on the single bus is low, and the first communication frame after the response corresponds to the first data value. Therefore, when the first communication frame is sent, the initial level state of the first communication frame is high, resulting in a level jump.
[0049] In the embodiment of the present invention, considering that the first communication frame needs to correspond to the first data value or the second data value according to the difference in valid data, normal data transmission can be satisfied. Therefore, when the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response, the communication frame includes two different level states, corresponding to the first data value, and the communication frame includes one level state, corresponding to the second data value. That is, if the level state at the end of the first communication frame in the communication frame encoded based on the preset coding rule is different from the level state at the beginning of the first communication frame, the communication frame includes two different level states, at this time, the communication frame corresponds to the first data value; if the level state at the end of the first communication frame is the same as the level state at the beginning of the first communication frame, the communication frame includes one level state, at this time, the communication frame corresponds to the second data value. Thus, when the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response, the first communication frame can correspond to the first data value or the second data value, satisfying normal data transmission.
[0050] In the embodiment of the present invention, the level state of the single bus after transmitting the response can be high level or low level. Figure 4a The response shown starts with a low level, followed by a rising edge, a falling edge, and ends with a low level. Figure 4a After the response is received, the level of the single bus after transmitting the response is low. Figure 4b The response shown starts with a low level, followed by a rising edge, and ends with a high level, so that Figure 4b After the response is received, the level state of the single bus after transmitting the response is high level.
[0051] In order to normally send a communication frame to the second device, and to realize that the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response. In the embodiment of the present invention, when the level state after the single bus transmits the response is low, and the first communication frame corresponds to the first data value, the level state at the beginning of the first communication frame is high, and the level state at the end of the first communication frame is low.
[0052] like Figure 4a As shown, in Figure 4a In the embodiment, after the response, the level state of the single bus is low, and the first communication frame after the response corresponds to the first data value. Therefore, when the first communication frame is sent, the starting level state of the first communication frame is high, and the ending level state of the first communication frame is low.
[0053] In another embodiment of the present invention, when the level state after the single bus transmits the response is high, and the first communication frame corresponds to the first data value, the level state at the beginning of the first communication frame is low, and the level state at the end of the first communication frame is high.
[0054] like Figure 4b As shown, in Figure 4b In the embodiment, after the response, the level state of the single bus is high, and the first communication frame after the response corresponds to the first data value. Therefore, when the first communication frame is sent, the starting level state of the first communication frame is low, and the ending level state of the first communication frame is high.
[0055] In another embodiment of the present invention, when the level state of the response after the single bus transmits the acknowledgement is low and the first communication frame corresponds to the second data value, the level state of the first communication frame is high.
[0056] like Figure 4c As shown, in Figure 4c In the embodiment, after the response, the level state of the single bus is low level, and the first communication frame after the response corresponds to the second data value. At this time, when the first communication frame is sent, the level state of the first communication frame is high level.
[0057] In another embodiment of the present invention, when the level state after the single bus transmits the acknowledgement response is high and the first communication frame corresponds to the second data value, the level state of the first communication frame is low.
[0058] like Figure 4d As shown, in Figure 4d In the embodiment, after the response, the level state of the single bus is a high level, and the first communication frame after the response corresponds to the second data value. At this time, when the first communication frame is sent, the level state of the first communication frame is a low level.
[0059] In an embodiment of the present invention, considering that when the first communication frame corresponds to the first data value, there will be a second communication frame after the first communication frame that also corresponds to the first data value. In order to further improve the transmission efficiency of the communication frame, in an embodiment of the present invention, when the first communication frame corresponds to the first data value, the two-level state interleaving mode of the second communication frame after the first communication frame is different from the two-level interleaving mode of the first communication frame; the second communication frame is a communication frame corresponding to the first data value. That is, the two-level state interleaving modes of each communication frame corresponding to the first data value are different, and the two-level state interleaving modes of the second communication frame are the same, that is, when the first communication frame corresponds to the first data value, and the two-level state interleaving mode of the first communication frame is: the starting level state is low level, and the ending level state is high level, the two-level state interleaving mode of the second communication frame after the first communication frame is: the starting level state of the second communication frame is high level, and the ending level state is low level. When the first communication frame corresponds to the first data value, and the two level states of the first communication frame are interlaced in a manner that the starting level state is a high level and the ending level state is a low level, the two level states of the second communication frame after the first communication frame are interlaced in a manner that the starting level state of the second communication frame is a low level and the ending level state is a high level.
[0060] Compared with a method in which the two level states of each of the second communication frames are interleaved in different ways, a method in which the two level states of each of the second communication frames are interleaved in the same way will improve encoding and parsing efficiency.
[0061] like Figure 4a As shown, in Figure 4a In the embodiment, the first communication frame after the response corresponds to the first data value. Therefore, when the first communication frame is sent, the starting level state of the first communication frame is a high level, and the ending level state of the first communication frame is a low level. For the second communication frame after the first communication frame, the second communication frame corresponds to the first data value, the starting level state of the second communication frame is a low level, and the ending level state of the second communication frame is a high level.
[0062] Optionally, in an embodiment of the present invention, the two level states of each of the second communication frames are interleaved differently, and among the multiple second communication frames corresponding to the same response, there is at least one second communication frame whose starting level state is a low level and whose ending level state is a high level, and there is at least one second communication frame whose starting level state is a high level and whose ending level state is a low level.
[0063] In the embodiment of the present invention, in order to further improve the transmission efficiency, the level states of the communication frames corresponding to adjacent second data values are different.
[0064] The communication frames corresponding to the adjacent second data values refer to that, in the order of the communication frames, there may be at least one communication frame corresponding to the first data value between two communication frames corresponding to the second data values, or there may be no communication frame corresponding to the first data value. Figure 4a As shown, the communication frames are logic 0, logic 1, logic 1, logic 0, logic 0, and logic 1 in sequence. Among them, there is no other logic 0 or logic 1 between the first logic 1 and the second logic 1, so the first logic 1 and the second logic 1 are adjacent, and there are two logic 0s between the second logic 1 and the third logic 1, so the second logic 1 and the third logic 1 are also adjacent, and there is a logic 0 between the third logic 1 and the fourth logic 1, so the third logic 1 and the fourth logic 1 are also adjacent. Compared with the method in which the level state of the communication frame corresponding to the second data value is the same, it is easier to distinguish each communication frame. In the embodiment of the present invention, the period of each communication frame is the same, so Figure 4a In the example, the duration of the level corresponding to each communication frame on the bus is the same.
[0065] In summary, in an embodiment of the present invention, based on the response corresponding to the start instruction, the level state after the single bus transmission of the response response is determined; based on the preset coding rule, a communication frame is sent to the second device; the level state at the beginning of the first communication frame is different from the level state after the single bus transmission of the response response, so that after the response pulse, a level jump is provided, and the time when the communication frame starts to be transmitted is clarified through the level jump. Without setting the start bit before the communication frame, the time when the communication frame starts to be transmitted can also be accurately grasped. On the other hand, when the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes two identical level states, it corresponds to the second data value. Therefore, when the level state at the beginning of the first communication frame is different from the level state after the single bus transmission of the response response, the communication frame can also be transmitted normally. In the embodiment of the present invention, the communication frame can be transmitted normally without setting the start bit before the communication frame, which improves the efficiency of sending the communication frame and can send the communication frame efficiently.
[0066] In another embodiment of the present invention, it includes:
[0067] Step 201, when the first communication frame corresponds to the first data value, obtain the first communication frame to be checked in the second communication frame and the two level state interleaving mode of the first communication frame.
[0068] When sending a communication frame, the first device can verify the first communication frame to be verified corresponding to the first data value, so as to ensure the correctness of sending the communication frame. Specifically, when sending a communication frame, the first device can obtain the data value corresponding to the first communication frame in the communication frame. When the first communication frame corresponds to the first data value, the first device obtains the two level states of the first communication frame in an interleaved manner for use in verification. When the first device sends a communication frame, the first device obtains the first communication frame to be verified from the second communication frame, and the first communication frame to be verified is at least one communication frame in the second communication frame.
[0069] Step 202: Check the first communication frames to be checked in sequence according to the two level states of the first communication frame.
[0070] In the example of the present invention, when the first communication frame corresponds to the first data value, each first communication frame to be checked can be checked in sequence according to the order of the first communication frame to be checked in the communication frame. Since the interleaving mode of the two level states of the second communication frame after the first communication frame is different from the interleaving mode of the two levels of the first communication frame, and the first communication frame to be checked is at least one communication frame in the second communication frame, it is possible to check whether the interleaving mode of the two level states of the communication frame to be checked is the same as the two interleaving modes of the first communication frame to check whether there is an error in the transmitted communication frame.
[0071] Step 203: When the interleaving mode of the two level states of the communication frame to be checked is the same as the interleaving mode of the two level states of the first communication frame, it is determined that the sent communication frame has an error.
[0072] Step 204: When the interleaving mode of the two level states of the communication frame to be verified is different from the interleaving mode of the two level states of the first communication frame, it is determined that the sent communication frame is correct.
[0073] In another embodiment of the present invention, the second device may perform verification, including:
[0074] After the second device receives the communication frame, when the first communication frame corresponds to the first data value, the first communication frame to be verified in the second communication frame and the two-level state interleaving mode of the first communication frame are obtained; according to the two-level state interleaving mode of the first communication frame, the first communication frame to be verified is verified in sequence; when the interleaving mode of the two-level states of the communication frame to be verified is the same as the interleaving mode of the two-level states of the first communication frame, it is determined that the sent communication frame has an error; when the interleaving mode of the two-level states of the communication frame to be verified is different from the interleaving mode of the two-level states of the first communication frame, it is determined that the sent communication frame is correct. The specific process of the second device performing the verification is similar to steps 201-204, therefore, the relevant description of steps 201-204 can be referred to, and no further description is given here.
[0075] Further references Figure 3 , which shows a process 300 of another embodiment of a single bus communication method. The process 300 based on the single bus communication method includes the following steps:
[0076] Step 301, sequentially verifying the second communication frame to be verified corresponding to the second data value.
[0077] When sending a communication frame, the first device can verify the second communication frame to be verified corresponding to the second data value, so as to ensure the correctness of the sent communication frame. Specifically, the first device obtains the second communication frame to be verified for the second data value from the communication frame, and verifies the second communication frame to be verified according to the corresponding order of the second communication frame to be verified in the communication frame.
[0078] Step 302: When the level states of two adjacent second communication frames to be checked are the same, it is determined that an error exists in the sent communication frame.
[0079] Step 303: When the level states of two adjacent second communication frames to be verified are different, it is determined that the sent communication frame is correct.
[0080] Among them, the adjacent second communication frames to be checked are in the order of communication frames, and there may be at least one communication frame corresponding to the first data value between two second communication frames to be checked, or there may be no communication frame corresponding to the first data value.
[0081] Since the communication frame in the example of the present invention includes a level state corresponding to the second data value, therefore, when sending the communication frame in the example of the present invention, the level states of the communication frames corresponding to the adjacent second data values will be different. Then, it can be determined that there is an error in the sent communication frame based on whether the level states of the two adjacent second communication frames to be checked are the same, further improving the reliability of the communication frame.
[0082] In another embodiment of the present invention, the second device may perform verification, including:
[0083] After receiving the communication frame, the second device checks the second communication frame to be checked corresponding to the second data value in order; when the level states of two adjacent second communication frames to be checked are the same, it is determined that the sent communication frame has an error; when the level states of two adjacent second communication frames to be checked are different, it is determined that the sent communication frame is correct. The specific process of the second device checking is similar to step 301-step 303, and therefore, the relevant description of step 301-step 303 can be referred to, and will not be repeated here.
[0084] In yet another embodiment of the present invention, the start instruction is a write command or a read command.
[0085] Optionally, when the start instruction is a write command, the process includes steps 401 to 403. Specifically, before step 101, the process includes:
[0086] Step 401: The first device sends the write command to the second device.
[0087] When the first device sends a write command to the second device, the first device is a master device and the second device is a slave device. Before the master device sends a communication frame to the slave device, the master device needs to send a write command to the slave device to inform the slave device to prepare to receive the communication frame.
[0088] like Figure 7a As shown, during the execution of the write command Twc, the level of the single bus will first be pulled low and continue for the write command low level duration Twch, and then the level of the single bus will be pulled high for the write command pulse width duration Tmcs / 2, and then the level of the single bus will be pulled low for the write command pulse width duration Tmcs / 2.
[0089] Step 101, based on the response corresponding to the start instruction, determining the level state after the single bus transmits the response, includes:
[0090] Step 402: After receiving the response returned by the second device, the first device determines the level state of the single bus after transmitting the response.
[0091] After the master device sends a write command to the slave device, the master device waits for the slave device to reply with an acknowledgment within a preset time. If the slave device replies with an acknowledgment within the preset time, it means that the slave device is ready to transmit the communication frame. If the slave device does not reply with an acknowledgment within the preset time, the master device can resend the start command and wait for the slave device to reply with an acknowledgment within the preset time again. Figure 4a, as shown in FIG. 1 , after the write command, after Tde time (Tde time is less than the preset time), the second device replies with an acknowledgement response Tack.
[0092] Since the master device sends the write command to the slave device, after receiving the response returned by the slave device, the master device masters the single bus and needs to determine the level state of the single bus after transmitting the response.
[0093] The description of step 402 may refer to step 101 and will not be repeated here.
[0094] Step 102, sending a communication frame to the second device based on a preset coding rule includes:
[0095] Step 403: The first device sends a communication frame to the second device based on a preset coding rule.
[0096] In the embodiment of the present invention, the master device sends a communication frame to the slave device based on a preset coding rule. After the master device sends the communication frame to the slave device, it can also send a write end instruction to the slave device, and the slave device stops receiving after detecting the write end instruction.
[0097] In the embodiment of the present invention, after the slave device stops receiving, it may return a response corresponding to the write end instruction to the master device to inform the master device that the slave device stops receiving.
[0098] like Figure 7b As shown, during the execution of the write end Twe, the level of the single bus will first be pulled low and last for the write end pulse width duration Tweh / 2, then the level of the single bus will be pulled high for the write command pulse width duration Tmeh / 2, and then the level of the single bus will be pulled low for the write command low level duration Twes.
[0099] In an embodiment of the present invention, the first device sends the write command to the second device; after receiving the response returned by the second device, the first device determines the level state of the single bus after transmitting the response; the first device sends a communication frame to the second device based on a preset coding rule, so that when the first device sends a communication frame to the second device, the communication frame can be transmitted normally without setting a start bit before the communication frame, thereby improving the efficiency of sending communication frames and allowing communication frames to be sent efficiently.
[0100] Optionally, when the start instruction is a read command, the process includes steps 501 to 503. Specifically, before step 101, the process includes:
[0101] Step 501: The first device receives the read command sent by the second device.
[0102] When the first device receives the read command sent by the second device, the first device is a slave device and the second device is a master device. Before the slave device sends a communication frame to the master device, the slave device needs to receive the read command sent by the master device to learn that a communication frame needs to be sent to the master device.
[0103] like Figure 7c As shown, during the execution of the read command Trc, the level of the single bus will first be pulled low and last for the read command low level duration Trch, and then the level of the single bus will be pulled high for the read command high level duration Trcs.
[0104] Step 101, based on the response corresponding to the start instruction, determining the level state after the single bus transmits the response, includes:
[0105] Step 502: After the first device sends the response to the second device, the first device determines the level state of the single bus after the response is transmitted.
[0106] After receiving the read command sent by the master device, the slave device returns a response to the master device to inform the master device that it is ready to send a communication frame to the master device. Since the slave device sends the communication frame to the master device, the slave device has mastered the single bus and needs to determine the level state of the single bus after transmitting the response.
[0107] Step 102, sending a communication frame to the second device based on a preset coding rule, includes:
[0108] Step 503: The first device sends a communication frame to the second device based on a preset coding rule.
[0109] The slave device sends a communication frame to the master device based on a preset coding rule.
[0110] In the embodiment of the present invention, after the slave device sends a communication frame to the master device, it may also send a read end instruction to the master device. After the master device detects the read end instruction, it stops receiving.
[0111] like Figure 7d As shown, during the time of executing the read end Tre, the level of the single bus will first be pulled low and continue for the read end pulse width duration Treh / 2, then the level of the single bus will be pulled high and continue for the read end pulse width duration Treh / 2, and then the level of the single bus will be pulled low and last for the read end low level duration Tres.
[0112] In the embodiment of the present invention, after the master device stops receiving, it may return a response corresponding to the read end instruction to the slave device, so as to inform the slave device that the master device stops receiving.
[0113] Since the second device sends the read command to the first device, Figure 4e After the first device returns a response to the read command to the second device, the first device will send a communication frame to the second device based on a preset coding rule, thereby sending a communication frame corresponding to the read command. Therefore, when the first device sends a communication frame to the second device, the communication frame can be transmitted normally without setting a start bit before the communication frame, thereby improving the efficiency of sending communication frames and allowing communication frames to be sent efficiently.
[0114] In the embodiment of the present invention, the duration of the level of the read command, the write command, the write end, the read end, and the waiting time Tde on the bus is different from the duration of the communication frame on the bus.
[0115] Further references Figure 5 , which shows a process 600 of another embodiment of a single bus communication method, applied to a second device, wherein the second device is connected to a first device via a single bus. The process 600 of the single bus communication method includes the following steps:
[0116] Step 601: Receive a communication frame sent by a first device.
[0117] The second device is connected to the first device via a single bus, so after the first device sends a communication frame to the second device, the second device will receive the communication frame sent by the first device.
[0118] When the first device is a master device and the second device is a slave device, the master device determines the level state of the single bus after transmitting the response based on the response corresponding to the start instruction, sends a communication frame to the slave device based on a preset coding rule, and the slave device receives the communication frame sent by the master device.
[0119] When the first device is a slave device and the second device is a master device, the slave device determines the level state of the single bus after transmitting the response based on the response corresponding to the start instruction, sends a communication frame to the master device based on a preset coding rule, and the master device receives the communication frame sent by the slave device.
[0120] The process of the first device sending a communication frame can be referred to above and will not be elaborated here.
[0121] Step 602: When the first communication frame is received, the data value corresponding to the first communication frame is parsed according to a preset decoding rule, and the clock signal is parsed.
[0122] When the second device receives the first communication frame, it parses and decodes the first communication frame according to the preset decoding rule, thereby parsing the data value corresponding to the first communication frame and parsing the clock signal. The preset decoding rule corresponds to the preset encoding rule.
[0123] When the first device is the master device and the second device is the slave device, the slave device determines the level state of the single bus according to the response corresponding to the start instruction. When the response ends at a low level, the level state of the single bus is a low level, and when the response ends at a high level, the level state of the single bus is a high level. The slave device parses the first communication frame after the response according to the preset decoding rules, and parses the data value corresponding to the first communication frame. At the same time, when the level state of the first communication frame is compared to be different from the level state of the single bus, the time when the communication frame starts to be sent is obtained, thereby parsing the clock signal.
[0124] When the first device is a slave device and the second device is a master device, the master device determines the level state of the single bus according to the response corresponding to the start instruction. When the response ends at a low level, the level state of the single bus is a low level, and when the response ends at a high level, the level state of the single bus is a high level. The master device parses the first communication frame after the response according to the preset decoding rule, parses the data value corresponding to the first communication frame, and at the same time, when the level state of the first communication frame is compared to be different from the level state of the single bus, the time when the communication frame starts to be sent is obtained, thereby parsing the clock signal.
[0125] Step 603: When a clock signal is parsed, subsequent communication frames are parsed based on the clock signal and a preset decoding rule.
[0126] Since the clock signal is obtained through analysis and the time when the communication frame starts to be sent is determined, the subsequent communication frames are analyzed based on the time when the communication frame starts to be sent to obtain the data values corresponding to the subsequent communication frames.
[0127] When the first device is a master device and the second device is a slave device, the slave device parses subsequent communication frames based on the clock signal and a preset decoding rule.
[0128] When the first device is a slave device and the second device is a master device, the master device parses subsequent communication frames based on the clock signal and a preset decoding rule.
[0129] In an example of the present invention, by parsing the first communication frame, parsing the data value corresponding to the first communication frame, and parsing the clock signal, based on the clock signal and the preset decoding rules, each communication frame after the first communication frame is parsed, so that the communication frame can be used normally.
[0130] In an example of the present invention, the data value corresponding to the first communication frame is parsed through a preset decoding rule, and the clock signal is parsed, and the subsequent communication frames are parsed based on the clock signal and the preset decoding rule, thereby avoiding the need to set the start bit before transmitting the communication frame and improving the efficiency of sending the communication frame.
[0131] The following is an example of an implementation process of the present invention. Figure 8a :
[0132] S1, starts when the first device needs to issue a write command;
[0133] S2, the first device is used as the master device, the second device is used as the slave device, the first device and the second device are connected via a bus, and the master and slave devices are initialized;
[0134] S3, the master device sends a write command to the slave device;
[0135] S4, the slave device responds to the write command, and replies an acknowledgment to the master device, and the master device starts writing data after receiving the acknowledgment;
[0136] S5, when the data writing is completed, the master device sends a write end command to the slave device;
[0137] S6, end.
[0138] Figure 8b and Figure 8a Correspondingly, therefore, Figure 8b The corresponding execution process can be referred to Figure 8a , I will not go into details here.
[0139] Further references Fig. 9 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a single bus communication device, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0140] like Fig. 9 As shown, the above-mentioned single bus communication device 700 in this embodiment includes:
[0141] A response module 701 is used to determine the level state of the single bus after transmitting the response based on the response corresponding to the start instruction;
[0142] The sending module 702 is used to send a communication frame to the second device based on a preset coding rule; wherein the first communication frame is used for the second device to parse the data value and for the second device to obtain the clock signal; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response; when the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes two identical level states, it corresponds to the second data value.
[0143] In summary, the single bus communication device provided by the embodiment of the present invention determines the level state after the single bus transmits the response response based on the response response corresponding to the start instruction; sends a communication frame to the second device based on a preset coding rule; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response response, so that after the response pulse, a level jump is provided, and the time when the communication frame starts to be transmitted is clarified through the level jump. Without setting the start bit before the communication frame, the time when the communication frame starts to be transmitted can also be accurately grasped. On the other hand, when the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes two identical level states, it corresponds to the second data value. Therefore, when the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response response, the communication frame can also be transmitted normally. In the embodiment of the present invention, the communication frame can be transmitted normally without setting the start bit before the communication frame, which improves the efficiency of sending the communication frame and can send the communication frame efficiently.
[0144] Some optional implementations of this embodiment include:
[0145] An acquisition module, used for acquiring the first communication frame to be checked in the second communication frame and the two level state interleaving mode of the first communication frame when the first communication frame corresponds to the first data value;
[0146] A first verification module, used for verifying the first communication frame to be verified in sequence according to the two level state interleaving mode of the first communication frame;
[0147] A first check submodule, used for determining that an error exists in a sent communication frame when the interleaving mode of the two level states of the communication frame to be checked is the same as the two interleaving modes of the first communication frame;
[0148] The second check submodule determines that the sent communication frame is correct when the interleaving mode of the two level states of the communication frame to be checked is different from the two interleaving modes of the first communication frame.
[0149] Some optional implementations of this embodiment include:
[0150] A second verification module, used for sequentially verifying the second communication frame to be verified corresponding to the second data value;
[0151] A third check submodule, used for determining that an error exists in the sent communication frame when the level states of two adjacent second communication frames to be checked are the same;
[0152] The fourth check submodule is used to determine that the sent communication frame is correct when the level states of two adjacent second communication frames to be checked are different.
[0153] In some optional implementations of this embodiment, when the start instruction is a write command, the method includes:
[0154] A first sending module, configured to send the write command from the first device to the second device;
[0155] The response module is specifically configured to determine, after the first device receives the response returned by the second device, a level state after the single bus transmits the response.
[0156] The sending module is specifically configured to send a communication frame from the first device to the second device based on a preset coding rule.
[0157] In some optional implementations of this embodiment, when the start instruction is a read command, the method includes:
[0158] A second sending module, configured to receive, by the first device, the read command sent by the second device;
[0159] The response module is specifically configured to determine the level state of the single bus after the first device sends the response to the second device, after the first device sends the response to the second device;
[0160] The sending module is specifically configured to send a communication frame from the first device to the second device based on a preset coding rule.
[0161] Further references Fig.10 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a single bus communication device, which is similar to Figure 5 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0162] like Fig.10 As shown, the above-mentioned single bus communication device 800 in this embodiment is applied to a second device, and the second device is connected to the first device through a single bus, including:
[0163] The receiving module 801 is used to receive a communication frame sent by the first device;
[0164] A first parsing module 802 is used to parse the data value corresponding to the first communication frame and the clock signal according to a preset decoding rule when the first communication frame is received;
[0165] The second parsing module 803 is used to parse subsequent communication frames based on the clock signal and preset decoding rules when a clock signal is parsed.
[0166] The present invention also provides an electronic device, see Fig.11 , including: a processor 1011, a memory 1012, and a computer program 1013 stored in the memory and executable on the processor, wherein when the processor executes the program, the single bus-based communication method of the aforementioned embodiment is implemented.
[0167] The present invention also provides a readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the single bus-based communication method of the aforementioned embodiment.
[0168] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0169] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific languages is for disclosing the best mode of the present invention.
[0170] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0171] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0172] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0173] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0174] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0175] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0176] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0177] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A single bus communication method, characterized in that: Applied to a first device, the first device is connected to a second device via a single bus, the method comprising: Based on the response corresponding to the start instruction, determining the level state of the single bus after transmitting the response; A communication frame is sent to the second device based on a preset coding rule; wherein the first communication frame is used for the second device to parse data values and for the second device to obtain a clock signal; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response; when the communication frame includes two different level states, it corresponds to the first data value; when the communication frame includes one level state, it corresponds to the second data value.
2. The method according to claim 1, characterized in that Also includes: When the first communication frame corresponds to the first data value, the interleaving manner of the two level states of the second communication frame after the first communication frame is different from the interleaving manner of the two levels of the first communication frame; The second communication frame is a communication frame corresponding to the first data value.
3. The method according to claim 2, characterized in that Also includes: When the first communication frame corresponds to the first data value, obtaining the first communication frame to be checked in the second communication frame and the two level state interleaving mode of the first communication frame; According to the interleaving mode of the two level states of the first communication frame, the first communication frame to be checked is checked in sequence; When the interleaving mode of the two level states of the communication frame to be checked is the same as the interleaving mode of the two level states of the first communication frame, determining that the sent communication frame has an error; When the interleaving manner of the two level states of the communication frame to be verified is different from the interleaving manner of the two level states of the first communication frame, it is determined that the sent communication frame is correct.
4. The method according to claim 2 or 3, characterized in that: Also includes: Checking the second communication frame to be checked corresponding to the second data value in sequence; When the level states of two adjacent second communication frames to be checked are the same, determining that an error exists in the sent communication frame; When the level states of two adjacent second communication frames to be verified are different, it is determined that the sent communication frame is correct.
5. The method according to claim 1, characterized in that In the case where the start instruction is a write command, the method further includes: The first device sends the write command to the second device; The step of determining the level state of the single bus after transmitting the response based on the response corresponding to the start instruction includes: After receiving the response returned by the second device, the first device determines the level state of the single bus after transmitting the response; The sending of the communication frame to the second device based on the preset coding rule comprises: The first device sends a communication frame to the second device based on a preset coding rule.
6. The method according to claim 1, characterized in that In the case where the start instruction is a read command, the method further includes: Receiving, by the first device, the read command sent by the second device; The step of determining the level state of the single bus after transmitting the response based on the response corresponding to the start instruction includes: After the first device sends the response to the second device, determining a level state of the single bus after the response is transmitted; The sending of the communication frame to the second device based on the preset coding rule comprises: The first device sends a communication frame to the second device based on a preset coding rule.
7. A single bus communication method, characterized in that: Applied to a second device, the second device is connected to a first device via a single bus, the method comprising: Receiving a communication frame sent by the first device; When the first communication frame is received, the data value corresponding to the first communication frame is parsed according to a preset decoding rule, and the clock signal is parsed; When a clock signal is parsed, subsequent communication frames are parsed based on the clock signal and a preset decoding rule.
8. A single bus communication device, applied to a first device, wherein the first device is connected to a second device via a single bus, the device comprising: A response module, used for determining a level state of the single bus after transmitting the response based on the response corresponding to the start instruction; A sending module, used for sending a communication frame to the second device based on a preset coding rule; wherein the first communication frame is used for the second device to parse a data value and for the second device to obtain a clock signal; the level state at the beginning of the first communication frame is different from the level state after the single bus transmits the response; when the communication frame includes two different level states, it corresponds to a first data value; when the communication frame includes two identical level states, it corresponds to a second data value.
9. A single bus communication device, applied to a second device, wherein the second device is connected to a first device via a single bus, the device comprising: A receiving module, used for receiving a communication frame sent by the first device; A first parsing module is used to parse the data value corresponding to the first communication frame and the clock signal according to a preset decoding rule when the first communication frame is received; The second parsing module is used to parse subsequent communication frames based on the clock signal and preset decoding rules when a clock signal is parsed.
10. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the single bus-based communication method as described in any one of claims 1 to 6 or the single bus-based communication method as described in claim 7 is implemented.
11. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the single bus-based communication methods in claims 1-6 or the single bus-based communication method in claim 7.
