CN115687198A - Device communication device and method based on SPI - Google Patents

Device communication device and method based on SPI Download PDF

Info

Publication number
CN115687198A
CN115687198A CN202211306785.6A CN202211306785A CN115687198A CN 115687198 A CN115687198 A CN 115687198A CN 202211306785 A CN202211306785 A CN 202211306785A CN 115687198 A CN115687198 A CN 115687198A
Authority
CN
China
Prior art keywords
data
slave
receiving
mode
port
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
CN202211306785.6A
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.)
Huizhou Foryou General Electronics Co Ltd
Original Assignee
Huizhou Foryou General Electronics 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 Huizhou Foryou General Electronics Co Ltd filed Critical Huizhou Foryou General Electronics Co Ltd
Priority to CN202211306785.6A priority Critical patent/CN115687198A/en
Publication of CN115687198A publication Critical patent/CN115687198A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Communication Control (AREA)

Abstract

The invention provides a device communication device and a method based on SPI, and the method comprises the following steps: the device comprises a host, a slave, a serialization module and a deserializing module, wherein the slave is provided with a sending request port and a receiving ready port, the sending request port is used for outputting a sending request signal, and the receiving ready port is used for outputting a receiving ready signal; the host is correspondingly provided with a sending request receiving port and a receiving ready receiving port, the sending request receiving port is used for receiving sending request signals sent by the slave, and the receiving ready receiving port is used for receiving ready signals sent by the slave. The invention greatly improves the SPI communication transmission efficiency of the FPD-LINK interface in the prior art, which is limited due to chip limitation.

Description

