SPI communication system and method, electronic equipment and computer readable storage medium
By introducing a receive preparation line, a receive acknowledgment line, and a data exception line into the SPI communication bus, the problems of insufficient data timeliness and integrity in inter-core communication of the SPI bus are solved, and the synchronization, integrity, and timeliness of data transmission are realized.
Patent Information
- Application Number
- CN202510990725.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-10-28
AI Technical Summary
The SPI bus cannot guarantee the timeliness and integrity of data in inter-core communication and cannot meet the requirements of complex inter-core communication protocols.
Introducing a receive preparation line, a receive acknowledgment line, and a data error line into the SPI communication bus enables data transmission synchronization and error detection, ensuring that data transmission only begins when the receiver is ready and that error information is promptly fed back after reception is complete.
It improves the synchronization and integrity of data transmission, avoids data packet loss and backlog, and ensures the timeliness of data transmission.
Smart Images

Figure CN120849331A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and more specifically, to SPI communication systems, methods, electronic devices, and computer-readable storage media. Background Technology
[0002] In intelligent driving domain control of vehicles, the SOC (System on Chip) chip used can be a multi-core heterogeneous chip containing different types of processing units, such as MCU (Microcontroller Unit) and Acore (processor core), and the processing units choose SPI (Serial Peripheral interface) protocol for inter-core communication.
[0003] However, the SPI bus only includes the Serial Clock line (SCK), Master Output / Slave Input data line (MOSI), Master Input / Slave Output data line (MISO), and Slave Select line (NSS), which cannot guarantee the timeliness and integrity of data communication between cores, and thus cannot meet the requirements of complex inter-core communication protocols.
[0004] In summary, improving the timeliness and integrity of data transmission via the SPI bus is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide an SPI communication system that can, to a certain extent, solve the technical problem of how to improve the timeliness and integrity of data transmission via the SPI bus. This application also provides an SPI communication method, an electronic device, and a computer-readable storage medium.
[0006] To achieve the above objectives, this application provides the following technical solution:
[0007] An SPI communication system includes a master device and a slave device, wherein the master device and the slave device are connected via an SPI communication bus, the SPI communication bus comprising:
[0008] A receive preparation line is used to transmit a receive preparation signal between the slave device and the master device, the receive preparation signal indicating that the device is ready to receive data.
[0009] A receive response line is used to transmit a receive response signal between the slave device and the master device, the receive response signal indicating that the data reception operation has been completed;
[0010] A data anomaly line is used to transmit a data anomaly signal between the slave device and the master device, the data anomaly signal indicating that the received data is abnormal.
[0011] Preferably, the SPI communication bus further includes:
[0012] A receive prompt line is used to transmit a receive prompt signal between the slave device and the master device, the receive prompt signal being used to indicate that preparation is made to receive data.
[0013] Preferably, the master device includes a microcontroller unit, and the slave device includes a processor core.
[0014] An SPI communication method, applied to a master device in an SPI communication system as described in any of the preceding claims, comprising:
[0015] Acquire the master device data to be transmitted;
[0016] Receive the receive ready signal transmitted from the device via the receive ready line;
[0017] Send the master device data to the slave device;
[0018] The receiver receives the response signal transmitted by the slave device via the response line;
[0019] In response to receiving a data anomaly signal transmitted by the slave device via the data anomaly line, the master device performs anomaly transmission processing on the data.
[0020] If a data anomaly signal is not received through the data anomaly line, the transmission of the master device data is completed.
[0021] Preferably, after acquiring the master device data to be transmitted and before receiving the receive preparation signal transmitted by the slave device via the receive preparation line, the method further includes:
[0022] A receive prompt signal is transmitted to the slave device via the receive prompt line to prepare the slave device to receive data;
[0023] Sending the master device data to the slave device includes:
[0024] Detect whether a reception prompt signal has been transmitted to the slave device via the reception prompt line;
[0025] In response to the receipt indication signal being transmitted via the receipt indication line, the master device data is sent to the slave device.
[0026] Preferably, after detecting whether a reception prompt signal has been transmitted to the slave device via the reception prompt line, the method further includes:
[0027] In response to the failure to transmit the reception prompt signal via the reception prompt line, the slave device data transmitted by the slave device is received;
[0028] After receiving the data from the slave device, a receive response signal is transmitted to the slave device via the receive response line.
[0029] Preferably, after transmitting the receive response signal to the slave device via the receive response line, the method further includes:
[0030] Detect whether the data from the slave device is abnormal;
[0031] In response to the abnormal data of the slave device, a data abnormality signal is transmitted to the slave device through the data abnormality line so that the slave device performs abnormal transmission processing on the slave device data;
[0032] If the slave device data is normal, the reception of the slave device data is completed.
[0033] An SPI communication method, applied to a slave device in any of the above-described SPI communication systems, includes:
[0034] The receive preparation signal is transmitted to the master device via the receive preparation line;
[0035] Receive master device data transmitted by the master device;
[0036] After receiving the data from the master device, a receive response signal is transmitted to the master device via the receive response line;
[0037] Detect whether the main device data is abnormal;
[0038] In response to the abnormality of the master device data, a data abnormality signal is transmitted to the master device through the data abnormality line so that the master device can perform abnormal transmission processing on the master device data;
[0039] If the master device data is found to be normal, the reception of the master device data is completed.
[0040] An electronic device, comprising:
[0041] Memory, used to store computer programs;
[0042] A processor for implementing the steps of any of the above-described SPI communication methods when executing the computer program.
[0043] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of any of the SPI communication methods described above.
[0044] This application provides an SPI communication system, including a master device and a slave device, which are connected by an SPI communication bus. The SPI communication bus includes: a receive preparation line for transmitting a receive preparation signal between the slave device and the master device, the receive preparation signal indicating that data is ready to be received; a receive acknowledge line for transmitting a receive acknowledge signal between the slave device and the master device, the receive acknowledge signal indicating that the data reception operation has been completed; and a data error line for transmitting a data error signal between the slave device and the master device, the data error signal indicating that the received data is abnormal. In this application, the SPI communication bus used by the master and slave devices is equipped with a receive preparation line, a receive acknowledgment line, and a data error line. Since the receive preparation line transmits a receive preparation signal indicating readiness to receive data, the receiver only sends the receive preparation signal after completing data reception preparation. This allows the receiver to decide whether to start transmission, avoiding data packet loss caused by starting transmission before the receiver is ready, thus ensuring data synchronization and integrity. Since the receive acknowledgment line transmits a receive acknowledgment signal indicating completion of the data reception operation, the receiver notifies the transmitter that data reception is complete after completion, guiding the transmitter to transmit new data. This avoids data backlog and information loss due to continuous data transmission by the transmitter, ensuring data integrity. Since the data error line transmits a data error signal indicating abnormal received data, compared to detecting data errors through a timeout mechanism, the receiver can proactively and promptly inform the transmitter of data errors, improving the efficiency of data error communication and avoiding transmission delays for data with high time synchronization requirements, ensuring data timeliness. The SPI communication method, electronic device, and computer-readable storage medium provided in this application also solve the corresponding technical problems. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0046] Figure 1 This is a schematic diagram of the structure of an SPI communication system provided in an embodiment of this application;
[0047] Figure 2 A flowchart of the SPI communication method applied to the master device;
[0048] Figure 3 A flowchart illustrating the SPI communication method applied to a slave device;
[0049] Figure 4 This is a schematic diagram showing the connection between the MCU and Acore;
[0050] Figure 5 This is a timing diagram of the MCU sending data to Acore.
[0051] Figure 6 Timing diagram for Acore sending data to the MCU;
[0052] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;
[0053] Figure 8 This is another structural schematic diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0054] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0055] Please see Figure 1 , Figure 1 This is a schematic diagram of the structure of an SPI communication system provided in an embodiment of this application.
[0056] This application provides an SPI communication system, including a master device and a slave device, which are connected by an SPI communication bus. The SPI communication bus includes:
[0057] The receive preparation line is used to transmit a receive preparation signal between the slave device and the master device. The receive preparation signal indicates that the device is ready to receive data. For ease of understanding, the one that sends data between the master and slave devices is called the transmitting party, and the one that receives data between the master and slave devices is called the receiving party. It is easy to understand that when the transmitting party is the master device, the receiving party is the slave device, and when the transmitting party is the slave device, the receiving party is the master device. During the process of the transmitting party sending data to the receiving party, after the receiving party is ready to receive data, it can transmit the receive preparation signal to the transmitting party through this receive preparation line. After receiving this receive preparation signal, the transmitting party knows that the receiving party is ready to receive data, and the transmitting party can then start transmitting data.
[0058] The receive acknowledgment line is used to transmit receive acknowledgment signals between the slave and master devices. These signals indicate the completion of data reception. For example, during data transmission from the transmitter to the receiver, if the transmitter transmits a data frame and the receiver receives it, the receiver can send a receive acknowledgment signal to the transmitter indicating the completion of data reception. Upon receiving this signal, the transmitter knows the receiver has received the data frame and can prepare to transmit a new frame. Conversely, if the transmitter does not receive this signal, it can continue transmitting the data frame until it receives the signal before sending the next frame. To prevent the transmitter from continuously transmitting the same data frame due to a prolonged lack of response, a first timeout can be set. If the transmitter does not receive the signal within this first timeout after transmitting a data frame, it can perform appropriate actions, such as ending data transmission.
[0059] The data anomaly line is used to transmit data anomaly signals between the slave and master devices. These signals indicate that the received data is abnormal. For example, during data transmission from the transmitter to the receiver, if the receiver detects an anomaly in the received data, it can send a data anomaly signal to the transmitter via this line. Upon receiving this signal, the transmitter is aware of the anomaly and can take appropriate measures, such as retransmitting the data. Conversely, if the transmitter does not receive this signal, it can continue transmitting the next data. To avoid delays caused by the transmitter continuously waiting for a data anomaly signal, this line is used. To delay the transmission of the next data, a second timeout can be set. If the receiver does not transmit a data error signal to the transmitter within the second timeout after the transmitter has finished transmitting the data, the transmitter can prepare to transmit the next data. Alternatively, a data normal line can be set in the SPI communication bus. The data normal line is used to transmit a data normal signal between the slave and master devices. The data normal signal indicates that the received data is normal. In this way, after the receiver determines that the received data is normal, it can directly transmit a data normal signal through this data normal line. After receiving this data normal signal, the transmitter can prepare to send the next data, thereby shortening the transmitter's waiting time and speeding up data transmission efficiency.
[0060] In an exemplary embodiment, to facilitate the receiver's preparation for receiving data, the SPI communication bus provided in this application may further include a receive prompt line for transmitting a receive prompt signal between the slave device and the master device. The receive prompt signal is used to indicate that preparation for receiving data is required. That is, during the process of transmitting data from the transmitter to the receiver, the transmitter can first transmit a receive prompt signal to the receiver via this receive prompt line. Upon receiving this receive prompt signal, the receiver is aware that preparation for receiving data is necessary, thus enabling it to prepare for receiving data.
[0061] It should be noted that in the SPI communication bus provided in this application, the two ends of the receive preparation line, receive acknowledge line, data error line, and receive prompt line can be connected to pins set by the master and slave devices, such as GPIO (General-purpose input / output) pins. The high and low levels of the pins are used to indicate whether the transmitted signal is valid. For example, the default pin level is high, and when the pin level changes to low, it indicates that the transmitted signal is valid. For ease of understanding, taking the receive preparation signal as an example, if the slave device does not transmit the receive preparation signal through the receive preparation line, the pin of the receive preparation line in the slave device remains at a high level. At this time, the pin of the receive preparation line in the master device is also at a high level, and the master device does not receive the receive preparation signal. If the slave device transmits the receive preparation signal through the receive preparation line, the pin of the receive preparation line in the slave device is pulled low from a high level. At this time, the pin of the receive preparation line in the master device also changes from a high level to a low level, and the master device receives the receive preparation signal. The transmission principle of other signals is the same and will not be described in detail.
[0062] It should also be noted that the SPI communication bus provided in this application also includes the basic transmission lines of the SPI communication bus, that is, it also includes the chip select bus, clock bus, master data transmission line and slave data transmission line; wherein, the chip select bus is used by the master device to transmit the chip select signal to the slave device, and the chip select signal is used to determine which slave device receives data; the clock bus is used by the master device to transmit the clock signal to the slave device; the master data transmission line is used by the master device to transmit data to the slave device; and the slave data transmission line is used by the slave device to transmit data to the master device.
[0063] To facilitate understanding of the application of the SPI communication system provided in this application, it is assumed that data is being transmitted from the master device to the slave device. The transmission process can be as follows:
[0064] The master device sends a receive prompt signal to the slave device via the receive prompt line, so that the slave device can start preparing to receive data after receiving the receive prompt signal;
[0065] Once the device is ready to receive data, it transmits a receive ready signal to the master device via the receive ready line to inform the master device that it has begun to prepare to receive data.
[0066] After receiving the receive ready signal, the master device sends a chip select signal to the slave device through the chip select bus and transmits a clock signal to the slave device through the clock bus.
[0067] The master device transmits master device data to the slave device through the master data transmission line. Master device data refers to the data sent by the master device to the slave device. Master device data may include vehicle performance data, vehicle operation data, vehicle inspection items, etc.
[0068] After receiving data from the master device, the receiving device transmits a receiving response signal to the master device via the receiving response line to inform the master device that the data receiving operation has been completed.
[0069] If the device detects whether the received data from the master device is abnormal, it transmits a data abnormality signal to the master device through the data abnormality line to inform the master device that there is an abnormality in data transmission; if there is no abnormality, no operation is performed.
[0070] If the master device receives a data error signal, it can retransmit the master device data to the slave device; if it does not receive a data error signal, it can complete the transmission of the master device data.
[0071] Accordingly, assuming data is being transferred from the slave device to the master device, and considering that the slave device may have lower privileges than the master device, we can divide the transmission into two scenarios: the slave device fully utilizes the SPI communication bus, and the slave device can only utilize a portion of the SPI communication bus. When the slave device fully utilizes the SPI communication bus, the data transmission process can be as follows:
[0072] The slave device sends a receive prompt signal to the master device via the receive prompt line, so that the master device can start preparing to receive data after receiving the receive prompt signal;
[0073] After receiving the receive prompt signal, the master device sends a chip select signal to the slave device through the chip select bus and transmits a clock signal to the slave device through the clock bus.
[0074] Once the master device is ready to receive data, it transmits a receive ready signal to the slave device via the receive ready line to inform the slave device that it has begun to prepare to receive data.
[0075] The slave device transmits slave device data to the master device via the data transmission line. Slave device data refers to the data sent from the slave device to the master device. Slave device data may include vehicle performance data, vehicle operation data, vehicle inspection results, etc.
[0076] After receiving data from the slave device, the master device transmits a reception response signal to the slave device via the reception response line to inform the slave device that the data reception operation has been completed.
[0077] The master device detects whether the received data from the slave device is abnormal. If an abnormality is found, it transmits a data abnormality signal to the slave device through the data abnormality line to inform the slave device that there is an abnormality in the data transmission. If no abnormality is found, no operation is performed.
[0078] If the slave device receives a data error signal, it can retransmit the slave device data to the master device; if it does not receive a data error signal, it can complete the transmission of the slave device data.
[0079] When the slave device can only use a portion of the SPI communication bus, the data transmission process can be as follows:
[0080] The slave device transmits a receive ready signal to the master device via the receive ready line to inform the master device that it is ready to receive data;
[0081] After receiving the receive ready signal, the master device sends a chip select signal to the slave device through the chip select bus and transmits a clock signal to the slave device through the clock bus.
[0082] The slave device transmits slave device data to the master device via a data transmission line. Slave device data refers to the data sent from the slave device to the master device.
[0083] After receiving data from the slave device, the master device transmits a reception response signal to the slave device via the reception response line to inform the slave device that the data reception operation has been completed.
[0084] After this, the master device can end the receiving operation or detect whether the received slave device data is abnormal. If there is an abnormality, it will transmit a data abnormality signal to the slave device through the data abnormality line to inform the slave device that there is an abnormality in the data transmission; if there is no abnormality, no operation will be performed.
[0085] Correspondingly, if the slave device receives a data error signal, it can retransmit the slave device data to the master device; if it does not receive a data error signal, it can complete the transmission of the slave device data.
[0086] This application provides an SPI communication system, including a master device and a slave device, which are connected by an SPI communication bus. The SPI communication bus includes: a receive preparation line for transmitting a receive preparation signal between the slave device and the master device, the receive preparation signal indicating that data is ready to be received; a receive acknowledge line for transmitting a receive acknowledge signal between the slave device and the master device, the receive acknowledge signal indicating that the data reception operation has been completed; and a data error line for transmitting a data error signal between the slave device and the master device, the data error signal indicating that the received data is abnormal. In this application, the SPI communication bus used by the master and slave devices is equipped with a receive preparation line, a receive acknowledgment line, and a data error line. Since the receive preparation line transmits a receive preparation signal indicating readiness to receive data, the receiver only sends the receive preparation signal after completing data reception preparation. This allows the receiver to decide whether to start transmission, avoiding data packet loss caused by starting transmission before the receiver is ready, thus ensuring data synchronization and integrity. Since the receive acknowledgment line transmits a receive acknowledgment signal indicating completion of the data reception operation, the receiver notifies the transmitter that data reception is complete after completion, guiding the transmitter to transmit new data. This avoids data backlog and information loss due to continuous data transmission by the transmitter, ensuring data integrity. Since the data error line transmits a data error signal indicating abnormal received data, compared to detecting data errors through a timeout mechanism, the receiver can proactively and promptly inform the transmitter of data errors, improving the efficiency of data error communication and avoiding transmission delays for data with high time synchronization requirements, ensuring data timeliness.
[0087] Based on the above embodiments, this application also provides an SPI communication method, which, when applied to the master device in the SPI communication system described in any of the above embodiments, such as... Figure 2 As shown, the following steps may be included:
[0088] Step S101: Obtain the master device data to be transmitted.
[0089] Step S102: Receive the receive preparation signal transmitted from the device via the receive preparation line.
[0090] Step S103: Send master device data to slave device.
[0091] Step S104: Receive the receive response signal transmitted from the device via the receive response line.
[0092] Step S105: In response to receiving a data error signal transmitted from the slave device via the data error line, perform error transmission processing on the master device data.
[0093] Step S106: In response to the failure to receive a data error signal through the data error line, the transmission of data by the master device is completed.
[0094] In an exemplary embodiment, after acquiring the master device data to be transmitted, before receiving the receive preparation signal transmitted by the slave device via the receive preparation line, the master device may also transmit a receive prompt signal to the slave device via the receive prompt line to enable the slave device to prepare to receive data.
[0095] In this process, considering that the receive preparation line can be used for both data transmission from the master device to the slave device and data transmission from the slave device to the master device, but during data transmission from the master device to the slave device, the receive preparation line is used for the slave device to respond to the receive prompt signal transmitted by the master device, and during data transmission from the slave device to the master device, the receive preparation line is used for the slave device to prompt the master device to receive data. Therefore, the master device can distinguish between receiving data and transmitting data by analyzing the function of the receive preparation line. That is, during the process of sending master device data to the slave device, it can detect whether a receive prompt signal has been transmitted to the slave device through the receive prompt line; in response to the transmission of a receive prompt signal through the receive prompt line, the master device sends master device data to the slave device; in response to the absence of a receive prompt signal through the receive prompt line, the master device receives the slave device data transmitted by the slave device, and after receiving the slave device data, it transmits a receive response signal to the slave device through the receive response line.
[0096] In an exemplary embodiment, after the master device transmits a receive response signal to the slave device via the receive response line, it can also detect whether the slave device data is abnormal; in response to the slave device data being abnormal, it transmits a data abnormal signal to the slave device via the data abnormality line so that the slave device performs abnormal transmission processing on the slave device data; in response to the slave device data being normal, the reception of the slave device data is completed.
[0097] The corresponding description of the SPI communication method provided in the embodiments of this application can be found in the above embodiments, and will not be repeated here.
[0098] This application provides an SPI communication method applied to a master device in an SPI communication system as described in any of the above embodiments. The method includes: acquiring master device data to be transmitted; receiving a receive preparation signal transmitted by a slave device via a receive preparation line; sending master device data to a slave device; receiving a receive acknowledgment signal transmitted by a slave device via a receive acknowledgment line; performing abnormal transmission processing on the master device data in response to receiving a data abnormality signal transmitted by a slave device via a data abnormality line; and completing the transmission of master device data in response to not receiving a data abnormality signal via a data abnormality line. In this application, the SPI communication bus used by the master and slave devices is equipped with a receive preparation line, a receive acknowledgment line, and a data error line. Since the receive preparation line transmits a receive preparation signal indicating readiness to receive data, the slave device sends the receive preparation signal only after completing data reception preparation. This allows the slave device to decide when to start transmission, avoiding data packet loss caused by starting transmission before the slave device is ready, thus ensuring data synchronization and integrity. Since the receive acknowledgment line transmits a receive acknowledgment signal indicating completion of data reception, the slave device notifies the master device that data reception is complete after completion, guiding the transmission of new data and preventing data backlog and information loss due to continuous data transmission by the master device, ensuring data integrity. Since the data error line transmits a data error signal indicating abnormal received data, compared to detecting data errors through a timeout mechanism, the slave device can proactively and promptly inform the master device of data errors, improving the efficiency of data error communication and avoiding transmission delays for data with high time synchronization requirements, ensuring data timeliness.
[0099] Based on the above embodiments, this application also provides an SPI communication method, which, when applied to a slave device in an SPI communication system as described in any of the above embodiments, such as... Figure 3 As shown, the following steps may be included:
[0100] Step S201: Transmit a receive preparation signal to the master device via the receive preparation line.
[0101] Step S202: Receive master device data transmitted by the master device.
[0102] Step S203: After receiving the data from the master device, transmit the receive response signal to the master device through the receive response line.
[0103] Step S204: Check if the main device data is abnormal.
[0104] Step S205: In response to a data anomaly in the master device, a data anomaly signal is transmitted to the master device via the data anomaly line so that the master device can perform anomaly transmission processing on the master device data.
[0105] Step S206: If the master device data is normal, the reception of master device data is completed.
[0106] In an exemplary embodiment, before transmitting a receive preparation signal to the master device via the receive preparation line, the slave device may also receive a receive prompt signal transmitted by the master device via the receive prompt line to begin preparing to receive data, such as reserving free storage space for the received data.
[0107] In this process, considering that the receive preparation line can be used for both data transmission from the master device to the slave device and data transmission from the slave device to the master device, but during data transmission from the master device to the slave device, the receive preparation line is used for the slave device to respond to the receive prompt signal transmitted by the master device, and during data transmission from the slave device to the master device, the receive preparation line is used for the slave device to prompt the master device to receive data. Therefore, the slave device can distinguish between receiving data and transmitting data by analyzing the function of the receive preparation line. That is, during the process of receiving master device data transmitted by the master device, it can detect whether it has received the receive prompt signal transmitted by the master device through the receive prompt line; in response to receiving the receive prompt signal through the receive prompt line, it receives the master device data transmitted by the master device; in response to not receiving the receive prompt signal through the receive prompt line, it transmits slave device data to the master device.
[0108] The corresponding description of the SPI communication method provided in the embodiments of this application can be found in the above embodiments, and will not be repeated here.
[0109] To facilitate understanding of the SPI communication scheme provided in this application, it is assumed that the SPI communication system of this application is applied to intelligent driving domain control, with the master device including a microcontroller unit (MCU) and the slave device including a processor core (Acore), such as Figure 4As shown, the chip select bus is represented by SPI-CS, the clock bus by SPI-CLK, the master data transmission line by SPI-MOSI (Master Output Slave Input), the slave data transmission line by SPI-MISO (Slave Output Master Input), the receive ready line by READY, the receive acknowledge line by ACK, the data error line by ERR, and the receive prompt line by IND. Furthermore, the chip select signal output by SPI-CS is controlled by the Master; the clock signal output by SPI-CLK is controlled by the Master; SPI-MOSI outputs data from the Master and inputs data from the slave; SPI-MISO outputs data from the slave and inputs data from the master; ACK is controlled by the slave, indicating a data reception response upon receiving a data frame, with a default high level and active on the falling edge; READY is controlled by the slave, serving as a buffer ready signal to inform the master that data can be transmitted, with a default high level and active on the falling edge; ERR is controlled by the slave, indicating that upon receiving an incomplete or erroneous data frame, the slave instructs the master to retransmit the frame, with a default high level and active on the falling edge; IND is controlled by the Master, serving as the master data transmission initiation signal, with a default high level and active on the falling edge.
[0110] During the process of the MCU sending data to Acore, the transmission timing is as follows: Figure 5 As shown, the process includes the following:
[0111] When the MCU sends data to Acore, it first pulls the IND GPIO to notify Acore that it is about to send data and that Acore needs to prepare.
[0112] After receiving an IND GPIO interrupt, Acore prepares to receive data. Once the preparation is complete, it pulls the READY GPIO to notify the MCU that it is ready to send data.
[0113] After receiving the READY GPIO interrupt, the MCU outputs CS and CLK signals to begin data transmission;
[0114] After Acore receives a data frame, it pulls the ACK GPIO to notify the MCU that data reception is complete.
[0115] If Acore receives data containing missing or erroneous data, it will pull the ERR GPIO low to notify the MCU; if Acore receives correct data, it will not pull the ERR GPIO low.
[0116] When the MCU receives an ERR signal, it will retransmit this frame of data.
[0117] Correspondingly, during the process of Acore sending data to the MCU, the transmission timing is as follows: Figure 6 As shown, the process includes the following:
[0118] Acore triggers the READY signal to notify the MCU that data needs to be sent;
[0119] After receiving the READY signal, the MCU pulls CS low and provides the CLK signal;
[0120] Acore begins sending a frame of data;
[0121] After the MCU receives a frame of data, it pulls the ACK signal low.
[0122] This application also provides an electronic device and a computer-readable storage medium, both of which have the corresponding effects of the SPI communication method provided in the embodiments of this application. Please refer to... Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0123] An electronic device provided in this application includes a memory 201 and a processor 202. The memory 201 stores a computer program, and the processor 202 executes the computer program to implement the steps of the SPI communication method described in any of the above embodiments.
[0124] Please see Figure 8 Another electronic device provided in this application embodiment may further include: an input port 203 connected to the processor 202 for transmitting commands input from the outside to the processor 202; a display unit 204 connected to the processor 202 for displaying the processing results of the processor 202 to the outside; and a communication module 205 connected to the processor 202 for enabling communication between the electronic device and the outside. The display unit 204 may be a display panel, a laser scanner, or the like; the communication method used by the communication module 205 includes, but is not limited to, Mobile High-Definition Link (MHL), Universal Serial Bus (USB), High-Definition Multimedia Interface (HDMI), wireless connectivity: Wireless Fidelity (WiFi), Bluetooth communication technology, Bluetooth Low Energy communication technology, and communication technology based on IEEE 802.11s.
[0125] This application provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the steps of the SPI communication method described in any of the above embodiments.
[0126] The computer-readable storage media involved in this application include random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs (compact disc read-only memory), or any other form of storage media known in the art.
[0127] This application provides a computer program product, including a computer program / instructions, which, when executed by a processor, implement the steps of the SPI communication method described in any of the above embodiments.
[0128] For descriptions of relevant parts in the SPI communication method, electronic device, and computer-readable storage medium provided in this application's embodiments, please refer to the detailed description of the corresponding parts in the SPI communication system provided in this application's embodiments; they will not be repeated here. Furthermore, parts of the technical solutions provided in this application that are consistent with the implementation principles of corresponding technical solutions in the prior art have not been described in detail to avoid excessive elaboration.
[0129] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0130] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. An SPI communication system, characterized in that, It includes a master device and a slave device, which are connected via an SPI communication bus, the SPI communication bus including: A receive preparation line is used to transmit a receive preparation signal between the slave device and the master device, the receive preparation signal indicating that the device is ready to receive data. A receive response line is used to transmit a receive response signal between the slave device and the master device, the receive response signal indicating that the data reception operation has been completed; A data anomaly line is used to transmit a data anomaly signal between the slave device and the master device, the data anomaly signal indicating that the received data is abnormal.
2. The SPI communication system according to claim 1, characterized in that, The SPI communication bus also includes: A receive prompt line is used to transmit a receive prompt signal between the slave device and the master device, the receive prompt signal being used to indicate that preparation is made to receive data.
3. The SPI communication system according to claim 2, characterized in that, The master device includes a microcontroller unit, and the slave device includes a processor core.
4. An SPI communication method, characterized in that, A master device applied in any one of the SPI communication systems as described in claims 1 to 3, comprising: Acquire the master device data to be transmitted; Receive the receive ready signal transmitted from the device via the receive ready line; Send the master device data to the slave device; The receiver receives the response signal transmitted by the slave device via the response line; In response to receiving a data anomaly signal transmitted by the slave device via the data anomaly line, the master device performs anomaly transmission processing on the data. If a data anomaly signal is not received through the data anomaly line, the transmission of the master device data is completed.
5. The SPI communication method according to claim 4, characterized in that, After acquiring the master device data to be transmitted and before receiving the receive preparation signal transmitted by the slave device via the receive preparation line, the method further includes: A receive prompt signal is transmitted to the slave device via the receive prompt line to prepare the slave device to receive data; Sending the master device data to the slave device includes: Detect whether a reception prompt signal has been transmitted to the slave device via the reception prompt line; In response to the receipt indication signal being transmitted via the receipt indication line, the master device data is sent to the slave device.
6. The SPI communication method according to claim 5, characterized in that, After detecting whether a reception prompt signal has been transmitted to the slave device via the reception prompt line, the method further includes: In response to the failure to transmit the reception prompt signal via the reception prompt line, the slave device data transmitted by the slave device is received; After receiving the data from the slave device, a receive response signal is transmitted to the slave device via the receive response line.
7. The SPI communication method according to claim 6, characterized in that, After transmitting the receive response signal to the slave device via the receive response line, the method further includes: Detect whether the data from the slave device is abnormal; In response to the abnormal data of the slave device, a data abnormality signal is transmitted to the slave device through the data abnormality line so that the slave device performs abnormal transmission processing on the slave device data; If the slave device data is normal, the reception of the slave device data is completed.
8. An SPI communication method, characterized in that, A slave device applied in an SPI communication system as described in any one of claims 1 to 3, comprising: The receive preparation signal is transmitted to the master device via the receive preparation line; Receive master device data transmitted by the master device; After receiving the data from the master device, a receive response signal is transmitted to the master device via the receive response line; Detect whether the main device data is abnormal; In response to the abnormality of the master device data, a data abnormality signal is transmitted to the master device through the data abnormality line so that the master device can perform abnormal transmission processing on the master device data; If the master device data is found to be normal, the reception of the master device data is completed.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the SPI communication method according to any one of claims 4 to 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the SPI communication method according to any one of claims 4 to 8.
Citation Information
Patent Citations
Serial communication system between devices and method
CN102354305A
Bus data transmission method and system, and sub device
CN107465487A
Stable data transmission system based on SPI communication
CN113037419A
SPI (Serial Peripheral Interface) communication data receiving and transmitting anomaly detection control system and detection method
CN116185936A
System and method for solving SPI (Serial Peripheral Interface) master-slave switching interaction
CN116260675A
Cited By
SPI (Serial Peripheral Interface) communication system, SPI communication method and printing equipment
CN121579407A