SPI communication method, apparatus and device, readable storage medium and program product

By analyzing the transmission requirements of the application programming interface and finding the requirements of the target serial peripheral interface that meets the requirements, the problem of high initialization in SPI communication has been solved, and the effect of simplifying operations and improving communication efficiency is achieved.

CN119377149APending Publication Date: 2025-01-28SUZHOU WATECH ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411375778.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-29
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

When using the characteristic functions of SPI, traditional methods require frequent initialization, resulting in high operation repetition and low communication efficiency.

Method used

By analyzing the transmission requirements of the application programming interface, determine the configuration requirements of the serial peripheral interface, and find the target serial peripheral interface that meets the requirements, reduce the number of initialization, and improve the communication efficiency.

Benefits of technology

Significantly reduced the number of initialization, simplified the operation steps, improved communication efficiency, adapted to a variety of different transmission requirements, and reduced the development time for SPI communication control code.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377149A_ABST
    Figure CN119377149A_ABST
Patent Text Reader

Abstract

The invention relates to an SPI communication method and device, equipment, a readable storage medium and a program product. The method can be applied to a communication circuit comprising a plurality of serial peripheral interfaces, and comprises the following steps: analyzing a transmission requirement of an application programming interface to obtain a configuration requirement for the serial peripheral interfaces, the transmission requirement comprising any one of a transmission mode, a frame type and a working mode, and the transmission requirement comprising any one of the transmission mode, the frame type and the working mode; any two or more than two requirements are combined; according to the configuration requirement, searching each serial peripheral interface until a target serial peripheral interface meeting the configuration requirement is found; and switching the application programming interface to the target serial peripheral interface, and establishing communication. Therefore, different SPIs can be switched for communication by analyzing the transmission requirements of the API and according to different transmission requirements, repeated initialization does not need to be carried out according to the characteristics and functions of the SPIs, operation is simplified, and communication efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to an SPI communication method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art

[0002] Absolute encoders are often used in precision automation equipment to measure posture information at different positions. Synchronous Serial Interface (SSI) is a common interface method for high-precision absolute encoders. It can achieve high-precision and high-real-time angle output and has strong anti-interference performance. It is widely used. Generally, the serial peripheral interface (SPI) of the microcontroller unit (MCU) is used to receive SSI type encoders.

[0003] In traditional technology, by configuring the microcontroller and initializing the multiplexer, the timer interrupt is controlled, the (Input / Output, IO) input / output sends a chip select signal, and determines whether the microcontroller SPI (Direct Memory Access, DMA) direct memory access receiving mode receives the completion flag. According to the SSI interface protocol, the IO is delayed to control the sending of the chip select signal to realize the reception of the SSI interface encoder data.

[0004] However, the above method needs to be re-initialized each time when using the characteristic functions of SPI, resulting in high operation repetition and low communication efficiency. Summary of the invention

[0005] Based on this, it is necessary to provide an SPI communication method, device, computer equipment, computer-readable storage medium and computer program product that can significantly reduce the number of initializations, simplify the operation steps and improve communication efficiency when using the characteristic functions of SPI to address the above technical problems.

[0006] In a first aspect, the present application provides an SPI communication method, which is applied to a communication circuit including multiple serial peripheral interfaces, and the method comprises:

[0007] Parsing the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements;

[0008] According to the configuration requirements, searching for each serial peripheral interface until a target serial peripheral interface that meets the configuration requirements is found;

[0009] The application programming interface is switched to the target serial peripheral interface, and communication is established.

[0010] In one embodiment, the parsing of the transmission requirements of the application programming interface to obtain the configuration requirements for the serial peripheral interface includes:

[0011] When the transmission requirements of the application programming interface include a transmission mode, the transmission mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the transmission mode, wherein the configuration requirements regarding the transmission mode include: any one of half-duplex transmission, half-duplex reception, and full-duplex transmission and reception.

[0012] In one embodiment, the parsing of the transmission requirements of the application programming interface to obtain the configuration requirements for the serial peripheral interface includes:

[0013] When the transmission requirements of the application programming interface include a frame type, the frame type is parsed to determine the configuration requirements of the serial peripheral interface regarding the frame type, wherein the configuration requirements regarding the frame type include: single-line or dual-line;

[0014] When the transmission requirements of the application programming interface include a working mode, the working mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the working mode, wherein the configuration requirements regarding the working mode include: a host or a slave.

