CN111490920A - SPI-based data transmission method, system and device - Google Patents

SPI-based data transmission method, system and device Download PDF

Info

Publication number
CN111490920A
CN111490920A CN201910088059.3A CN201910088059A CN111490920A CN 111490920 A CN111490920 A CN 111490920A CN 201910088059 A CN201910088059 A CN 201910088059A CN 111490920 A CN111490920 A CN 111490920A
Authority
CN
China
Prior art keywords
target data
spi
master device
signal line
slave
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910088059.3A
Other languages
Chinese (zh)
Inventor
刘俊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Haikang Automobile Technology Co ltd
Original Assignee
Hangzhou Haikang Automobile Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Haikang Automobile Technology Co ltd filed Critical Hangzhou Haikang Automobile Technology Co ltd
Priority to CN201910088059.3A priority Critical patent/CN111490920A/en
Publication of CN111490920A publication Critical patent/CN111490920A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • H04L12/40Bus networks
    • H04L12/40006Architecture of a communication node
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L5/00Arrangements affording multiple use of the transmission path
    • H04L5/14Two-way operation using the same type of signal, i.e. duplex

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Information Transfer Systems (AREA)

Abstract

The invention provides a data transmission method, a system and a device based on SPI, the data transmission method based on SPI is applied to slave equipment, the slave equipment is connected to master equipment through an SPI signal line and a slave equipment control master equipment signal line SW, the method comprises the following steps: when the slave equipment needs to transmit target data to the master equipment, a first indication signal is sent to the master equipment through the SW, and the first indication signal is used for indicating the master equipment to receive the target data; target data is transmitted to the master device through the SPI signal line. The slave device can actively transmit data to the master device.

Description

