Communication method between devices, interaction panel and storage medium

By introducing a status indicator pin into the SPI bus, the problem of lack of status confirmation in the SPI bus during data transmission is solved, and state synchronization between master and slave devices is achieved, data loss is avoided and data transmission efficiency is improved.

CN119557257APending Publication Date: 2025-03-04GUANGZHOU KINDLINK INTELLIGENT TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411532255.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The SPI bus lacks a confirmation mechanism for the status of the master and slave device during data transmission, which may lead to data transmission errors when the slave device is not prepared and reduces data transmission efficiency.

Method used

By introducing a first pin into the SPI bus to indicate the status information of the slave device, the master device can determine whether the slave device is in the ready state by obtaining the level parameters of this pin, and send or receive data in the ready state.

Benefits of technology

The status confirmation between master and slave devices is realized, data loss caused by slave devices not being prepared for reception is avoided, data transmission is ensured, and data transmission efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557257A_ABST
    Figure CN119557257A_ABST
Patent Text Reader

Abstract

The invention provides an inter-device communication method, an interaction panel and a storage medium, a master device and a slave device are connected through an SPI bus, the SPI bus comprises a first pin, and the first pin indicates state information of the slave device; the method comprises the following steps: a master device obtains a level parameter of a first pin, and determines whether a slave device is in a first target state based on the level parameter of the first pin; when the slave device is in the first target state, the master device sends a request data packet to the slave device; after the slave device receives the request data packet, the slave device adjusts the first pin to be in a second target state and generates a response data packet of the request data packet; the slave device adjusts the first pin to be in a first target state and sends a response data packet to the master device; and the master device obtains the level parameter of the first pin, receives the response data packet after determining that the slave device is in the first target state based on the level parameter of the first pin, and realizes communication with the slave device. The method can improve the data transmission efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communications, and more specifically, to a communication method between devices, an interactive tablet, and a storage medium. Background Art

[0002] In electronic systems, the demand for high-speed data communication between chips is growing. As a full-duplex communication bus, the Serial Peripheral Interface (SPI) bus has become the mainstream choice for inter-chip communication because it supports a master-slave mode communication architecture.

[0003] In the related art, the SPI bus provides communication specifications at the physical layer, but its data transmission mechanism is completely initiated by the master device, and lacks a mechanism to confirm the status of the master and slave devices. When the master device initiates data transmission, the slave device is not ready, which may cause data transmission errors, thereby reducing data transmission efficiency. Therefore, how to improve data transmission efficiency has become an urgent problem to be solved. Summary of the invention

[0004] The present application provides a communication method between devices, an interactive tablet and a storage medium, which can improve data transmission efficiency.

[0005] In a first aspect, a communication method between devices is provided, the communication method being applied to a communication system including a master device and a slave device; the master device and the slave device are connected via an SPI bus, the SPI bus including a first pin, the first pin being used to indicate status information of the slave device; the method comprising:

[0006] The master device obtains a level parameter of the first pin, and determines whether the slave device is in a first target state based on the level parameter of the first pin; wherein the first target state is used to indicate that the slave device is in a first level state;

[0007] When the slave device is in the first target state, the master device sends a request data packet to the slave device;

[0008] After the slave device receives the request data packet, the slave device adjusts the first pin to a second target state and generates a response data packet to the request data packet; wherein the second target state is used to indicate that the slave device is in a second level state;

[0009] The slave device adjusts the first pin to the first target state, and sends the response data packet to the master device;

[0010] The master device obtains the level parameter of the first pin, and after determining that the slave device is in the first target state based on the level parameter of the first pin, receives the response data packet to achieve communication with the slave device.

[0011] In the above technical solution, the master device and the slave device are connected through an SPI bus, and the SPI bus includes a first pin, and the first pin is used to indicate the status information of the slave device; by modifying the definition of the pin in the SPI bus, the status information of the slave device can be synchronized to the master device; compared with the prior art, in the process of the master device sending a data packet to the slave device, since the slave device is not in a ready state in real time, and the master device cannot determine the status of the slave device, that is, send data to the slave device, which may cause data loss, the slave device of the present application synchronizes the status information of the slave device to the master device by adjusting the level parameter of the first pin, and the master device can determine the status information of the slave device by obtaining the level parameter of the first pin, and send or receive data when the slave device is in the first target state (ready state), which can realize the status confirmation of both the master and the slave, thereby avoiding data loss caused by the slave device not being ready to receive data during data transmission, ensuring the effectiveness of data transmission, and thus improving data transmission efficiency.

[0012] In combination with the first aspect, in some possible implementations, the receiving the response data packet and implementing communication with the slave device includes:

[0013] When the master device receives the response data packet, it determines the target data of the response data packet, and based on the target data, implements reading data or writing data with the slave device.

[0014] The above technical solution, when the transmission type of the request data packet is a read data type or a write data type, realizes reading data or writing data between the slave device through the target data of the response data packet, which can make the master device and the slave device read and write data more efficient.

[0015] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, implementing the reading or writing of data with the slave device based on the target data includes:

[0016] When the transmission type of the request data packet is a read data type, the target data indicates a readable data length, and based on the readable data length, the data of the slave device is read;

[0017] When the transmission type of the request data packet is a write data type, the target data indicates a writable data length, and data is written to the slave device based on the writable data length.

[0018] In the above technical scheme, when the transmission type of the request data packet is a read data type, the target data indicates the readable data length, and based on the readable data length, the data of the slave device is read; when the transmission type of the request data packet is a write data type, the target data indicates the writable data length, and based on the writable data length, the data is written to the slave device; through the readable data length and the writable data length, the transmission data length between the master device and the slave device can be limited, thereby improving the efficiency of the master device reading data from the slave device or the master device writing data to the slave device.

[0019] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, reading the data from the slave device based on the readable data length includes:

[0020] Receive a first data packet sent by the slave device; wherein the data length of the first data packet is less than or equal to the readable data length.

[0021] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the method also includes: after the master device receives the first data packet, determining first confirmation data based on the first data packet; wherein the first confirmation data is used to indicate whether the first data packet is a valid data packet; and sending the first confirmation data to the slave device.

[0022] In the above technical solution, the master device determines the first confirmation data based on the first data packet. Since the first confirmation data indicates whether the first data packet is valid data, sending the first confirmation data to the slave device can enable the slave device to know whether the first data packet is sent successfully, and then determine whether the first data packet needs to be sent repeatedly.

[0023] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, determining the first confirmation data based on the first data packet includes:

[0024] receiving first verification data sent by the slave device, and determining second verification data based on the first data packet; wherein the first verification data is obtained by the slave device based on the first data packet;

[0025] When the first verification data is equal to the second verification data, determining that the first confirmation data indicates that the first data packet is a valid data packet;

[0026] When the first verification data is not equal to the second verification data, it is determined that the first confirmation data indicates that the first data packet is an invalid data packet.

[0027] In the above technical scheme, when the first check data is equal to the second check data, it is determined that the first confirmation data indicates that the first data packet is a valid data packet, and when the first check data is not equal to the second check data, it is determined that the first confirmation data indicates that the first data packet is an invalid data packet; the master device compares the first check value with the second check value, and determines the validity of the first data packet, that is, whether the first data packet is transmitted correctly, through the consistency of the first check value and the second check value, so as to improve the validity of the first confirmation data and further improve the accuracy of data transmission by confirming the data on both the master device and the slave device.

[0028] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, writing data to the slave device based on the writable data length includes:

[0029] Based on the writable data length, a second data packet is generated; wherein the data length of the second data packet is less than or equal to the writable data length; and the second data packet is sent to the slave device.

[0030] In combination with the first aspect and the above-mentioned implementation manner, in some possible implementation manners, the method further includes: the master device receives second confirmation data sent by the slave device; wherein the second confirmation data is used to indicate whether the second data packet is a valid data packet.

[0031] In the above technical solution, the slave device determines the second confirmation data based on the second data packet. Since the second confirmation data indicates whether the second data packet is valid data, the second confirmation data is sent to the master device, so that the master device can know whether the second data packet is sent successfully, and then determine whether the second data packet needs to be sent repeatedly.

[0032] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, generating a response data packet to the request data packet includes:

[0033] Determine a transmission type of the request data packet; and generate the response data packet based on the transmission type.

[0034] The above technical solution determines the data that needs to be included in the response data packet through the transmission type of the request data packet, thereby generating the response data packet.

[0035] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, generating the response data packet based on the transmission type includes:

[0036] When the transmission type is a control type, the slave device generates the response data packet based on feedback data corresponding to the control type;