[0015] In one embodiment, searching for each serial peripheral interface according to the configuration requirement until a target serial peripheral interface that meets the configuration requirement is found includes:

[0016] Traversing each serial peripheral interface and obtaining configuration parameters of each serial peripheral interface; wherein the configuration parameters of each serial peripheral interface have been preset during initialization;

[0017] The configuration parameters of each serial peripheral interface are compared with the configuration requirements one by one until a serial peripheral interface that meets the configuration requirements is found, and the serial peripheral interface that meets the configuration requirements is used as a target serial peripheral interface.

[0018] In one embodiment, before parsing the transmission requirements of the application programming interface to obtain the configuration requirements for the serial peripheral interface, the method further includes:

[0019] Initialize the clock in the communication circuit, the general input / output interface, and the selector for switching the serial peripheral interface;

[0020] Initialize each serial peripheral interface and determine the configuration parameters of each serial peripheral interface, wherein the configuration parameters include: any parameter of transmission mode, frame type, working mode, or a combination of any two or more parameters.

[0021] In one embodiment, after switching the application programming interface to the target serial peripheral interface and establishing communication, the method further includes:

[0022] Determine whether the currently established communication is terminated according to a preset period;

[0023] If the currently established communication has ended, the transmission requirements of the next application programming interface are parsed to obtain the configuration requirements for the serial peripheral interface, and according to the configuration requirements, each serial peripheral interface is searched until a target serial peripheral interface that meets the configuration requirements is found; the application programming interface is switched to the target serial peripheral interface to establish communication;

[0024] If the currently established communication has not ended, the currently established communication will continue to be maintained.

[0025] In a second aspect, the present application further provides an SPI communication device, which is applied to a communication circuit including multiple serial peripheral interfaces, and the device includes:

[0026] A parsing module, used to parse the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements;

[0027] A search module, used to search for each serial peripheral interface according to the configuration requirements until a target serial peripheral interface that meets the configuration requirements is found;

[0028] The switching and communication module is used to switch the application programming interface to the target serial peripheral interface and establish communication.

[0029] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0030] Parsing the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements;

[0031] According to the configuration requirements, searching for each serial peripheral interface until a target serial peripheral interface that meets the configuration requirements is found;

[0032] The application programming interface is switched to the target serial peripheral interface, and communication is established.

[0033] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the following steps are implemented:

[0034] Parsing the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements;

[0035] According to the configuration requirements, searching for each serial peripheral interface until a target serial peripheral interface that meets the configuration requirements is found;

[0036] The application programming interface is switched to the target serial peripheral interface, and communication is established.

[0037] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0038] Parsing the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements;

[0039] According to the configuration requirements, searching for each serial peripheral interface until a target serial peripheral interface that meets the configuration requirements is found;

[0040] The application programming interface is switched to the target serial peripheral interface, and communication is established.

[0041] The above-mentioned SPI communication method, device, computer equipment, computer-readable storage medium and computer program product obtain configuration requirements for the serial peripheral interface by parsing the transmission requirements of the application programming interface, wherein the transmission requirements include: any one of the requirements of the transmission mode, frame type, and working mode, and any combination of two or more requirements; so that when the serial peripheral interface is set, it can adapt to a variety of different transmission requirements of the application programming interface. According to the configuration requirements, each serial peripheral interface is searched until a target serial peripheral interface that meets the configuration requirements is found; since there are multiple serial peripheral interfaces, and the configuration parameters of each serial peripheral interface are pre-set according to the transmission requirements of the application programming interface, it is only required to find a target serial peripheral interface that meets the configuration requirements, and there is no need to perform repeated initialization operations. The application programming interface is switched to the target serial peripheral interface, and communication is established. Therefore, by parsing the transmission requirements of the API and switching different SPIs for communication according to different transmission requirements, there is no need to perform repeated initialization according to the characteristic functions of the SPI, which simplifies the operation and improves the efficiency of communication. In addition, it is convenient for users to use, so that users do not need to care about the working principle inside the communication circuit, and reduce the development time for SPI communication control code. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0043] FIG1 is an application environment diagram of an SPI communication method in one embodiment;

[0044] Figure 2 A schematic diagram of a flow chart of an SPI communication method in one embodiment;

[0045] FIG3 is a schematic diagram showing the principle of an SPI communication method in one embodiment;

[0046] FIG4 is a schematic flow chart of a method for switching SPI communications in different transmission modes in one embodiment;

