CN115941382A - Flow control method and device for SPI communication, terminal equipment and storage medium - Google Patents
Flow control method and device for SPI communication, terminal equipment and storage medium Download PDFInfo
- Publication number
- CN115941382A CN115941382A CN202211407623.1A CN202211407623A CN115941382A CN 115941382 A CN115941382 A CN 115941382A CN 202211407623 A CN202211407623 A CN 202211407623A CN 115941382 A CN115941382 A CN 115941382A
- Authority
- CN
- China
- Prior art keywords
- data
- frame
- master device
- slave device
- flow control
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Communication Control (AREA)
Abstract
本发明公开了一种SPI通信的流控方法、装置、终端设备及存储介质,所述方法应用于包括主设备和从设备SPI通信的流控系统,所述主设备和所述从设备之间的通信通道包括一个SPI接口和与SPI接口相关联的两个GPIO引脚;所述方法包括:主设备和从设备之间通过通信通道进行数据传输;当从设备向主设备发送数据时,将第二GPIO引脚设置为第一状态,向主设备发送中断信号;主设备接收到中断信号后发起传输,接收从所述从设备发送的数据;当从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。本发明使用较少的GPIO引脚,节省了芯片硬件资源,主从设备可以随时发送数据,实现数据应答与重传机制,保证了数据的实时性和可靠性,减少了CPU的额外开销。
The invention discloses a flow control method, device, terminal equipment and storage medium for SPI communication. The method is applied to a flow control system including a master device and a slave device for SPI communication. The communication channel comprises an SPI interface and two GPIO pins associated with the SPI interface; the method includes: carrying out data transmission through the communication channel between the master device and the slave device; when the slave device sends data to the master device, the The second GPIO pin is set to the first state, and sends an interrupt signal to the master device; the master device initiates transmission after receiving the interrupt signal, and receives the data sent from the slave device; when the slave device detects the first GPIO pin When it changes from high level to low level, it is judged that the data frame transmission is completed. The present invention uses fewer GPIO pins, saves chip hardware resources, and master-slave devices can send data at any time, realize data response and retransmission mechanism, ensure real-time performance and reliability of data, and reduce CPU overhead.
Description
技术领域technical field
本发明涉及通信技术领域,尤其涉及一种SPI通信的流控方法、装置、终端设备及存储介质。The present invention relates to the field of communication technology, in particular to a flow control method, device, terminal equipment and storage medium for SPI communication.
背景技术Background technique
根据SPI通信原理,在每个Clock周期内,SPI设备都会发送并接收一个bit大小的数据(不管是主设备还是从设备),相当于该设备有一个bit大小的数据被交换了。由于时钟是由主设备提供的,因此从设备无法主动发送数据。从设备若想随时发送数据,主设备必须使用轮询方式不断发起传输,而大部分时间总线上都是无效数据,导致主设备产生额外的CPU开销。在主设备和从设备没有固定帧长时,从设备不知道收取数据是否完成。此外,SPI没有指定的流控制,没有应答机制确认是否接收到数据,或者使用了较多的GPIO引脚来实现流控与应答,成本较高。According to the principle of SPI communication, in each Clock cycle, the SPI device will send and receive a bit-sized data (whether it is a master device or a slave device), which means that the device has a bit-sized data exchanged. Since the clock is provided by the master device, the slave device cannot actively send data. If the slave device wants to send data at any time, the master device must use the polling method to continuously initiate transmission, and most of the time the bus is invalid data, resulting in additional CPU overhead for the master device. When the master device and the slave device do not have a fixed frame length, the slave device does not know whether the data collection is completed. In addition, SPI has no specified flow control, and there is no response mechanism to confirm whether data is received, or more GPIO pins are used to realize flow control and response, and the cost is relatively high.
发明内容Contents of the invention
本发明所要解决的技术问题在于,提供一种SPI通信的流控方法、装置、终端设备及存储介质,使用较少的GPIO引脚,节省了芯片硬件资源,主从设备可以随时发送数据,实现数据应答与重传机制,保证了数据的实时性和可靠性,减少了CPU的额外开销。The technical problem to be solved by the present invention is to provide a flow control method, device, terminal equipment and storage medium for SPI communication, use less GPIO pins, save chip hardware resources, and the master and slave devices can send data at any time to realize The data response and retransmission mechanism ensures the real-time and reliability of the data and reduces the extra overhead of the CPU.
为了实现上述目的,本发明实施例提供了一种SPI通信的流控方法,应用于SPI通信的流控系统,所述流控系统包括主设备和至少一个从设备,所述主设备和所述从设备之间的通信通道包括一个SPI接口和与所述SPI接口相关联的两个GPIO引脚;其中,第一GPIO引脚为所述从设备的输入,与所述SPI接口中的CS引脚连接;第二GPIO引脚为所述从设备的输出,与所述主设备连接,所述SPI通信的流控方法包括:In order to achieve the above object, an embodiment of the present invention provides a flow control method for SPI communication, which is applied to a flow control system for SPI communication. The flow control system includes a master device and at least one slave device, and the master device and the The communication channel between the slave devices includes an SPI interface and two GPIO pins associated with the SPI interface; wherein, the first GPIO pin is the input of the slave device, and the CS pin in the SPI interface The pin is connected; the second GPIO pin is the output of the slave device, which is connected with the master device, and the flow control method of the SPI communication includes:
所述主设备和所述从设备之间通过所述通信通道进行数据传输;performing data transmission between the master device and the slave device through the communication channel;
当所述从设备向所述主设备发送数据时,将所述第二GPIO引脚设置为第一状态,向所述主设备发送中断信号;When the slave device sends data to the master device, the second GPIO pin is set to a first state, and an interrupt signal is sent to the master device;
所述主设备接收到所述中断信号后发起传输,接收从所述从设备发送的数据;The master device initiates transmission after receiving the interrupt signal, and receives the data sent from the slave device;
当所述从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。When the slave device detects that the first GPIO pin changes from a high level to a low level, it is determined that the data frame transmission is completed.
作为上述方案的改进,所述从设备向所述主设备发送数据时,所述从设备的接口传输长度设为最大帧长,所述主设备的接口传输长度设为最小帧长。As an improvement of the above solution, when the slave device sends data to the master device, the interface transmission length of the slave device is set to a maximum frame length, and the interface transmission length of the master device is set to a minimum frame length.
作为上述方案的改进,所述当从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成,之后还包括:As an improvement of the above solution, when the slave device detects that the first GPIO pin changes from high level to low level, it is determined that the data frame transmission is completed, and then it also includes:
判断从所述主设备返回的数据帧是否有效;judging whether the data frame returned from the master device is valid;
若有效,则判断从所述主设备返回的数据帧的类别;若为请求帧,则将所述主设备返回的数据帧放入所述从设备的接收缓冲区,生成所述请求帧的应答帧,放入所述从设备的发送缓冲区;若为应答帧,则设置应答标志位,进行下一帧数据的传输;If it is valid, then judge the category of the data frame returned from the master device; if it is a request frame, put the data frame returned by the master device into the receiving buffer of the slave device, and generate the response of the request frame frame, put into the sending buffer of the slave device; if it is a response frame, then set the response flag bit, and carry out the transmission of the next frame of data;
若无效,则直接进入应答等待,收到应答则将已发送的数据帧从所述从设备的发送缓冲区中移除,进行下一帧数据的传输。If it is invalid, it will directly enter the response waiting, and when the response is received, the sent data frame will be removed from the sending buffer of the slave device, and the next frame of data will be transmitted.
作为上述方案的改进,所述主设备发起传输时,循环检测所述主设备的发送缓冲区;As an improvement of the above solution, when the master device initiates transmission, the sending buffer of the master device is cyclically detected;
当所述主设备的发送缓冲区有待发送数据帧时,以预设帧长取出所述待发送数据帧,调用所述SPI接口向所述从设备发送所述待发送数据帧。When there is a data frame to be sent in the sending buffer of the master device, the data frame to be sent is taken out with a preset frame length, and the SPI interface is called to send the data frame to be sent to the slave device.
作为上述方案的改进,所述调用所述SPI接口向所述从设备发送所述待发送数据帧,之后还包括:As an improvement of the above solution, the calling of the SPI interface sends the data frame to be sent to the slave device, and then further includes:
所述主设备接收从所述从设备返回的数据帧,并判断返回的数据帧是否有效;The master device receives the data frame returned from the slave device, and judges whether the returned data frame is valid;
若有效,则对有效数据帧进行处理,处理完成后进入应答等待;If it is valid, it will process the valid data frame, and enter the response waiting after the processing is completed;
若无效,则直接进入应答等待;If it is invalid, it will directly enter the response waiting;
应答等待超时则发起重传,收到应答则将所述待发送数据帧从所述主设备的发送缓冲区中移除,进行下一帧数据的传输。Retransmission is initiated when the response waits for a timeout, and the data frame to be sent is removed from the sending buffer of the master device when the response is received, and the next frame of data is transmitted.
作为上述方案的改进,所述对有效数据帧进行处理,具体包括:As an improvement of the above solution, the processing of the effective data frame specifically includes:
判断所述有效数据帧的长度是否不大于所述预设帧长;judging whether the length of the valid data frame is not greater than the preset frame length;
若否,则发起二次传输,对剩余未接收的数据进行接收;If not, initiate a second transmission to receive the remaining unreceived data;
若是,则判断所述有效数据帧的类别;If so, then judge the category of the valid data frame;
若所述有效数据帧为请求帧,则将所述有效数据帧放入所述主设备的接收缓冲区,生成所述请求帧的应答帧,放入所述主设备的发送缓冲区;If the valid data frame is a request frame, then put the valid data frame into the receiving buffer of the master device, generate a response frame of the request frame, and put it into the sending buffer of the master device;
若所述有效数据帧为应答帧,则设置应答标志位,进行下一帧数据的传输。If the valid data frame is a response frame, the response flag bit is set to transmit the next frame of data.
作为上述方案的改进,所述有效数据帧的长度为帧头长度、数据长度和校验区长度的总和。As an improvement of the above scheme, the length of the valid data frame is the sum of the length of the frame header, the length of the data and the length of the check area.
本发明实施例还提供了一种SPI通信的流控装置,应用于SPI通信的流控系统,所述流控系统包括主设备和至少一个从设备,所述主设备和所述从设备之间的通信通道包括一个SPI接口和与所述SPI接口相关联的两个GPIO引脚;其中,第一GPIO引脚为所述从设备的输入,与所述SPI接口中的CS引脚连接;第二GPIO引脚为所述从设备的输出,与所述主设备连接,所述SPI通信的流控装置包括:The embodiment of the present invention also provides a flow control device for SPI communication, which is applied to the flow control system of SPI communication. The flow control system includes a master device and at least one slave device, and the master device and the slave device The communication channel comprises an SPI interface and two GPIO pins associated with the SPI interface; wherein, the first GPIO pin is the input of the slave device and is connected to the CS pin in the SPI interface; the second Two GPIO pins are the output of the slave device, connected with the master device, and the flow control device of the SPI communication includes:
传输模块,用于所述主设备和所述从设备之间通过所述通信通道进行数据传输;a transmission module, configured to perform data transmission between the master device and the slave device through the communication channel;
中断模块,用于当所述从设备向所述主设备发送数据时,将所述第二GPIO引脚设置为第一状态,向所述主设备发送中断信号;An interrupt module, configured to set the second GPIO pin to a first state and send an interrupt signal to the master device when the slave device sends data to the master device;
接收模块,用于所述主设备接收到所述中断信号后发起传输,接收从所述从设备发送的数据;A receiving module, configured for the master device to initiate transmission after receiving the interrupt signal, and receive data sent from the slave device;
检测模块,用于当所述从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。The detection module is configured to determine that the data frame transmission is completed when the slave device detects that the first GPIO pin changes from a high level to a low level.
本发明实施例还提供了一种终端设备,包括处理器、存储器以及存储在所述存储器中且被配置为由所述处理器执行的计算机程序,所述处理器执行所述计算机程序时实现上述任一项所述的SPI通信的流控方法。An embodiment of the present invention also provides a terminal device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the above-mentioned The flow control method of the SPI communication described in any one.
本发明实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质包括存储的计算机程序,其中,在所述计算机程序运行时控制所述计算机可读存储介质所在设备执行上述任一项所述的SPI通信的流控方法。An embodiment of the present invention also provides a computer-readable storage medium, the computer-readable storage medium includes a stored computer program, wherein, when the computer program is running, the device where the computer-readable storage medium is located is controlled to perform any of the above tasks. A flow control method of the SPI communication.
相对于现有技术,本发明实施例提供的一种SPI通信的流控方法、装置、终端设备及存储介质的有益效果在于:通过在主设备和从设备之间的通信通道增加两个与SPI接口相关联的GPIO引脚,其中,第一GPIO引脚为从设备的输入,与SPI接口中的CS引脚连接;第二GPIO引脚为从设备的输出,与主设备连接。主设备和从设备之间通过所述通信通道进行数据传输;当所述从设备向所述主设备发送数据时,将所述第二GPIO引脚设置为第一状态,向所述主设备发送中断信号;所述主设备接收到所述中断信号后发起传输,接收从所述从设备发送的数据;当所述从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。本发明实施例使用较少的GPIO引脚,节省了芯片硬件资源,主从设备可以随时发送数据,实现数据应答与重传机制,保证了数据的实时性和可靠性,减少了CPU的额外开销。Compared with the prior art, the beneficial effect of the flow control method, device, terminal device and storage medium of the SPI communication provided by the embodiment of the present invention is that: through the communication channel between the master device and the slave device, two communication channels with SPI are added. The GPIO pins associated with the interface, wherein the first GPIO pin is the input of the slave device and is connected to the CS pin in the SPI interface; the second GPIO pin is the output of the slave device and is connected to the master device. Perform data transmission between the master device and the slave device through the communication channel; when the slave device sends data to the master device, set the second GPIO pin to the first state, and send the data to the master device Interrupt signal; the master device initiates transmission after receiving the interrupt signal, and receives data sent from the slave device; when the slave device detects that the first GPIO pin changes from a high level to a low level , to determine that the data frame transmission is complete. The embodiment of the present invention uses fewer GPIO pins, which saves chip hardware resources. The master and slave devices can send data at any time, realize the data response and retransmission mechanism, ensure the real-time performance and reliability of the data, and reduce the extra overhead of the CPU. .
附图说明Description of drawings
图1是本发明提供的一种SPI通信的流控方法的一个优选实施例的流程示意图;Fig. 1 is the flow diagram of a preferred embodiment of the flow control method of a kind of SPI communication provided by the present invention;
图2是本发明提供的一种SPI通信的流控系统的一个优选实施例的结构示意图;Fig. 2 is the structural representation of a preferred embodiment of the flow control system of a kind of SPI communication provided by the present invention;
图3是本发明提供的一种SPI通信的流控方法中从设备发起传输的流程示意图;Fig. 3 is a schematic flow diagram of a slave device initiating transmission in a flow control method of SPI communication provided by the present invention;
图4是本发明提供的一种SPI通信的流控方法中主设备收到从设备传输请求后的流程示意图;Fig. 4 is a schematic flow diagram after the master device receives the transfer request from the device in the flow control method of a kind of SPI communication provided by the present invention;
图5是本发明提供的一种SPI通信的流控方法中主设备发起传输的流程示意图;Fig. 5 is a schematic flow diagram of a master device initiating a transmission in a flow control method for SPI communication provided by the present invention;
图6是本发明提供的一种SPI通信的流控方法中主设备处理有效数据帧的流程示意图;Fig. 6 is a schematic flow diagram of a master device processing valid data frames in a flow control method for SPI communication provided by the present invention;
图7是本发明提供的一种SPI通信的流控方法中有效数据帧的结构示意图;Fig. 7 is the structural representation of effective data frame in the flow control method of a kind of SPI communication provided by the present invention;
图8是本发明提供的一种SPI通信的流控装置的一个优选实施例的结构示意图;Fig. 8 is a schematic structural diagram of a preferred embodiment of a flow control device for SPI communication provided by the present invention;
图9是本发明提供的一种终端设备的一个优选实施例的结构示意图。Fig. 9 is a schematic structural diagram of a preferred embodiment of a terminal device provided by the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.
请参阅图1,图1是本发明提供的一种SPI通信的流控方法的一个优选实施例的流程示意图。所述SPI通信的流控方法应用于SPI通信的流控系统,所述流控系统包括主设备和至少一个从设备,所述主设备和所述从设备之间的通信通道包括一个SPI接口和与所述SPI接口相关联的两个GPIO引脚;其中,第一GPIO引脚为所述从设备的输入,与所述SPI接口中的CS引脚连接;第二GPIO引脚为所述从设备的输出,与所述主设备连接,所述SPI通信的流控方法包括:Please refer to FIG. 1 . FIG. 1 is a schematic flowchart of a preferred embodiment of a flow control method for SPI communication provided by the present invention. The flow control method of the SPI communication is applied to the flow control system of the SPI communication, the flow control system includes a master device and at least one slave device, and the communication channel between the master device and the slave device includes an SPI interface and Two GPIO pins associated with the SPI interface; wherein, the first GPIO pin is the input of the slave device, connected with the CS pin in the SPI interface; the second GPIO pin is the slave The output of the device is connected with the master device, and the flow control method of the SPI communication includes:
S1,所述主设备和所述从设备之间通过所述通信通道进行数据传输;S1, performing data transmission between the master device and the slave device through the communication channel;
S2,当所述从设备向所述主设备发送数据时,将所述第二GPIO引脚设置为第一状态,向所述主设备发送中断信号;S2. When the slave device sends data to the master device, set the second GPIO pin to a first state, and send an interrupt signal to the master device;
S3,所述主设备接收到所述中断信号后发起传输,接收从所述从设备发送的数据;S3. The master device initiates transmission after receiving the interrupt signal, and receives data sent from the slave device;
S4,当所述从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。S4. When the slave device detects that the first GPIO pin changes from a high level to a low level, determine that the data frame transmission is completed.
具体的,请参阅图2,图2是本发明提供的一种SPI通信的流控系统的一个优选实施例的结构示意图。本发明实施例中SPI通信的流控系统包括主设备和至少一个从设备,主设备和从设备之间的通信通道包括一个SPI接口和与SPI接口相关联的两个GPIO引脚。其中,第一GPIO引脚为从设备的输入,与SPI接口中的CS引脚连接。第二GPIO引脚为从设备的输出,与主设备连接。SPI接口包括MOSI、MISO、SCLK和CS信号线。其中,SCLK、MOSI、CS信号均由主设备控制产生,SCLK是时钟信号,用以同步数据。MOSI是主设备输出从设备输入信号,主设备通过此信号线传输数据给从设备。CS为片选信号,用以选定从设备,低电平有效。而MISO的信号由从设备产生,主设备通过该信号线读取从设备的数据。MOSI与MISO的信号只在CS为低电平的时候才有效,在SCLK的每个时钟周期MOSI和MISO传输一位数据。本发明实施例中主设备和从设备之间通过通信通道进行数据传输。当从设备主动向主设备发送数据时,将第二GPIO引脚设置为第一状态,向主设备发送中断信号。其中,第一状态指GPIO2从高电平(默认状态为高电平)设为低电平再设为高电平,因为主设备使用的是下降沿触发中断。主设备接收到中断信号后发起传输,接收从从设备发送的数据。若主设备没有发起传输,从设备会一直阻塞。当从设备检测到第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。Specifically, please refer to FIG. 2 . FIG. 2 is a schematic structural diagram of a preferred embodiment of an SPI communication flow control system provided by the present invention. The flow control system for SPI communication in the embodiment of the present invention includes a master device and at least one slave device, and the communication channel between the master device and the slave device includes an SPI interface and two GPIO pins associated with the SPI interface. Wherein, the first GPIO pin is the input of the slave device, and is connected with the CS pin in the SPI interface. The second GPIO pin is the output of the slave device, which is connected to the master device. The SPI interface includes MOSI, MISO, SCLK and CS signal lines. Among them, SCLK, MOSI, and CS signals are all controlled and generated by the master device, and SCLK is a clock signal for synchronizing data. MOSI is the master device output slave device input signal, the master device transmits data to the slave device through this signal line. CS is a chip select signal, which is used to select a slave device and is active at low level. The MISO signal is generated by the slave device, and the master device reads the data of the slave device through the signal line. The signals of MOSI and MISO are only valid when CS is low, and MOSI and MISO transmit one bit of data in each clock cycle of SCLK. In the embodiment of the present invention, data transmission is performed between the master device and the slave device through a communication channel. When the slave device actively sends data to the master device, the second GPIO pin is set to the first state, and an interrupt signal is sent to the master device. Wherein, the first state means that GPIO2 is set from a high level (the default state is a high level) to a low level and then to a high level, because the master device uses a falling edge to trigger an interrupt. After receiving the interrupt signal, the master device initiates the transmission and receives the data sent from the slave device. If the master device does not initiate a transfer, the slave device will always block. When the slave device detects that the first GPIO pin changes from a high level to a low level, it is determined that the data frame transmission is completed.
需要说明的是,在SPI通信中,SPI主设备以从设备支持的频率通过SCLK线给到SPI从设备,这意味着从设备是无法主动向主设备发送数据的,只能主设备轮询向从设备发或者从设备主动通过一个IO口来告知主设备数据到达。因此,本发明实施例在主设备和从设备之间的通信通道增加两个与SPI接口相关联的GPIO引脚。It should be noted that in SPI communication, the SPI master device sends the SPI slave device to the SPI slave device through the SCLK line at the frequency supported by the slave device, which means that the slave device cannot actively send data to the master device. The slave device sends or the slave device actively informs the master device of the arrival of data through an IO port. Therefore, in the embodiment of the present invention, two GPIO pins associated with the SPI interface are added to the communication channel between the master device and the slave device.
本发明实施例使用较少的GPIO引脚实现SPI通信的流控,主设备使用了一个GPIO引脚,从设备使用了两个GPIO引脚,硬件结构简单,节省了芯片硬件资源。从设备传输使用最大帧长,主设备通过检测帧头中的数据长度来判断是否进行二次传输。因此主从设备无需使用固定帧长进行收发数据,传输帧长由每次实际需要传输的数据长度来确定,避免了额外的时钟开销。从设备使用GPIO中断通知主设备开启传输,从设备可随时主动发送数据,主设备无需循环接收数据,降低了CPU资源占用。主从设备可随时收发数据并在发送时会对接收到的数据进行处理,实现了有效数据的全双工传输,极大提高了SPI的通信速率。主从设备均进行了软件应答重传机制,保证了每次数据收发的正确性。The embodiment of the present invention uses fewer GPIO pins to realize the flow control of SPI communication, the master device uses one GPIO pin, and the slave device uses two GPIO pins, the hardware structure is simple, and chip hardware resources are saved. The slave device uses the maximum frame length for transmission, and the master device judges whether to perform secondary transmission by detecting the data length in the frame header. Therefore, the master and slave devices do not need to use a fixed frame length to send and receive data, and the transmission frame length is determined by the actual data length to be transmitted each time, avoiding additional clock overhead. The slave device uses the GPIO interrupt to notify the master device to start transmission, the slave device can actively send data at any time, and the master device does not need to receive data in a loop, which reduces the CPU resource usage. The master-slave device can send and receive data at any time and process the received data when sending, realizing full-duplex transmission of valid data and greatly improving the communication rate of SPI. Both the master and slave devices implement the software response retransmission mechanism to ensure the correctness of each data transmission and reception.
在另一个优选实施例中,所述从设备向所述主设备发送数据时,所述从设备的接口传输长度设为最大帧长,所述主设备的接口传输长度设为最小帧长。In another preferred embodiment, when the slave device sends data to the master device, the interface transmission length of the slave device is set to a maximum frame length, and the interface transmission length of the master device is set to a minimum frame length.
具体的,由于主设备可能会发起多次调用,而从设备不知道每次会传输多长,因此需要将从设备的接口传输长度设为最大帧长,主设备的接口传输长度设为最小帧长。Specifically, since the master device may initiate multiple calls, and the slave device does not know how long each transmission will be, it is necessary to set the interface transmission length of the slave device to the maximum frame length, and the interface transmission length of the master device to the minimum frame length long.
在又一个优选实施例中,所述当从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成,之后还包括:In yet another preferred embodiment, when the slave device detects that the first GPIO pin changes from a high level to a low level, it is determined that the data frame transmission is completed, and then it also includes:
判断从所述主设备返回的数据帧是否有效;judging whether the data frame returned from the master device is valid;
若有效,则判断从所述主设备返回的数据帧的类别;若为请求帧,则将所述主设备返回的数据帧放入所述从设备的接收缓冲区,生成所述请求帧的应答帧,放入所述从设备的发送缓冲区;若为应答帧,则设置应答标志位,进行下一帧数据的传输;If it is valid, then judge the category of the data frame returned from the master device; if it is a request frame, put the data frame returned by the master device into the receiving buffer of the slave device, and generate the response of the request frame frame, put into the sending buffer of the slave device; if it is a response frame, then set the response flag bit, and carry out the transmission of the next frame of data;
若无效,则直接进入应答等待,收到应答则将已发送的数据帧从所述从设备的发送缓冲区中移除,进行下一帧数据的传输。If it is invalid, it will directly enter the response waiting, and when the response is received, the sent data frame will be removed from the sending buffer of the slave device, and the next frame of data will be transmitted.
具体的,请参阅图3和图4,图3是本发明提供的一种SPI通信的流控方法中从设备发起传输的流程示意图,图4是本发明提供的一种SPI通信的流控方法中主设备收到从设备传输请求后的流程示意图。当从设备主动向主设备发送数据时,从从设备的发送缓冲区中取出待发送数据帧,将第二GPIO引脚设置为第一状态,向主设备发送中断信号,通知主设备发起传输。主设备接收到中断信号后发起传输,接收从从设备发送的数据。从设备在接收状态中,当从设备检测到第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成,退出接收状态,进行接收到数据的处理。判断从主设备返回的数据帧是否有效。若有效,则判断从主设备返回的数据帧的类别。若为请求帧,则将主设备返回的数据帧放入从设备的接收缓冲区,生成请求帧的应答帧,放入从设备的发送缓冲区。若为应答帧,则设置应答标志位,进行下一帧数据的传输。若无效,则直接进入应答等待,收到应答则将已发送的数据帧从从设备的发送缓冲区中移除,进行下一帧数据的传输。Specifically, please refer to Fig. 3 and Fig. 4, Fig. 3 is a schematic flow chart of a flow control method for SPI communication provided by the present invention, and Fig. 4 is a flow control method for SPI communication provided by the present invention Schematic diagram of the process after the master device receives the transfer request from the slave device. When the slave device actively sends data to the master device, it takes out the data frame to be sent from the send buffer of the slave device, sets the second GPIO pin to the first state, sends an interrupt signal to the master device, and notifies the master device to initiate the transmission. After receiving the interrupt signal, the master device initiates the transmission and receives the data sent from the slave device. In the receiving state, when the slave device detects that the first GPIO pin changes from high level to low level, it determines that the data frame transmission is completed, exits the receiving state, and processes the received data. Determine whether the data frame returned from the master device is valid. If valid, judge the type of the data frame returned from the master device. If it is a request frame, put the data frame returned by the master device into the receive buffer of the slave device, generate a response frame of the request frame, and put it into the send buffer of the slave device. If it is a response frame, set the response flag bit to transmit the next frame of data. If it is invalid, it will directly enter the response waiting, and when the response is received, the sent data frame will be removed from the sending buffer of the slave device, and the next frame of data will be transmitted.
需要说明的是,和主设备处理收到的有效数据帧不同,从设备无需进行二次传输,通过GPIO1的状态即可判断整个数据帧传输是否完成。It should be noted that, unlike the master device processing the received valid data frame, the slave device does not need to perform secondary transmission, and can judge whether the entire data frame transmission is completed through the state of GPIO1.
本发明实施例使用较少的GPIO引脚,节省了芯片硬件资源,主从设备可以随时发送数据,实现数据应答与重传机制,保证了数据的实时性和可靠性,减少了CPU的额外开销。The embodiment of the present invention uses fewer GPIO pins, which saves chip hardware resources. The master and slave devices can send data at any time, realize the data response and retransmission mechanism, ensure the real-time performance and reliability of the data, and reduce the extra overhead of the CPU. .
在又一个优选实施例中,所述主设备发起传输时,循环检测所述主设备的发送缓冲区;In yet another preferred embodiment, when the master device initiates transmission, the sending buffer of the master device is cyclically detected;
当所述主设备的发送缓冲区有待发送数据帧时,以预设帧长取出所述待发送数据帧,调用所述SPI接口向所述从设备发送所述待发送数据帧。When there is a data frame to be sent in the sending buffer of the master device, the data frame to be sent is taken out with a preset frame length, and the SPI interface is called to send the data frame to be sent to the slave device.
具体的,请参阅图5,图5是本发明提供的一种SPI通信的流控方法中主设备发起传输的流程示意图。主设备发起传输时,发送任务不断循环检测主设备的发送缓冲区。当主设备的发送缓冲区有待发送数据帧时,以预设帧长sLen取出待发送数据帧,调用SPI接口向从设备发送待发送数据帧。Specifically, please refer to FIG. 5 . FIG. 5 is a schematic flowchart of a master device initiating transmission in a flow control method for SPI communication provided by the present invention. When the master device initiates transmission, the sending task continuously checks the send buffer of the master device in a loop. When there are data frames to be sent in the sending buffer of the master device, the data frame to be sent is taken out with the preset frame length sLen, and the SPI interface is called to send the data frame to be sent to the slave device.
在又一个优选实施例中,所述调用所述SPI接口向所述从设备发送所述待发送数据帧,之后还包括:In yet another preferred embodiment, the calling the SPI interface to send the data frame to be sent to the slave device, and then also include:
所述主设备接收从所述从设备返回的数据帧,并判断返回的数据帧是否有效;The master device receives the data frame returned from the slave device, and judges whether the returned data frame is valid;
若有效,则对有效数据帧进行处理,处理完成后进入应答等待;If it is valid, it will process the valid data frame, and enter the response waiting after the processing is completed;
若无效,则直接进入应答等待;If it is invalid, it will directly enter the response waiting;
应答等待超时则发起重传,收到应答则将所述待发送数据帧从所述主设备的发送缓冲区中移除,进行下一帧数据的传输。Retransmission is initiated when the response waits for a timeout, and the data frame to be sent is removed from the sending buffer of the master device when the response is received, and the next frame of data is transmitted.
具体的,请参阅图6,图6是本发明提供的一种SPI通信的流控方法中主设备处理有效数据帧的流程示意图。当主设备的发送缓冲区有待发送数据帧时,以预设帧长取出待发送数据帧,调用SPI接口向从设备发送待发送数据帧之后,主设备接收从从设备返回的数据帧,并判断返回的数据帧是否有效。若从设备返回的数据帧有效,则对有效数据帧进行处理,处理完成后进入应答等待。若从设备返回的数据帧无效,则直接进入应答等待。应答等待超时则发起重传,收到应答则将待发送数据帧从主设备的发送缓冲区中移除,进行下一帧数据的传输。Specifically, please refer to FIG. 6 . FIG. 6 is a schematic flowchart of a master device processing valid data frames in a flow control method for SPI communication provided by the present invention. When there are data frames to be sent in the sending buffer of the master device, the data frame to be sent is taken out with the preset frame length, and after calling the SPI interface to send the data frame to be sent to the slave device, the master device receives the data frame returned from the slave device and judges the return Is the data frame valid. If the data frame returned from the device is valid, it will process the valid data frame, and enter the response waiting after the processing is completed. If the data frame returned from the device is invalid, it will directly enter the response waiting. If the response waits for timeout, retransmission is initiated, and when the response is received, the data frame to be sent is removed from the sending buffer of the master device, and the next frame of data is transmitted.
在又一个优选实施例中,所述对有效数据帧进行处理,具体包括:In yet another preferred embodiment, the processing of valid data frames specifically includes:
判断所述有效数据帧的长度是否不大于所述预设帧长;judging whether the length of the valid data frame is not greater than the preset frame length;
若否,则发起二次传输,对剩余未接收的数据进行接收;If not, initiate a second transmission to receive the remaining unreceived data;
若是,则判断所述有效数据帧的类别;If so, then judge the category of the valid data frame;
若所述有效数据帧为请求帧,则将所述有效数据帧放入所述主设备的接收缓冲区,生成所述请求帧的应答帧,放入所述主设备的发送缓冲区;If the valid data frame is a request frame, then put the valid data frame into the receiving buffer of the master device, generate a response frame of the request frame, and put it into the sending buffer of the master device;
若所述有效数据帧为应答帧,则设置应答标志位,进行下一帧数据的传输。If the valid data frame is a response frame, the response flag bit is set to transmit the next frame of data.
具体的,主设备在对有效数据帧进行处理时,从接收到的数据的帧头中获取该帧数据的长度rLen,判断有效数据帧的长度rLen是否不大于预设帧长sLen。若有效数据帧的长度rLen大于预设帧长sLen,则说明从设备发送的数据帧还有剩余未接收的,需要再次调用SPI接口发起二次传输,完成剩余数据的接收。若有效数据帧的长度rLen不大于预设帧长sLen,则说明从设备发送的数据帧本次调用已经全部接收完,进一步通过帧头信息判断有效数据帧的类别。若有效数据帧为请求帧,则将有效数据帧放入主设备的接收缓冲区,生成请求帧的应答帧,放入主设备的发送缓冲区。若有效数据帧为应答帧,则表明主设备上一次的请求帧收到了应答,可以进行下一帧数据的传输。Specifically, when processing the valid data frame, the master device obtains the length rLen of the frame data from the frame header of the received data, and judges whether the length rLen of the valid data frame is not greater than the preset frame length sLen. If the length rLen of the valid data frame is greater than the preset frame length sLen, it means that there are still unreceived data frames sent from the device, and it is necessary to call the SPI interface again to initiate a second transmission to complete the reception of the remaining data. If the length rLen of the valid data frame is not greater than the preset frame length sLen, it means that all the data frames sent by the slave device have been received in this call, and the type of the valid data frame is further judged by the frame header information. If the valid data frame is a request frame, put the valid data frame into the receiving buffer of the master device, generate a response frame of the request frame, and put it into the sending buffer of the master device. If the valid data frame is a response frame, it indicates that the last request frame of the master device has received a response, and the next frame of data can be transmitted.
作为优选方案,所述有效数据帧的长度为帧头长度、数据长度和校验区长度的总和。As a preferred solution, the length of the effective data frame is the sum of the length of the frame header, the length of the data and the length of the check area.
具体的,请参阅图7,图7是本发明提供的一种SPI通信的流控方法中有效数据帧的结构示意图。本发明实施例中有效数据帧包括帧头、数据和校验区。其中,帧头包括标志符、序列号和总长度。标志符标识本帧数据类,可以是主设备发送给从设备的请求帧、从设备发送给主设备的请求帧、主设备发送给从设备的应答帧、从设备发送给主设备的应答帧。序列号,每次发送请求帧都有唯一的序列号,对应的应答帧与其序列号保持一致。总长度=帧头长度+数据长度+校验区长度。Specifically, please refer to FIG. 7, which is a schematic structural diagram of a valid data frame in a flow control method for SPI communication provided by the present invention. The effective data frame in the embodiment of the present invention includes a frame header, data and check area. Among them, the frame header includes identifier, sequence number and total length. The identifier identifies the data type of this frame, which can be a request frame sent from the master device to the slave device, a request frame sent from the slave device to the master device, a response frame sent from the master device to the slave device, and a response frame sent from the slave device to the master device. Sequence number, each request frame sent has a unique sequence number, and the corresponding response frame is consistent with its sequence number. Total length = frame header length + data length + check area length.
相应地,本发明还提供一种SPI通信的流控装置,能够实现上述实施例中的SPI通信的流控方法的所有流程。Correspondingly, the present invention also provides a flow control device for SPI communication, which can realize all the processes of the flow control method for SPI communication in the above embodiments.
请参阅图8,图8是本发明提供的一种SPI通信的流控装置的一个优选实施例的结构示意图。所述SPI通信的流控装置应用于SPI通信的流控系统,所述流控系统包括主设备和至少一个从设备,所述主设备和所述从设备之间的通信通道包括一个SPI接口和与所述SPI接口相关联的两个GPIO引脚;其中,第一GPIO引脚为所述从设备的输入,与所述SPI接口中的CS引脚连接;第二GPIO引脚为所述从设备的输出,与所述主设备连接,所述SPI通信的流控装置包括:Please refer to FIG. 8 . FIG. 8 is a schematic structural diagram of a preferred embodiment of a flow control device for SPI communication provided by the present invention. The flow control device of the SPI communication is applied to the flow control system of the SPI communication, the flow control system includes a master device and at least one slave device, and the communication channel between the master device and the slave device includes an SPI interface and Two GPIO pins associated with the SPI interface; wherein, the first GPIO pin is the input of the slave device, connected with the CS pin in the SPI interface; the second GPIO pin is the slave The output of the equipment is connected with the main equipment, and the flow control device of the SPI communication includes:
传输模块801,用于所述主设备和所述从设备之间通过所述通信通道进行数据传输;A
中断模块802,用于当所述从设备向所述主设备发送数据时,将所述第二GPIO引脚设置为第一状态,向所述主设备发送中断信号;An interrupt
接收模块803,用于所述主设备接收到所述中断信号后发起传输,接收从所述从设备发送的数据;A receiving
检测模块804,用于当所述从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。The
优选地,所述从设备向所述主设备发送数据时,所述从设备的接口传输长度设为最大帧长,所述主设备的接口传输长度设为最小帧长。Preferably, when the slave device sends data to the master device, the interface transmission length of the slave device is set to a maximum frame length, and the interface transmission length of the master device is set to a minimum frame length.
优选地,所述当从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成,之后还包括:Preferably, when the slave device detects that the first GPIO pin changes from high level to low level, it is determined that the data frame transmission is completed, and then it also includes:
判断从所述主设备返回的数据帧是否有效;judging whether the data frame returned from the master device is valid;
若有效,则判断从所述主设备返回的数据帧的类别;若为请求帧,则将所述主设备返回的数据帧放入所述从设备的接收缓冲区,生成所述请求帧的应答帧,放入所述从设备的发送缓冲区;若为应答帧,则设置应答标志位,进行下一帧数据的传输;If it is valid, then judge the category of the data frame returned from the master device; if it is a request frame, put the data frame returned by the master device into the receiving buffer of the slave device, and generate the response of the request frame frame, put into the sending buffer of the slave device; if it is a response frame, then set the response flag bit, and carry out the transmission of the next frame of data;
若无效,则直接进入应答等待,收到应答则将已发送的数据帧从所述从设备的发送缓冲区中移除,进行下一帧数据的传输。If it is invalid, it will directly enter the response waiting, and when the response is received, the sent data frame will be removed from the sending buffer of the slave device, and the next frame of data will be transmitted.
优选地,所述主设备发起传输时,循环检测所述主设备的发送缓冲区;Preferably, when the master device initiates a transmission, the sending buffer of the master device is cyclically detected;
当所述主设备的发送缓冲区有待发送数据帧时,以预设帧长取出所述待发送数据帧,调用所述SPI接口向所述从设备发送所述待发送数据帧。When there is a data frame to be sent in the sending buffer of the master device, the data frame to be sent is taken out with a preset frame length, and the SPI interface is called to send the data frame to be sent to the slave device.
优选地,所述调用所述SPI接口向所述从设备发送所述待发送数据帧,之后还包括:Preferably, the calling the SPI interface to send the data frame to be sent to the slave device, and then also include:
所述主设备接收从所述从设备返回的数据帧,并判断返回的数据帧是否有效;The master device receives the data frame returned from the slave device, and judges whether the returned data frame is valid;
若有效,则对有效数据帧进行处理,处理完成后进入应答等待;If it is valid, it will process the valid data frame, and enter the response waiting after the processing is completed;
若无效,则直接进入应答等待;If it is invalid, it will directly enter the response waiting;
应答等待超时则发起重传,收到应答则将所述待发送数据帧从所述主设备的发送缓冲区中移除,进行下一帧数据的传输。Retransmission is initiated when the response waits for a timeout, and the data frame to be sent is removed from the sending buffer of the master device when the response is received, and the next frame of data is transmitted.
优选地,所述对有效数据帧进行处理,具体包括:Preferably, the processing of valid data frames specifically includes:
判断所述有效数据帧的长度是否不大于所述预设帧长;judging whether the length of the valid data frame is not greater than the preset frame length;
若否,则发起二次传输,对剩余未接收的数据进行接收;If not, initiate a second transmission to receive the remaining unreceived data;
若是,则判断所述有效数据帧的类别;If so, then judge the category of the valid data frame;
若所述有效数据帧为请求帧,则将所述有效数据帧放入所述主设备的接收缓冲区,生成所述请求帧的应答帧,放入所述主设备的发送缓冲区;If the valid data frame is a request frame, then put the valid data frame into the receiving buffer of the master device, generate a response frame of the request frame, and put it into the sending buffer of the master device;
若所述有效数据帧为应答帧,则设置应答标志位,进行下一帧数据的传输。If the valid data frame is a response frame, the response flag bit is set to transmit the next frame of data.
优选地,所述有效数据帧的长度为帧头长度、数据长度和校验区长度的总和。Preferably, the length of the effective data frame is the sum of the frame header length, data length and check area length.
在具体实施当中,本发明实施例提供的SPI通信的流控装置的工作原理、控制流程及实现的技术效果,与上述实施例中的SPI通信的流控方法对应相同,在此不再赘述。In specific implementation, the working principle, control process and technical effects of the flow control device for SPI communication provided by the embodiment of the present invention are the same as those of the flow control method for SPI communication in the above embodiment, and will not be repeated here.
请参阅图9,图9是本发明提供的一种终端设备的一个优选实施例的结构示意图。所述终端设备包括处理器901、存储器902以及存储在所述存储器902中且被配置为由所述处理器901执行的计算机程序,所述处理器901执行所述计算机程序时实现上述任一实施例所述的SPI通信的流控方法。Please refer to FIG. 9 . FIG. 9 is a schematic structural diagram of a preferred embodiment of a terminal device provided by the present invention. The terminal device includes a
优选地,所述计算机程序可以被分割成一个或多个模块/单元(如计算机程序1、计算机程序2、……),所述一个或者多个模块/单元被存储在所述存储器902中,并由所述处理器901执行,以完成本发明。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机程序指令段,该指令段用于描述所述计算机程序在所述终端设备中的执行过程。Preferably, the computer program can be divided into one or more modules/units (such as computer program 1, computer program 2, ...), and the one or more modules/units are stored in the
所述处理器901可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等,通用处理器可以是微处理器,或者所述处理器901也可以是任何常规的处理器,所述处理器901是所述终端设备的控制中心,利用各种接口和线路连接所述终端设备的各个部分。The
所述存储器902主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序等,数据存储区可存储相关数据等。此外,所述存储器902可以是高速随机存取存储器,还可以是非易失性存储器,例如插接式硬盘,智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡和闪存卡(Flash Card)等,或所述存储器902也可以是其他易失性固态存储器件。The
需要说明的是,上述终端设备可包括,但不仅限于,处理器、存储器,本领域技术人员可以理解,图9的结构示意图仅仅是上述终端设备的示例,并不构成对上述终端设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件。It should be noted that the above-mentioned terminal device may include, but not limited to, a processor and a memory. Those skilled in the art can understand that the schematic structural diagram in FIG. 9 is only an example of the above-mentioned terminal device, and does not constitute a limitation on the above-mentioned terminal device. More or fewer components than shown, or combinations of certain components, or different components may be included.
本发明实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质包括存储的计算机程序,其中,在所述计算机程序运行时控制所述计算机可读存储介质所在设备执行上述任一实施例所述的SPI通信的流控方法。An embodiment of the present invention also provides a computer-readable storage medium, the computer-readable storage medium includes a stored computer program, wherein, when the computer program is running, the device where the computer-readable storage medium is located is controlled to perform any of the above tasks. A flow control method for SPI communication described in an embodiment.
本发明实施例提供了一种SPI通信的流控方法、装置、终端设备及存储介质,通过在主设备和从设备之间的通信通道增加两个与SPI接口相关联的GPIO引脚,其中,第一GPIO引脚为从设备的输入,与SPI接口中的CS引脚连接;第二GPIO引脚为从设备的输出,与主设备连接。主设备和从设备之间通过所述通信通道进行数据传输;当所述从设备向所述主设备发送数据时,将所述第二GPIO引脚设置为第一状态,向所述主设备发送中断信号;所述主设备接收到所述中断信号后发起传输,接收从所述从设备发送的数据;当所述从设备检测到所述第一GPIO引脚从高电平变为低电平时,判定数据帧传输完成。本发明实施例使用较少的GPIO引脚,节省了芯片硬件资源,主从设备可以随时发送数据,实现数据应答与重传机制,保证了数据的实时性和可靠性,减少了CPU的额外开销。The embodiment of the present invention provides a flow control method, device, terminal device and storage medium for SPI communication, by adding two GPIO pins associated with the SPI interface through the communication channel between the master device and the slave device, wherein, The first GPIO pin is the input of the slave device and is connected to the CS pin in the SPI interface; the second GPIO pin is the output of the slave device and is connected to the master device. Perform data transmission between the master device and the slave device through the communication channel; when the slave device sends data to the master device, set the second GPIO pin to the first state, and send the data to the master device Interrupt signal; the master device initiates transmission after receiving the interrupt signal, and receives the data sent from the slave device; when the slave device detects that the first GPIO pin changes from high level to low level , to determine that the data frame transmission is complete. The embodiment of the present invention uses fewer GPIO pins, which saves chip hardware resources. The master and slave devices can send data at any time, realize the data response and retransmission mechanism, ensure the real-time performance and reliability of the data, and reduce the extra overhead of the CPU. .
需说明的是,以上所描述的系统实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本实施例方案的目的。另外,本发明提供的系统实施例附图中,模块之间的连接关系表示它们之间具有通信连接,具体可以实现为一条或多条通信总线或信号线。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。It should be noted that the system embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physically separated. A unit can be located in one place, or it can be distributed to multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. In addition, in the drawings of the system embodiments provided by the present invention, the connection relationship between modules indicates that they have communication connections, which can be implemented as one or more communication buses or signal lines. It can be understood and implemented by those skilled in the art without creative effort.
以上所述是本发明的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本发明原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也视为本发明的保护范围。The above description is a preferred embodiment of the present invention, and it should be pointed out that for those skilled in the art, without departing from the principle of the present invention, some improvements and modifications can also be made, and these improvements and modifications are also considered Be the protection scope of the present invention.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211407623.1A CN115941382B (en) | 2022-11-10 | 2022-11-10 | SPI communication flow control method, SPI communication flow control device, terminal equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211407623.1A CN115941382B (en) | 2022-11-10 | 2022-11-10 | SPI communication flow control method, SPI communication flow control device, terminal equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115941382A true CN115941382A (en) | 2023-04-07 |
CN115941382B CN115941382B (en) | 2024-12-17 |
Family
ID=86653106
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211407623.1A Active CN115941382B (en) | 2022-11-10 | 2022-11-10 | SPI communication flow control method, SPI communication flow control device, terminal equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115941382B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116795744A (en) * | 2023-08-15 | 2023-09-22 | 三峡智控科技有限公司 | LS2K1000LA and MCU communication control method |
CN118227403A (en) * | 2024-05-23 | 2024-06-21 | 上海泰矽微电子有限公司 | SPI communication conflict detection circuit and method |
CN118535357A (en) * | 2024-07-25 | 2024-08-23 | 北京鉴智科技有限公司 | Synchronous communication system, method, device, electronic equipment and storage medium |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101272405A (en) * | 2007-03-22 | 2008-09-24 | 北京创毅视讯科技有限公司 | Receiving equipment, MMIS interface and data interaction method |
CN102508799A (en) * | 2011-11-30 | 2012-06-20 | 北京宏思电子技术有限责任公司 | Automatic control method, system and USB (universal serial bus) device |
CN102819512A (en) * | 2012-06-28 | 2012-12-12 | 惠州市德赛西威汽车电子有限公司 | Full-duplex communication device based on SPI and method thereof |
CN103192545A (en) * | 2013-03-29 | 2013-07-10 | 天津大学 | Controller, control system and control method of hydraulic machine movement on basis of Ethernet |
CN103744825A (en) * | 2013-12-31 | 2014-04-23 | 北京中宇新泰科技发展有限公司 | Bidirectional real-time communication method of extendable and compatible SPI (Serial Peripheral Interface) |
CN110865954A (en) * | 2019-11-25 | 2020-03-06 | 南京科远智慧科技集团股份有限公司 | Method for automatically defining variable-length frame end based on DMA (direct memory access) SPI (serial peripheral interface) inter-device communication |
CN213182729U (en) * | 2020-09-24 | 2021-05-11 | 上海途鸽数据科技有限公司 | Bus extension device based on FPGA chip |
-
2022
- 2022-11-10 CN CN202211407623.1A patent/CN115941382B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101272405A (en) * | 2007-03-22 | 2008-09-24 | 北京创毅视讯科技有限公司 | Receiving equipment, MMIS interface and data interaction method |
CN102508799A (en) * | 2011-11-30 | 2012-06-20 | 北京宏思电子技术有限责任公司 | Automatic control method, system and USB (universal serial bus) device |
CN102819512A (en) * | 2012-06-28 | 2012-12-12 | 惠州市德赛西威汽车电子有限公司 | Full-duplex communication device based on SPI and method thereof |
CN103192545A (en) * | 2013-03-29 | 2013-07-10 | 天津大学 | Controller, control system and control method of hydraulic machine movement on basis of Ethernet |
CN103744825A (en) * | 2013-12-31 | 2014-04-23 | 北京中宇新泰科技发展有限公司 | Bidirectional real-time communication method of extendable and compatible SPI (Serial Peripheral Interface) |
CN110865954A (en) * | 2019-11-25 | 2020-03-06 | 南京科远智慧科技集团股份有限公司 | Method for automatically defining variable-length frame end based on DMA (direct memory access) SPI (serial peripheral interface) inter-device communication |
CN213182729U (en) * | 2020-09-24 | 2021-05-11 | 上海途鸽数据科技有限公司 | Bus extension device based on FPGA chip |
Non-Patent Citations (1)
Title |
---|
王莹;: "基于LPC2103的SPI总线技术的应用", 信息化纵横, no. 07, 10 April 2009 (2009-04-10) * |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116795744A (en) * | 2023-08-15 | 2023-09-22 | 三峡智控科技有限公司 | LS2K1000LA and MCU communication control method |
CN116795744B (en) * | 2023-08-15 | 2023-12-19 | 三峡智控科技有限公司 | LS2K1000LA and MCU communication control method |
CN118227403A (en) * | 2024-05-23 | 2024-06-21 | 上海泰矽微电子有限公司 | SPI communication conflict detection circuit and method |
CN118535357A (en) * | 2024-07-25 | 2024-08-23 | 北京鉴智科技有限公司 | Synchronous communication system, method, device, electronic equipment and storage medium |
CN118535357B (en) * | 2024-07-25 | 2024-09-27 | 北京鉴智科技有限公司 | Synchronous communication system, method, device, electronic equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115941382B (en) | 2024-12-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN115941382A (en) | Flow control method and device for SPI communication, terminal equipment and storage medium | |
US7266625B2 (en) | Data communication system | |
JPS639261B2 (en) | ||
CN116150054B (en) | Interrupt information processing method based on PCIE | |
CN114826542B (en) | Data transmission method, device, equipment and medium based on asynchronous serial communication | |
CN103650401A (en) | Internal communication method for mobile terminal | |
WO2022089313A1 (en) | Communication processing method and apparatus, storage medium, chip and related device | |
US8108736B2 (en) | Multi-partition computer system, failure handling method and program therefor | |
CN112422485A (en) | Communication method and device of transmission control protocol | |
CN115982090B (en) | Method and device for realizing remote memory access by cooperation of software and hardware | |
KR20050080704A (en) | Apparatus and method of inter processor communication | |
CN112363962B (en) | Data communication method, system, electronic device and computer storage medium | |
JP4231690B2 (en) | Broadcast data via the bus | |
CN114281739B (en) | A data exchange system and method | |
CN116126756A (en) | SRIO realizing device and method based on FMQL | |
US20040177164A1 (en) | System and method for reclaiming transmit descriptors | |
CN104850517A (en) | Method and apparatus for transmitting packet data using DMA | |
CN117278505B (en) | Message transmission method, system, equipment and medium between RAID card nodes | |
CN116208573B (en) | Data processing method, device, electronic equipment and storage medium | |
WO2022124083A1 (en) | Communication device, communication method, and program | |
JP3176199B2 (en) | Server client system | |
CN118764336A (en) | A bus communication system, method, electronic device and storage medium | |
CN118796736A (en) | A business control system, method and related equipment for a multi-channel server | |
CN118295954A (en) | Data transmission method and communication system of processing card based on PCIe protocol | |
JP2502850B2 (en) | Communication method for SCSI system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
EE01 | Entry into force of recordation of patent licensing contract | ||
EE01 | Entry into force of recordation of patent licensing contract |
Application publication date: 20230407 Assignee: Guangzhou Xinghe Zhidong Automotive Technology Co.,Ltd. Assignor: Xinghe Zhilian Automobile Technology Co.,Ltd. Contract record no.: X2024980023730 Denomination of invention: A flow control method, device, terminal equipment, and storage medium for SPI communication License type: Common License Record date: 20241111 |
|
GR01 | Patent grant | ||
GR01 | Patent grant |