CN117667813A - Data communication method, device, electronic device and storage medium - Google Patents

Data communication method, device, electronic device and storage medium Download PDF

Info

Publication number
CN117667813A
CN117667813A CN202311446397.2A CN202311446397A CN117667813A CN 117667813 A CN117667813 A CN 117667813A CN 202311446397 A CN202311446397 A CN 202311446397A CN 117667813 A CN117667813 A CN 117667813A
Authority
CN
China
Prior art keywords
data
slave
master
slave device
master device
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
CN202311446397.2A
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.)
Foss Hangzhou Intelligent Technology Co Ltd
Original Assignee
Foss Hangzhou Intelligent 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 Foss Hangzhou Intelligent Technology Co Ltd filed Critical Foss Hangzhou Intelligent Technology Co Ltd
Priority to CN202311446397.2A priority Critical patent/CN117667813A/en
Publication of CN117667813A publication Critical patent/CN117667813A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F13/00Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F13/38Information transfer, e.g. on bus
    • G06F13/42Bus transfer protocol, e.g. handshake; Synchronisation
    • G06F13/4282Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2213/00Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
    • G06F2213/0038System on Chip

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

The application relates to a data communication method, a device, an electronic device and a storage medium, wherein the data communication method comprises the following steps: when the slave device is in a ready state, a slave device state signal is sent to the master device through a first universal channel; the master device sends master data information to the slave device through the SPI communication channel based on the slave device state signal; the slave device sends slave data information to the master device through the SPI communication channel based on the master data information; when the master equipment determines that the residual slave data quantity and the residual master data quantity in the slave data information are both preset values, the master equipment enters a dormant state; and when the slave equipment determines that the residual main data quantity and the residual slave data quantity in the main data information are both preset values, the slave equipment enters a dormant state. According to the method and the device, the problem of resource waste caused by communication maintenance in the form of sending the empty packet when the master device and the slave device do not have data transmission is solved, the occupation of broadband is reduced, and the resources of data transmission are effectively saved.

Description