[0047] FIG5 is a schematic flow chart of an SPI communication method in another embodiment;

[0048] FIG6 is a schematic flow chart of an SPI communication method in yet another embodiment;

[0049] FIG7 is a block diagram of a SPI communication device according to an embodiment;

[0050] FIG. 8 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] The SPI communication method provided in the embodiment of the present application can be applied to the communication circuit shown in Figure 1. There are multiple application programming interfaces (APIs) 101, and the transmission requirements of each API may be different. For example, the configuration requirements of the working mode, frame type, state machine (host or slave), and IO, etc. are set specifically according to the different API transmission requirements. In the existing technical solutions, when the API transmission requirements change, the SPI needs to be initialized. Therefore, in the application scenarios with multiple API transmission requirements, the initialization operation is often required frequently, resulting in very complicated operations. On the code development side, it is necessary to develop an adaptive code for each SPI application scenario, which takes a long time to develop, has low efficiency, and is not compatible with a variety of different SPI communication scenarios. In response to this technical problem, the embodiment of the present application analyzes the transmission requirements of multiple accessed APIs at the code control layer 102 to obtain configuration requirements for the serial peripheral interface 104, wherein the transmission requirements include: any one of the transmission mode, frame type, and operating mode, and a combination of any two or more of the requirements; according to the configuration requirements, search for each serial peripheral interface 104 until a target serial peripheral interface that meets the configuration requirements is found; then switch the application programming interface 101 to the target serial peripheral interface through the selector 103, and establish communication.

[0053] In an exemplary embodiment, Figure 2 As shown, an SPI communication method is provided, which is described by taking the method applied to the communication circuit in FIG. 1 as an example, and includes the following steps 201 to 203. Among them:

[0054] Step 201 , parse the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface.

[0055] The transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements.

[0056] In this embodiment, as shown in FIG1 , an execution program for analyzing API transmission requirements can be compiled in the code control layer. In this way, when an API access request is received, the API transmission requirements can be analyzed first to clarify the transmission mode in which the API requires to work, the frame type of video transmission, and the working mode (host or slave).

[0057] Exemplarily, when the transmission requirements of the application programming interface include a transmission mode, the transmission mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the transmission mode, wherein the configuration requirements regarding the transmission mode include: any one of half-duplex transmission, half-duplex reception, and full-duplex transmission and reception.

[0058] Exemplarily, when the transmission requirements of the application programming interface include a frame type, the frame type is parsed to determine the configuration requirements of the serial peripheral interface regarding the frame type, wherein the configuration requirements regarding the frame type include: single-wire or dual-wire.

[0059] Exemplarily, when the transmission requirements of the application programming interface include an operating mode, the operating mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the operating mode, wherein the configuration requirements regarding the operating mode include: a host or a slave.

[0060] In an optional implementation, as shown in FIG3 , the code control layer completes the functions of four parts, namely, transmission mode switching, frame type switching, working mode switching, and IO control. Exemplarily, it is assumed that three SPIs are provided in the communication circuit, and for the sake of easy distinction, they are respectively defined as SPI1, SPI2, and SPI3, wherein during initialization, SPI1 is initialized to half-duplex transmission, SPI2 is initialized to half-duplex reception, and SPI3 is initialized to full-duplex transmission and reception. Furthermore, the multiplexing of IO is realized through the code control layer, and finally communication is established with a standard SPI interface.

[0061] It should be noted that, in addition to being divided into three SPIs according to the transmission mode and completing the settings of the three SPIs uniformly during initialization, the frame type and the working mode can also be considered in combination. For example, a certain SPI is defined as single-line, half-duplex, and host transmission mode; a certain SPI is defined as single-line, half-duplex, and slave transmission mode, etc. This embodiment does not limit the number of SPIs in the communication circuit, nor does it limit the configuration parameters of each SPI. Therefore, SPI switching can be performed flexibly according to a variety of different API transmission requirements.

[0062] Step 202: Search various serial peripheral interfaces according to the configuration requirements until a target serial peripheral interface that meets the configuration requirements is found.

[0063] In this embodiment, the configuration parameters of each serial peripheral interface have been set during initialization, so it is only necessary to compare the configuration parameters of each serial peripheral interface according to the configuration requirements to find a target serial peripheral interface that meets the configuration requirements.