Device communication device and method based on SPI
Technical Field
The invention relates to the technical field of communication, in particular to a device communication device and method based on SPI.
Background
At present, an IVI system (vehicle information system) is connected with an instrument through an FPD-LINK interface, the IVI system sends video data to the instrument through the interface to realize screen projection, and upgrade data can be sent to the instrument from the IVI system through a 4-wire standard SPI interface of a transparent transmission mechanism, the IVI system serves as a master in an SPI communication protocol, and the instrument serves as a slave, as shown in fig. 1.
However, when the 4-wire standard SPI communication protocol in the FPD-LINK interface adopts the full duplex mode, due to the synchronous transmission mechanism of the SPI, when the master sends data without a request from the slave, the slave must check bytes by bytes to detect a frame header when receiving a data frame, and the interaction loss is large; moreover, limited by FPD-LINK chip, the SPI clock can only reach about 800kHz at maximum under the full duplex mode. This results in the 4-wire standard SPI protocol in such FPD-LINK interface, which has a slow actual transmission speed (about only 2.7 MB/min), and thus the upgrade time is very long, which seriously affects the user experience.
Disclosure of Invention
The invention provides a device communication device and method based on SPI, which aims to overcome the defects in the prior art and improve the SPI communication transmission efficiency of an FPD-LINK interface in the prior art, which is limited due to chip limitation.
In order to achieve the purpose, the technical scheme adopted by the invention is as follows:
one aspect of the present invention provides an SPI-based device communication method, including: the device comprises a host, a slave, a serialization module and a deserializing module, wherein the host is communicated with the serialization module through a standard 4-wire SPI (serial peripheral interface), the slave is communicated with the deserializing module through a standard 4-wire SPI, and the serialization module and the deserializing module are connected through an FPD-LINK (flat panel display-LINK) interface;
the slave is also provided with a sending request port and a receiving ready port, wherein the sending request port is used for outputting a sending request signal, and the receiving ready port is used for outputting a receiving ready signal;
the host is correspondingly provided with a sending request receiving port and a receiving ready receiving port, the sending request receiving port is used for receiving sending request signals sent by the slave, and the receiving ready receiving port is used for receiving ready signals sent by the slave.
Specifically, the working mode of the standard 4-wire SPI interface is a half-duplex mode.
Specifically, the half-duplex mode includes: when the host machine sends data to the slave machine, a first working frequency is adopted, and when the slave machine sends data to the host machine, a second working frequency is adopted, wherein the first working frequency is greater than the second working frequency.
Specifically, the master and the slave transmit data in a data frame manner, and each time one data frame is transmitted.
Specifically, the working modes of the slave machine comprise a data receiving permission mode and a data sending mode.
Specifically, the allowed data receiving mode is: when the slave machine is ready to receive, the slave machine sets a receiving ready line to be an effective level and sets a sending request signal line to be an ineffective level, so that the master machine generates sending interruption;
the data sending mode is as follows: when the slave machine transmits data to the host machine, the slave machine sets the sending request signal to be active level and sets the receiving ready signal to be inactive level, so that the host machine generates receiving interruption.
Specifically, the sending request port, the receiving ready port, the sending request receiving port and the receiving ready receiving port are GPIO ports.
Another aspect of the present invention provides an SPI-based device communication apparatus, including: the method comprises the steps of allowing a slave to transmit data from a host, transmitting the data from the slave to the host and using a data frame for communication between the host and the slave, wherein the data frame consists of data length, data type, data content and a check code.
Specifically, the slave allows the master to transmit data, and the slave includes:
a1, a slave sets a self working mode as a data receiving allowing mode, wherein the data receiving allowing mode is to set a sending request signal as an invalid level and set a receiving ready signal as an effective level;
step A2, after the host detects the allowable data receiving mode of the slave, generating a clock signal with a first working frequency, and sending a data frame to the slave through an MOSI data line;
step A3, the slave sets the self working mode as a data sending mode, sends a response frame to the master through the MISO data line and returns to the step A1, wherein the data sending mode is to set a sending request signal line as an effective level and set a receiving request line as an ineffective level;
and step A4, the host receives the response frame, judges whether the current frame data is correctly transmitted according to the response frame, and transmits the next data frame if the current frame data is correctly transmitted, otherwise judges whether the retransmission times exceed a preset threshold value, and terminates transmission if the current frame data is correctly transmitted, otherwise retransmits the current frame data.
Specifically, the step of transmitting data from the slave to the master includes:
b1, the slave sets the self working mode as a data sending mode, wherein the data sending mode is to set a sending request signal line as an effective level and set a receiving request line as an ineffective level;
b2, after the host detects the data transmission mode of the slave, generating a clock signal of a second working frequency, and receiving a data frame from the slave through the MISO data line;
step B3, the slave sets the self working mode as an allowed data receiving mode, the host sends a response frame to the slave through the MOSI data line and returns to the step B1, the allowed data receiving mode sets the sending request signal as an invalid level and sets the receiving ready signal as an effective level;
and step B4, the slave machine receives the response frame, judges whether the current frame data is correctly sent or not according to the response frame, if so, sends the next data frame, otherwise, judges whether the retransmission times exceed a preset threshold value or not, if so, stops transmission, and otherwise, retransmits the current data frame.
The invention has the beneficial effects that: the invention adopts a half-duplex mode, the host sends data to the slave by using a high-frequency clock, and the slave sends data to the host by using a low-frequency clock, so that the host can quickly send large-capacity data to the slave; and, different from the present standard SPI communication protocol, the data transmission request is controlled by the slave, the host can send data only after the slave is prepared, thus the step of searching for the frame header can be saved, the interactive loss is greatly saved, the transmission efficiency is improved, and the SPI communication transmission efficiency limited by the chip limitation of the FPD-LINK interface in the prior art is improved.
Drawings
Fig. 1 is a schematic structural diagram of a conventional SPI device communication apparatus;
FIG. 2 is a schematic diagram of the communication device of the SPI-based device according to the present invention;
fig. 3 is a schematic diagram of a data frame according to the present invention.
Detailed Description
The embodiments of the present invention will be described in detail with reference to the accompanying drawings, which are for reference and illustrative purposes only and are not intended to limit the scope of the invention.
In the flow described in the specification, claims or drawings of the present invention, the serial numbers of the respective steps (e.g., steps 10, 20, etc.) are included for distinguishing the respective steps, and the serial numbers themselves do not represent any execution order. It should be noted that, the descriptions of "first", "second", etc. herein are only used for distinguishing the description objects, etc., and do not represent the order of precedence, nor indicate that "first", "second", etc. are of different types.
Example 1
As shown in fig. 2, the present embodiment provides an SPI-based device communication apparatus, including: the device comprises a host, a slave, a serialization module and a deserializing module, wherein the host is communicated with the serialization module through a standard 4-line SPI (serial peripheral interface), the slave is communicated with the deserializing module through a standard 4-line SPI, and the serialization module and the deserializing module are connected through an FPD-LINK (flat panel display-LINK) interface;
the slave is also provided with a sending request port and a receiving ready port, wherein the sending request port is used for outputting a sending request signal RTS, and the receiving ready port is used for outputting a receiving ready signal RTR;
the master is correspondingly provided with a sending request receiving port and a receiving ready receiving port, the sending request receiving port is used for receiving a sending request signal RTS sent by the slave, and the receiving ready receiving port is used for receiving a receiving ready signal RTR sent by the slave.
In this embodiment, the sending request port, the receiving ready port, the sending request receiving port, and the receiving ready receiving port are GPIO ports.
In this embodiment, the working mode of the standard 4-wire SPI interface is a half-duplex mode.
In this embodiment, the half-duplex mode includes: when the host machine sends data to the slave machine, a first working frequency is adopted, and when the slave machine sends data to the host machine, a second working frequency is adopted, wherein the first working frequency is greater than the second working frequency.
In this embodiment, the working modes of the slave include a data reception permission mode and a data transmission mode.
In this embodiment, the allowable data receiving mode is: when the slave machine is ready to receive, the slave machine sets a receiving ready line RTR to be an effective level, sets a sending request signal line RTS to be an ineffective level, and enables the host machine to generate sending interruption;
the data sending mode is as follows: when the slave transmits data to the host, the slave sets a request sending signal RTS to be an effective level and sets a ready receiving signal RTR to be an ineffective level, so that the host generates receiving interruption.
In one implementation, the active level may be defined as a low level and the inactive level may be defined as a high level. Of course, the definition can be made according to actual requirements.
In this embodiment, the master and the slave transmit data in a data frame manner, and each time one data frame is transmitted.
In specific implementation, the IVI system is set as an SPI master, and the instrument is set as an SPI slave.
The GPIO11 of the slave meter is set as a transmit request port, the GPIO12 is set as a receive ready port, the GPIO21 of the master IVI is set as a transmit request receive port, and the GPIO22 is set as a receive ready receive port. GPIOs 11 and 12 on the slave instrument are set as outputs, and GPIOs 21 and 22 on the host IVI are set as inputs.
When the system works, when the host IVI sends data to the slave instrument, the clock working frequency is about 13 MHz; when the slave instrument sends data to the host IVI, the clock working frequency is 800kHz.
Example 2
The embodiment provides an SPI-based device communication method, which includes: the method comprises the steps of allowing a slave to transmit data from a master, transmitting data from the slave to the master and using data frames for communication between the master and the slave.
In specific implementation, the Data frame is composed of a Data length Data Len, a Data Type, a Data content Data and a check code CRC, as shown in fig. 3.
In this embodiment, the step of allowing the slave to transmit data by the master includes:
step A1, the slave sets the self working mode as a data receiving permission mode, wherein the data receiving permission mode is to set a request signal RTS to be invalid level and set a ready signal RTR to be valid level.
And step A2, after the host detects the allowable data receiving mode of the slave, generating a clock signal with a first working frequency, and sending a data frame to the slave through the MOSI data line.
And step A3, the slave sets the self working mode as a data sending mode, sends a response frame to the master through the MISO data line and returns to the step A1, wherein the data sending mode is to set a request sending signal line RTS as an effective level and set a request receiving line RTR as an ineffective level.
And step A4, the host receives the response frame, judges whether the current frame data is correctly sent according to the response frame, if so, sends the next data frame, otherwise, judges whether the retransmission times exceed a preset threshold (for example, 3 times), if so, stops transmission, otherwise, retransmits the current data frame.
In this embodiment, the step of transmitting data from the slave to the master includes:
and B1, the slave sets the self working mode to be a data sending mode, wherein the data sending mode is to set a request sending signal line RTS to be an effective level and set a request receiving line RTR to be an ineffective level.
And step B2, after the host detects the data transmission mode of the slave, generating a clock signal of a second working frequency, and receiving the data frame from the slave through the MISO data line.
And step B3, the slave sets the self working mode to be a data receiving permission mode, the host sends a response frame to the slave through the MOSI data line and returns to the step B1, and the data receiving permission mode sets the RTS to be an invalid level and sets the RTR to be an effective level.
And step B4, the slave receives the response frame, judges whether the current frame data is correctly sent or not according to the response frame, if so, sends the next data frame, otherwise, judges whether the retransmission times exceed a preset threshold (for example, 3 times), if so, stops transmission, otherwise, retransmits the current data frame.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present invention and should not be taken as limiting the scope of the present invention.