Data communication method, device, electronic device and storage medium
Technical Field
The present disclosure relates to the field of data communication technologies, and in particular, to a data communication method, a device, an electronic device, and a storage medium.
Background
With the continuous development of intelligent driving assistance technology, in an embedded System for intelligent driving, the amount of data transmitted between a System on a Chip (SOC) and a micro control unit (Micro Control Unit, MCU) is also increased, and data interaction is performed between the System on a Chip and the MCU through a serial peripheral channel (Serial Peripheral Interface, SPI).
The SPI communication module generally provides a physical layer and a data link layer, the MCU is used as a master device, the SOC is used as a slave device, and after the master device establishes SPI communication with the slave device, the master device and the slave device conduct data transmission based on an SPI communication channel. If there is no data transmission between the master device and the slave device, the SPI communication is still maintained in the form of transmitting null packets in the communication period, and the bandwidth occupation is high, thereby causing resource waste.
Aiming at the problem that communication is maintained in the form of empty packets when master and slave devices have no data transmission requirement in the related technology, and further resource waste is caused, no effective solution is proposed at present.
Disclosure of Invention
In this embodiment, a data communication method, apparatus, electronic device, and storage medium are provided to solve the problem of resource waste caused by that communication is maintained in the form of empty packets when master-slave devices do not have a data transmission requirement in the related art.
In a first aspect, in this embodiment, a data communication method is provided, which is applied to a data communication system, where the data communication system includes a master device and a slave device, where a connection is established between the master device and the slave device through an SPI communication channel and a first universal channel, where the first universal channel is used to transmit signals to the master device by the slave device, and the data communication method includes:
when the slave device is in a ready state, a slave device state signal is sent to the master device through the first universal channel;
the master device receives the slave device state signal based on the first general channel, and sends main data information to the slave device through the SPI communication channel based on the slave device state signal, wherein the main data information at least comprises main data currently transmitted by the master device and residual main data quantity to be transmitted by the master device;
the slave device receives the master data information based on the SPI communication channel and sends slave data information to the master device through the SPI communication channel based on the master data information, wherein the slave data information at least comprises slave data currently transmitted by the slave device and residual slave data quantity to be transmitted by the slave device;
The master device receives the slave data information based on the SPI communication channel, and when the residual slave data quantity in the slave data information and the residual master data quantity are determined to be preset values, the master device enters a dormant state;
and when the slave equipment determines that the residual main data quantity and the residual slave data quantity in the main data information are both the preset value, the slave equipment enters a dormant state.
In some embodiments, the master device and the slave device further establish a connection through a second common channel, where the second common channel is used for transmitting signals to the slave device by the master device, and after the slave device enters the sleep state, the data communication method further includes:
when the master device needs to send data, the master device sends a device wake-up signal to the slave device through the second common channel;
the slave device receives the device wake-up signal based on the second general channel, and feeds back a device recovery signal to the master device through the first general channel based on the device wake-up signal and the ready state of the slave device;
the master device receives the device recovery signal based on the first universal channel and resumes data communication with the slave device based on the device recovery signal.
In some embodiments, the first general channel connection and the second general channel connection are established between the master device and the slave device through a general input/output interface GPIO;
and when the slave device is in a ready state, sending a slave device state signal to the master device through the first universal channel, wherein the method comprises the following steps of:
when the slave device is in a ready state, controlling a GPIO pin of the first general channel to be a first high-level signal, and transmitting the first high-level signal to the master device;
the master device sending a device wake-up signal to the slave device over the second common channel, comprising:
and the master device controls the GPIO pin of the second common channel to be a second high-level signal and transmits the second high-level signal to the slave device.
In some embodiments, after the master device sends a device wake-up signal to the slave device through the second common channel, the method further includes:
if the master device does not receive the device recovery signal fed back by the slave device within a preset time period, the master device retransmits the device wake-up signal at preset interval time and records the retransmission times;
And when the retransmission times are greater than or equal to a retransmission threshold value, the master device reestablishes SPI communication connection with the slave device.
In some embodiments, the master data information further includes a slave data check result, the slave data check result characterizing a check result of slave data information sent by the slave device in a previous communication period in the master device, and the data communication method further includes:
the slave device determines whether to retransmit the slave data information sent by the slave device in a communication period based on the slave data verification result;
if the slave device retransmits, the slave device constructs slave data information of the current communication period according to the slave data sent in the previous communication period, and sends the slave data information of the current communication period to the master device;
the slave data information further comprises a master data verification result, the master data verification result represents a verification result of master data information sent by the master device in a communication period in the slave device, and the data communication method further comprises the steps of:
the master device receives the slave data information and determines whether to resend the master data information sent by the master device in a communication period based on the master data verification result;
If the primary equipment retransmits, the primary equipment constructs the primary data information of the current communication period according to the primary data sent in the previous communication period, and sends the primary data information of the current communication period to the secondary equipment.
In some embodiments, the master device includes a plurality of to-be-transmitted master data packets, each master data packet includes corresponding master data and a type of the master data, and if the type of the master data is real-time data, the master device sets a transmission sequence of the master data packet corresponding to the real-time data to a highest level.
In some embodiments, the slave device includes a plurality of slave data packets to be sent, each slave data packet includes corresponding slave data and a type of the slave data, and if the type of the slave data is real-time data, the slave device sets a sending sequence of the slave data packets corresponding to the real-time data to a highest level.
In a second aspect, in this embodiment, there is provided a data communication apparatus applied to a data communication system, where the data communication system includes a master device and a slave device, where a connection is established between the master device and the slave device through an SPI communication channel and a first universal channel, where the first universal channel is used to transmit signals to the master device by the slave device, and the data communication apparatus includes:
The state signal sending module is used for sending a slave device state signal to the master device through the first universal channel when the slave device is in a ready state;
the master data transmission module is used for receiving the slave device state signal by the master device based on the first general channel, and sending master data information to the slave device through the SPI communication channel based on the slave device state signal, wherein the master data information at least comprises the master data currently transmitted by the master device and the residual master data quantity to be transmitted by the master device;
the slave data transmission module is used for receiving the master data information based on the SPI communication channel by the slave device and sending slave data information to the master device through the SPI communication channel based on the master data information, wherein the slave data information at least comprises slave data currently transmitted by the slave device and residual slave data quantity to be transmitted by the slave device;
the first dormancy module is used for receiving the slave data information by the master device based on the SPI communication channel, and determining that the master device enters a dormancy state when the residual slave data amount in the slave data information and the residual master data amount are all preset values;
And the second dormancy module is used for the slave equipment to enter a dormancy state when the slave equipment determines that the residual master data quantity in the master data information and the residual slave data quantity are both the preset value.
In a third aspect, in this embodiment, there is provided an electronic device including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the data communication method described in the first aspect.
In a fourth aspect, in the present embodiment, there is provided a storage medium having stored thereon a computer program which, when executed by a processor, implements the data communication method of the second aspect described above.
Compared with the related art, in the data communication method provided in the embodiment, when the slave device is in the ready state, the slave device sends the slave device state signal to the master device through the first general channel, and then the master device sends data to the slave device through the SPI communication channel according to the slave device ready state signal, so that the problem that the bandwidth utilization rate is low due to the fact that the slave device sends data to the slave device when the slave device cannot receive data can be effectively avoided, the slave device can send data to the master device through the SPI communication channel, in the process of SPI communication, the slave device can determine whether the slave device enters the dormant state according to whether the residual master data amount and the residual slave data amount are both preset values, the master device can determine whether the master device enters the dormant state according to whether the residual slave data amount and the residual master data amount are both preset values, namely, when the slave device determines that the residual slave data amount and the residual slave data amount are both preset values, the master device enters the dormant state, that is, the master device enters the master device and the slave device does not transmit the data, and the problem that the slave device cannot transmit the residual data is not transmitted in the idle state is solved, and the problem that the slave device cannot transmit the residual data is completely is solved, and the data is not transmitted in the idle state is completely.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the other features, objects, and advantages of the application.
Drawings
The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and together with the description serve to explain the application and do not constitute an undue limitation to the application. In the drawings:
fig. 1 is an application scenario schematic diagram of a data communication method provided in an embodiment of the present application;
fig. 2 is a flowchart of a data communication method provided in an embodiment of the present application;
fig. 3 is a schematic diagram of a data communication structure between a master device and a slave device according to an embodiment of the present application;
FIG. 4 is a flow chart of data communication between a master device and a slave device provided in an embodiment of the present application;
FIG. 5 is a schematic diagram of a data format of a frame of data according to an embodiment of the present application;
fig. 6 is a block diagram of a data communication device according to an embodiment of the present application.
Detailed Description
For a clearer understanding of the objects, technical solutions and advantages of the present application, the present application is described and illustrated below with reference to the accompanying drawings and examples.
Unless defined otherwise, technical or scientific terms used herein shall have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terms "a," "an," "the," "these," and the like in this application are not intended to be limiting in number, but rather are singular or plural. The terms "comprising," "including," "having," and any variations thereof, as used in the present application, are intended to cover a non-exclusive inclusion; for example, a process, method, and system, article, or apparatus that comprises a list of steps or modules (units) is not limited to the list of steps or modules (units), but may include other steps or modules (units) not listed or inherent to such process, method, article, or apparatus. The terms "connected," "coupled," and the like in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. Reference to "a plurality" in this application means two or more. "and/or" describes an association relationship of an association object, meaning that there may be three relationships, e.g., "a and/or B" may mean: a exists alone, A and B exist together, and B exists alone. Typically, the character "/" indicates that the associated object is an "or" relationship. The terms "first," "second," "third," and the like, as referred to in this application, merely distinguish similar objects and do not represent a particular ordering of objects.
With the continuous development of intelligent driving assistance technology, in an embedded System for intelligent driving, the amount of data transmitted between a System on a Chip (SOC) and a micro control unit (Micro Control Unit, MCU) is also increased, and data interaction is performed between the System on a Chip and the MCU through a serial peripheral channel (Serial Peripheral Interface, SPI).
The SPI communication module generally provides a physical layer and a data link layer, the MCU is used as a master device, the SOC is used as a slave device, and after the master device establishes SPI communication with the slave device, the master device and the slave device conduct data transmission based on an SPI communication channel. If there is no data transmission between the master device and the slave device, the SPI communication is still maintained in the form of transmitting null packets in the communication period, and the bandwidth occupation is high, thereby causing resource waste.
Therefore, aiming at the problem that communication is maintained in the form of empty packets when master-slave devices have no data transmission requirement in the related art, and resource waste is caused, no effective solution is proposed at present.
The data communication method provided in the embodiment of the present application may be applied to an application scenario shown in fig. 1, fig. 1 is a schematic diagram of an application scenario of the data communication method provided in the embodiment of the present application, where the application scenario may be a data communication system, specifically, the data communication system may be an auxiliary driving control system, the data communication system may include a master device MCU and a slave device SOC, and an auxiliary driving controller may relate to services such as signal transceiving, image, radar data processing, and vehicle control, where the image and radar data processing services are mostly run on the slave device SOC, and the signal transceiving and vehicle control are run on the master device MCU. And data interaction is carried out between the two through SPI.
In the embodiment of the application, a data communication method is provided, and fig. 2 is a flowchart of the data communication method provided in the embodiment of the application, where the method may be applied to a data communication system, where the data communication system includes a master device and a slave device, where connection is established between the master device and the slave device through an SPI communication channel and a first general channel, where the first general channel is a signal transmitted from the slave device to the master device. Specifically, as shown in fig. 2, the process includes the following steps:
in step S201, when the slave device is in the ready state, a slave device status signal is sent to the master device through the first universal channel.
For example, when the slave device is in the ready state, the slave device transmits a slave device status signal to the master device over the first common channel, the status signal being used to characterize the slave device as being in the ready state.
In step S202, the master device receives the slave device status signal based on the first universal channel, and transmits master data information to the slave device through the SPI communication channel based on the slave device status signal.
The main data information at least comprises main data currently transmitted by the main device and the residual main data quantity to be transmitted by the main device.
In step S203, the slave device receives the master data information based on the SPI communication channel, and transmits the slave data information to the master device through the SPI communication channel based on the master data information.
The slave data information at least comprises slave data currently transmitted by the slave device and the residual slave data quantity to be transmitted by the slave device.
The master device receives a slave device status signal via the first universal interface, thereby causing the master device to determine that the slave device's current status is ready. And, the master device may establish an SPI communication connection with the slave device based on the slave device's ready state.
When the master device and the slave device establish SPI communication, SPI full duplex communication may be implemented, that is, the master device may send master data information to the slave device through the SPI channel, and the slave device may send slave data information to the master device through the SPI channel, where the master data information may include master data currently transmitted by the master device and remaining master data to be transmitted by the master device, and the slave data information may include slave data currently transmitted by the slave device and remaining slave data to be transmitted by the slave device.
In the SPI communication, the SPI master device sends data to the SPI slave device through an SCLK line at the frequency supported by the slave device, which means that the slave device cannot actively send data to the master device, therefore, in the process of the master-slave device communication based on the SPI, the slave device sends a pulse signal to the master device through a first general interface, the state signal of the slave device can be the pulse signal, after the master device receives the pulse signal once, the master device sends a frame of master data information to the slave device, so that the slave device receives the master data information, and feedback is made according to the master data information, namely the slave device determines slave data according to the master data in the received master data information, determines the residual slave data amount to be transmitted in the slave device according to the residual master data amount in the master data information, generates slave data information according to the slave data and the residual slave data, and feeds the slave data information back to the master device.
Specifically, in the driving assistance scenario, the main data may be a vehicle control signal, an image, a radar or the like receiving and transmitting signal, and the sub data may be a processing signal of the image, the radar or the like data, or may be another signal, which is not limited herein.
In step S204, the master device receives the slave data information based on the SPI communication channel, and determines that the remaining slave data amount and the remaining master data amount in the slave data information are both preset values, and the master device enters a sleep state.
In step S205, when the slave device determines that the remaining master data amount and the remaining slave data amount in the master data information are both preset values, the slave device enters a sleep state.
The master device receives the slave data information sent by the slave device based on the SPI communication channel, and determines whether the master device enters a sleep state according to the remaining slave data amount in the slave data information and the remaining master data amount to be transmitted in the master device, specifically, when the remaining slave data amount and the remaining master data amount are both preset values, the master device enters the sleep state.
The slave device determines whether the slave device enters a sleep state according to the residual master data amount in the master data information and the residual slave data amount to be transmitted in the slave device, and specifically, when the residual master data amount and the residual slave data amount are both preset values, the slave device enters the sleep state. After the slave device enters the sleep state, the slave device stops transmitting the pulse signal to the master device through the first common channel.
The preset value may represent the data amount when no data is transmitted in the master device, i.e. the preset value may be zero.
Specifically, when the remaining master data amount and the remaining slave data amount are both zero, it indicates that no data needs to be transmitted in both the master device and the slave device, and at this time, the master device and the slave device may enter a sleep state. When the residual main data volume and the residual slave data volume are zero, the master-slave device enters a dormant state, so that communication is maintained by sending empty packets when the master device and the slave device have no data transmission, the problem of occupation of broadband is effectively solved, and the resources of data transmission are saved.
After the master device and the slave device enter the sleep state, the SPI connection state between the master device and the slave device is not disconnected, and only the data transmission is stopped.
In the implementation process, when the slave device is in a ready state, a slave device state signal is sent to the master device through the first universal channel, and then the master device sends data to the slave device through the SPI communication channel according to the slave device ready state signal, so that the problem that the bandwidth utilization rate is low due to the fact that the slave device sends data to the slave device when the slave device cannot receive data can be effectively avoided, the slave device can also send data to the master device through the SPI communication channel, in the process based on SPI communication, the slave device can determine whether the slave device enters a dormant state according to the residual master data amount and whether the residual slave data amount are preset values or not, the master device can determine whether the master device enters the dormant state according to the residual slave data amount and whether the residual master data amount are preset values or not, namely, when the slave device determines that the residual slave data amount and the residual master data amount are preset values, the master device enters the dormant state when the master device determines that the residual slave data amount and the residual master data amount are all the preset values, that the slave device does not have a data transmission requirement, namely, the slave device cannot enter the dormant state when the residual slave device and the residual slave device is not have a dormant state, and the data packet transmission form is not occupied by the communication, and the problem is solved, and the problem that the data transmission of the residual data packets and the slave device and the data transmission is not occupied is completely is solved.
In some embodiments, the connection between the master device and the slave device is further established through a second common channel, the second common channel is used for transmitting signals to the slave device for the master device, and after the slave device enters the sleep state, the data communication method may further include the following steps:
step 1: when the master device needs to send data, the master device sends a device wake-up signal to the slave device through the second common channel.
Step 2: the slave device receives the device wake-up signal based on the second common channel and feeds back a device resume signal to the master device via the first common channel based on the device wake-up signal and the ready state of the slave device.
Step 3: the master device receives the device recovery signal based on the first universal channel and resumes data communication with the slave device based on the device recovery signal.
For example, when new data needs to be sent in the master device after the master device and the slave device enter the sleep state, the master device may send a device wake-up signal to the slave device through the second common channel, and further the slave device receives the device wake-up signal, and the slave device may enter the wake-up state from the sleep state according to the device wake-up signal.
Further, after the slave device enters the wake-up state, whether the slave device can receive and send data or not is detected, namely whether the slave device is in a ready state or not, when the slave device is waken up and enters the ready state, the slave device feeds back a device recovery signal to the master device through the first general channel, namely the slave device can conduct data transmission.
After receiving the equipment recovery signal of the slave equipment, the master equipment recovers the data communication with the slave equipment, thereby recovering the SPI communication between the master equipment and the slave equipment.
It should be noted that, because the SPI communication connection between the master and slave devices is not disconnected after the master and slave devices enter the sleep state, when the master and slave devices are awakened from the sleep state, data transmission based on the SPI can be directly performed, the SPI communication connection does not need to be established again, communication time is saved, and data transmission efficiency is improved.
In the implementation process, after the master device and the slave device enter the dormant state, if the master device needs to send data, the master device sends a device wake-up signal to the slave device through the second common channel, so that the slave device is awakened, and after the slave device is awakened, a device recovery signal is fed back to the master device according to the ready state of the slave device, so that the slave device can perform data transmission. And after the master device receives the device recovery signal of the slave device, recovering the data communication with the slave device, thereby realizing the recovery of the data transmission between the master device and the slave device.
In some of these embodiments, a first general purpose channel connection and a second general purpose channel connection are established between the master device and the slave device via a general purpose input/output interface GPIO.
And when the slave device is in a ready state, sending a slave device state signal to the master device through the first universal channel, wherein the method comprises the following steps of: and when the slave device is in a ready state, controlling the GPIO pin of the first general channel to be a first high-level signal, and transmitting the first high-level signal to the master device.
The master device sending a device wake-up signal to the slave device over a second common channel, comprising: the master device controls the GPIO pin of the second common channel to be a second high-level signal and transmits the second high-level signal to the slave device.
Illustratively, both the first and second common channels may be GPIO channels, thereby enabling transmission of data between the master and slave devices via a six-wire system.
Specifically, fig. 3 is a schematic diagram of a data communication structure between a Master device and a Slave device provided in this embodiment of the present application, as shown in fig. 3, a Master terminal 301 is a Master device and is also an initiator of data, a Slave terminal 302 is a Slave device and is also a receiver of data, in SPI communication in fig. 3, data transmission and control are implemented through six signal lines, where SCLK represents a serial clock line output from the Master device, MOSI represents a signal line from which the Master device outputs data input from the Slave device, MISO represents a signal line from which the Master device outputs data input from the Slave device, CS represents a chip select signal line, GPIO1 is a first general channel signal line, and is used to send a pulse signal to the Master device when the Slave device is in a ready state, and GPIO2 is a second general channel signal line, and is used to send a device wake-up signal to the Slave device when the Master device needs to send data.
The Master terminal is a functional safety Master monitoring chip, can provide a stable and reliable SPI communication clock and performs SPI full duplex communication. And the Slave end is used as a sensor data source side and is used for designing a GPIO communication period triggering channel.
In SPI communication, an SPI master device sends data to an SPI slave device through an SCLK line at a frequency supported by the slave device, which means that the slave device cannot actively send data to the master device, when the master device and the slave device start to power up, after the slave device is ready, the slave device can pull up a GPIO1 pin first, and then the GPIO1 generates a first high level signal, and the first high level signal is transmitted to the master device through a GPIO1 signal line, that is, the first high level signal is a slave device state signal.
After receiving the first high-level signal of the GPIO1, the master equipment establishes SPI communication connection with the slave equipment, and after the SPI communication connection between the master equipment and the slave equipment is established, the master equipment and the slave equipment perform SPI-based data transmission. And in the process of SPI-based data transmission of the master device and the slave device, the slave device transmits pulse signals to the master device based on the GPIO1 signal line.
When the slave device determines that the master device and the slave device have no data transmission, the master device and the slave device enter a dormant state, and the slave device stops pulling up the GPIO1 pin, so that the master device cannot receive a pulse signal of the slave device, at the moment, SPI communication between the master device and the slave device is not disconnected, and only data transmission is stopped.
When the master device and the slave device enter a sleep state, if the master device needs to send data, the master device is awakened, the master device can pull up the GPIO2 pin, namely, the GPIO2 pin is controlled to output a second high-level signal, the second high-level signal is transmitted to the slave device through a GPIO2 signal line, after the slave device receives the second high-level signal of the GPIO2, the slave device is awakened, after the slave device is awakened, whether the slave device is in a ready state or not is determined, if the slave device is in the ready state, the slave device pulls up the GPIO1 pin, the GPIO1 generates a first high-level signal, the first high-level signal is transmitted to the master device through the GPIO1 signal line, and SPI communication between the slave device and the slave device can be directly restored after the master device receives the first high-level signal of the GPIO 1.
In the communication process, the communication period is determined by the slave equipment, so that communication with any period can be realized, the master equipment only determines the initiation of communication, if any task delay exists between the two end equipment, the period is prolonged, communication interaction data failure is not caused, and the robustness of SPI communication are improved.
In the implementation process, the first general channel and the second general channel are set as GPIO, and the dormancy and the awakening of the master-slave equipment are realized by changing the level signals of the GPIO channels, so that the robustness and the robustness of SPI communication are improved.
In some of these embodiments, after the master device sends the device wake-up signal to the slave device through the second common channel, further comprising:
step 1: if the device recovery signal fed back by the slave device is not received in the master device in the preset time period, the master device retransmits the device wake-up signal at preset interval time and records the retransmission times.
Step 2: when the number of retransmissions is greater than or equal to the retransmission threshold, the master device reestablishes the SPI communication connection with the slave device.
The master device may further record a time of starting to transmit the device wake-up signal after transmitting the device wake-up signal to the slave device through the second common channel, and if the master device does not receive the device resume signal fed back by the slave device within a preset time period after transmitting the device wake-up signal, the master device retransmits the device wake-up signal at a preset interval time, and the master device records the number of times of retransmitting the device wake-up signal.
When the number of times the resending device wakes up the signal is greater than or equal to the resending threshold, possibly due to the fact that the SPI communication connection between the master device and the slave device is broken, the master device reestablishes the SPI communication connection with the slave device, namely an SPI abnormal reconnection mechanism is entered.
Specifically, fig. 4 is a flow chart of data communication between a master device and a slave device according to an embodiment of the present application, as shown in fig. 4, where the flow chart includes:
step S401: the master device and the slave device enter a sleep state.
Specifically, when neither the master nor the slave has data transmission, the master and the slave enter a sleep state.
Step S402: there is data in the master device to be transmitted.
Further, when the master device and the slave device go to sleep, new data is generated in the master device, and there is data to be transmitted to the slave device.
Step S403: the master pulls up the GPIO2 pin and records the number of pulls up.
When the main device has data to be transmitted, the main device pulls up the GPIO2 pin, so that an IO_IND positive pulse is generated, the IO_IND positive pulse is a high-level signal, namely a device wake-up signal, and the high-level signal is transmitted to the auxiliary device through a signal line, so that the auxiliary device is waken up according to the high-level signal, and the main device records the pulling-up times once when pulling up the GPIO2 pin every time, so that the recording of the pulling-up times is realized.
And further, after the slave device is awakened, determining whether the slave device is in a ready state, if the slave device is in the ready state, pulling up the GPIO1 pin by the slave device, so that the slave device generates an IO_RDY positive pulse, and transmitting the IO_RDY positive pulse to the master device, wherein the IO_RDY positive pulse is a device recovery signal fed back by the slave device.
Step S404: and judging whether the master device receives a device recovery signal of the slave device in a preset time period.
Further, the master device starts timing after pulling up the GPIO2 pin, and if the master device receives the device recovery signal fed back by the slave device within the preset period of time, step S405 is executed. If the master device does not receive the device recovery signal fed back by the slave device within the preset time period, step S406 is executed.
Specifically, the preset interval period may be 50ms, or may be 30ms, or may be other time, and may be adaptively set according to actual situations, which is not limited herein.
Step S405: the master device communicates SPI data with the slave device.
Specifically, when the master device receives a device recovery signal fed back by the slave device within a preset time period, the master device and the slave device perform data communication based on SPI.
Step S406: and judging whether the pull-up times reach a retransmission threshold.
If the master device does not receive the device recovery signal fed back by the slave device within the preset time period, judging whether the pull-up times of the current master device reach the retransmission threshold, and if the pull-up times of the current master device do not reach the retransmission threshold, returning to step S403. If the number of times of pull-up of the current master device has reached the retransmission threshold, step S407 is performed.
Specifically, the retransmission threshold may be 3 times, or may be 5 times, or may be other times, and may be adaptively set according to the actual situation, which is not limited herein.
Step S407: entering an SPI abnormal reconnection mechanism.
Specifically, if the current pull-up times of the master device have reached the retransmission threshold, the master device and the slave device enter an SPI abnormal reconnection mechanism, namely the master device and the slave device are in SPI communication connection again.
When the master device and the slave device are in SPI communication connection, the master device can send handshake information to the slave device, further, the slave device generates response information according to the handshake information sent by the master device and sends the response information to the master device, further, when the master device receives the response information, the SPI communication connection is established with the slave device, and after the SPI communication connection is established, the master data information is sent to the slave device.
In some embodiments, the master data information further includes a slave data check result, the slave data check result characterizing a check result in the master device of slave data information sent in a last communication cycle of the slave device, and the data communication method may further include:
step 1: the slave device determines whether to retransmit the slave data information transmitted by the slave device in the last communication cycle based on the slave data check result.
Step 2: if the slave device retransmits, the slave device constructs slave data information of the current communication period according to the slave data sent in the previous communication period, and sends the slave data information of the current communication period to the master device.
The master device, before sending the master data information, further includes checking the slave data in the slave data information received in the previous communication period to obtain a slave data check result, further, according to the slave data check result, the master data to be sent in the current communication period and the residual master data to be sent in the master device after the current communication period, constructs the master data information in the current communication period, and sends the master data information to the slave device based on the established SPI communication connection, so that the master data information received by the slave device includes the slave data check result.
Further, the slave device checks the slave data verification result included in the master data information, determines whether to retransmit the slave data sent in the last communication period of the slave device according to the slave data verification result, specifically, if the slave data verification result does not pass, the slave device needs to retransmit the slave data sent in the last communication period, and if the slave data verification result passes, the slave device does not need to retransmit the slave data sent in the last communication period.
Further, when the slave device needs to retransmit the slave data transmitted in the previous communication period, the slave device constructs slave data information of the current communication period according to the slave data transmitted in the previous communication period, the remaining slave data amount to be transmitted in the slave device and the master data verification result, and transmits the slave data information of the current period to the master device.
That is, when the slave device transmits the slave data a to the master device in the first communication period, further, the slave device receives the master data information B transmitted by the master device in the second communication period, the master data information B includes the slave data check result a of the master device on the slave data a, and when the slave device determines that the slave data check result a is not passed, the slave data transmitted by the slave device to the master device in the third communication period is still a.
The slave data information further includes a master data verification result, the master data verification result represents a verification result of the master data information sent by the master device in a communication period in the slave device, and the data communication method further includes:
step 1: the master device receives the slave data information and determines whether to retransmit the master data information transmitted in a communication cycle on the master device based on the master data verification result.
Step 2: if the data is retransmitted, the master device constructs the master data information of the current communication period according to the master data sent in the previous communication period, and sends the master data information of the current communication period to the slave device.
And in the same way, the slave device further comprises a step of checking the main data in the main data information received in the last communication period before sending the slave data information to obtain a main data checking result, and further, the slave device constructs the slave data information of the current communication period according to the slave data to be sent in the current communication period and the residual slave data quantity to be sent in the slave device after the current communication period according to the main data checking result, and sends the slave data information to the main device based on the established SPI communication connection, so that the slave data information received by the main device comprises the main data checking result.
Further, the master device checks a master data verification result included in the slave data information, determines whether to retransmit the master data sent in the last communication period of the master device according to the master data verification result, specifically, if the master data verification result does not pass, the master device needs to retransmit the master data sent in the last communication period, and if the master data verification result passes, the master device does not need to retransmit the master data sent in the last communication period.
Further, when the master device needs to retransmit the master data sent in the previous communication period, the master device constructs master data information of the current communication period according to the master data sent in the previous communication period, the remaining master data amount to be sent in the master device and the slave data verification result, and sends the master data information of the current period to the master device.
It should be noted that, the data transmitted in each communication period may be defined as one frame of data, that is, the master device and the slave device transmit only one frame of data at a time, and the master device may divide all the master data to be transmitted into a plurality of master data packets, each master data packet only includes one frame of master data, and only transmits one master data packet at a time. Similarly, the slave device may divide all the slave data to be transmitted into a plurality of slave data packets, each of which includes only one frame of slave data, and only one slave data packet is transmitted at a time. After all the master data packets and all the slave data packets are sent, the master device and the slave device enter a dormant state.
When the master device and the slave device perform data communication, the master data information and the slave data information are all transmitted in the form of data packets, the length of each frame of data packet interacted with each other is a fixed value, and fig. 5 is a schematic diagram of the data form of one frame of data provided in the embodiment of the application, as shown in fig. 5, each frame of data packet includes: a frame header 501, a data body 502, an end identifier 503, and a padding field 504.
Wherein, frame header 501 includes: the frame number (Seq) of the current frame, the timestamp (timestamp), the padding semantics (handshakes), the calculated value of all data checksum except the header, the data type (frameType), the response information to the last cycle transmitted data (dataAck) and the amount of remaining data to be transmitted (toTxBufNum).
Wherein, if the frame data is single frame data, the value of the data type (frameType) is 0, if the frame data is long frame data, the value of the data type (frameType) is 1, if the frame data is long frame data end frame, the value of the data type (frameType) is 2, and if the frame data is real-time data, the value of the data type (frameType) is 3.
If the response information sent in the previous period is correct, i.e. the verification is passed, the value of the dataAck is 1, and if the response information sent in the previous period is wrong, i.e. the verification is not passed, the value of the dataAck is 0, and retransmission is required.
If the totxBufNum in the main data information sent by the main device is zero, the current communication period is indicated to have completed sending all the main data, and the next communication period is indicated to have no main data. If the totxBufNum in the slave data information sent by the slave device is zero, the current period is indicated to have completed sending all the slave data, and the next communication period is indicated to have no slave data. If the totxBufNum in the master data information and the slave data information is zero, the master device and the slave device pause SPI communication, and the two ends enter a dormant state so as to save bandwidth occupation.
The data volume 502 includes: type ID (Item ID) of the valid data, length (Length) of the valid data, total packet number (pkgSum) of the valid data, and packetization index (pkgsdex). If the data is single frame data, the value of the total packet number (pkgSum) of the effective data is 1, and the value of the packetization index (pkgsdex) is 0. If the data is long frame data, the value of the total packet number (pkgSum) of the effective data is the corresponding total number of packets, and the value of the packet index (pkgsdex) is increased by one sequentially from 0.
An end identifier 503 is present at the end of the body 502 and a pad field 504 is used to form a complete single frame of data by the pad field when there is less data.
In the implementation process, the data verification result of the previous communication period and the data of the current communication period are combined into data information, so that when the master-slave equipment receives the data information, whether the data of the previous communication period is transmitted or not can be confirmed.
In some embodiments, the master device includes a plurality of to-be-transmitted master data packets, each of the master data packets includes corresponding master data and a type of the master data, and if the type of the master data is real-time data, the master device sets a transmission order of the master data packets corresponding to the real-time data to be a highest level.
In some embodiments, the slave device includes a plurality of slave data packets to be transmitted, each slave data packet includes corresponding slave data and a type of the slave data, and if the type of the slave data is real-time data, the slave device sets a transmission sequence of the slave data packet corresponding to the real-time data to a highest level.
The master device and the slave device may include a plurality of data packets to be transmitted, where each data packet includes corresponding data and a data type, where the data type may include single frame data, long frame data, and real-time data, a transmission sequence of the data packets of the real-time data is set to a highest level, if there are a plurality of data packets of the real-time data, the plurality of real-time data packets are ordered according to a time sequence of the real-time data, and after transmission of all the data packets of the real-time data is completed, the long frame data packet is transmitted, and after transmission of all the long frame data packets is completed, the single frame data packet is transmitted.
The master device and the slave device comprise a sending buffer queue, a receiving buffer queue and a DMA module.
When data information needs to be sent, data to be transmitted is obtained from a sending buffer queue, when the master device needs to send the data, the data to be transmitted is the master data to be transmitted, and when the slave device needs to send the data, the data to be transmitted is the slave data to be transmitted.
The sending Buffer queue consists of m TX buffers: the TX Buffer size is 5120 bytes, and the setting of m is mainly dependent on the maximum data of the data to be transmitted, i.e. the packet number of the long frame.
Specifically, the following principle is followed for storing the transmitted data into the transmission Buffer queue TX Buffer:
(1) When the single data length transmitted is smaller than or equal to the total data length of the TX Buffer, the single data is placed in a centralized mode according to the most full principle, the most full TX Buffer is placed in the single data, the frame header type is set to 0, the total packet number (pkgSum) of the effective data is set to 1, and the single data is transmitted according to a single frame.
(2) When the single data length of the transmission is greater than the total data length of the TX Buffer, the transmission is performed according to a long frame, i.e., multi-frame transmission. The data fragments are put into an empty TX buffer, the frame header frameType is set to 1, the total number of packets of valid data (pkgSum) is set to the total number of packets, and the pkgsdex packetization index increases by 1 sequentially with the number of packets starting from 0.
(3) The real-time data is placed alone, the frame header frameType is set to 3, and the remaining rules refer to the single frame rules.
The transmit data transfer is divided into 2 phases: (1) packaging; (2) copying.
Specifically, the data to be transmitted is obtained from the sending buffer queue, the data value (checksum) of the data to be transmitted is calculated and recorded in the frame header, and further, the current data frame number (sequence count) and the current time stamp are filled, so that the data packaging is realized.
Further, the packed data is copied to TX XMA in the DMA module, and SPI transmission is further carried out.
Specifically, the selection of a TX Buffer to copy to TX XMA follows the following principle:
(1) The real-time data is sent preferentially and can interrupt the sending of long frames.
If the real-time data exists, the real-time data is preferentially transmitted, if the long frame data is currently transmitted, the real-time data is preferentially transmitted, and after the real-time data transmission is completed, the long frame data is transmitted.
(2) And the second step of transmitting retransmission data is canceled when the retransmission threshold is reached.
If the retransmitted data exists, the priority of the retransmitted data is second, and the TX Buffer for storing the retransmitted data is selected to be copied to the TX XMA, and the retransmission is stopped until the retransmission times are larger than the preset retransmission times.
(3) The priority of the long frame is third, and the packetization of the long frame must be continuously transmitted, and the packetization index pkgIndex in the data information must be continuously transmitted.
If there is retransmission of both long frame data and single frame data, the long frame data is preferentially retransmitted, and the packetization of the long frame data must be continuously transmitted, and the packetization index pkgIndex must be continuously transmitted.
(4) TX Buffer with blocking up to threshold is sent.
If the data needing to be retransmitted reaches the blocking threshold, the transmission Buffer queue TX Buffer reaching the blocking threshold is preferably selected and copied to TX XMA.
(5) And transmitting the TX Buffer with the most effective data.
If there are multiple retransmission data, the transmission Buffer queue TX Buffer with the most effective data in the data body is preferentially selected and copied to TX XMA.
When the data information needs to be received, the received data is put into a receiving Buffer queue RX Buffer, when the master device needs to receive the data, the received data is slave data, and when the slave device needs to receive the data, the received data is master data.
The received data transfer is divided into 3 phases: (1) copying; (2) checking; (3) unpacking.
Specifically, the received data is copied from the RX XMA into the receive Buffer queue RX Buffer.
Further, the data in the receive Buffer RX Buffer is checked. If the verification is correct and the data is long frame data, the received data is put into a long frame Buffer queue LRX Buffer, and whether the long frame sub-packet data is completely received is judged by pkgSum, pkgIndex. If not all of the packets are received, the long frame packetization is continued.
Further, the received complete data is unpacked according to the type ID (Item ID) of the valid data and the Length (Length) of the valid data.
In the implementation process, the sending sequence of the real-time data is set to be the highest level, so that the real-time performance of data transmission can be effectively ensured, and the transmission of long-frame data can be interrupted, thereby avoiding transmission blockage caused by long-time occupation of resources by long-frame transmission.
Although the steps in the flowcharts according to the embodiments described above are shown in order as indicated by the arrows, these steps are not necessarily executed in order as indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
In this embodiment, a data communication device is further provided, and the device is used to implement the foregoing embodiments and preferred embodiments, and will not be described in detail. The terms "module," "unit," "sub-unit," and the like as used below may refer to a combination of software and/or hardware that performs a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementations in hardware, or a combination of software and hardware, are also possible and contemplated.
Fig. 6 is a block diagram of a data communication device according to an embodiment of the present application, where the data communication device is applied to a data communication system, and the data communication system includes: the data communication system includes a master device and a slave device, wherein the master device and the slave device establish a connection through an SPI communication channel and a first universal channel, and the first universal channel is used for transmitting signals from the slave device to the master device, as shown in fig. 6, and the apparatus includes:
a status signal sending module 601, configured to send a status signal of the slave device to the master device through the first universal channel when the slave device is in a ready state;
the master data transmission module 602 is configured to receive, by a master device, a slave device status signal based on the first general channel, and send, by an SPI communication channel, master data information to the slave device, where the master data information includes at least master data currently transmitted by the master device and a remaining amount of master data to be transmitted by the master device;
the slave data transmission module 603 is configured to receive master data information based on the SPI communication channel, and send slave data information to the master device through the SPI communication channel based on the master data information, where the slave data information includes at least slave data currently transmitted by the slave device and a remaining slave data amount to be transmitted by the slave device;
The first sleep module 604 is configured to receive the slave data information based on the SPI communication channel, and determine that the remaining slave data amount and the remaining master data amount in the slave data information are both preset values, where the master device enters a sleep state;
and the second sleep module 605 is configured to enter a sleep state when the slave device determines that the remaining master data amount and the remaining slave data amount in the master data information are both preset values.
In some embodiments, the connection between the master device and the slave device is further established through a second common channel, where the second common channel is used for transmitting signals to the slave device, and the second sleep module 605 is further configured to, after the slave device enters the sleep state:
when the master device needs to send data, the master device sends a device wake-up signal to the slave device through a second common channel;
the slave device receives a device wake-up signal based on the second general channel, and feeds back a device resume signal to the master device through the first general channel based on the device wake-up signal and the ready state of the slave device;
the master device receives the device recovery signal based on the first universal channel and resumes data communication with the slave device based on the device recovery signal.
In some of these embodiments, a first general purpose channel connection and a second general purpose channel connection are established between the master device and the slave device via a general purpose input/output interface GPIO.
The status signal transmitting module 601 is specifically configured to:
when the slave device is in a ready state, controlling a GPIO pin of a first general channel to be a first high-level signal, and transmitting the first high-level signal to the master device;
the second dormancy module 605 specifically is configured to: the master device controls the GPIO pin of the second common channel to be a second high-level signal and transmits the second high-level signal to the slave device.
In some of these embodiments, the second sleep module 605 is further configured to:
if the master device does not receive the device recovery signal fed back by the slave device within the preset time period, the master device retransmits the device wake-up signal at preset interval time and records the retransmission times;
when the number of retransmissions is greater than or equal to the retransmission threshold, the master device reestablishes the SPI communication connection with the slave device.
In some embodiments, the master data information further includes a slave data check result, where the slave data check result characterizes a check result of the slave data information sent by the slave device in a previous communication period, and the slave data transmission module 603 is further configured to:
The slave device determines whether to retransmit the slave data information transmitted by the slave device in a previous communication period based on the slave data verification result;
if the slave device retransmits, the slave device constructs slave data information of the current communication period according to the slave data sent in the previous communication period, and sends the slave data information of the current communication period to the master device;
the slave data information further includes a master data verification result, where the master data verification result characterizes a verification result of the master data information sent by the master device in a communication period in the slave device, and the master data transmission module 602 is further configured to:
the master device receives the slave data information and determines whether to retransmit the master data information sent by the master device in a communication period based on the master data verification result;
if the data is retransmitted, the master device constructs the master data information of the current communication period according to the master data sent in the previous communication period, and sends the master data information of the current communication period to the slave device.
In some embodiments, the master device includes a plurality of to-be-transmitted master data packets, each of the master data packets includes corresponding master data and a type of the master data, and if the type of the master data is real-time data, the master device sets a transmission order of the master data packets corresponding to the real-time data to be a highest level.
In some embodiments, the slave device includes a plurality of slave data packets to be transmitted, each slave data packet includes corresponding slave data and a type of the slave data, and if the type of the slave data is real-time data, the slave device sets a transmission sequence of the slave data packet corresponding to the real-time data to a highest level.
The above-described respective modules may be functional modules or program modules, and may be implemented by software or hardware. For modules implemented in hardware, the various modules described above may be located in the same processor; or the above modules may be located in different processors in any combination.
In one embodiment, there is also provided an electronic device including a memory and a processor, the memory storing a computer program, the processor implementing the steps of the method embodiments described above when executing the computer program.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
It should be noted that, user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the patent. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (10)