[0037] When the transmission type is a read data type, the slave device generates the response data packet based on a readable data length corresponding to the read data type;

[0038] When the transmission type is a write data type, the slave device generates the response data packet based on a writable data length corresponding to the write data type.

[0039] In the above technical scheme, when the transmission type of the request data packet is a control type, the slave device generates a response data packet based on the feedback data corresponding to the control type; when the transmission type of the request data packet is a read data type (write data type), the slave device generates a response data packet based on the readable data length (writable data length) corresponding to the read data type; since the response data packet is associated with the transmission type of the request data packet, the data corresponding to the request data packet can be returned through the response data packet, thereby improving the efficiency of subsequent data communications.

[0040] In combination with the first aspect and the above implementation manner, in some possible implementation manners, determining whether the slave device is in the first target state based on the level parameter of the first pin includes:

[0041] When the level parameter of the first pin is a first preset parameter, it is determined that the slave device is in the first target state; wherein the first preset parameter is used to indicate the level parameter of the slave device in the first target state.

[0042] In the above technical solution, since the first preset parameter indicates the level parameter of the slave device in the first target state, the master device can determine the state of the slave device through the level parameter of the first pin; compared with the prior art, the states of the master and slave devices are difficult to synchronize. The present application can synchronize the states of the master and slave devices through the level parameter of the first pin, which can avoid data loss caused by the slave device not being ready to receive during data transmission, thereby improving data transmission efficiency.

[0043] In combination with the first aspect and the foregoing implementation manner, in some possible implementation manners, after the slave device receives the request data packet, the slave device adjusts the first pin to a second target state, including:

[0044] After the slave device receives the request data packet, the slave device adjusts the level parameter of the first pin to a second preset parameter; wherein the second preset parameter is used to indicate the level parameter of the slave device in the second target state.

[0045] In the above technical solution, after the slave device receives the request data packet, the slave device adjusts the level parameter of the first pin to the second preset parameter; since the second preset parameter indicates the level parameter of the slave device in the second target state, that is, the slave device is in a non-ready state, the slave device can synchronize the state of the slave device to the master device by adjusting the level parameter of the first pin, thereby avoiding the master device from sending data to the slave device during this period, resulting in data loss, and thus improving the security and effectiveness of data communication.

[0046] In a second aspect, an interactive tablet is provided, comprising: a master device, a slave device and an SPI bus, wherein the master device and the slave device are connected via the SPI bus, the SPI bus comprising a first pin, and the first pin is used to indicate status information of the slave device; wherein the master device and the slave device are used to execute the communication method between devices in the above-mentioned first aspect or any possible implementation manner of the first aspect.

[0047] In a third aspect, an interactive tablet is provided, comprising a memory and a processor, wherein the memory is used to store executable program code; the processor is used to call and run the executable program code from the memory, so that the interactive tablet executes the communication method between devices in any possible implementation of the first aspect.

[0048] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the communication method between devices in the above-mentioned first aspect or any possible implementation of the first aspect.

[0049] In a fifth aspect, a computer program product is provided, which includes: a computer program code, which, when executed on a computer, enables the computer to execute the method for communication between devices in the first aspect or any possible implementation of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 It is a scenario diagram of a communication method between devices provided in an embodiment of the present application;

[0051] Figure 2 is a schematic diagram of the structure of an interactive tablet provided in an embodiment of the present application;

[0052] Figure 3 is a schematic flow chart of a communication method between devices provided in an embodiment of the present application;

[0053] Figure 4 This is a data interaction diagram of a communication method between devices provided in an embodiment of the present application;

[0054] Figure 5 This is a signal timing diagram of a communication method between devices provided in an embodiment of the present application;

[0055] Figure 6 It is a signal timing diagram of another communication method between devices provided in an embodiment of the present application;

[0056] Figure 7 It is an interactive flow chart of a communication method between devices provided in an embodiment of the present application;

[0057] Figure 8 It is a structural diagram of a communication device between devices provided in an embodiment of the present application;

[0058] Fig. 9 It is a schematic diagram of the structure of another interactive tablet provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0060] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.

[0061] It should be noted that in the related art, the SPI bus provides communication specifications at the physical layer, but its data transmission mechanism is completely initiated by the master device, and lacks a confirmation mechanism for the master and slave device status. When the master device initiates data transmission, the slave device is not ready, which may cause data transmission errors, thereby reducing data transmission efficiency. In view of this, the present application provides a communication method between devices, an interactive tablet, and a storage medium, which can improve data transmission efficiency.

[0062] Figure 1 It is a scenario diagram of a communication method between devices provided in an embodiment of the present application.

[0063] For example, Figure 1As shown, the master device is a main control system-on-chip (System on Chip, SOC), and the slave device is an audio digital signal processor (Digital Signal Processor, DSP). The physical layer of the master control SOC and the audio DSP are connected through an SPI bus. The SPI bus includes a first pin, which is a ready pin (Ready, RDY). The RDY pin is controlled by the slave device and can indicate the status information of the slave device; the SPI bus also includes a data transmission pin (Master Out Slave In, MOSI) from the master device to the slave device, that is, the MOSI pin through which the master control SOC sends data to the audio DSP, a data transmission pin (Master In Slave Out, MISO) from the slave device to the master device, that is, the MISO pin through which the audio DSP sends data to the master control SOC, and a clock pin (Serial Clock, SCK) controlled by the master control SOC. It can be understood that when the master control SOC determines that the audio DSP is in the first target state through the RDY pin, a clock signal is sent to the audio DSP.

[0064] Exemplarily, the first target state may be a low level state.

[0065] Exemplarily, the master SOC needs to establish a connection with the audio DSP and send the original data to the audio DSP for processing, then the master DSP determines that the transmission type is a write data type and generates a request data packet with a transmission type of the write data type.

[0066] Table 1 is a schematic diagram of a request data packet provided in an embodiment of the present application.

[0067] Table 1

[0068]

[0069] Exemplarily, as shown in Table 1, the request data packet (REQUEST) includes a req_mark field, a mod_id field, a comm_type field, a comm_seq field, an arg0 field, an arg1 field, and a chksum field. Specifically, the req_mark field is used to indicate the REQUEST mark, for example, fixed to 0x5152, that is, when the req_mark field is 0x5152, it indicates that the data packet is a request data packet; the mod_id field is used to indicate the module id, indicating the module that initiates the REQUEST; the comm_type field is used to indicate the transmission type, wherein the transmission type includes a read data type (0); a write data type (1); a read data with data check type (2); a write data with data check type (3); a control type (4);

[0070] The comm_seq field is used to indicate the transmission sequence number of the current data packet, starting from 0 and increasing by 1; the arg0 field is used to indicate the attached parameters. If the transmission type of the data packet is the control type, this field is the command attachment parameter 0; if the transmission type of the data packet is the read-write type, this field is the requested data length; the arg1 field is used to indicate the parameters attached to the control type or read-write type request; the chksum field is used to indicate the cyclic redundancy check value (CRC check value) of the REQUEST.

[0071] Table 2 is a schematic table of a request data packet transmission type provided in an embodiment of the present application as a write data type.

[0072] Table 2

[0073] Byte Fields Description (Explanation) 0-1 req_mark 0x5152 2 mod_id 0x5555 3 comm_type (1) 4-7 comm_seq 0 8-11 arg0 128 bytes 12-15 arg1 0xFF 16 chksum 0x00

[0074] Exemplarily, as shown in Table 2, the master SOC generates a request data packet according to the data format corresponding to the request data packet (as shown in Table 1), and the req_mark field indicates that the data packet is a request data packet; the module corresponding to 0x5555 is the audio application module (there is a one-to-one correspondence between the module ID and the module in the master device), that is, the audio application module in the master SOC initiates a data transmission request; the comm_type field indicates that the transmission type of the request data packet is a write data type; the arg0 field indicates that the data length requested by the master SOC is 128 bytes; the arg1 field indicates that the 0xFF module in the audio DSP is requested to perform data processing, and the module ID and the module in the slave device correspond one-to-one. It can be determined that the 0xFF module is an algorithm module according to the preset mapping relationship, and the algorithm module in the audio DSP is requested to perform data processing; the chksum field indicates the check value of the request data packet.

[0075] Exemplarily, when the master SOC generates a request data packet, the level parameter of the RDY pin is obtained. When the level parameter of the RDY pin indicates that the audio DSP is in a low level state, the request data packet is sent to the audio DSP through the MOSI pin. After the audio DSP receives the request data packet, the level parameter of the RDY pin is adjusted to a high level state (the second target state), and the check value in the request data packet is determined to be 0x00. The master device calculates the check value based on the request data packet. When the calculated check value is equal to 0x00, a response data packet (REPLY) of the request data packet is generated.