Claims (10)

1. An SPI-based device communication apparatus, comprising: the device comprises a host, a slave, a serialization module and a deserializing module, wherein the host is communicated with the serialization module through a standard 4-wire SPI (serial peripheral interface), the slave is communicated with the deserializing module through a standard 4-wire SPI, and the serialization module and the deserializing module are connected through an FPD-LINK (flat panel display-LINK) interface;
the slave is also provided with a sending request port and a receiving ready port, wherein the sending request port is used for outputting a sending request signal, and the receiving ready port is used for outputting a receiving ready signal;
the master is correspondingly provided with a sending request receiving port and a receiving ready receiving port, the sending request receiving port is used for receiving sending request signals sent by the slave, and the receiving ready receiving port is used for receiving ready signals sent by the slave.
2. An SPI-based device communication apparatus according to claim 1, wherein said standard 4-wire SPI interface mode of operation is half-duplex.
3. The SPI-based device communication apparatus according to claim 2, wherein the half-duplex mode comprises: when the host machine sends data to the slave machine, a first working frequency is adopted, and when the slave machine sends data to the host machine, a second working frequency is adopted, wherein the first working frequency is greater than the second working frequency.
4. An SPI-based device communication apparatus as in claim 3 wherein the master and slave transmit data in data frames, one data frame at a time.
5. The SPI-based device communication apparatus of claim 4, wherein the slave's operating modes include an allowed data reception mode, a data transmission mode.
6. An SPI-based device communication apparatus as in claim 5, wherein said allowed data reception mode is: when the slave machine is ready to receive, the slave machine sets a receiving ready line to be an effective level and sets a sending request signal line to be an ineffective level, so that the master machine generates sending interruption;
the data sending mode is as follows: when the slave machine transmits data to the host machine, the slave machine sets the sending request signal to be active level and sets the receiving ready signal to be inactive level, so that the host machine generates receiving interruption.
7. The SPI-based device communication apparatus according to any one of claims 1 to 6, wherein the send request port, the receive ready port, the send request receive port, the receive ready receive port are GPIO ports.
8. An SPI-based device communication method is characterized by comprising the following steps: the method comprises a step that a slave machine allows a host machine to transmit data, a step that the slave machine transmits data to the host machine, and a data frame used for communication between the host machine and the slave machine, wherein the data frame consists of data length, data type, data content and a check code.
9. The SPI-based device communication method according to claim 8, wherein the slave allowing the master to transmit data comprises:
a1, a slave sets a self working mode as a data receiving allowing mode, wherein the data receiving allowing mode is to set a sending request signal as an invalid level and set a receiving ready signal as an effective level;
step A2, after the host detects the allowable data receiving mode of the slave, generating a clock signal with a first working frequency, and sending a data frame to the slave through an MOSI data line;
step A3, the slave sets the self working mode as a data sending mode, sends a response frame to the master through the MISO data line and returns to the step A1, wherein the data sending mode is to set a sending request signal line as an effective level and set a receiving request line as an ineffective level;
and step A4, the host receives the response frame, judges whether the current frame data is correctly sent or not according to the response frame, if so, sends the next data frame, otherwise, judges whether the retransmission times exceed a preset threshold value or not, if so, stops transmission, and otherwise, retransmits the current data frame.
10. The SPI-based device communication method according to claim 8, wherein said step of transmitting data from the slave to the master comprises:
b1, the slave sets the self working mode as a data sending mode, wherein the data sending mode is to set a sending request signal line as an effective level and set a receiving request line as an ineffective level;
b2, after the host detects the data transmission mode of the slave, generating a clock signal of a second working frequency, and receiving a data frame from the slave through the MISO data line;
step B3, the slave sets the self working mode as an allowed data receiving mode, the host sends a response frame to the slave through the MOSI data line and returns to the step B1, the allowed data receiving mode sets the sending request signal as an invalid level and sets the receiving ready signal as an effective level;
and step B4, the slave machine receives the response frame, judges whether the current frame data is correctly sent or not according to the response frame, if so, sends the next data frame, otherwise, judges whether the retransmission times exceed a preset threshold value or not, if so, stops transmission, and otherwise, retransmits the current data frame.
CN202211306785.6A 2022-10-22 2022-10-22 Device communication device and method based on SPI Pending CN115687198A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211306785.6A CN115687198A (en) 2022-10-22 2022-10-22 Device communication device and method based on SPI

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211306785.6A CN115687198A (en) 2022-10-22 2022-10-22 Device communication device and method based on SPI