1. A data communication method, applied to a data communication system, the data communication system including a master device and a slave device, the master device and the slave device establishing a connection through an SPI communication channel and a first universal channel, the first universal channel being for the slave device to transmit signals to the master device, the data communication method comprising:
When the slave device is in a ready state, a slave device state signal is sent to the master device through the first universal channel;
the master device receives the slave device state signal based on the first general channel, and sends main data information to the slave device through the SPI communication channel based on the slave device state signal, wherein the main data information at least comprises main data currently transmitted by the master device and residual main data quantity to be transmitted by the master device;
the slave device receives the master data information based on the SPI communication channel and sends slave data information to the master device through the SPI communication channel based on the master data information, wherein the slave data information at least comprises slave data currently transmitted by the slave device and residual slave data quantity to be transmitted by the slave device;
the master device receives the slave data information based on the SPI communication channel, and when the residual slave data quantity in the slave data information and the residual master data quantity are determined to be preset values, the master device enters a dormant state;
and when the slave equipment determines that the residual main data quantity and the residual slave data quantity in the main data information are both the preset value, the slave equipment enters a dormant state.
2. The data communication method according to claim 1, wherein a connection is further established between the master device and the slave device through a second common channel, the second common channel transmitting a signal to the slave device for the master device, the data communication method further comprising, after the slave device enters a sleep state:
when the master device needs to send data, the master device sends a device wake-up signal to the slave device through the second common channel;
the slave device receives the device wake-up signal based on the second general channel, and feeds back a device recovery signal to the master device through the first general channel based on the device wake-up signal and the ready state of the slave device;
the master device receives the device recovery signal based on the first universal channel and resumes data communication with the slave device based on the device recovery signal.
3. The data communication method according to claim 2, wherein the first general purpose channel connection and the second general purpose channel connection are established between the master device and the slave device through a general purpose input/output interface GPIO;
And when the slave device is in a ready state, sending a slave device state signal to the master device through the first universal channel, wherein the method comprises the following steps of:
when the slave device is in a ready state, controlling a GPIO pin of the first general channel to be a first high-level signal, and transmitting the first high-level signal to the master device;
the master device sending a device wake-up signal to the slave device over the second common channel, comprising:
and the master device controls the GPIO pin of the second common channel to be a second high-level signal and transmits the second high-level signal to the slave device.
4. The data communication method according to claim 2, further comprising, after the master device transmits a device wake-up signal to the slave device through the second common channel:
if the master device does not receive the device recovery signal fed back by the slave device within a preset time period, the master device retransmits the device wake-up signal at preset interval time and records the retransmission times;
and when the retransmission times are greater than or equal to a retransmission threshold value, the master device reestablishes SPI communication connection with the slave device.
5. The data communication method according to claim 1, wherein the master data information further includes a slave data check result, the slave data check result characterizing a check result in the master device of slave data information transmitted in a last communication cycle of the slave device, the data communication method further comprising:
the slave device determines whether to retransmit the slave data information sent by the slave device in a communication period based on the slave data verification result;
if the slave device retransmits, the slave device constructs slave data information of the current communication period according to the slave data sent in the previous communication period, and sends the slave data information of the current communication period to the master device;
the slave data information further comprises a master data verification result, the master data verification result represents a verification result of master data information sent by the master device in a communication period in the slave device, and the data communication method further comprises the steps of:
the master device receives the slave data information and determines whether to resend the master data information sent by the master device in a communication period based on the master data verification result;
if the primary equipment retransmits, the primary equipment constructs the primary data information of the current communication period according to the primary data sent in the previous communication period, and sends the primary data information of the current communication period to the secondary equipment.
6. The data communication method according to claim 1, wherein the master device includes a plurality of to-be-transmitted master data packets, each master data packet includes corresponding master data and a type of the master data, and if the type of the master data is real-time data, the master device sets a transmission order of the master data packets corresponding to the real-time data to a highest level.
7. The data communication method according to claim 1, wherein the slave device includes a plurality of slave data packets to be transmitted, each slave data packet includes corresponding slave data and a type of the slave data, and if the type of the slave data is real-time data, the slave device sets a transmission order of the slave data packets corresponding to the real-time data to a highest level.
8. A data communication apparatus, characterized in that it is applied to a data communication system, the data communication system includes a master device and a slave device, a connection is established between the master device and the slave device through an SPI communication channel and a first universal channel, the first universal channel is a signal transmitted from the slave device to the master device, and the data communication apparatus includes:
The state signal sending module is used for sending a slave device state signal to the master device through the first universal channel when the slave device is in a ready state;
the master data transmission module is used for receiving the slave device state signal by the master device based on the first general channel, and sending master data information to the slave device through the SPI communication channel based on the slave device state signal, wherein the master data information at least comprises the master data currently transmitted by the master device and the residual master data quantity to be transmitted by the master device;
the slave data transmission module is used for receiving the master data information based on the SPI communication channel by the slave device and sending slave data information to the master device through the SPI communication channel based on the master data information, wherein the slave data information at least comprises slave data currently transmitted by the slave device and residual slave data quantity to be transmitted by the slave device;
the first dormancy module is used for receiving the slave data information by the master device based on the SPI communication channel, and determining that the master device enters a dormancy state when the residual slave data amount in the slave data information and the residual master data amount are all preset values;
And the second dormancy module is used for the slave equipment to enter a dormancy state when the slave equipment determines that the residual master data quantity in the master data information and the residual slave data quantity are both the preset value.
9. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, the processor being arranged to run the computer program to perform the data communication method of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the data communication method of any one of claims 1 to 7.
CN202311446397.2A 2023-10-31 2023-10-31 Data communication method, device, electronic device and storage medium Pending CN117667813A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311446397.2A CN117667813A (en) 2023-10-31 2023-10-31 Data communication method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311446397.2A CN117667813A (en) 2023-10-31 2023-10-31 Data communication method, device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN117667813A true CN117667813A (en) 2024-03-08