[0076] Table 3 is a schematic diagram of a response data packet provided in an embodiment of the present application.

[0077] Table 3

[0078]

[0079] Exemplarily, as shown in Table 3, the response data packet includes a reply_mark field, a ret_code field, a comm_seq field, a ret0 field, a ret1 field, and a chksum field; the reply_mark field is used to indicate the REPLY mark, for example, fixed to 0xa1a0, that is, when the reply_mark field is 0xa1a0, it indicates that the data packet is a response data packet; the ret_code field is used to indicate the return result code of a signed 8-bit integer, a negative number indicates an error, and a positive number indicates success; the comm_seq field is used to indicate the transmission sequence number of the current data packet, which starts from 0 and increases by 1, and needs to be consistent with the corresponding REQUEST sequence number; the ret0 field is used to indicate the additional parameters, if it is a control type, this field returns additional information; if it is a read-write type, this field indicates the actual length of data that can be transmitted; the ret1 field is used to indicate the additional information returned by the control type or the read-write type; the chksum field is used to indicate the CRC check value of the response data packet.

[0080] Table 4 is a schematic diagram of a response data packet to a request data packet provided in an embodiment of the present application.

[0081] Table 4

[0082] Byte Fields Description (Explanation) 0-1 reply_mark 0xa1a0 2-3 ret_code 0x01 4-7 comm_seq 0 8-11 ret0 128 bytes 12-15 ret1 0 16 chksum 0x11

[0083] Exemplarily, as shown in Table 4, the audio DSP generates a response data packet according to the data format corresponding to the response data packet and the request data packet. The reply_mark field indicates that the data packet is a response data packet; the ret_code field indicates that the transmission is successful; the comm_seq field is 0 (consistent with the corresponding request data packet sequence number); the ret0 field is used for the writable data length of 128 bytes; the ret1 field is used to indicate that there is no additional information; the chksum field is used to indicate that the CRC check value of the response data packet is 0x11.

[0084] Furthermore, after generating a response data packet of the request data packet, the audio DSP adjusts the RDY pin to a low level state and sends a response data packet to the master SOC through the MISO pin. After receiving the response data packet, the master SOC determines that the check value of the response data packet is 0x11, and the master SOC calculates the check value of the response data packet. When the check value calculated by the master SOC is equal to 0x11, the master SOC determines that the writable data length of the response data packet is 128 bytes, and the audio application module passes the 128-byte original audio data (first data packet) to the physical layer, so that the physical layer sends the original audio data to the physical layer of the audio DSP through the MOSI pin.

[0085] After the physical layer of the audio DSP receives the original audio data, it passes the original audio data to the algorithm module, processes the original audio data through the algorithm module to generate processed audio data, and passes the processed audio data to the physical layer of the audio DSP. The physical layer of the audio DSP sends the processed audio data to the physical layer of the master SOC through the MISO pin, and sends confirmation data to the master SOC through the MISO pin to indicate that the original audio data transmission is successful; when the physical layer of the master SOC receives the processed audio data, it passes the processed audio data to the audio application module, and determines that the original audio data transmission is successful through the confirmation data, then the communication between the master SOC and the audio DSP ends.

[0086] Figure 2 It is a structural schematic diagram of an interactive tablet provided in an embodiment of the present application.

[0087] For example, Figure 2 (a) shows a schematic diagram of the structure of an interactive tablet in which the master and slave devices are not synchronized. Figure 2 (b) is a schematic diagram of the structure of an interactive tablet for synchronizing the status of master and slave devices.

[0088] For example, Figure 2 As shown in (a), the master device and the slave device are connected via the SPI bus, but the SPI bus includes the MOSI pin for the master device to send data to the slave device, the MISO pin for the slave device to send data to the master device, the SCK pin controlled by the master device, and the chip select pin (SC). During the communication between the master device and the slave device, the master device selects the slave device to be interacted with through the SC chip select pin. However, the data communication is controlled and executed by the master device, but since the status between the master device and the slave device is difficult to synchronize, the slave device may not be ready to receive data during the process of the master device sending data to the slave device, resulting in data loss, making it difficult to ensure the efficiency of data transmission.

[0089] For example, Figure 2 As shown in (b), the master device and the slave device are connected via an SPI bus. The SPI bus includes a MOSI pin for the master device to send data to the slave device, a MISO pin for the slave device to send data to the master device, an SCK pin controlled by the master device, and a RDY pin controlled by the slave device.

[0090] Exemplarily, the slave device synchronizes the status information of the slave device to the master device by controlling the RDY pin, so that the master device can determine the status of the slave device. For example, when the slave device adjusts the RDY pin to a low level state, it indicates that the slave device is in the first target state (ready state), that is, the slave device can receive data, and then the master device can determine the status of the slave device through the level parameter of the RDY pin, and send data to the slave device, which can avoid data loss caused by the slave device not being ready to receive data; further, before the slave device sends data to the master device, the slave device adjusts the level parameter of the RDY pin, thereby informing the master device to send data to the master device, realizing status synchronization between the master device and the slave device, and thus improving data transmission efficiency.

[0091] Specifically, the master device obtains the level parameter of the RDY pin. When the level parameter of the RDY pin is low, it is determined that the slave device is in the first target state (low level state) and that the slave device is ready to receive data, and then the master device sends a request data packet to the slave device; after the slave device receives the request data packet, the slave device adjusts the RDY pin to the second target state (high level state) and generates a response data packet for the request data packet; after the slave device generates the response data packet, the slave device adjusts the RDY pin to the first target state (low level state) and sends a response data packet to the master device. The master device obtains the level parameter of the RDY pin, and based on the level parameter of the RDY pin, after determining that the slave device is in the first target state (low level state), receives the response data packet and realizes communication with the slave device.

[0092] In the above technical solution, the slave device can synchronize the status between the master device and the slave device in real time by adjusting the level parameters of the RDY pin, and can synchronize the status of the slave device, thereby improving the data transmission efficiency without increasing the input and output of the SPI bus.

[0093] Figure 3 It is a schematic flowchart of a communication method between devices provided in an embodiment of the present application.

[0094] For example, Figure 3 The method is applied to a communication system including a master device and a slave device, wherein the master device and the slave device are connected via an SPI bus, and the SPI bus includes a first pin, and the first pin is used to indicate status information of the slave device.

[0095] Exemplarily, the first pin is the RDY pin.

[0096] Exemplarily, the master device and the slave device are connected via an SPI bus, which includes a MOSI pin, a MISO pin, an SCK pin, and a RDY pin. The master device sends data to the slave device via the MOSI pin and receives data sent by the slave device via the MISO pin. The SCK pin is used to provide a clock signal, and the RDY pin is used to indicate status information of the slave device.

[0097] For example, Figure 3 As shown, the method 300 includes the following processes:

[0098] S310: The master device obtains a level parameter of a first pin, and determines whether the slave device is in a first target state based on the level parameter of the first pin.

[0099] Exemplarily, the first target state is used to indicate that the slave device is in a first level state. For example, the first level state is a low level state, indicating that the slave device is ready to receive data sent by the master device (or send data to the master device) at any time.

[0100] Optionally, the first level state can be a low level state or a high level state; the second level state can be a low level state or a high level state. It can be understood that the first level state is inconsistent with the second level state, that is, when the first level state is a low level state, the second level state is a high level state, and when the first level state is a high level state, the second level state is a low level state.

[0101] Exemplarily, one end of the RDY pin is connected to the master device, and the other end is connected to the slave device, and the master device determines the state of the slave device by monitoring the level parameter of the RDY pin. For example, the master device can collect the level parameter of the RDY pin in real time, or determine it according to the clock frequency, which is not specifically limited here.

[0102] Exemplarily, when the level parameter of the first pin is a first preset parameter, it is determined that the slave device is in a first target state, and the first preset parameter indicates the level parameter of the slave device in the first target state; when the level parameter of the first pin is a second preset parameter, it is determined that the slave device is in a second target state, and the second preset parameter indicates the level parameter of the slave device in the second target state.

[0103] Exemplarily, the first pin is the RDY pin.

[0104] For example, the level parameter of the RDY pin can be 0 (low level) and 1 (high level), and the first preset parameter corresponding to the first target state is 0 (low level). When the level parameter of the RDY pin is 0, it is determined that the slave device is in a ready-to-receive state, and a request data packet is sent to the slave device. Alternatively, when the level parameter of the RDY pin is 1, the level parameter of the RDY pin is continuously obtained until the level parameter of the RDY pin is 0, and a request data packet is sent to the slave device.