[0064] Exemplarily, each serial peripheral interface is traversed, and configuration parameters of each serial peripheral interface are obtained; wherein the configuration parameters of each serial peripheral interface have been preset during initialization; the configuration parameters of each serial peripheral interface are compared with the configuration requirements one by one until a serial peripheral interface that meets the configuration requirements is found, and the serial peripheral interface that meets the configuration requirements is used as the target serial peripheral interface.

[0065] Step 203: switch the application programming interface to the target serial peripheral interface and establish communication.

[0066] For example, an electronic switch can be used to select one of multiple input signals and transmit it to a single output line, such as a multiplexer (MUX for short). The MUX is used to switch multiple serial peripheral interfaces.

[0067] In an optional embodiment, as shown in FIG4 , the SPI communication circuit includes three serial peripheral interfaces: SPI1, SPI2, and SPI3. First, initialize the clock, GPIO (general input / output interface), and MUX chip, and initialize SPI1 as a full-duplex host, SPI2 as a full-duplex slave, and SPI3 as a half-duplex slave. Parse the API of the code control layer to determine the transmission mode required by the API; if full-duplex host transmission is required, switch to SPI1, and the MUX (multiplexer) selects the pin of SPI1 for SPI communication; if full-duplex slave transmission is required, switch to SPI2, and the MUX selects the pin of SPI2 for SPI communication; if half-duplex slave transmission is required, switch to SPI3, and the MUX selects the pin of SPI3 for SPI communication. Determine whether the communication is over. If so, analyze the transmission requirements of the next API; if not, continue SPI communication. Thus, by parsing the transmission requirements of the API and switching different SPI functions according to different transmission requirements, the MUX selects different SPIs for communication. This communication method can be applied to a variety of different application scenarios and is convenient for users to use. There is no need to repeatedly expand functions and develop codes, nor is there a need to initialize SPI every time a new requirement is encountered. This greatly simplifies the operation and improves communication efficiency.

[0068] The above-mentioned SPI communication method, device, computer equipment, computer-readable storage medium and computer program product obtain configuration requirements for the serial peripheral interface by parsing the transmission requirements of the application programming interface, wherein the transmission requirements include: any one of the requirements of the transmission mode, frame type, and working mode, and any combination of two or more requirements; so that when the serial peripheral interface is set, it can adapt to a variety of different transmission requirements of the application programming interface. According to the configuration requirements, each serial peripheral interface is searched until a target serial peripheral interface that meets the configuration requirements is found; since there are multiple serial peripheral interfaces, and the configuration parameters of each serial peripheral interface are pre-set according to the transmission requirements of the application programming interface, it is only required to find a target serial peripheral interface that meets the configuration requirements, and there is no need to perform repeated initialization operations. The application programming interface is switched to the target serial peripheral interface, and communication is established. Therefore, by parsing the transmission requirements of the API and switching different SPIs for communication according to different transmission requirements, there is no need to perform repeated initialization according to the characteristic functions of the SPI, which simplifies the operation and improves the efficiency of communication. In addition, it is convenient for users to use, so that users do not need to care about the working principle inside the communication circuit, and reduce the development time for SPI communication control code.

[0069] In another exemplary embodiment, as shown in FIG5 , a SPI communication method is provided, which is described by taking the method applied to the communication circuit in FIG1 as an example, and includes the following steps 501 to 505. Among them:

[0070] Step 501, initializing a clock, a general input / output interface, and a selector for switching a serial peripheral interface in a communication circuit.

[0071] In this embodiment, as shown in FIG. 1 and FIG. 3 , an initialization program can be compiled in the code control layer to initialize the clock, the general input / output interface, and the selector for switching the serial peripheral interface in the communication circuit, so as to facilitate clock control and SPI switching control during subsequent SPI communication.

[0072] Step 502, initializing each serial peripheral interface and determining configuration parameters of each serial peripheral interface.

[0073] In this embodiment, an initialization program can be compiled in the code control layer to initialize each serial peripheral interface in the communication circuit and determine the configuration parameters of each serial peripheral interface, so that it can be applied to a variety of different SPI communication scenarios without repeatedly performing SPI initialization operations.

[0074] Step 503: parse the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface.

[0075] Step 504: Search various serial peripheral interfaces according to the configuration requirements until a target serial peripheral interface that meets the configuration requirements is found.

[0076] Step 505: switch the application programming interface to the target serial peripheral interface and establish communication.