Family

ID=90077899

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311446397.2A Pending CN117667813A (en) 2023-10-31 2023-10-31 Data communication method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN117667813A (en)

Similar Documents

Publication Publication Date Title
JP4198741B2 (en) Communication device, communication system, communication method, communication program, communication circuit
EP0525985B1 (en) High speed duplex data link interface
US5163055A (en) Communications system using a fault tolerant protocol
US5933435A (en) Optimized method of data communication and system employing same
JPH02228855A (en) Data communication system and data communication method
CN111130710B (en) SPI-based duplex communication method
GB2282474A (en) Buffer memory management for a computer network.
EP1986340A2 (en) System and method for improving symmetry in data tranfer in LLC layer of peer to peer NFC device
CN114968876B (en) Data communication method, system, electronic device and storage medium
WO2024131009A1 (en) Inter-chip communication method and storage medium
CN117667813A (en) Data communication method, device, electronic device and storage medium
WO2024037076A1 (en) Data interaction method, apparatus and system, and electronic device and storage medium
WO2023011351A1 (en) Universal serial bus power delivery-based communication method and related apparatus
KR100859499B1 (en) Data transmitting/receiving method and communication system thereof
KR20020009282A (en) Data transmission system and method for transmitting data frames
JP2002176460A (en) Transmitter and communication system
JP3148733B2 (en) Signal processing device and signal processing system
JP4035077B2 (en) Data transmission / reception device and data transmission / reception method
JPH04245355A (en) File transfer system
JP2000101656A (en) Infrared data transmitter and receiver
JP2002077304A (en) Communication system, communication control method, and record medium with its control program recorded thereon
JPH06112973A (en) Packet re-transmission system
CN116528199A (en) Configuration method, device, base station, terminal and storage medium for configuring authorized CG
WO2018059414A1 (en) Data transmission method and device
CN113672545A (en) Method and device for transmitting power data between double processors

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