[0105] In the above technical solution, since the first preset parameter indicates the level parameter of the slave device in the first target state, the master device can determine the state of the slave device through the level parameter of the first pin; compared with the prior art, the states of the master and slave devices are difficult to synchronize. The present application can synchronize the states of the master and slave devices through the level parameter of the first pin, which can avoid data loss caused by the slave device not being ready to receive during data transmission, thereby improving data transmission efficiency.

[0106] S320, when the slave device is in the first target state, the master device sends a request data packet to the slave device.

[0107] Exemplarily, the master device obtains the level parameter of the first pin, and based on the level parameter of the first pin, determines whether the slave device is in the first target state. When the slave device is in the first target state, that is, the slave device is in a ready state, the master device sends a request data packet to the slave device.

[0108] Exemplarily, the request data packet (REQUEST data packet) includes a req_mark field, a mod_id field, a comm_type field, a comm_seq field, an arg0 field, an arg1 field, and a chksum field. Specifically, the req_mark field is used to indicate the REQUEST mark, for example, it is fixed to 0x5152, that is, when the req_mark field is 0x5152, it indicates that the data packet is a request data packet; the mod_id field is used to indicate the module id, indicating the module that initiates the REQUEST; the comm_type field is used to indicate the transmission type, wherein the transmission type includes a read data type (0); a write data type (1); a read data with a data check type (2); a write data with a data check type (3); a control type (4); the comm_seq field is used to indicate the transmission sequence number of the current data packet, starting from 0 and increasing by 1; the arg0 field is used to indicate the attached parameters, if the transmission type of the data packet is a control type, this field is the command attachment parameter 0, if the transmission type of the data packet is a read-write type, this field is the requested data length; the arg1 field is used to indicate the parameters attached to the control type or read-write type request; the chksum field is used to indicate the cyclic redundancy check value (CRC check value) of the REQUEST.

[0109] Exemplarily, after sending a request data packet to the slave device, the master device can obtain a level parameter of the first pin. When the level parameter of the first pin is a second preset parameter, the second preset parameter indicates that the slave device is in a second target state, and it is determined that the slave device has received the request data packet.

[0110] S330, after receiving the request data packet from the device, the slave device adjusts the first pin to a second target state and generates a response data packet to the request data packet.

[0111] Exemplarily, the second target state is used to indicate that the slave device is in a second level state; the second level state indicates that the slave device is in a non-ready state. When the slave device is in the second target state, it indicates that the slave device is currently in a non-ready state, that is, the master device cannot send a data packet to the slave device at the current stage; at this time, if the master device sends a data packet to the slave device, it may cause the data packet to be lost.

[0112] Exemplarily, after receiving the request data packet from the device, the slave device adjusts the first pin to the second target state. Specifically, after receiving the request data packet from the device, the slave device adjusts the level parameter of the first pin to a second preset parameter, and the second preset parameter is used to indicate the level parameter of the slave device in the second target state.

[0113] For example, the second preset parameter is 1, and when the level parameter of the RDY pin is 1, it indicates that the slave device is in a non-ready state. After the slave device receives the request data packet, the slave device adjusts the RDY pin from a 0 level to a 1 level.

[0114] In the above technical solution, after the slave device receives the request data packet, the slave device adjusts the level parameter of the first pin to the second preset parameter; since the second preset parameter indicates the level parameter of the slave device in the second target state, that is, the slave device is in a non-ready state, the slave device can synchronize the state of the slave device to the master device by adjusting the level parameter of the first pin, thereby avoiding the master device from sending data to the slave device during this period, resulting in data loss, and thus improving the security and effectiveness of data communication.

[0115] In addition, when the slave device receives the request data packet sent by the master device, it determines whether the request data packet is a valid data packet. Specifically, the slave device determines the check data in the request data packet, and calculates the check data according to the request data packet, and compares the calculated check data with the check data in the request data packet. When the calculated check data is equal to the check data in the request data packet, it is determined that the request data packet is a valid data packet, and a response data packet of the request data packet is generated; when the calculated check data is not equal to the check data of the request data packet, it is determined that the request data packet is an invalid data packet, and then after adjusting the first pin to the first target state, the request data packet sent by the master device can continue to be received.

[0116] Exemplarily, after receiving the request data packet, the slave device determines the transmission type of the request data packet, and generates a response data packet to the request data packet based on the transmission type of the request data packet.

[0117] Exemplarily, the transmission type may be any one of a control type, a read data type, a write data type, a read data with data check type, a write data with data check type. Thus, by determining the transmission type of the request data packet, the data to be included in the response data packet can be determined, thereby generating a response data packet.

[0118] Specifically, the transmission type of the request data packet is determined. When the transmission type of the request data packet is a control type, the slave device generates a response data packet based on the feedback data corresponding to the control type; when the transmission type of the request data packet is a read data type, the slave device generates a response data packet based on the readable data length corresponding to the read data type; when the transmission type of the request data packet is a write data type, the slave device generates a response data packet based on the writable data length corresponding to the write data type.

[0119] Exemplarily, when the transmission type of the request data packet is a control type, and the control command corresponding to the control type is "turn on the A zone indicator light", the slave device executes the control command accordingly, and determines the corresponding feedback data, such as the A zone indicator light has been turned on, and returns the feedback data in the response data packet. When the transmission type of the request data packet is a read data type (including read data with data check type), the slave device determines the readable data length corresponding to the read data type, and returns the readable data length in the response data packet. When the transmission type of the request data packet is a write data type (write data with data check type), the slave device determines the writable data length corresponding to the write data type, and returns the writable data length in the response data packet.

[0120] Exemplarily, a response data packet (REPLY data packet) includes a reply_mark field, a ret_code field, a comm_seq field, a ret0 field, a ret1 field, and a chksum field. The reply_mark field is used to indicate the REPLY mark, for example, it is fixed to 0xa1a0, then when the reply_mark field is 0xa1a0, it indicates that the current data packet is a response data packet; the ret_code field is used to indicate the return result code of a signed 8-bit integer, a negative number indicates an error, and a positive number indicates success; the comm_seq field is used to indicate the transmission sequence number of the current data packet, which starts from 0 and increases by 1, and needs to be consistent with the corresponding REQUEST sequence number; the ret0 field is used to indicate the additional parameters, if it is a control type, this field returns additional information; if it is a read-write data type, this field indicates the actual length of data that can be transmitted; the ret1 field is used to indicate the additional information returned by the control type or the read-write data type; the chksum field is used to indicate the checksum value of the REPLY.

[0121] In the above technical scheme, when the transmission type of the request data packet is a control type, the slave device generates a response data packet based on the feedback data corresponding to the control type; when the transmission type of the request data packet is a read data type (write data type), the slave device generates a response data packet based on the readable data length (writable data length) corresponding to the read data type; since the response data packet is associated with the transmission type of the request data packet, the data corresponding to the request data packet can be returned through the response data packet, thereby improving the efficiency of subsequent data communications.

[0122] S340, the slave device adjusts the first pin to a first target state, and sends a response data packet to the master device.

[0123] Exemplarily, when the slave device generates a response data packet to the request data packet, the slave device adjusts the first pin to the first target state and sends a response data packet to the master device. For example, the slave device adjusts the RDY pin from a high level to a low level (from the second target state to the first target state) and sends a response data packet to the master device.

[0124] S350, the master device obtains the level parameter of the first pin, and after determining that the slave device is in the first target state based on the level parameter of the first pin, receives a response data packet to achieve communication with the slave device.

[0125] Exemplarily, the master device obtains the level parameter of the first pin, and based on the level parameter of the first pin, determines whether the slave device is in the first target state. When the slave device is in the first target state, it receives a response data packet to achieve communication with the slave device.

[0126] It can be understood that when the transmission type of the request data packet is a control type, the data transmission ends after the master device receives the response data packet; when the transmission type of the request data packet is a read data type or a write data type, the master device realizes reading data or writing data with the slave device after receiving the response data packet.

[0127] Exemplarily, when the transmission type of the request data packet is a read data type or a write data type, after the master device receives the response data packet, it determines the target data of the response data packet, and based on the target data of the response data packet, implements the reading or writing of data with the slave device. It is understandable that when the transmission type of the request data packet is a read data type or a write data type, the target data of the response data packet can make the master device and the slave device read and write data more efficiently.

[0128] Specifically, when the transmission type of the request data packet is a read data type, the target data indicates the readable data length, and based on the readable data length, data is read from the slave device; when the transmission type of the request data packet is a write data type, the target data indicates the writable data length, and based on the writable data length, data is written to the slave device.