[0077] For the specific implementation process and technical effects of steps 501 to 503 in this embodiment, please refer to Figure 2 The descriptions of steps 201 to 203 in the illustrated method embodiment are not repeated here.

[0078] In this embodiment, the transmission requirements of the API can be parsed, and different SPIs can be switched for communication according to different transmission requirements, without the need for repeated initialization according to the characteristic functions of the SPI, thereby simplifying the operation and improving the efficiency of communication. In addition, it can also be convenient for users to use, so that users do not need to care about the working principle inside the communication circuit, and reduce the development time for the SPI communication control code.

[0079] In another exemplary embodiment, as shown in FIG6 , a SPI communication method is provided, which is described by taking the method applied to the communication circuit in FIG1 as an example, and includes the following steps 601 to 605. Among them:

[0080] Step 601, parse the transmission requirements of the application programming interface to obtain the configuration requirements for the serial peripheral interface.

[0081] Step 602: Search various serial peripheral interfaces according to the configuration requirements until a target serial peripheral interface that meets the configuration requirements is found.

[0082] Step 603: switch the application programming interface to the target serial peripheral interface and establish communication.

[0083] For the specific implementation process and technical effects of steps 601 to 603 in this embodiment, please refer to Figure 2 The descriptions of steps 201 to 203 in the illustrated method embodiment are not repeated here.

[0084] Step 604, judging whether the currently established communication is ended according to a preset period, if so, returning to step 601; if not, executing step 605.

[0085] Step 605: Maintain the currently established communication.

[0086] In this embodiment, it is possible to determine whether the current SPI communication is finished by a periodic trigger signal or according to a preset period. If it is finished, the transmission requirements of the next application programming interface are analyzed, and the SPI that meets the transmission requirements of the next application programming interface is switched. Therefore, different SPIs can be switched autonomously for communication according to the transmission requirements of the changing API, and there is no need to perform repeated initialization according to the characteristic functions of the SPI, which simplifies the operation and improves the efficiency of communication.

[0087] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0088] Based on the same inventive concept, the embodiment of the present application also provides an SPI communication device for implementing the SPI communication method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more SPI communication device embodiments provided below can refer to the limitations on the SPI communication method above, and will not be repeated here.

[0089] In an exemplary embodiment, as shown in FIG. 7 , a SPI communication device is provided, including: a parsing module 701, a search module 702, and a switching and communication module 703, wherein:

[0090] The parsing module 701 is used to parse the transmission requirements of the application programming interface to obtain the configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements;

[0091] A search module 702, configured to search for each serial peripheral interface according to the configuration requirement until a target serial peripheral interface that meets the configuration requirement is found;

[0092] The switching and communication module 703 is used to switch the application programming interface to the target serial peripheral interface and establish communication.

[0093] Exemplarily, the parsing module 701 is specifically used to: when the transmission requirements of the application programming interface include a transmission mode, parse the transmission mode to determine the configuration requirements of the serial peripheral interface regarding the transmission mode, wherein the configuration requirements regarding the transmission mode include: any one of half-duplex transmission, half-duplex reception, and full-duplex transmission and reception.

[0094] Exemplarily, the parsing module 701 is specifically used to: when the transmission requirements of the application programming interface include a frame type, parse the frame type to determine the configuration requirements of the serial peripheral interface regarding the frame type, wherein the configuration requirements regarding the frame type include: single-line or dual-line;

[0095] When the transmission requirements of the application programming interface include a working mode, the working mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the working mode, wherein the configuration requirements regarding the working mode include: a host or a slave.

[0096] Exemplarily, the search module 702 is specifically used to: traverse each serial peripheral interface and obtain the configuration parameters of each serial peripheral interface; wherein the configuration parameters of each serial peripheral interface have been preset during initialization;

[0097] The configuration parameters of each serial peripheral interface are compared with the configuration requirements one by one until a serial peripheral interface that meets the configuration requirements is found, and the serial peripheral interface that meets the configuration requirements is used as a target serial peripheral interface.

[0098] Exemplarily, the above-mentioned device may also include: an initialization module 704, wherein the initialization module 704 is used to initialize the clock, the general input / output interface, and the selector for switching the serial peripheral interface in the communication circuit; initialize each serial peripheral interface, and determine the configuration parameters of each serial peripheral interface, wherein the configuration parameters include: any parameter in the transmission mode, frame type, and working mode, and a combination of any two or more parameters.