SPI-based data transmission method, system and device
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a data transmission method, system, and apparatus based on an SPI.
Background
SPI is an abbreviation for Serial Peripheral Interface (Serial Peripheral Interface), a high-speed, full-duplex, synchronous communication bus. A master device and one or more slave devices are usually provided in an SPI communication system, full-duplex communication needs to be performed between the master device and the slave device through SPI signal lines, and the SPI signal lines usually include 4 lines: a clock signal line for the master device to transmit a clock signal to the slave device, a master output slave input data line, a master input slave output data line, and a master enable slave chip select signal line.
In a related SPI communication mode, full duplex communication between the master device and the slave device is completed through the SPI signal line, and all data interaction is dominated by the master device, that is, the master device can actively transmit data to the slave device, and when the master device controls the slave device to transmit required data to the master device, the slave device transmits data to the master device according to the master device requirements. In the above manner, all data interaction is performed when the master device needs the data interaction, and the slave device cannot actively transmit data to the master device.
Disclosure of Invention
In view of this, the present invention provides a data transmission method, system and apparatus based on SPI, which can realize the active data transmission from the slave device to the master device.
The invention provides a data transmission method based on SPI, which is applied to a slave device, the slave device is connected to a master device through an SPI signal line and a slave device control master device signal line SW, the method comprises:
when the slave equipment needs to transmit target data to the master equipment, a first indication signal is sent to the master equipment through the SW, and the first indication signal is used for indicating the master equipment to receive the target data;
target data is transmitted to the master device through the SPI signal line.
According to an embodiment of the invention, the first indication signal is further used for instructing the master device to store target data.
According to an embodiment of the present invention, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In accordance with one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
determining that the target data transfer is complete comprises: and determining that the target data transmission is completed when the end mark is transmitted.
According to an embodiment of the present invention, the transmitting the target data to the master device through the SPI signal line further includes:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
A second aspect of the present invention provides an SPI-based data transmission method, applied to a master device, which is connected to a slave device through an SPI signal line and a slave device control master device signal line SW, the method including:
receiving a first indication signal sent by a slave device through the SW, wherein the first indication signal is used for indicating the master device to receive target data;
and when the first indication signal is received, receiving target data transmitted from the equipment through the SPI signal line.
According to an embodiment of the present invention, the first indication signal is further used for instructing the master device to store target data;
after receiving the target data transmitted from the device through the SPI signal line, the method may further include:
storing the received target data in the master device.
According to an embodiment of the present invention, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In accordance with one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
after receiving the target data transmitted from the device through the SPI signal line, the method further includes:
and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
According to an embodiment of the invention, when receiving the first indication signal, the method further comprises:
judging whether the master device sends a clock signal to the slave device through the SPI signal line currently;
if yes, continuing to send a clock signal to the slave equipment through the SPI signal line;
and if not, sending a clock signal to the slave equipment through the SPI signal line.
A third aspect of the present invention provides an SPI-based data transmission system comprising a master device and a slave device, the master device being connected to the slave device through an SPI signal line and a slave device control master device signal line SW, wherein,
the slave device is used for sending a first indication signal to the master device through the SW and transmitting target data to the master device through the SPI signal line when the slave device needs to transmit the target data to the master device; the first indication signal is used for indicating the main equipment to receive target data;
the master device is used for receiving a first indication signal sent by the slave device through the SW, and receiving target data transmitted by the slave device through the SPI signal line when the first indication signal is received.
According to an embodiment of the present invention, the first indication signal is further used for instructing the master device to store target data;
the master device is further used for receiving the target data transmitted by the slave device through the SPI signal line: storing the received target data in the master device.
According to an embodiment of the present invention, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In accordance with one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
the slave device is further to: determining that the target data transmission is completed when the end marker is transmitted;
the master device is further used for receiving the target data transmitted by the slave device through the SPI signal line: and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
In accordance with one embodiment of the present invention,
upon receiving the first indication signal, the master device is further configured to: judging whether the master device sends a clock signal to the slave device through the SPI signal line currently; if yes, continuing to send a clock signal to the slave equipment through the SPI signal line; if not, sending a clock signal to the slave equipment through the SPI signal line;
the slave device, when transmitting the target data to the master device over the SPI signal line, is further to:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
A fourth aspect of the present invention provides an SPI-based data transmission apparatus applied to a slave device connected to a master device through an SPI signal line and a slave device control master device signal line SW, the apparatus comprising:
an indication signal sending module, configured to send a first indication signal to a master device through the SW when a slave device needs to transmit target data to the master device, where the first indication signal is used to indicate the master device to receive the target data;
and the target data transmission module is used for transmitting the target data to the master equipment through the SPI signal line.
According to an embodiment of the invention, the first indication signal is further used for instructing the master device to store target data.
According to an embodiment of the present invention, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In accordance with one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged; the target data transmission module is used for determining that the target data transmission is completed: and determining that the target data transmission is completed when the end mark is transmitted.
According to an embodiment of the invention, the target data transmission module is further configured to:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
A fifth aspect of the present invention provides an SPI-based data transmission apparatus, applied to a master device connected to a slave device through an SPI signal line and a slave device control master device signal line SW, the apparatus comprising:
an indication signal receiving module, configured to receive, through the SW, a first indication signal sent from a slave device, where the first indication signal is used to indicate the master device to receive target data;
and the target data receiving module is used for receiving the target data transmitted by the slave equipment through the SPI signal line when the first indication signal is received.
According to an embodiment of the present invention, the first indication signal is further used for instructing the master device to store target data;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
storing the received target data in the master device.
According to an embodiment of the present invention, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In accordance with one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
According to an embodiment of the present invention, when receiving the first indication signal, the apparatus further comprises:
the judging module is used for judging whether the master equipment sends a clock signal to the slave equipment through the SPI signal line at present;
the first clock sending module is used for continuing sending a clock signal to the slave equipment through the SPI signal line if the clock signal is received;
and the second clock sending module is used for sending a clock signal to the slave equipment through the SPI signal line if the slave equipment does not receive the clock signal.
The invention relates to an electronic device in a sixth aspect, which comprises a processor and a memory; the memory stores a program that can be called by the processor; when the processor executes the program, the SPI-based data transmission method according to the foregoing embodiment is implemented.
A seventh aspect of the present invention is a machine-readable storage medium on which a program is stored, the program, when executed by a processor, implementing the SPI-based data transmission method according to the foregoing embodiments.
The embodiment of the invention has the following beneficial effects:
in the embodiment of the invention, the signal line SW of the slave device control master device is additionally connected between the master device supporting SPI communication and the slave device, when the slave device needs to transmit the target data to the master device, the first indication signal indicating the master device to receive the target data can be transmitted through the SW, so that the master device receives the data transmitted from the slave device according to the first indication signal, and the slave device can actively transmit the data to the master device.
Drawings
Fig. 1 is a schematic flowchart of an SPI-based data transmission method according to an embodiment of the present invention;
FIG. 2 is a block diagram of an SPI-based data transmission system according to an embodiment of the present invention;
FIG. 3 is a block diagram of an SPI-based data transmission apparatus according to an embodiment of the present invention;
FIGS. 4-7 are schematic waveforms on various lines of a slave device and a master device in communication according to an embodiment of the present invention;
FIG. 8 is a flowchart illustrating a method for SPI-based data transmission according to another embodiment of the present invention;
fig. 9 is a block diagram of an SPI-based data transmission apparatus according to another embodiment of the present invention;
fig. 10 is a block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, third, etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one type of device from another. For example, a first device may also be referred to as a second device, and similarly, a second device may also be referred to as a first device, without departing from the scope of the present invention. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
In order to make the description of the present invention clearer and more concise, some technical terms in the present invention are explained below:
GPIO: general Purpose Input/Output interface, or bus extender, the GPIO interface may be configured as an Input or Output interface through software.
Full duplex communication: allowing simultaneous data transmission in both directions (from master to slave and vice to master) corresponds in its capacity to a combination of two simplex communication modes, allowing simultaneous bidirectional transmission of signals, the bidirectional transmission being temporally synchronized.
Although SPI communication is a full duplex communication method, when a master device transmits data to a slave device, the slave device transmits data to the master device synchronously. But the data transferred from the slave to the master is either invalid data or data transferred at the request of the master (passive transfer). The slave device does not actively transmit data to the master device, but the master device dominates the data transmission, and as long as the master device does not request data from the slave device, the master device is not ready to receive the data transmitted by the slave device, which is invalid data for the master device.
Therefore, in the related SPI communication, the master device and the slave device are not in peer-to-peer relationship, the slave device cannot actively transmit data to the master device, and even if the slave device actively transmits data to the master device, the master device does not prepare to receive the data, so that the SPI technology is greatly limited in an application scenario and can only be applied to a scenario in which the master device controls data transmission of the slave device.
Based on the above discovery, in the embodiment of the present invention, by additionally connecting the slave device control master device signal line SW between the master device and the slave device supporting SPI communication, when the slave device needs to transmit target data to the master device, the master device may transmit a first indication signal indicating that the master device receives the target data through the SW, so that the master device receives the data transmitted from the slave device according to the first indication signal, and the slave device may actively transmit data to the master device.
In the embodiment of the invention, under the condition that the data transmission function of the slave equipment controlled by the master equipment is not influenced, the slave equipment can actively transmit data to the master equipment, so that the communication of the master equipment and the slave equipment is more equal, the method and the device are not only suitable for the scene that the master equipment controls the data transmission of the slave equipment, but also suitable for the scene that the master equipment and the slave equipment are in equal communication, and the limitation of the SPI technology in the application scene is broken through.
The following describes the SPI-based data transmission method, system and apparatus according to the embodiments of the present invention in more detail, but should not be limited thereto.
In the embodiment of the invention, the slave device and the master device can communicate peer to peer, an SPI-based data transmission system is formed between the slave device and the master device, and full-duplex communication can be carried out between the slave device and the master device. Specifically, the master device may include embedded devices such as a single chip, a DSP (Digital Signal Processing), an ARM (Advanced RISC Machines, a 32-bit reduced instruction set processor architecture) and the like supporting SPI communication, and the slave device may also include embedded devices such as a single chip, a DSP, an ARM and the like. The master and slave devices may be the same type of device, but may of course be different.
The SPI-based data transmission system can be used in products such as a driving recorder, a vehicle machine, a TBOX (vehicle-mounted communication box for communicating with a background system, a mobile phone APP and the like in an interconnection manner), an Advanced Driver Assistance System (ADAS), a vehicle-mounted streaming media rearview mirror and the like.
Specifically, taking ADAS as an example: compared with the conventional SPI communication mode, on the basis of the SPI-based data transmission method, the MCU can also actively transmit data to the ARM, for example, the MCU can actively transmit the acquired vehicle body information states (vehicle speed, steering lamp, steering angle, brake, accelerator and the like) to the ARM.
In the embodiment of the invention, the slave device and the master device are provided with four SPI interfaces (a clock interface, a data input interface, a data output interface and a chip selection interface) supporting SPI communication, and in addition, a control interface for connecting a slave device control master device signal line SW is respectively expanded. The control interface may be implemented by a GPIO interface, where the GPIO interface of the master device is configured as an input interface and the GPIO interface of the slave device is configured as an output interface.
Because only one slave device control master device signal line needs to be added between the master device and the slave device, only one GPIO interface needs to be correspondingly extended on the master device and the slave device, the loss on software and hardware resources is less, and the control complexity is lower.
A first aspect of the present invention provides an SPI-based data transmission method, which in one embodiment is applied to a slave device, which is connected to a master device through an SPI signal line and a slave device control master device signal line SW;
referring to fig. 1, the method comprises the steps of:
s100: when the slave equipment needs to transmit target data to the master equipment, a first indication signal is sent to the master equipment through the SW, and the first indication signal is used for indicating the master equipment to receive the target data;
s200: target data is transmitted to the master device through the SPI signal line.
The execution subject of the SPI-based data transmission method of the present embodiment is a slave device supporting SPI communication, and more specifically, may be a processing unit of the slave device for processing an SPI communication-related transaction. The SPI underlying drivers of the slave device and the master device are set to be in full duplex transmission.
Referring to fig. 2, an SPI-based data transmission system is shown, including a slave device 10 and a master device 20, wherein the slave device 10 is operable to perform the above steps S100-S200, and realizes transmission of target data with the master device 20, the slave device 10 and the master device 20 are connected by an SPI signal line and a slave device control master device signal line SW, and the SPI signal line includes a clock signal line C L K for transmitting a clock signal to the slave device by the master device, a master device output slave device input data line MOSI, a master device input slave device output data line MISO, and a master device enable slave device chip select signal line cs.
In step S100, when the slave device needs to transmit target data to the master device, a first indication signal is sent to the master device through the SW, where the first indication signal is used to indicate the master device to receive the target data.
A way to determine the need to transfer target data to a master device such as, but not limited to: when the slave device acquires a first instruction indicating that target data is to be transmitted to the master device, it is determined that the target data needs to be transmitted to the master device.
The slave device may receive a plurality of first commands in a short time, and the first commands may be commands transmitted by the master device or triggered by the slave device. For example, during the process of the slave device actively transmitting data to the master device, the master device requires the slave device to passively transmit data.
In order to avoid that the slave device cannot process the corresponding transaction according to the first instruction, the received first instruction is firstly cached in the instruction cache queue, then the first instruction is sequentially obtained from the instruction cache queue, and the target data is determined to be transmitted to the master device according to the first instruction. Of course, the first instruction may also be received in real time.
Transmitting a first indication signal through the SW. The first indication signal may be a level signal, for example, when the level of the SW is a first level, it indicates that the slave device is transmitting the first indication signal to the master device, and when the level of the SW is a second level, it indicates that the slave device is not transmitting the first indication signal to the master device. The first level may be a low level and the second level may be a high level, or vice versa. Of course, the first indication signal may be a pulse signal or the like as long as it can function to notify the master device of the reception of the target data.
In step S200, target data is transmitted to the master device through the SPI signal line. Specifically, target data can be transmitted to the main device through a MISO in the SPI signal line, and the original SPI signal line is utilized to transmit the target data, so that software and hardware resources can be saved.
The target data may be data already existing in the device, or may be data acquired from an external device by the device, and is not limited in particular. The specific source of the target data may give a specific indication in the first instruction.
Since the first indication signal is used for indicating the master device to receive the target data, when the master device receives the first indication signal, the master device receives the target data through the SPI signal line according to the first indication signal. In other words, the slave device can control the master device to receive the target data through the first indication signal, and the slave device actively transmits data to the master device. When the slave device actively transmits data, the slave device informs the master device of receiving the data, and data transmission failure caused by the fact that the data are not received in the active transmission of the slave device is avoided.
The master device may implement a timely response to the first indication signal through the interrupt resource therein. Specifically, the interrupt controller of the master device sends an interrupt request to the processing unit of the master device when receiving the first indication signal, and the processing unit processes the interrupt transaction indicated by the first indication signal in time, receives the target data transmitted from the slave device in time, and prepares to receive the target data, for example, allocates a storage space for the target data. Of course, the manner in which the master responds to the first indication signal is not limited to interrupting the response.
It will be appreciated that because of the full duplex communication between the slave device and the master device, the master device will also transmit data, which may be useful data or useless data, to the slave device synchronously while the slave device is actively transmitting target data to the master device.
In one embodiment, the above method flow can be executed by the SPI-based data transmission device 100, as shown in fig. 3, the SPI-based data transmission device 100 mainly includes 2 modules: an indication signal sending module 101 and a target data transmission module 102. The indication signal sending module 101 is configured to execute the step S100, and the target data transmission module 102 is configured to execute the step S200.
In one embodiment, the first indication signal is further used to instruct the master device to store target data.
After receiving the target data transmitted by the slave device through the SPI signal line, the master device also stores the received target data in the master device for subsequent data processing. Of course, the master device may directly perform processing after receiving the target data, and store the target data after the processing is completed.
In one embodiment, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
The first indication signal is a signal whose level is maintained constant in a specified time interval, and may be a high level or a low level, and when the slave device does not transmit, the level on the SW is a level opposite to the level of the first indication signal. For example, a first indication signal with a low level is transmitted through the SW in a designated time interval; before and after the specified time interval, the level of the signal transmitted on SW is high, indicating that the slave device is not transmitting the first indication signal.
The master device needs to receive the target data in response to the first indication signal, and a certain time is required for the response process, including the reading time of the first indication signal, the time required for preparing to receive the target data, and the like. Thus, if the first indication signal starts transmission simultaneously with the target data, there may be a case where the master device delays data reception in responding to the first indication signal, resulting in incomplete received target data.
Therefore, in this embodiment, the transmission of the first indication signal precedes the transmission of the target data, and the transmission of the target data is resumed after the first indication signal has been transmitted for the first time t 1. Meanwhile, in order to avoid the problem that the target data is not completely received when the master device determines that the transmission of the first indication signal is finished due to the transmission delay, in this embodiment, the slave device continues to transmit the first indication signal for the second time t2 through the SW after determining that the transmission of the target data is finished.
t1 and t2 are not particularly limited and may be determined based on the data throughput rate associated with the SPI communication by the master device, such as the time required to throughput a specified amount of data, which may be 1, 2, 4, or 8 bytes, etc. Of course, other factors, such as master interrupt response time, etc., may also be considered, and t1 or t2 used for each transmission may be the same or different.
In one embodiment, the target data comprises a start marker, valid data, and an end marker arranged in sequence;
determining that the target data transfer is complete comprises: and determining that the target data transmission is completed when the end mark is transmitted.
Due to the full-duplex communication between the slave device and the master device, the slave device can synchronously transmit data to the master device in the process of transmitting data to the slave device, if the slave device needs to transmit target data to the master device in the process, the target data can be mixed with useless data, and the master device is very likely to receive the useless data when receiving the data, so that the distinction between the useless data and the target data needs to be considered.
In this embodiment, the head of the valid data is a start mark, and the tail of the valid data is an end mark, where the start mark determines the start of transmission of the target data when transmission of the start mark starts, and the end mark determines the completion of transmission of the target data when transmission of the end mark is completed. In this manner, the useless data can be distinguished from the target data.
The master device can obtain valid data in the target data according to the start mark and the end mark. Of course, the master device may store all the received data, and identify the target data from the data during the subsequent processing, and acquire valid data from the target data.
In one embodiment, said transmitting target data to the master device over the SPI signal line further comprises:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
In order to realize data transmission and reception synchronization of the master device and the slave device, when the master device receives a first indication signal, the master device judges whether the master device transmits a clock signal to the slave device through C L K currently, if not, the clock signal is transmitted to the slave device through C L K, if yes, the clock signal is continuously transmitted to the slave device through C L K, so that the slave device transmits target data to the master device through an SPI signal line based on the clock signal received through C L K, and synchronous transmission of the data is realized.
In the case where the master device is required to enable the slave device, the master device may also transmit a chip select signal to the slave device through the CS to enable the slave device when transmitting a clock signal to the slave device through C L K.
In the waveforms corresponding to MISO and MOSI of fig. 4-7, there are filled patterns indicating that useful data is being transmitted and no filled patterns indicating that useless data is being transmitted, in the waveform corresponding to CS, there are low periods indicating that the master is enabled for the slave and communication can be performed between the master and the slave and high periods not enabled, the master transmits a clock signal for clock synchronization to the slave through C L K, and in order to ensure synchronization, the master transmits a clock signal to the slave through C L K when any one of the slave and the master actively transmits data.
The first state: referring to fig. 4, the master device actively transmits data to the slave device (hereinafter, useful data actively transmitted by the master device is referred to as a data), and the slave device does not have useful data to transmit and thus transmits useless data to the master device. The master device transmits A data to the slave device through the MOSI, and the slave device receives the A data; the waveform corresponding to the SW is high level, which indicates that the first indicating signal is not transmitted on the SW; the slave device synchronously transfers the useless data to the master device through the MISO, and the master device does not receive the useless data because the master device does not receive the first indication signal.
The second state: referring to fig. 5, the master device does not have a data to be transmitted, and the slave device transmits useful data (the useful data transmitted by the slave device is target data) to the master device. After the waveform corresponding to the SW is subjected to transition from high to low, the waveform corresponding to the SW maintains the low level for the first time t1, the slave starts to transmit target data to the master through the MISO and finishes transmitting the target data, and after the waveform corresponding to the SW continues to maintain the low level for the first time t2, the waveform corresponding to the SW is subjected to transition from low to high; the master device receives the target data through the MISO when receiving the first indication signal; the method comprises the steps that a master device transmits useless data to a slave device through an MOSI, the slave device needs to receive and store all data transmitted by the master device, and then the data are analyzed according to a packet protocol, effective data in the stored data are obtained, and the useless data are discarded.
The third state: referring to fig. 6, after the master starts to transmit a data to the slave for a certain period of time, the slave transmits target data to the master, and the target data of the slave is transmitted earlier than the a data of the master. The waveform corresponding to the SW is changed from high to low and then changed from low to high in the process of A data transmission, the low level indicates that a first indication signal is transmitted on the SW, after the waveform corresponding to the SW completes the jump from high to low, the waveform corresponding to the SW maintains the low level for the first time t1, the slave device starts to transmit target data to the master device through the MISO, the target data is transmitted, and after the waveform corresponding to the SW continues to maintain the low level for the first time t2, the waveform corresponding to the SW further jumps from low to high; the master device receives the target data through the MISO when receiving the first indication signal; the master device transmits the A data to the slave device through the MOSI, and the slave device receives and stores the A data.
Referring to fig. 7, after a period of time, the master device starts to transmit a data to the slave device, the slave device starts to transmit target data to the master device, the a data of the master device is transmitted before the target data of the master device, the waveform corresponding to SW is changed from high to low and then changed from low to high in the process of transmitting the a data, the low level indicates that the slave device transmits a first indication signal to the master device through the SW, wherein after the waveform corresponding to SW is changed from high to low, the waveform corresponding to SW maintains the low level for a first time t1, the slave device starts to transmit the target data to the master device through MISO, the target data is transmitted, after the waveform corresponding to SW continues to maintain the low level for a first time t2, the waveform corresponding to SW is changed from low to high, the master device transmits the a data to the slave device through the MOSI, and when the a data transmission is finished, the slave device receives and stores all data transmitted by the master device, then analyzes according to the packet protocol, the a data is obtained from the stored and the slave device transmits a useless data when the first indication signal is lost, the slave device also transmits the clock signal when the clock signal is lost, L, the slave device stops transmitting.
A second aspect of the present invention provides an SPI-based data transmission method, which in one embodiment is applied to a master device connected to a slave device through an SPI signal line and a slave device control master device signal line SW;
referring to fig. 8, the method includes the steps of:
t100: receiving a first indication signal sent by a slave device through the SW, wherein the first indication signal is used for indicating the master device to receive target data;
t200: and when the first indication signal is received, receiving target data transmitted from the equipment through the SPI signal line.
In one embodiment, the above method flow can be executed by an SPI-based data transmission device, as shown in fig. 9, the SPI-based data transmission device 200 mainly includes 2 modules: an indication signal receiving module 201 and a target data receiving module 202. The indication signal receiving module 201 is configured to perform the step T100, and the target data receiving module 202 is configured to perform the step T200.
In one embodiment, the first indication signal is further used to instruct the master device to store target data;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
storing the received target data in the master device.
In one embodiment, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In one embodiment, the target data comprises a start marker, valid data, and an end marker arranged in sequence;
after receiving the target data transmitted from the device through the SPI signal line, the method further includes:
and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
In one embodiment, when receiving the first indication signal, the method further comprises:
judging whether the master device sends a clock signal to the slave device through the SPI signal line currently;
if yes, continuing to send a clock signal to the slave equipment through the SPI signal line;
and if not, sending a clock signal to the slave equipment through the SPI signal line.
For the specific content of the SPI-based data transmission method provided by the second aspect of the present invention, reference may be made to the aforementioned description of the SPI-based data transmission method provided by the first aspect of the present invention, and details are not repeated herein.
A third aspect of the present invention provides an SPI-based data transmission system, referring to fig. 2, comprising a master device 20 and a slave device 10, the master device 20 being connected to the slave device 10 through an SPI signal line, and a slave device control master device signal line SW, wherein,
the slave device 10 is configured to send a first indication signal to the master device 20 through the SW and transmit target data to the master device 20 through the SPI signal line when the slave device 10 needs to transmit the target data to the master device; the first indication signal is used for indicating the main device 20 to receive target data;
the master device 20 is configured to receive a first indication signal sent from the slave device 10 through the SW, and receive target data transmitted from the slave device 10 through the SPI signal line when receiving the first indication signal.
The SPI-based data transmission system according to the embodiment of the present invention is described in more detail below with reference to fig. 2, but should not be limited thereto.
The slave device 10 and the master device 20 are connected through an SPI signal line and a slave device control master device signal line SW, the SPI signal line comprises a clock signal line C L K for transmitting a clock signal to the slave device by the master device, a master device output slave device input data line MOSI, a master device input slave device output data line MISO and a master device enable slave device chip selection signal line CS.
A way to determine the need for a slave device 10 to transfer target data to a master device 20 such as, but not limited to: when the slave device 10 acquires the first instruction instructing the transfer of the target data to the master device 20, it is determined that the transfer of the target data to the master device 20 is necessary.
The slave device 10 may receive a plurality of first commands in a short time, and these first commands may be commands transmitted from the master device 20 or triggered commands on the slave device 10. For example, during the active transmission of data from slave device 10 to master device 20, master device 20 requires slave device 10 to passively transmit data.
In order to avoid that the slave device 10 cannot process the corresponding transaction according to the first instruction, the received first instruction may be buffered in the instruction buffer queue, and then the first instruction is sequentially obtained from the instruction buffer queue, and it is determined that the target data needs to be transmitted to the master device 20 according to the first instruction. Of course, the first instruction may also be received in real time.
When the slave device 10 needs to transmit target data to the master device, the slave device 10 transmits a first instruction signal to the master device 20 through the SW. The first indication signal may be a level signal, for example, when the level on SW is a first level, indicating that the slave device 10 is transmitting the first indication signal to the master device 20, and when the level on SW is a second level, indicating that the slave device 10 is not transmitting the first indication signal to the master device 20. The first level may be a low level and the second level may be a high level, or vice versa. Of course, the first instruction signal may be a pulse signal or the like as long as it can function to notify the host device 20 of the reception of the target data.
The slave device 10 transmits target data to the master device 20 through the SPI signal line. Specifically, target data can be transmitted to the main device through a MISO in the SPI signal line, and the original SPI signal line is utilized to transmit the target data, so that software and hardware resources can be saved.
The target data may be data already existing in the device 10, or may be data acquired from an external device by the device 10, and is not limited in particular. The specific source of the target data may give a specific indication in the first instruction.
When the slave device 10 transmits the first indication signal to the master device 20 through the SW, correspondingly, the master device 20 may receive the first indication signal transmitted from the slave device 10 through the SW, and when the master device 20 receives the first indication signal, the master device 20 receives the target data transmitted from the slave device 10 through the SPI signal line.
Since the first indication signal is used to indicate the master device 20 to receive the target data, when the master device 20 receives the first indication signal, the target data is received through the SPI signal line according to the first indication signal. In other words, the slave device 10 may control the master device 20 to receive the target data through the first indication signal, which enables the slave device 10 to actively transmit data to the master device 20. When the slave device 10 actively transmits data, the master device 20 is notified to receive the data, so that the slave device 10 is prevented from actively transmitting data and failing to transmit the data because the data is not received.
Master device 20 may implement a timely response to the first indication signal through the interrupt resource therein. Specifically, the interrupt controller of the master device 20 sends an interrupt request to the processing unit of the master device 20 when receiving the first indication signal, and the processing unit processes the interrupt transaction indicated by the first indication signal in time, receives the target data transmitted from the slave device 10 in time, and also performs a preparation operation for receiving the target data, such as allocating a storage space for the target data. Of course, the manner in which master device 20 responds to the first indication signal is not limited to interrupting the response.
It will be appreciated that due to the full duplex communication between the slave device 10 and the master device 20, when the slave device 10 actively transmits target data to the master device 20, the master device 20 may also synchronously transmit data, which may be useful data or useless data, to the slave device 10.
In one embodiment, the first indication signal is further used to instruct the master device 20 to store target data;
the master device 20, after receiving the target data transmitted from the slave device 10 through the SPI signal line, is further configured to: the received target data is stored in the master device 20.
After receiving the target data transmitted from the slave device 10 through the SPI signal line, the master device 20 further stores the received target data in the master device 20 according to the indication of the first indication signal, and may store the received target data in the memory of the master device 20, so as to perform subsequent data processing. Of course, the host device 20 may directly perform processing after receiving the target data, and may store the target data after the processing is completed.
In one embodiment, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
The first indication signal is a signal whose level is maintained constant in a specified time interval, and may be a high level or a low level, and when the slave device 10 does not transmit the first indication signal, the level on the SW is a level opposite to the level of the first indication signal. For example, a first indication signal with a low level is transmitted through the SW in a designated time interval; before and after the specified time interval, the level of the signal transmitted on SW is high, indicating that the slave device 10 is not transmitting the first indication signal.
The master device 20 needs to receive the target data in response to the first indication signal, and the response process needs a certain time including the reading time of the first indication signal, the time needed to prepare for receiving the target data, and the like. Thus, if the first indication signal starts transmission simultaneously with the target data, there may be a case where data reception is delayed in the host device 20 in response to the first indication signal, resulting in incomplete received target data.
Therefore, in this embodiment, the transmission of the first indication signal precedes the transmission of the target data, and the transmission of the target data is resumed after the first indication signal has been transmitted for the first time t 1. Meanwhile, in order to avoid the problem that the target data is not completely received when the master device 20 determines that the transmission of the first indication signal is finished due to the transmission delay, in this embodiment, the slave device 10 continues to transmit the first indication signal through the SW for the second time t2 after determining that the transmission of the target data is finished.
t1 and t2 are not particularly limited and may be determined based on the data throughput rate associated with SPI communications by master device 20, such as the time required to throughput a specified amount of data, which may be 1, 2, 4, or 8 bytes, etc. Of course, other factors may also be considered, such as master 20 interrupt response time, etc., and t1 or t2 used for each transmission may be the same or different.
In one embodiment, the target data comprises a start marker, valid data, and an end marker arranged in sequence;
the slave device 10 is further configured to: determining that the target data transmission is completed when the end marker is transmitted;
the master device 20, after receiving the target data transmitted from the slave device through the SPI signal line, is further configured to: and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
Due to the full duplex communication between the slave device 10 and the master device 20, during the process of transmitting data from the master device 20 to the slave device 10, the slave device 10 will synchronously transmit data to the master device 20, if during the process, the slave device 10 needs to transmit target data to the master device 20, the target data will be included in some useless data, and when receiving data, the master device 20 will most likely receive some useless data, and it needs to consider how to distinguish the useless data from the target data.
In this embodiment, the head of the valid data is a start mark, and the tail of the valid data is an end mark, where the start mark determines the start of transmission of the target data when transmission of the start mark starts, and the end mark determines the completion of transmission of the target data when transmission of the end mark is completed. In this manner, the useless data can be distinguished from the target data.
The host device 20 may obtain valid data in the target data according to the start flag and the end flag. Of course, the host device 20 may store all the received data, and identify the target data from the data during the subsequent processing, and obtain the valid data from the target data.
In one embodiment, upon receiving the first indication signal, the master device 20 is further configured to: judging whether the master device 20 currently sends a clock signal to the slave device through the SPI signal line; if yes, continuing to send a clock signal to the slave device 10 through the SPI signal line; if not, sending a clock signal to the slave device 10 through the SPI signal line;
the slave device 10, when transmitting target data to the master device 20 via the SPI signal line, is further configured to:
in the process of receiving the clock signal transmitted by the master device 20 through the SPI signal line by the slave device 10, target data is transmitted to the master device 20 through the SPI signal line based on the clock signal.
In order to realize data transmission and reception synchronization of the master device and the slave device, when receiving the first indication signal, the master device 20 determines whether the master device 20 is currently transmitting a clock signal to the slave device 10 through C L K, if not, the clock signal is transmitted to the slave device 10 through C L K in the SPI signal line, if so, the clock signal is continuously transmitted to the slave device 10 through C L K, so that the slave device 10 transmits target data to the master device 20 through MISO in the SPI signal line based on the clock signal received through C L K, and synchronous transmission of the data is realized.
In the case where the master device 20 is required to enable the slave device 20, the master device 20 may also transmit a chip select signal to the slave device 10 through the CS in the SPI signal line to enable the slave device 10 when transmitting a clock signal to the slave device 10 through C L K.
In the waveforms corresponding to MISO and MOSI of fig. 4-7, there are filled patterns indicating that useful data is being transmitted and no filled patterns indicating that useless data is being transmitted, in the waveform corresponding to CS, there are low periods indicating that the master is enabled for the slave and communication can be performed between the master and the slave and high periods not enabled, the master transmits a clock signal for clock synchronization to the slave through C L K, and in order to ensure synchronization, the master transmits a clock signal to the slave through C L K when any one of the slave and the master actively transmits data.
The first state: referring to fig. 4, the master device actively transmits data to the slave device (hereinafter, useful data actively transmitted by the master device is referred to as a data), and the slave device does not have useful data to transmit and thus transmits useless data to the master device. The master device transmits A data to the slave device through the MOSI, and the slave device receives the A data; the waveform corresponding to the SW is high level, which indicates that the first indicating signal is not transmitted on the SW; the slave device synchronously transfers the useless data to the master device through the MISO, and the master device does not receive the useless data because the master device does not receive the first indication signal.
The second state: referring to fig. 5, the master device does not have a data to be transmitted, and the slave device transmits useful data (the useful data transmitted by the slave device is target data) to the master device. After the waveform corresponding to the SW is subjected to transition from high to low, the waveform corresponding to the SW maintains the low level for the first time t1, the slave starts to transmit target data to the master through the MISO and finishes transmitting the target data, and after the waveform corresponding to the SW continues to maintain the low level for the first time t2, the waveform corresponding to the SW is subjected to transition from low to high; the master device receives the target data through the MISO when receiving the first indication signal; the method comprises the steps that a master device transmits useless data to a slave device through an MOSI, the slave device needs to receive and store all data transmitted by the master device, and then the data are analyzed according to a packet protocol, effective data in the stored data are obtained, and the useless data are discarded.
The third state: referring to fig. 6, after the master starts to transmit a data to the slave for a certain period of time, the slave transmits target data to the master, and the target data of the slave is transmitted earlier than the a data of the master. The waveform corresponding to the SW is changed from high to low and then changed from low to high in the process of A data transmission, the low level indicates that a first indication signal is transmitted on the SW, after the waveform corresponding to the SW completes the jump from high to low, the waveform corresponding to the SW maintains the low level for the first time t1, the slave device starts to transmit target data to the master device through the MISO, the target data is transmitted, and after the waveform corresponding to the SW continues to maintain the low level for the first time t2, the waveform corresponding to the SW further jumps from low to high; the master device receives the target data through the MISO when receiving the first indication signal; the master device transmits the A data to the slave device through the MOSI, and the slave device receives and stores the A data.
Referring to fig. 7, after a period of time, the master device starts to transmit a data to the slave device, the slave device starts to transmit target data to the master device, the a data of the master device is transmitted before the target data of the master device, the waveform corresponding to SW is changed from high to low and then changed from low to high in the process of transmitting the a data, the low level indicates that the slave device transmits a first indication signal to the master device through the SW, wherein after the waveform corresponding to SW is changed from high to low, the waveform corresponding to SW maintains the low level for a first time t1, the slave device starts to transmit the target data to the master device through MISO, the target data is transmitted, after the waveform corresponding to SW continues to maintain the low level for a first time t2, the waveform corresponding to SW is changed from low to high, the master device transmits the a data to the slave device through the MOSI, and when the a data transmission is finished, the slave device receives and stores all data transmitted by the master device, then analyzes according to the packet protocol, the a data is obtained from the stored and the slave device transmits a useless data when the first indication signal is lost, the slave device also transmits the clock signal when the clock signal is lost, L, the slave device stops transmitting.
A fourth aspect of the present invention provides an SPI-based data transmission apparatus, which is applied to a slave device connected to a master device through an SPI signal line and a slave device control master device signal line SW;
referring to fig. 3, the SPI-based data transmission device 100 includes:
an indication signal sending module 101, configured to send a first indication signal to a master device through the SW when a slave device needs to transmit target data to the master device, where the first indication signal is used to indicate the master device to receive the target data;
and a target data transmission module 102, configured to transmit the target data to the master device through the SPI signal line.
In one embodiment, the first indication signal is further used to instruct the master device to store target data.
In one embodiment, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged; the target data transmission module is used for determining that the target data transmission is completed: and determining that the target data transmission is completed when the end mark is transmitted.
In one embodiment, the target data transfer module is further configured to:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
The implementation process of the function and the effect of each unit in the SPI-based data transmission device provided in the fourth aspect of the present invention is specifically detailed in the implementation process of the corresponding step in the SPI-based data transmission method provided in the first aspect of the present invention, and is not described herein again.
A fifth aspect of the present invention provides an SPI-based data transmission apparatus, which is applied to a master device, the master device being connected to a slave device through an SPI signal line and a slave device control master device signal line SW;
referring to fig. 9, the SPI-based data transmission device 200 includes:
an indication signal receiving module 201, configured to receive a first indication signal sent by a slave device through the SW, where the first indication signal is used to indicate the master device to receive target data;
and a target data receiving module 202, configured to receive, when the first indication signal is received, target data transmitted from the device through the SPI signal line.
In one embodiment, the first indication signal is further used to instruct the master device to store target data;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
storing the received target data in the master device.
In one embodiment, the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
In one embodiment of the present invention,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
In one embodiment, when receiving the first indication signal, the apparatus further comprises:
the judging module is used for judging whether the master equipment sends a clock signal to the slave equipment through the SPI signal line at present;
the first clock sending module is used for continuing sending a clock signal to the slave equipment through the SPI signal line if the clock signal is received;
and the second clock sending module is used for sending a clock signal to the slave equipment through the SPI signal line if the slave equipment does not receive the clock signal.
The implementation process of the function and the effect of each unit in the SPI-based data transmission device provided in the fifth aspect of the present invention is specifically detailed in the implementation process of the corresponding step in the SPI-based data transmission method provided in the second aspect of the present invention, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, wherein the units described as separate parts may or may not be physically separate, and the parts shown as units may or may not be physical units.
The invention also provides an electronic device, which comprises a processor and a memory; the memory stores a program that can be called by the processor; when the processor executes the program, the SPI-based data transmission method as described in the foregoing embodiment is implemented.
The embodiments of the SPI-based data transmission apparatus provided in the fourth and fifth aspects of the present invention can be applied to an electronic device, and accordingly, the electronic device serves as a slave device. The embodiments of the SPI-based data transmission apparatus according to the fourth and fifth aspects of the present invention can also be applied to an electronic device, and accordingly, the electronic device serves as a master device. Taking a software implementation as an example, as a logical device, the device is formed by reading, by a processor of the electronic device where the device is located, a corresponding computer program instruction in the nonvolatile memory into the memory for operation. From a hardware aspect, as shown in fig. 10, fig. 10 is a hardware structure diagram of an electronic device where the SPI-based data transmission device 100 is located according to an exemplary embodiment of the present invention, and except for the processor 510, the memory 530, the interface 520, and the nonvolatile memory 540 shown in fig. 10, the electronic device where the device 100 is located in the embodiment may also include other hardware according to an actual function of the electronic device, which is not described again.
The present invention also provides a machine-readable storage medium on which a program is stored, which when executed by a processor, implements the SPI-based data transmission method as described in any one of the preceding embodiments.
The present invention may take the form of a computer program product embodied on one or more storage media including, but not limited to, disk storage, CD-ROM, optical storage, and the like, having program code embodied therein. Machine-readable storage media include both permanent and non-permanent, removable and non-removable media, and the storage of information may be accomplished by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of machine-readable storage media include, but are not limited to: phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technologies, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium, may be used to store information that may be accessed by a computing device.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (25)