Publications (1)

Publication Number Publication Date
CN115687198A true CN115687198A (en) 2023-02-03

Family

ID=85099709

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211306785.6A Pending CN115687198A (en) 2022-10-22 2022-10-22 Device communication device and method based on SPI

Country Status (1)

Country Link
CN (1) CN115687198A (en)

Similar Documents

Publication Publication Date Title
CN102819512B (en) A kind of full-duplex communication device based on SPI and method thereof
JP6061868B2 (en) Serial interface
US20040236890A1 (en) System for extending length of a connection to a USB device
US7149835B2 (en) System for extending length of a connection to a USB device
CN101788972A (en) System and method for transmitting data
CN108255776B (en) I3C master device compatible with APB bus, master-slave system and communication method
US20050080935A1 (en) Device-side controller, host-side controller, communication controller, USB system, and packet communications method
CN108111382B (en) Communication device based on I3C bus and communication method thereof
EP1751664A1 (en) Bi-directional serial interface for communication control
US20050027889A1 (en) USB extender
CN107908589B (en) I3C communication verification system and method for verifying slave device and master-slave device
US20090063717A1 (en) Rate Adaptation for Support of Full-Speed USB Transactions Over a High-Speed USB Interface
WO2021128712A1 (en) Battery address management method and battery management system
CN111352887B (en) PCI bus-to-configurable frame length serial bus adaptation and transmission method
CN102929830A (en) Software simulation rapid communication protocol
CN115687198A (en) Device communication device and method based on SPI
EP1014644A2 (en) Distribution of error correction and compression processing
US8000278B2 (en) De-activation, at least in part, of receiver, in response, at least in part, to determination that an idle condition exists
US20240104046A1 (en) Spread spectrum clock negotiation method, and peripheral component interconnect express device and system
CN105866798A (en) Vehicle-mounted terminal IOT (Internet of Things) method based on Beidou communication
CN111130678B (en) Data transmission method, device, equipment and computer readable storage medium
US20040174819A1 (en) Physical layer (PHY) with smart cable analyzing (SCA) and apparatus employing the same
US7334040B2 (en) Method of transmission between two processors of a radio communication unit
CN107346294B (en) Data flow control system and method based on SPI protocol
CN111597017A (en) Synchronous control method for double microprocessors

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