[0129] In the above technical scheme, when the transmission type of the request data packet is a read data type, the target data indicates the readable data length, and based on the readable data length, the data of the slave device is read; when the transmission type of the request data packet is a write data type, the target data indicates the writable data length, and based on the writable data length, the data is written to the slave device; through the readable data length and the writable data length, the transmission data length between the master device and the slave device can be limited, thereby improving the efficiency of the master device reading data from the slave device or the master device writing data to the slave device.

[0130] Exemplarily, after the slave device sends a response data packet to the master device, the slave device adjusts the first pin to the second target state. When the transmission type of the request data packet is a read data type, the target data indicates a readable data length, the slave device generates a first data packet based on the readable data length, the data length of the first data packet is less than or equal to the readable data length, the slave device adjusts the first pin to the first target state, and sends the first data packet to the master device, and the master device receives the first data packet sent by the slave device.

[0131] In one example, after the master device receives the first data packet, the master device determines first confirmation data based on the first data packet, the first confirmation data indicates whether the first data packet is a valid data packet, and sends the first confirmation data to the slave device. For example, after the master device receives the first data packet, it determines that the first confirmation data indicates that the first data packet is a valid data packet; or, after the master device receives the first data packet, it determines whether the data in the first data packet is request data, when the data in the first data packet is request data, it determines that the first confirmation data indicates that the first data packet is a valid data packet, and when the data in the first data packet is not request data, it determines that the first confirmation data indicates that the first data packet is an invalid data packet.

[0132] In the above technical solution, the master device determines the first confirmation data based on the first data packet. Since the first confirmation data indicates whether the first data packet is valid data, sending the first confirmation data to the slave device can enable the slave device to know whether the first data packet is sent successfully, and then determine whether the first data packet needs to be sent repeatedly.

[0133] In another example, after the master device receives the first data packet, it receives first verification data determined by the slave device, the first verification data is obtained by the slave device through the first data packet, and based on the first data packet, determines second verification data, determines whether the first verification data is equal to the second verification data, and when the first verification data is equal to the second verification data, determines that first confirmation data indicates that the first data packet is a valid data packet; when the first verification data is not equal to the second verification data, determines that the first confirmation data indicates that the first data packet is an invalid data packet.

[0134] In the above technical scheme, when the first check data is equal to the second check data, it is determined that the first confirmation data indicates that the first data packet is a valid data packet, and when the first check data is not equal to the second check data, it is determined that the first confirmation data indicates that the first data packet is an invalid data packet; the master device compares the first check value with the second check value, and determines the validity of the first data packet, that is, whether the first data packet is transmitted correctly, through the consistency of the first check value and the second check value, so as to improve the validity of the first confirmation data and further improve the accuracy of data transmission by confirming the data on both the master device and the slave device.

[0135] Exemplarily, when the transmission type of the requested data packet is a write data type, the target data indicates the writable data length, and based on the writable data length, a second data packet is generated, and the data length of the second data packet is less than or equal to the writable data length; the master device obtains the level parameter of the first pin, and based on the level parameter of the first pin, determines whether the slave device is in a first target state, and when the slave device is in the first target state, the master device sends a second data packet to the slave device.

[0136] In one example, after receiving the second data packet from the slave device, the slave device determines second confirmation data based on the second data packet, the second confirmation data indicating whether the second data packet is a valid data packet, and sends the second confirmation data to the master device. After receiving the second confirmation data, the master device can determine whether the second data packet is sent successfully.

[0137] Optionally, the method for determining the second confirmation data may refer to the method for determining the first confirmation data in the aforementioned disclosed embodiment, which will not be described in detail here.

[0138] In the above technical solution, the slave device determines the second confirmation data based on the second data packet. Since the second confirmation data indicates whether the second data packet is valid data, the second confirmation data is sent to the master device, so that the master device can know whether the second data packet is sent successfully, and then determine whether the second data packet needs to be sent repeatedly.

[0139] In another example, after receiving the second data packet from the device, the third verification data determined by the master device is received, and based on the second data packet, the fourth verification data is obtained to determine whether the third verification data is equal to the fourth verification data. When the third verification data is equal to the fourth verification data, it is determined that the second confirmation data indicates that the second data packet is a valid data packet; when the third verification data is not equal to the fourth verification data, it is determined that the second confirmation data indicates that the second data packet is an invalid data packet. The slave device compares the third verification value with the fourth verification value, and determines the validity of the second data packet, that is, whether the second data packet is transmitted correctly, by comparing the third verification value with the fourth verification value, and by the consistency of the third verification value with the fourth verification value, the validity of the second data packet is determined, that is, whether the second data packet is transmitted correctly, so that the validity of the second confirmation data can be improved by confirming the data on both the master device side and the slave device side, thereby improving the accuracy of data transmission.

[0140] In the above technical solution, the master device and the slave device are connected through an SPI bus, and the SPI bus includes a first pin, and the first pin is used to indicate the status information of the slave device; by modifying the definition of the pin in the SPI bus, the status information of the slave device can be synchronized to the master device; compared with the prior art, in the process of the master device sending a data packet to the slave device, since the slave device is not in a ready state in real time, and the master device cannot determine the status of the slave device, that is, send data to the slave device, which may cause data loss, the slave device of the present application synchronizes the status information of the slave device to the master device by adjusting the level parameter of the first pin, and the master device can determine the status information of the slave device by obtaining the level parameter of the first pin, and send or receive data when the slave device is in the first target state (ready state), which can realize the status confirmation of both the master and the slave, thereby avoiding data loss caused by the slave device not being ready to receive data during data transmission, ensuring the effectiveness of data transmission, and thus improving data transmission efficiency.

[0141] Figure 4 This is a data interaction diagram of a communication method between devices provided in an embodiment of the present application.

[0142] For example, Figure 4 (a) is an interactive diagram of a request data packet transmission type of a read data type. Figure 4 (b) is an interaction diagram in which the transmission type of the request data packet is a write data type.

[0143] For example, Figure 4 As shown in (a), when the transmission type of the request data packet (REQUEST) is a read data type, after the master device receives the response data packet (REPLY) sent by the slave device, the slave device generates a first data packet (DATA) based on the response data packet, and sends the first data packet (DATA) to the master device. After the master device receives the first data packet, the master device generates first confirmation data (ACK), the first confirmation data indicates whether the first data packet is a valid data packet, and sends the first confirmation data to the slave device, thereby enabling the master device to read the data from the slave device.

[0144] For example, Figure 4 As shown in (b), when the transmission type of the request data packet (REQUEST) is a write data type, after the master device receives the response data packet (REPLY) sent by the slave device, the master device generates a second data packet (DATA) based on the response data packet, and sends the second data packet to the slave device. After the slave device receives the second data packet, the slave device generates second confirmation data (ACK), the second confirmation data indicates whether the second data packet is a valid data packet, and sends the second confirmation data to the master device, thereby enabling the master device to write data to the slave device.

[0145] Figure 5 It is a signal timing diagram of a communication method between devices provided in an embodiment of the present application.

[0146] For example, Figure 5 (a) in the figure shows a signal timing diagram of a control type transmission type of a request data packet. Figure 5 (b) in FIG. 1 is a signal timing diagram showing that the transmission type of the request data packet is a read data type. Figure 5 (c) in FIG. 1 is a signal timing diagram showing that the transmission type of the request data packet is a write data type. Figure 5 (d) in the figure shows a signal timing diagram of a request data packet transmission type of read data and a data check type. Figure 5 (e) in the figure shows a signal timing diagram in which the transmission type of the request data packet is write data and has a data check type.

[0147] It should be noted that the RDY pin (first pin) indicates the status information of the slave device. When the level parameter of the RDY pin is 0 (low level), the slave device is in the first target state (ready state), and the master device can send data to the slave device, or the slave device can send data to the master device; when the level parameter of the RDY pin is 1 (high level), the slave device is in the second target state (non-ready state), the slave device performs relevant data processing, and the master device and the slave device cannot interact with each other. In addition, the SCK pin provides a clock signal, which is controlled by the master device and used for synchronous data transmission; that is, the data communication between the master device and the slave device is sampled (sent) at the rising edge or falling edge of the clock signal; when the master device determines that the level parameter of the slave device is 0 (low level), it sends a clock signal to achieve communication with the slave device.