1. An SPI-based data transmission method applied to a slave device connected to a master device through an SPI signal line and a slave device control master device signal line SW, the method comprising:
when the slave equipment needs to transmit target data to the master equipment, a first indication signal is sent to the master equipment through the SW, and the first indication signal is used for indicating the master equipment to receive the target data;
target data is transmitted to the master device through the SPI signal line.
2. The SPI-based data transmission method according to claim 1, wherein said first indication signal is also used to instruct said master device to store target data.
3. The SPI-based data transmission method according to claim 1, wherein the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
4. The SPI-based data transmission method of claim 1,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
determining that the target data transfer is complete comprises: and determining that the target data transmission is completed when the end mark is transmitted.
5. The SPI-based data transmission method of claim 1, wherein said transmitting target data to a master device through an SPI signal line further comprises:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
6. An SPI-based data transmission method applied to a master device connected to a slave device through an SPI signal line and a slave device control master device signal line SW, the method comprising:
receiving a first indication signal sent by a slave device through the SW, wherein the first indication signal is used for indicating the master device to receive target data;
and when the first indication signal is received, receiving target data transmitted from the equipment through the SPI signal line.
7. The SPI-based data transmission method according to claim 6, wherein said first indication signal is further used to instruct said master device to store target data;
after receiving the target data transmitted from the device through the SPI signal line, the method may further include:
storing the received target data in the master device.
8. The SPI based data transmission method according to claim 6, wherein the first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
9. The SPI-based data transmission method of claim 6,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
after receiving the target data transmitted from the device through the SPI signal line, the method further includes:
and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
10. The SPI-based data transmission method of claim 6, wherein upon receipt of said first indication signal, the method further comprises:
judging whether the master device sends a clock signal to the slave device through the SPI signal line currently;
if yes, continuing to send a clock signal to the slave equipment through the SPI signal line;
and if not, sending a clock signal to the slave equipment through the SPI signal line.
11. An SPI-based data transmission system comprising a master device and a slave device, the master device being connected to the slave device via an SPI signal line and a slave device control master device signal line SW, wherein,
the slave device is used for sending a first indication signal to the master device through the SW and transmitting target data to the master device through the SPI signal line when the slave device needs to transmit the target data to the master device; the first indication signal is used for indicating the main equipment to receive target data;
the master device is used for receiving a first indication signal sent by the slave device through the SW, and receiving target data transmitted by the slave device through the SPI signal line when the first indication signal is received.
12. The SPI-based data transmission system according to claim 11, wherein said first indication signal is further used to instruct said master device to store target data;
the master device is further used for receiving the target data transmitted by the slave device through the SPI signal line: storing the received target data in the master device.
13. The SPI based data transmission system according to claim 11, wherein said first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
14. The SPI-based data transmission system of claim 11,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
the slave device is further to: determining that the target data transmission is completed when the end marker is transmitted;
the master device is further used for receiving the target data transmitted by the slave device through the SPI signal line: and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
15. The SPI-based data transmission system of claim 11,
upon receiving the first indication signal, the master device is further configured to: judging whether the master device sends a clock signal to the slave device through the SPI signal line currently; if yes, continuing to send a clock signal to the slave equipment through the SPI signal line; if not, sending a clock signal to the slave equipment through the SPI signal line;
the slave device, when transmitting the target data to the master device over the SPI signal line, is further to:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
16. An SPI-based data transmission apparatus applied to a slave device connected to a master device through an SPI signal line and a slave device control master device signal line SW, the apparatus comprising:
an indication signal sending module, configured to send a first indication signal to a master device through the SW when a slave device needs to transmit target data to the master device, where the first indication signal is used to indicate the master device to receive the target data;
and the target data transmission module is used for transmitting the target data to the master equipment through the SPI signal line.
17. The SPI-based data transmission apparatus according to claim 16, wherein said first indication signal is further used to instruct said master device to store target data.
18. The SPI based data transmission device according to claim 16, wherein said first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
19. The SPI-based data transmission apparatus of claim 16,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged; the target data transmission module is used for determining that the target data transmission is completed: and determining that the target data transmission is completed when the end mark is transmitted.
20. The SPI-based data transmission device of claim 16, wherein the target data transmission module is further configured to:
and in the process that the slave device receives a clock signal sent by the master device through the SPI signal line, transmitting target data to the master device through the SPI signal line based on the clock signal.
21. An SPI-based data transmission apparatus, applied to a master device connected to a slave device through an SPI signal line and a slave device control master device signal line SW, comprising:
an indication signal receiving module, configured to receive, through the SW, a first indication signal sent from a slave device, where the first indication signal is used to indicate the master device to receive target data;
and the target data receiving module is used for receiving the target data transmitted by the slave equipment through the SPI signal line when the first indication signal is received.
22. The SPI-based data transmission apparatus according to claim 21, wherein said first indication signal is further used to instruct said master device to store target data;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
storing the received target data in the master device.
23. The SPI based data transmission device according to claim 21, wherein said first indication signal is a signal whose level is maintained constant for a specified time interval;
the target data is transmitted beginning at a first time t1 after the smaller end of time of the specified time interval and is transmitted completing at a second time t2 before the larger end of time of the specified time interval; the t1 is earlier than the t 2.
24. An SPI-based data transmission apparatus as recited in claim 21,
the target data comprises a start mark, effective data and an end mark which are sequentially arranged;
after the target data receiving module receives the target data transmitted from the device through the SPI signal line, the target data receiving module is further configured to:
and acquiring effective data in the target data according to the starting mark and the ending mark, and executing corresponding processing on the effective data.
25. The SPI-based data transmission device of claim 21, when receiving said first indication signal, further comprising:
the judging module is used for judging whether the master equipment sends a clock signal to the slave equipment through the SPI signal line at present;
the first clock sending module is used for continuing sending a clock signal to the slave equipment through the SPI signal line if the clock signal is received;
and the second clock sending module is used for sending a clock signal to the slave equipment through the SPI signal line if the slave equipment does not receive the clock signal.
CN201910088059.3A 2019-01-29 2019-01-29 SPI-based data transmission method, system and device Pending CN111490920A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910088059.3A CN111490920A (en) 2019-01-29 2019-01-29 SPI-based data transmission method, system and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910088059.3A CN111490920A (en) 2019-01-29 2019-01-29 SPI-based data transmission method, system and device