[0099] Exemplarily, the switching and communication module 703 is also used to determine whether the currently established communication is ended according to a preset period after the application programming interface is switched to the target serial peripheral interface and communication is established; if the currently established communication has ended, the transmission requirements of the next application programming interface are parsed to obtain the configuration requirements for the serial peripheral interface, and according to the configuration requirements, each serial peripheral interface is searched until a target serial peripheral interface that meets the configuration requirements is found; the application programming interface is switched to the target serial peripheral interface to establish communication;

[0100] If the currently established communication has not ended, the currently established communication will continue to be maintained.

[0101] Each module in the above SPI communication device can be implemented in whole or in part by software, hardware and a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0102] In an exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be shown in FIG8. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected via a system bus, and the communication interface is connected to the system bus via the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data of SPI configuration parameters. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, an SPI communication method is implemented.

[0103] Those skilled in the art will understand that the structure shown in FIG. 8 is merely a block diagram of a partial structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0104] In an exemplary embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0105] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0106] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0107] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0108] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0109] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0110] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. An SPI communication method, characterized in that: Applied to a communication circuit including a plurality of serial peripheral interfaces, the method comprises: Parsing the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements; According to the configuration requirements, searching for each serial peripheral interface until a target serial peripheral interface that meets the configuration requirements is found; The application programming interface is switched to the target serial peripheral interface, and communication is established.

2. The method according to claim 1, characterized in that The transmission requirements of the application programming interface are parsed to obtain configuration requirements for the serial peripheral interface, including: When the transmission requirements of the application programming interface include a transmission mode, the transmission mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the transmission mode, wherein the configuration requirements regarding the transmission mode include: any one of half-duplex transmission, half-duplex reception, and full-duplex transmission and reception.

3. The method according to claim 1, characterized in that The transmission requirements of the application programming interface are parsed to obtain configuration requirements for the serial peripheral interface, including: When the transmission requirements of the application programming interface include a frame type, the frame type is parsed to determine the configuration requirements of the serial peripheral interface regarding the frame type, wherein the configuration requirements regarding the frame type include: single-line or dual-line; When the transmission requirements of the application programming interface include a working mode, the working mode is parsed to determine the configuration requirements of the serial peripheral interface regarding the working mode, wherein the configuration requirements regarding the working mode include: a host or a slave.

4. The method according to claim 1, characterized in that: According to the configuration requirements, searching for each serial peripheral interface until a target serial peripheral interface that meets the configuration requirements is found, including: Traversing each serial peripheral interface and obtaining configuration parameters of each serial peripheral interface; wherein the configuration parameters of each serial peripheral interface have been preset during initialization; The configuration parameters of each serial peripheral interface are compared with the configuration requirements one by one until a serial peripheral interface that meets the configuration requirements is found, and the serial peripheral interface that meets the configuration requirements is used as a target serial peripheral interface.

5. The method according to any one of claims 1 to 4, characterized in that: Before parsing the transmission requirements of the application programming interface to obtain the configuration requirements for the serial peripheral interface, the method further includes: Initialize the clock in the communication circuit, the general input / output interface, and the selector for switching the serial peripheral interface; Initialize each serial peripheral interface and determine the configuration parameters of each serial peripheral interface, wherein the configuration parameters include: any parameter of transmission mode, frame type, working mode, or a combination of any two or more parameters.

6. The method according to any one of claims 1 to 4, characterized in that: After switching the application programming interface to the target serial peripheral interface and establishing communication, the method further includes: Determine whether the currently established communication is terminated according to a preset period; If the currently established communication has ended, the transmission requirements of the next application programming interface are parsed to obtain the configuration requirements for the serial peripheral interface, and according to the configuration requirements, each serial peripheral interface is searched until a target serial peripheral interface that meets the configuration requirements is found; the application programming interface is switched to the target serial peripheral interface to establish communication; If the currently established communication has not ended, the currently established communication will continue to be maintained.

7. An SPI communication device, characterized in that: Applied to a communication circuit including multiple serial peripheral interfaces, the device comprises: A parsing module, used to parse the transmission requirements of the application programming interface to obtain configuration requirements for the serial peripheral interface, wherein the transmission requirements include: any one of the transmission mode, frame type, and working mode, or a combination of any two or more of the requirements; A search module, used to search for each serial peripheral interface according to the configuration requirements until a target serial peripheral interface that meets the configuration requirements is found; The switching and communication module is used to switch the application programming interface to the target serial peripheral interface and establish communication.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.