[0148] For example, Figure 5 As shown in (a), the master device generates a request data packet (REQUEST) based on the control data corresponding to the control type, and obtains the level parameter of the RDY pin. When the level parameter of the RDY pin is 0, the request data packet is sent to the slave device through the MOSI pin. After receiving the request data packet, the slave device determines the feedback data corresponding to the control data, generates a response data packet (REPLY) based on the feedback data, and sends the response data packet to the master device through the MISO pin. After the master device receives the response data packet, the communication between the master device and the slave device ends.

[0149] It is understandable that when the master device does not receive the response data packet, since it cannot determine whether the slave device has received the request data packet, it will send a request data packet to the slave device through the MOSI pin when the slave device is in the ready state until the response data packet is received.

[0150] For example, Figure 5 As shown in (b), the master device generates a request data packet (REQUEST) based on the request data corresponding to the read data type, and obtains the level parameter of the RDY pin. When the level parameter of the RDY pin is 0, the master device sends a request data packet to the slave device through the MOSI pin. When the slave device receives the request data packet, it determines the readable data length corresponding to the read data type, generates a response data packet (REPLY) based on the readable data length, and sends the response data packet to the master device through the MISO pin. After receiving the response data packet, the slave device generates a first data packet (DATA) based on the response data packet, and sends the first data packet to the master device through the MISO pin. After receiving the first data packet, the master device generates a first confirmation data (ACK) based on the first data packet, and sends the first confirmation data to the slave device through the MOSI pin.

[0151] For example, Figure 5 As shown in (c), the master device generates a request data packet (REQUEST) based on the request data corresponding to the write data type, and obtains the level parameter of the RDY pin. When the level parameter of the RDY pin is 0, the master device sends a request data packet to the slave device through the MOSI pin. When the slave device receives the request data packet, it determines the writable data length corresponding to the write data type, generates a response data packet (REPLY) based on the writable data length, and sends the response data packet to the master device through the MISO pin. After receiving the response data packet, the master device generates a second data packet (DATA) based on the response data packet, and sends the second data packet to the slave device through the MOSI pin. After receiving the second data packet, the slave device generates second confirmation data (ACK), and sends the second confirmation data to the master device through the MISO pin.

[0152] For example, Figure 5As shown in (d), the master device generates a request data packet (REQUEST) based on the read data and the request data corresponding to the data check type, and obtains the level parameter of the RDY pin. When the level parameter of the RDY pin is 0, the master device sends a request data packet to the slave device through the MOSI pin. When the slave device receives the request data packet, it determines the readable data length corresponding to the read data type, generates a response data packet (REPLY) based on the readable data length, and sends the response data packet to the master device through the MISO pin. After receiving the response data packet, the slave device generates a first data packet (DATA) based on the response data packet, and sends the first data packet to the master device through the MISO pin. After receiving the first data packet, the master device determines the second check data according to the first data packet, and receives the first check data (CHECKSUM) sent by the slave device. According to the first check data and the second check data, the master device generates the first confirmation data (ACK), and sends the first confirmation data to the slave device through the MOSI pin.

[0153] For example, Figure 5 As shown in (e), the master device generates a request data packet (REQUEST) based on the write data and the request data corresponding to the data check type, and obtains the level parameter of the RDY pin. When the level parameter of the RDY pin is 0, the master device sends the request data packet to the slave device through the MOSI pin. When the slave device receives the request data packet, it determines the writable data length corresponding to the write data type, generates a response data packet (REPLY) based on the writable data length, and sends the response data packet to the master device through the MISO pin. After receiving the response data packet, the master device generates a second data packet (DATA) based on the response data packet, and sends the second data packet to the slave device through the MOSI pin. After receiving the second data packet, the slave device generates fourth check data through the second data packet, and receives third check data (CHECKSUM) sent by the master device. The slave device generates second confirmation data (ACK) through the third check data and the fourth check data, and sends the second confirmation data to the master device through the MISO pin.

[0154] It can be understood that before the master device sends data to the slave device, it determines the status information of the slave device through the level parameter of the RDY pin, and sends data to the slave device when the level parameter of the RDY pin indicates that the slave device is in a ready state (low level / level parameter is 0); and before the slave device sends data to the master device, it sends the status information of the slave device (itself) through the level parameter of the RDY pin, and sends data to the master device when the level parameter of the RDY pin is controlled to indicate that the slave device is in a ready state (low level / level parameter is 0), thereby synchronizing the status of the master device and the slave device without increasing the input and output of the SPI bus, thereby improving the data transmission efficiency.

[0155] Figure 6 This is a signal timing diagram of another communication method between devices provided in an embodiment of the present application.

[0156] For example, Figure 6 As shown in the figure, taking the transmission type of the request data as the write data type as an example, the transmission of 512 bytes of data plus the accompanying signaling overhead consumes a total of 4375 clocks. Assuming that the clock frequency of the SCK pin is 25Mhz, the time consumed by 4375 clocks is 1 / 25000000×4375=175us.

[0157] In addition, since the clock signal of the SCK pin is not continuous during data transmission, there is a delay between each data packet, so the delay needs to be calculated. These calculation delays are mainly introduced by the master and slave device CPUs processing data. Assuming that these data processing is mainly data copying, on a processor with a main frequency of 100Mhz (the processor can execute 100,000,000 clock cycles per second), consider the processor's clock cycle and the overhead of the copy operation itself; assuming that the copy operation does not involve other complex calculations or interactions with external devices, it can be simply assumed that each byte copy requires one clock cycle; therefore, the total number of clock cycles required to copy 512 bytes is 512 clock cycles. Since the processor frequency is 100MHz and processes 100,000,000 clock cycles per second, the specific expression can be expressed as follows:

[0158] Total number of clock cycles = 512 bytes × 1 clock cycle / byte = 512 clock cycles

[0159] Time required = total number of clock cycles / processor frequency = 512 clock cycles / 100MHz

[0160] Furthermore, converting the processor frequency into seconds, 100 MHz = 100,000,000 Hz, the time required to copy 512 bytes on a processor with a main frequency of 100 MHz is 512 clock cycles / 100,000,000 Hz = 5.12 × 10^-6 seconds = 5.12 μs (microseconds).

[0161] Since data may need to be copied on both the master and slave ends, assuming that the CPU model and main frequency of the master and slave ends are the same, the time spent on CPU processing to transmit 512 bytes is 5.12×2=10.24us. Therefore, the total time to transmit 512 bytes is 175+10.24=195.24us, which is converted into a rate of 512B / 195.24us≈2.5M / s.

[0162] It can be understood that the data transmission in the present application can easily reach the level of megabytes per second, while the communication rate of the UART-based communication protocol is generally only two to three hundred k / s at most. Compared with the prior art, the present application can increase the data transmission rate without increasing the input and output of the SPI bus.

[0163] In the above technical solution, the master device and the slave device are connected through an SPI bus, and the SPI bus includes a first pin, and the first pin is used to indicate the status information of the slave device; by modifying the definition of the pin in the SPI bus, the status information of the slave device can be synchronized to the master device; compared with the prior art, in the process of the master device sending a data packet to the slave device, since the slave device is not in a ready state in real time, and the master device cannot determine the status of the slave device, that is, send data to the slave device, which may cause data loss, the slave device of the present application synchronizes the status information of the slave device to the master device by adjusting the level parameter of the first pin, and the master device can determine the status information of the slave device by obtaining the level parameter of the first pin, and send or receive data when the slave device is in the first target state (ready state), which can realize the status confirmation of both the master and the slave, thereby avoiding data loss caused by the slave device not being ready to receive data during data transmission, ensuring the effectiveness of data transmission, and thus improving data transmission efficiency.

[0164] Figure 7 It is an interactive flow chart of a communication method between devices provided in an embodiment of the present application.

[0165] For example, Figure 7 The method shown can be performed by an interactive tablet.

[0166] Exemplarily, the first pin is the RDY pin.

[0167] For example, Figure 7 As shown, the method 700 includes the following processes:

[0168] S710, controlling the level parameter of the RDY pin to be a first preset parameter.

[0169] Exemplarily, the first preset parameter indicates a level parameter of the slave device being in a first target state, that is, the slave device is in a ready state and can send and receive data; the first preset parameter may be 0.

[0170] Exemplarily, the slave device needs to perform communication configuration according to the pre-configured data so that the slave device can process data according to the data sent by the master device and return the data processing result. It can be understood that the preset configuration data is used to indicate the access characteristics of the slave device, for example, the preset configuration data is direct memory access (DMA) data.

[0171] Exemplarily, when the communication configuration is completed, the slave device controls the level parameter of the RDY pin to be the first preset parameter, and then synchronizes the state of the slave device by controlling the level parameter of the RDY pin.