Publications (1)

Publication Number Publication Date
CN111490920A true CN111490920A (en) 2020-08-04

Family

ID=71811525

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910088059.3A Pending CN111490920A (en) 2019-01-29 2019-01-29 SPI-based data transmission method, system and device

Country Status (1)

Country Link
CN (1) CN111490920A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984581A (en) * 2020-08-14 2020-11-24 广州邦讯信息系统有限公司 Linux-based SPI bus master-slave device communication system, method and device
CN112100100A (en) * 2020-08-26 2020-12-18 广州华欣电子科技有限公司 SPI communication method and SPI equipment
CN114338260A (en) * 2020-09-28 2022-04-12 宝能汽车集团有限公司 Display control system and method of vehicle digital instrument and vehicle
CN114528235A (en) * 2022-01-21 2022-05-24 厦门亿联网络技术股份有限公司 SPI (Serial peripheral interface) -based communication method, slave equipment and system
CN116795764A (en) * 2023-08-23 2023-09-22 北京紫光芯能科技有限公司 Control method and device for SPI master device to read data in slave device
CN114528235B (en) * 2022-01-21 2024-05-31 厦门亿联网络技术股份有限公司 SPI-based communication method, slave device and system

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101552733A (en) * 2009-05-15 2009-10-07 深圳华为通信技术有限公司 Data transmission realizing method and system based on SPI
CN102567261A (en) * 2010-12-31 2012-07-11 联芯科技有限公司 Enhanced SPI (serial peripheral interface) controller, communication system of enhanced SPI and data transmission method
CN103460201A (en) * 2011-02-15 2013-12-18 北欧半导体公司 Serial interface
CN103744825A (en) * 2013-12-31 2014-04-23 北京中宇新泰科技发展有限公司 Bidirectional real-time communication method of extendable and compatible SPI (Serial Peripheral Interface)
CN205263808U (en) * 2015-12-28 2016-05-25 杭州士兰控股有限公司 SPI slave unit and SPI communication system
CN106528484A (en) * 2016-10-28 2017-03-22 中国科学院上海微系统与信息技术研究所 Serial communication method
CN108446243A (en) * 2018-03-20 2018-08-24 上海奉天电子股份有限公司 A kind of two-way communication and system based on Serial Peripheral Interface (SPI)
CN108475241A (en) * 2016-09-29 2018-08-31 华为技术有限公司 A kind of data transmission method and device based on SPI
CN108763140A (en) * 2018-04-23 2018-11-06 深圳市文鼎创数据科技有限公司 A kind of method of two-way communication, system and terminal device
CN109240971A (en) * 2018-09-26 2019-01-18 威创集团股份有限公司 Communication means, apparatus and system

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101552733A (en) * 2009-05-15 2009-10-07 深圳华为通信技术有限公司 Data transmission realizing method and system based on SPI
CN102567261A (en) * 2010-12-31 2012-07-11 联芯科技有限公司 Enhanced SPI (serial peripheral interface) controller, communication system of enhanced SPI and data transmission method
CN103460201A (en) * 2011-02-15 2013-12-18 北欧半导体公司 Serial interface
CN103744825A (en) * 2013-12-31 2014-04-23 北京中宇新泰科技发展有限公司 Bidirectional real-time communication method of extendable and compatible SPI (Serial Peripheral Interface)
CN205263808U (en) * 2015-12-28 2016-05-25 杭州士兰控股有限公司 SPI slave unit and SPI communication system
CN108475241A (en) * 2016-09-29 2018-08-31 华为技术有限公司 A kind of data transmission method and device based on SPI
CN106528484A (en) * 2016-10-28 2017-03-22 中国科学院上海微系统与信息技术研究所 Serial communication method
CN108446243A (en) * 2018-03-20 2018-08-24 上海奉天电子股份有限公司 A kind of two-way communication and system based on Serial Peripheral Interface (SPI)
CN108763140A (en) * 2018-04-23 2018-11-06 深圳市文鼎创数据科技有限公司 A kind of method of two-way communication, system and terminal device
CN109240971A (en) * 2018-09-26 2019-01-18 威创集团股份有限公司 Communication means, apparatus and system

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111984581A (en) * 2020-08-14 2020-11-24 广州邦讯信息系统有限公司 Linux-based SPI bus master-slave device communication system, method and device
CN111984581B (en) * 2020-08-14 2022-05-10 广州邦讯信息系统有限公司 Linux-based SPI bus master-slave device communication system, method and device
CN112100100A (en) * 2020-08-26 2020-12-18 广州华欣电子科技有限公司 SPI communication method and SPI equipment
CN114338260A (en) * 2020-09-28 2022-04-12 宝能汽车集团有限公司 Display control system and method of vehicle digital instrument and vehicle
CN114528235A (en) * 2022-01-21 2022-05-24 厦门亿联网络技术股份有限公司 SPI (Serial peripheral interface) -based communication method, slave equipment and system
CN114528235B (en) * 2022-01-21 2024-05-31 厦门亿联网络技术股份有限公司 SPI-based communication method, slave device and system
CN116795764A (en) * 2023-08-23 2023-09-22 北京紫光芯能科技有限公司 Control method and device for SPI master device to read data in slave device
CN116795764B (en) * 2023-08-23 2024-01-02 北京紫光芯能科技有限公司 Control method and device for SPI master device to read data in slave device

Similar Documents

Publication Publication Date Title
CN111490920A (en) SPI-based data transmission method, system and device
US6721836B2 (en) Bus system having an address/control bus and a data bus, and a data transfer method thereof
US20060236001A1 (en) Direct memory access controller
CN103324599A (en) Inter-processor communication method and system on chip
CN113127213A (en) Method, device, equipment and storage medium for supporting multi-application data sharing
CN111984581B (en) Linux-based SPI bus master-slave device communication system, method and device
JP4902640B2 (en) Integrated circuit and integrated circuit system
US20180173651A1 (en) Data storage device access method, device and system
JPH08161254A (en) Information processing system and bus arbitration system therefor
US20040054843A1 (en) Configuration and method having a first device and a second device connected to the first device through a cross bar
JPH1040215A (en) Pci bus system
KR101260313B1 (en) Electric apparatus and data sending/receiving method thereof and slave apparatus and communication method between the plural number of apparatuses
KR100633742B1 (en) Direct memory access controller for updating data transmission size automatically from peripheral, and control method thereof
EP3819778A1 (en) Bus system and method for operating a bus system
US20140281381A1 (en) System-on-chip and method of operating the same
JP2006119724A (en) Cpu system, bus bridge, its control method, and computer system
JP2020098386A (en) Bus system
JP7363344B2 (en) Memory control device and control method
CN117439832A (en) Communication control method and system applied to host computer end and slave computer end
CN117407336A (en) DMA transmission method and device, SOC and electronic equipment
CN118138639A (en) Integrated domain controller, sensor data cross-domain transmission method thereof and vehicle-mounted equipment
KR20070081981A (en) Interface method and apparatus in cpuless system
US9921995B2 (en) Managing data in USB communication
CN117539805A (en) Sideband access method, memory controller, core particle and computer equipment
CN116601618A (en) USB-based communication method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200804