[0172] S720, determine whether the slave device is in the first target state; if so, execute S730.

[0173] Exemplarily, the first target state indicates that the slave device is in a first level state, and the first level state is a ready state of the slave device.

[0174] Exemplarily, the level parameter of the slave device controlling the RDY pin is a first preset parameter, the master device obtains the level parameter of the RDY pin, and when the level parameter of the first pin is the first preset parameter, it is determined that the slave device is in a first target state, and the first preset parameter indicates the level parameter of the slave device in the first target state.

[0175] For example, the level parameter of the RDY pin includes 0 (low level) and 1 (high level), the first preset parameter is 0, and the master device obtains the level parameter of the RDY pin as 0, then it is determined that the slave device is in the first target state (ready state), and a request data packet is sent to the slave device. Since the first preset parameter indicates the level parameter of the slave device in the first target state, by comparing the consistency of the level parameter of the RDY pin with the first preset parameter, the state of the slave device can be determined, so that the state of the master and slave devices can be synchronized through the level parameter of the RDY pin, and the data loss caused by the slave device not being ready to receive during the data transmission process can be avoided as much as possible, thereby improving the data transmission efficiency.

[0176] S730, sending a request data packet.

[0177] Exemplarily, the master device determines that the slave device is in the first target state, and then sends a request data packet to the slave device.

[0178] Optionally, the request data packet may refer to the aforementioned disclosed embodiment, which will not be described in detail here.

[0179] S740, controlling the level parameter of the RDY pin to be a second preset parameter.

[0180] Exemplarily, after receiving the request data packet sent by the master device, the device adjusts the level parameter of the RDY pin to the second preset level parameter 1 (high level), so that the second target state (non-ready state) can be synchronized to the master device.

[0181] Exemplarily, after sending a request data packet to the slave device, the master device may obtain a level parameter of the RDY pin, and when the level parameter of the RDY pin is a second preset parameter, it is determined that the slave device has received the request data packet. For example, the level parameter of the RDY pin includes 0 (low level) and 1 (high level), the second preset parameter of the second target state is 1 (high level), and the master device obtains a level parameter of the RDY pin as 1, then it is determined that the slave device has received the request data packet.

[0182] It can be understood that when the slave device is in the second target state, it means that the slave device is receiving data and processing the data, that is, the master device cannot send data packets to the slave device at this stage; at this time, if the master device sends a data packet to the slave device, it may cause data packet loss, resulting in a decrease in data transmission rate.

[0183] S750, determining a response data packet according to the request data packet.

[0184] Exemplarily, the transmission type of the request data packet is determined, and a response data packet is generated based on the transmission type. Specifically, when the transmission type is a control type, the slave device generates a response data packet based on feedback data corresponding to the control type; when the transmission type is a read data type, the slave device generates a response data packet based on a readable data length corresponding to the read data type; when the transmission type is a write data type, the slave device generates a response data packet based on a writable data length corresponding to the write data type.

[0185] Optionally, the method for generating the response data packet may refer to the method in the aforementioned disclosed embodiment, which will not be described in detail here.

[0186] S760, controlling the level parameter of the RDY pin to be a first preset parameter.

[0187] Exemplarily, after the slave device generates a response data packet to the request data packet, the level parameter of the RDY pin is controlled to be a first preset parameter, and the current state is synchronized to the master device to send the response data packet to the master device.

[0188] S770, send a response data packet.

[0189] Exemplarily, when the slave device determines a response data packet based on the request data packet, it controls the level parameter of the RDY pin to be a first preset parameter, synchronizes the current state to the master device, and sends a response data packet to the master device.

[0190] Exemplarily, after receiving the response data packet, the master device implements communication with the slave device based on the response data packet.

[0191] Optionally, the manner of implementing communication with the slave device based on the response data packet may refer to the manner in the aforementioned disclosed embodiment, which will not be described in detail here.

[0192] In the above technical solution, the master device and the slave device are connected through an SPI bus, and the SPI bus includes a first pin, and the first pin is used to indicate the status information of the slave device; by modifying the definition of the pin in the SPI bus, the status information of the slave device can be synchronized to the master device; compared with the prior art, in the process of the master device sending a data packet to the slave device, since the slave device is not in a ready state in real time, and the master device cannot determine the status of the slave device, that is, send data to the slave device, which may cause data loss, the slave device of the present application synchronizes the status information of the slave device to the master device by adjusting the level parameter of the first pin, and the master device can determine the status information of the slave device by obtaining the level parameter of the first pin, and send or receive data when the slave device is in the first target state (ready state), which can realize the status confirmation of both the master and the slave, thereby avoiding data loss caused by the slave device not being ready to receive data during data transmission, ensuring the effectiveness of data transmission, and thus improving data transmission efficiency.

[0193] It should be understood that the above examples are intended to help those skilled in the art understand the embodiments of the present application, rather than to limit the embodiments of the present application to the specific numerical values ​​or specific scenarios illustrated. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of the present application.

[0194] Combination of the above Figures 1 to 7 The communication method between devices provided in the embodiment of the present application is described in detail; Figure 8 and Fig. 9 The device embodiments of the present application are described in detail. It should be understood that the device in the embodiments of the present application can execute the various methods of the aforementioned embodiments of the present application, that is, the specific working processes of the following various products can refer to the corresponding processes in the aforementioned method embodiments.

[0195] Figure 8 It is a structural diagram of a communication device between devices provided in an embodiment of the present application.

[0196] For example, Figure 8 As shown, the inter-device communication device 800 is configured in the inter-device communication system, the master device and the slave device are connected via an SPI bus, the SPI bus includes a first pin, and the first pin is used to indicate the status information of the slave device; the inter-device communication device 800 includes:

[0197] The acquisition module 810 is used for the master device to acquire the level parameter of the first pin, and determine whether the slave device is in a first target state based on the level parameter of the first pin; wherein the first target state is used to indicate that the slave device is in a first level state;

[0198] A sending module 820, configured for the master device to send a request data packet to the slave device when the slave device is in the first target state;

[0199] A generating module 830 is used for adjusting the first pin of the slave device to a second target state after receiving the request data packet from the slave device, and generating a response data packet of the request data packet; wherein the second target state is used to indicate that the slave device is in a second level state;

[0200] An adjustment module 840, configured to adjust the first pin of the slave device to a first target state and send a response data packet to the master device;

[0201] The communication module 850 is used for the master device to obtain the level parameter of the first pin, and after determining that the slave device is in the first target state based on the level parameter of the first pin, receive a response data packet to achieve communication with the slave device.

[0202] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0203] When the master device receives the response data packet, it determines the target data of the response data packet, and based on the target data, implements reading data or writing data with the slave device.

[0204] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0205] When the transmission type of the request data packet is a read data type, the target data indicates a readable data length, and based on the readable data length, data from the slave device is read;

[0206] When the transmission type of the request data packet is a write data type, the target data indicates the writable data length, and data is written to the slave device based on the writable data length.

[0207] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0208] A first data packet sent from a device is received; wherein a data length of the first data packet is less than or equal to a readable data length.

[0209] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0210] After the master device receives the first data packet, it determines first confirmation data based on the first data packet; wherein the first confirmation data is used to indicate whether the first data packet is a valid data packet; and sends the first confirmation data to the slave device.

[0211] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0212] Receive first verification data sent from the device, and determine second verification data based on the first data packet; wherein the first verification data is obtained from the device based on the first data packet;

[0213] When the first verification data is equal to the second verification data, determining that the first confirmation data indicates that the first data packet is a valid data packet;

[0214] When the first verification data is not equal to the second verification data, it is determined that the first confirmation data indicates that the first data packet is an invalid data packet.

[0215] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0216] Based on the writable data length, a second data packet is generated; wherein the data length of the second data packet is less than or equal to the writable data length; and the second data packet is sent to the slave device.

[0217] Optionally, as an embodiment, the communication module 850 is specifically used for:

[0218] The master device receives second confirmation data sent by the slave device; wherein the second confirmation data is used to indicate whether the second data packet is a valid data packet.

[0219] Optionally, as an embodiment, the sending module 820 is specifically configured to:

[0220] Determine a transmission type of the request data packet; and generate a response data packet based on the transmission type.

[0221] Optionally, as an embodiment, the sending module 820 is specifically configured to:

[0222] When the transmission type is a control type, the slave device generates a response data packet based on the feedback data corresponding to the control type;

[0223] When the transmission type is a read data type, the slave device generates a response data packet based on the readable data length corresponding to the read data type;

[0224] When the transmission type is a write data type, the slave device generates a response data packet based on the writable data length corresponding to the write data type.

[0225] Optionally, as an embodiment, the acquisition module 810 is specifically used for:

[0226] When the level parameter of the first pin is the first preset parameter, it is determined that the slave device is in the first target state; wherein the first preset parameter is used to indicate the level parameter of the slave device in the first target state.

[0227] Optionally, as an embodiment, the sending module 820 is specifically configured to:

[0228] After receiving the request data packet from the slave device, the slave device adjusts the level parameter of the first pin to a second preset parameter; wherein the second preset parameter is used to indicate the level parameter of the slave device in the second target state.

[0229] It should be noted that the above-mentioned inter-device communication device 800 is embodied in the form of a functional unit. The term "module" here can be implemented in the form of software and / or hardware, and is not specifically limited to this.

[0230] For example, a "module" may be a software program, a hardware circuit, or a combination of the two that implements the above functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a combined logic circuit, and / or other suitable components that support the described functions.

[0231] Therefore, the units of each example described in the embodiments of the present application can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0232] Fig. 9 It is a schematic diagram of the structure of another interactive tablet provided in an embodiment of the present application.

[0233] For example, Fig. 9 As shown, the interactive tablet 900 includes: a memory 910 and a processor 920, wherein the memory 910 stores an executable program code 930, and the processor 920 is used to call and execute the executable program code 930 to perform a communication method between the devices.

[0234] Exemplarily, the memory 910 can be used to store relevant programs of the communication method between devices provided in the embodiments of the present application; the processor 920 can call the relevant programs of the communication method between devices stored in the memory 910 to execute the communication method between devices in the embodiments of the present application.

[0235] For example, the master device obtains the level parameter of the first pin, and determines whether the slave device is in a first target state based on the level parameter of the first pin; wherein the first target state is used to indicate that the slave device is in a first level state; when the slave device is in the first target state, the master device sends a request data packet to the slave device; after the slave device receives the request data packet, the slave device adjusts the first pin to a second target state, and generates a response data packet to the request data packet; wherein the second target state is used to indicate that the slave device is in a second level state; the slave device adjusts the first pin to the first target state, and sends a response data packet to the master device; the master device obtains the level parameter of the first pin, and determines that the slave device is in the first target state based on the level parameter of the first pin, and then receives the response data packet to achieve communication with the slave device.

[0236] In this embodiment, the functional modules of the device can be divided according to the above method example. For example, each functional module can be corresponded, or two or more functions can be integrated into one processing module. The above integrated module can be implemented in the form of hardware. It should be noted that the division of modules in this embodiment is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0237] In the case of dividing each functional module according to each function, the device may also include an acquisition module, a sending module, a generation module, an adjustment module, a communication module, etc. It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, which will not be repeated here.

[0238] It should be understood that the apparatus provided in this embodiment is used to execute the above-mentioned communication method between devices, and thus can achieve the same effect as the above-mentioned implementation method.

[0239] In the case of an integrated unit, the device may include a processing module and a storage module. The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits shown in conjunction with the disclosure of the present application. The processor may also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.

[0240] In addition, the device provided in the embodiments of the present application may specifically be a chip, a component or a module, and the chip may include a connected processor and a memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a communication method between devices provided in the above embodiments.

[0241] The present application also provides a computer-readable storage medium, in which a computer program code is stored. When the computer program code is executed on a computer, the computer executes the above-mentioned related method steps to implement a communication method between devices provided in the above-mentioned embodiment. Among them, computer-readable storage media may include but are not limited to any type of disk, including floppy disks, optical disks, digital versatile disks (DVD), compact disc read-only memory (CD-ROM), microdrives and magneto-optical disks, read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), electrically erasable programmable read only memory (EEPROM), dynamic random access memory (DRAM), video random access memory (VRAM), flash memory devices, magnetic cards or optical cards, nanosystems (including molecular memory ICs), or any type of medium or device suitable for storing instructions and / or data.

[0242] The present application also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement a communication method between devices provided in the above-mentioned embodiment.

[0243] Among them, the computer-readable storage medium, computer program product or chip provided in this application is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0244] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0245] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0246] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A communication method between devices, characterized in that: The communication method is applied to a communication system including a master device and a slave device; The master device is connected to the slave device via an SPI bus, the SPI bus includes a first pin, and the first pin is used to indicate status information of the slave device; the method includes: The master device obtains a level parameter of the first pin, and determines whether the slave device is in a first target state based on the level parameter of the first pin; wherein the first target state is used to indicate that the slave device is in a first level state; When the slave device is in the first target state, the master device sends a request data packet to the slave device; After the slave device receives the request data packet, the slave device adjusts the first pin to a second target state and generates a response data packet to the request data packet; wherein the second target state is used to indicate that the slave device is in a second level state; The slave device adjusts the first pin to the first target state, and sends the response data packet to the master device; The master device obtains the level parameter of the first pin, and after determining that the slave device is in the first target state based on the level parameter of the first pin, receives the response data packet to achieve communication with the slave device.

2. The method according to claim 1, characterized in that The receiving of the response data packet and implementing communication with the slave device includes: When the master device receives the response data packet, it determines the target data of the response data packet, and based on the target data, implements reading data or writing data with the slave device.

3. The method according to claim 2, characterized in that The step of realizing reading data or writing data with the slave device based on the target data includes: When the transmission type of the request data packet is a read data type, the target data indicates a readable data length, and based on the readable data length, the data of the slave device is read; When the transmission type of the request data packet is a write data type, the target data indicates a writable data length, and data is written to the slave device based on the writable data length.

4. The method according to claim 3, characterized in that The step of reading data from the slave device based on the readable data length includes: Receive a first data packet sent by the slave device; wherein the data length of the first data packet is less than or equal to the readable data length.

5. The method according to claim 4, characterized in that The method further comprises: After the master device receives the first data packet, first confirmation data is determined based on the first data packet; wherein the first confirmation data is used to indicate whether the first data packet is a valid data packet; The first confirmation data is sent to the slave device.

6. The method according to claim 5, characterized in that The determining first confirmation data based on the first data packet includes: receiving first verification data sent by the slave device, and determining second verification data based on the first data packet; wherein the first verification data is obtained by the slave device based on the first data packet; When the first verification data is equal to the second verification data, determining that the first confirmation data indicates that the first data packet is a valid data packet; When the first verification data is not equal to the second verification data, it is determined that the first confirmation data indicates that the first data packet is an invalid data packet.

7. The method according to claim 3, characterized in that The step of writing data to the slave device based on the writable data length comprises: Based on the writable data length, generating a second data packet; wherein the data length of the second data packet is less than or equal to the writable data length; The second data packet is sent to the slave device.

8. The method according to claim 7, characterized in that The method further comprises: The master device receives second confirmation data sent by the slave device; wherein the second confirmation data is used to indicate whether the second data packet is a valid data packet.

9. The method according to claim 1, characterized in that: The generating of a response data packet of the request data packet comprises: Determining a transmission type of the request data packet; Based on the transmission type, the response data packet is generated.

10. The method according to claim 9, characterized in that The generating the response data packet based on the transmission type includes: When the transmission type is a control type, the slave device generates the response data packet based on feedback data corresponding to the control type; When the transmission type is a read data type, the slave device generates the response data packet based on a readable data length corresponding to the read data type; When the transmission type is a write data type, the slave device generates the response data packet based on a writable data length corresponding to the write data type.

11. The method according to claim 1, characterized in that: The step of determining whether the slave device is in a first target state based on the level parameter of the first pin includes: When the level parameter of the first pin is a first preset parameter, determining that the slave device is in the first target state; The first preset parameter is used to indicate a level parameter of the slave device being in the first target state.

12. The method according to claim 1, characterized in that After the slave device receives the request data packet, the slave device adjusts the first pin to a second target state, including: After the slave device receives the request data packet, the slave device adjusts the level parameter of the first pin to a second preset parameter; The second preset parameter is used to indicate a level parameter of the slave device being in the second target state.

13. An interactive tablet, characterized in that: include: A master device, a slave device and an SPI bus, wherein the master device is connected to the slave device via the SPI bus, and the SPI bus comprises a first pin, and the first pin is used to indicate status information of the slave device; The master device and the slave device are used to execute the inter-device communication method as described in any one of claims 1 to 12.

14. An interactive tablet, characterized in that: include: A memory for storing executable program codes; A processor is used to call and run the executable program code from the memory, so that the interactive tablet executes the communication method between devices as described in any one of claims 1 to 12.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed, the inter-device communication method according to any one of claims 1 to 12 is implemented.