A SPI communication recovery method, device and equipment
By detecting the SPI channel status and pausing the DMA channel task, it was determined whether there was any remaining data in the data storage space. This resolved the SPI communication problem caused by the DMA module malfunction, and enabled the recovery of SPI communication and efficient system operation.
Patent Information
- Application Number
- CN202510651362.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-20
- Publication Date
- 2026-11-20
AI Technical Summary
In SPI interface failure scenarios, abnormal data transfer by the DMA module causes the SPI module to be unable to resume communication, and existing technologies cannot effectively restore SPI communication.
By detecting the communication status of the SPI channel, if the SPI pending state exceeds the time threshold, the SPI communication task of the target DMA channel is paused. It is then determined whether there is remaining data in the data storage space. If there is, the transmission continues; otherwise, the SPI pending state is resolved and the communication task is resumed. A fault flag is set and periodically checked to ensure recovery.
It effectively restored the SPI communication abnormal state caused by incomplete data transmission in the DMA model, improved the robustness of the system and the user driving experience, and avoided the impact of resetting the entire controller.
Smart Images

Figure CN123137973A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of device communication technology, specifically to a method, apparatus, and device for restoring SPI (Serial Peripheral Interface) communication. Background Technology
[0002] SPI is a synchronous serial communication interface primarily used for communication between microcontrollers and peripheral devices, and between microcontrollers themselves. It features simple circuit implementation, few bus pins, and relatively high transmission speed.
[0003] With the development of SPI interface technology, increasingly higher demands are being placed on the data reliability and throughput of the SPI interface. SPI combined with DMA (Direct Memory Access) can achieve high-speed, efficient data transmission, making it particularly suitable for scenarios requiring frequent transfers of large amounts of data. However, in some fault scenarios, anomalies in the DMA module during data transfer may cause the SPI module to lose communication. Summary of the Invention
[0004] In view of this, embodiments of this application provide an SPI communication recovery method, apparatus, and device to restore SPI communication.
[0005] To address the above problems, the technical solutions provided in this application are as follows:
[0006] A method for restoring SPI communication via a serial peripheral interface, the method comprising:
[0007] Detect the communication status of the target SPI channel;
[0008] If the communication status is in the SPI pending state for more than a time threshold, the target DMA channel corresponding to the target SPI channel is determined to be faulty.
[0009] Pause the SPI communication task corresponding to the target DMA channel;
[0010] Determine whether there is any remaining data in the data storage space corresponding to the target DMA channel;
[0011] If there is remaining data, trigger the transmission of that remaining data.
[0012] If there is no remaining data, the SPI pending state is lifted, and the SPI communication task corresponding to the target DMA channel is resumed.
[0013] In one possible implementation, after determining that the target DMA channel corresponding to the target SPI channel is faulty, the method further includes:
[0014] Set the fault flag bit of the target DMA channel;
[0015] Periodically determine whether to set the fault flag bit of the target DMA channel;
[0016] When it is determined that the fault flag bit of the target DMA channel is set, the SPI communication task corresponding to the target DMA channel is suspended.
[0017] In one possible implementation, after resolving the SPI pending state, the method further includes:
[0018] Clear the fault flag bit of the target DMA channel.
[0019] In one possible implementation, the method further includes:
[0020] Set the DMA processing interrupt function for the target DMA channel;
[0021] The step of determining whether there is remaining data in the data storage space corresponding to the target DMA channel includes:
[0022] The function for setting a DMA processing interrupt for the target DMA channel is called to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel.
[0023] In one possible implementation, detecting the communication status of the target SPI channel includes:
[0024] Periodically check the communication status of the target SPI channel.
[0025] In one possible implementation, the step of releasing the SPI pending state and resuming the SPI communication task corresponding to the target DMA channel if no remaining data exists includes:
[0026] If no remaining data is found, the SPI task completion interface is called to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel.
[0027] In one possible implementation, the target SPI channel is an SPI channel whose data transmission volume exceeds a certain threshold.
[0028] A serial peripheral interface (SPI) communication recovery device, the device comprising:
[0029] The detection unit is used to detect the communication status of the target SPI channel;
[0030] A determining unit is configured to determine that the target DMA channel corresponding to the target SPI channel is faulty if the communication status is in an SPI pending state for more than a time threshold.
[0031] A pause unit is used to pause the SPI communication task corresponding to the target DMA channel;
[0032] The first judgment unit is used to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel;
[0033] The first triggering unit is used to trigger the continued transmission of the remaining data if the judging unit determines that there is remaining data.
[0034] The release unit is used to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel if the judgment unit determines that there is no remaining data.
[0035] A serial peripheral interface (SPI) communication recovery device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the SPI communication recovery method as described above.
[0036] A computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the SPI communication recovery method as described in any of the preceding claims.
[0037] Therefore, the embodiments of this application have the following beneficial effects:
[0038] In this embodiment, the communication status of the target SPI channel is detected. If the communication status of the target SPI channel remains in a Pending state for more than a time threshold, it can be determined that the target DMA channel corresponding to this target SPI channel may be faulty. All SPI communication tasks corresponding to the target DMA channel are suspended. It is determined whether there is any remaining data in the data storage space corresponding to the target DMA channel. If there is remaining data, the remaining data is triggered to continue transmission; if there is no remaining data, the Pending state of the target SPI channel is lifted, and the SPI communication tasks corresponding to the target DMA channel are resumed. This resolves the abnormal SPI communication state caused by incomplete data transmission in the DMA model of the vehicle controller, thus restoring SPI communication. Attached Figure Description
[0039] Figure 1 A flowchart illustrating an SPI communication recovery method provided in this application embodiment;
[0040] Figure 2This is a flowchart of another SPI communication recovery method in the embodiments of this application;
[0041] Figure 3 This is a schematic diagram of an SPI communication recovery device provided in an embodiment of this application. Detailed Implementation
[0042] To make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the embodiments of this application will be further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0043] To facilitate understanding and explanation of the technical solutions provided in the embodiments of this application, the background technology of the embodiments of this application will be described first below.
[0044] In AUTOSAR (Automotive Open System Architecture), communication modules such as DMA and SPI modules can be included. In SPI communication controlled by DMA, data can be transferred from the DMA module to the SPI module. AUTOSAR provides a standardized software architecture that supports the integration and interoperability of automotive electronic systems.
[0045] However, the inventors discovered that in some fault scenarios, such as in the current vehicle controller system, both main chip data processing and SPI data transmission under DMA control require the main chip's data bus. If SPI is asynchronous and a large amount of data is transferred via DMA in a single SPI task, data loss may occur if other tasks simultaneously occupy the data bus. The current data transmission task will fail to complete, and the corresponding ISR (Interrupt Service Routine) will not be generated. Without an ISR, the DMAChannel Notification (DMA transfer completion interrupt notification function) cannot be triggered, and only a successful DMAChannel Notification can trigger the corresponding channel's SPI state machine to return to the idle state. Therefore, when an exception occurs during data transfer by the DMA module but the DMA register does not reflect the exception, the corresponding channel's SPI state machine cannot return to the idle state, and this SPI channel cannot continue to execute other tasks.
[0046] Based on this, the embodiments of this application provide an SPI communication recovery method, apparatus and device, which proposes a software solution to the problem that the SPI bus cannot return to an idle state in the scenario where the DMA module fails to transmit data completely and cannot generate an interrupt notification to the SPI module under the AUTOSAR architecture.
[0047] To facilitate understanding of the embodiments of this application, the following description, in conjunction with the accompanying drawings, illustrates an SPI communication recovery method provided by the embodiments of this application.
[0048] See Figure 1 As shown, this figure is a flowchart of an SPI communication recovery method provided in an embodiment of this application. Figure 1 As shown, the method may include S101-S106:
[0049] S101: Detect the communication status of the target SPI channel.
[0050] This application embodiment can be applied to the main chip of a vehicle controller. In the AUTOSAR architecture, in addition to the main chip, it can also have communication modules such as a DMA module and an SPI module. The SPI module can communicate with external SPI network devices via the DMA module. The DMA module can have one or more DMA channels, and the SPI module can also have one or more SPI channels; one DMA channel can correspond to one or more SPI channels. In SPI multi-channel switching, a channel can refer to the logical connection between the master device and a specific slave device. Each channel has a corresponding CS (Chip Select) signal, and the master device activates or disables the slave device by controlling the high or low level of the CS signal. Channels enable the master device to manage multiple slave devices and switch between different slave devices to perform different tasks or read / write different data.
[0051] Each SPI channel can have its own SPI state machine, which manages the communication status of that SPI channel, thereby detecting the communication status of the target SPI channel.
[0052] In one possible implementation, the specific implementation of S101 detecting the communication status of the target SPI channel may include:
[0053] Periodically check the communication status of the target SPI channel.
[0054] In practical applications, the communication status of the target SPI channel can be periodically detected using a periodic function, thereby promptly identifying any abnormalities in the communication status of the target SPI channel.
[0055] In one possible implementation, the target SPI channel can be an SPI channel whose data transmission volume exceeds a certain threshold. That is, communication status detection is prioritized for target SPI channels with high data transmission volumes. The threshold can be a data volume threshold per unit time, which can be set according to actual conditions; this application embodiment does not limit the value of the threshold.
[0056] S102: If the communication status is in the SPI pending state for more than the time threshold, determine that the target DMA channel corresponding to the target SPI channel is faulty.
[0057] If the communication status of the target SPI channel is in a Pending state, it typically means that some data transmissions or operations have not yet been completed during SPI communication, or that a problem has occurred at a certain stage, causing the SPI module to be in a waiting or uncertain state. If the communication status remains in the Pending state for more than a time threshold, it can be determined that the SPI task of this SPI channel has not been completed, and the corresponding DMA channel has not generated a transmission completion interrupt, thus indicating a fault in the target DMA channel corresponding to the target SPI channel. The time threshold can be set according to actual conditions, for example, 500 milliseconds (ms). This application embodiment does not limit the value of the time threshold.
[0058] S103: Pause the SPI communication task corresponding to the target DMA channel.
[0059] A target DMA channel can correspond to multiple SPI channels, including a target SPI channel, and each SPI channel may execute SPI communication tasks. If the target DMA channel is determined to be faulty, then all SPI communication tasks on each SPI channel corresponding to the target DMA channel need to be paused.
[0060] S104: Determine whether there is any remaining data in the data storage space corresponding to the target DMA channel.
[0061] Each DMA channel has a corresponding data storage space. It is determined whether there is any remaining data in the data storage space corresponding to the target DMA channel to determine whether the SPI communication task has actually been completed.
[0062] In practical applications, the execution order between S103 and S104 is not limited.
[0063] S105: If there is remaining data, trigger the transmission of the remaining data.
[0064] If there is remaining data, it means that the SPI communication task corresponding to the target DMA channel has not been actually completed. There is still remaining data in the data storage space. If the data transmission stops for some reason, resulting in a long-term SPI pending state, it is necessary to trigger the transmission of the remaining data to complete the SPI communication task.
[0065] S106: If there is no remaining data, release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel.
[0066] If there is no remaining data, it means that the data transmission is complete but no interruption has occurred, resulting in a long-term SPI pending state. In this case, it is necessary to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel.
[0067] In one possible implementation, if there is no remaining data in step S106, the specific implementation of releasing the pending SPI state and resuming the SPI communication task corresponding to the target DMA channel may include:
[0068] If no remaining data is found, the SPI task completion interface is called to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel.
[0069] In other words, in practical applications, the SPI task completion interface can be called to release the SPI pending state and quickly complete the state machine state transition.
[0070] In this embodiment, the communication status of the target SPI channel is detected. If the communication status of the target SPI channel remains in a Pending state for more than a time threshold, it can be determined that the target DMA channel corresponding to this target SPI channel may be faulty. All SPI communication tasks corresponding to the target DMA channel are suspended. It is determined whether there is any remaining data in the data storage space corresponding to the target DMA channel. If there is remaining data, the remaining data is triggered to continue transmission; if there is no remaining data, the Pending state of the target SPI channel is lifted, and the SPI communication tasks corresponding to the target DMA channel are resumed. This resolves the abnormal SPI communication state caused by incomplete data transmission in the DMA model of the vehicle controller, thus restoring SPI communication.
[0071] Based on the above embodiments, in one possible implementation, after determining in S102 that the target DMA channel corresponding to the target SPI channel is faulty, the above method may further include:
[0072] A1: Set the fault flag bit for the target DMA channel.
[0073] A2: Periodically check whether to set the fault flag bit of the target DMA channel.
[0074] A3: When the fault flag bit of the target DMA channel is set, the SPI communication task corresponding to the target DMA channel is paused.
[0075] After determining that the target DMA channel corresponding to the target SPI channel is faulty, the fault flag bit of the target DMA channel can be set. The fault flag bit is periodically checked by a periodic function. Once the fault flag bit is detected, all SPI communication tasks corresponding to the target DMA channel are suspended.
[0076] In one possible implementation, after S106 releases the SPI pending state, the above method may further include:
[0077] Clear the fault flag bit of the target DMA channel.
[0078] In practical applications, after setting the fault flag of the target DMA channel, if the SPI pending state is resolved, it is also necessary to clear the fault flag to make the SPI communication recovery process more accurate.
[0079] In one possible implementation, the method may also include:
[0080] Set the DMA processing interrupt function for the target DMA channel.
[0081] The specific implementation of S104 determining whether there is remaining data in the data storage space corresponding to the target DMA channel may include:
[0082] Call the DMA processing interrupt function for the target DMA channel to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel.
[0083] A DMA processing interrupt function (Mcl_Notification function) is pre-configured for the target DMA channel. This function checks whether there is remaining data in the data storage space corresponding to the target DMA channel. If there is remaining data, it triggers the continued transmission of the remaining data. If there is no remaining data, it calls the SPI task completion interface to release the SPI pending state and resumes the SPI communication task corresponding to the target DMA channel. It is important to note that if the original Mcl microcontroller code does not have an independent channel interface, the SPI channel needs to be filtered and decoupled from various peripherals based on the specific DMA usage.
[0084] By setting a DMA processing interrupt function, the corresponding DMA processing interrupt function can be called after it is determined that the target DMA channel corresponding to the target SPI channel is faulty, thereby restoring SPI communication.
[0085] See Figure 2 The diagram illustrates a flowchart of another SPI communication recovery method provided in an embodiment of this application, which may include steps S201-S207:
[0086] S201: Set the DMA processing interrupt function for the target DMA channel.
[0087] S202: Periodically check the communication status of the target SPI channel.
[0088] S203: Determine whether the communication status is in the SPI pending state for more than the time threshold. If yes, execute S204; otherwise, return to S202.
[0089] S204: Determine if the target DMA channel corresponding to the target SPI channel is faulty, and set the fault flag bit of the target DMA channel.
[0090] S205: Periodically check whether the fault flag bit of the target DMA channel is set. If so, execute S206.
[0091] S206: Pause the SPI communication task corresponding to the target DMA channel and call the DMA processing interrupt function for the target DMA channel. The DMA processing interrupt function determines whether there is any remaining data in the data storage space corresponding to the target DMA channel. If there is remaining data, the remaining data is triggered to continue transmission. If there is no remaining data, the SPI task completion interface is called to release the SPI pending state.
[0092] S207: After clearing the SPI pending state, clear the fault flag bit of the target DMA channel and resume the SPI communication task corresponding to the target DMA channel.
[0093] In this embodiment, a DMA processing interrupt function (Mcl_Notification function) is created for the target DMA channel corresponding to the SPI channel with a large data transmission volume. The periodic function periodically checks the state of each Sequence (communication state) of the SPI channel with a large data transmission volume. If the communication state remains in the SPIPending state for more than a certain time threshold (e.g., 500ms), it is determined that the SPI communication task is incomplete, the corresponding target DMA channel has not generated a transmission completion interrupt, and the fault flag bit of the target DMA channel is set. The fault flag bit is periodically checked; once a fault flag bit is detected, all SPI communication tasks of the target DMA channel are paused, and the corresponding DMA processing interrupt function is called. After the DMA processing interrupt function successfully processes the interrupt, the communication state is de-SPIPending, the fault flag bit is cleared, and all SPI communication tasks of the DMA channel continue.
[0094] This resolves the SPI communication anomaly caused by incomplete DMA data transfer in the vehicle controller. Examples include situations where the DMA fails to complete data transmission, resulting in the SPI communication state remaining in the SPIPending state; or where the DMA completes data transmission but does not generate an interrupt, also resulting in the SPI communication state remaining in the SPIPending state. SPI communication can be restored in all these scenarios.
[0095] Specifically, in this embodiment, there is no need to discard data already transmitted in the current SPI communication task; the remaining data can continue to be transmitted, improving software robustness. Decoupling the SPI channels avoids affecting the communication status of other peripherals, making it more agile and efficient than resetting the entire controller. Even if an SPI communication anomaly occurs due to incomplete DMA transmission, peripheral functions can be restored without the user's awareness, improving the user's driving experience.
[0096] Based on the SPI communication recovery method provided in the above-described method embodiments, this application also provides an SPI communication recovery device, which will be described below with reference to the accompanying drawings.
[0097] See Figure 3 As shown in the figure, this is a schematic diagram of the structure of an SPI communication recovery device provided in an embodiment of this application. Figure 3 As shown, the SPI communication recovery device includes:
[0098] The detection unit 301 is used to detect the communication status of the target SPI channel;
[0099] Determination unit 302 is used to determine that the target DMA channel corresponding to the target SPI channel is faulty if the communication status is in the SPI pending state for more than a time threshold.
[0100] The pause unit 303 is used to pause the SPI communication task corresponding to the target DMA channel;
[0101] The first judgment unit 304 is used to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel;
[0102] The first triggering unit 305 is used to trigger the continued transmission of the remaining data if the judging unit determines that there is remaining data.
[0103] The release unit 306 is used to release the SPI pending state and restore the SPI communication task corresponding to the target DMA channel if the judgment unit determines that there is no remaining data.
[0104] In one possible implementation, the device further includes:
[0105] The first setting unit is used to set the fault flag bit of the target DMA channel after determining that the target SPI channel is faulty;
[0106] The second judgment unit is used to periodically determine whether to set the fault flag bit of the target DMA channel;
[0107] The second triggering unit is used to trigger the pausing of the SPI communication task corresponding to the target DMA channel when the second judgment unit determines that the fault flag bit of the target DMA channel is set.
[0108] In one possible implementation, the device further includes:
[0109] The clearing unit is used to clear the fault flag bit of the target DMA channel after the SPI pending state is resolved.
[0110] In one possible implementation, the device further includes:
[0111] The second setting unit is used to set the DMA processing interrupt function for the target DMA channel;
[0112] The first judgment unit is specifically used for:
[0113] The function for setting a DMA processing interrupt for the target DMA channel is called to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel.
[0114] In one possible implementation, the detection unit is specifically used for:
[0115] Periodically check the communication status of the target SPI channel.
[0116] In one possible implementation, the release unit is specifically used for:
[0117] If no remaining data is found, the SPI task completion interface is called to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel.
[0118] In one possible implementation, the target SPI channel is an SPI channel whose data transmission volume exceeds a certain threshold.
[0119] In addition, this application embodiment also provides an SPI communication recovery device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the SPI communication recovery method as described in any of the above claims.
[0120] This application also provides a computer-readable storage medium storing instructions that, when executed on a terminal device, cause the terminal device to perform the SPI communication recovery method as described in any of the preceding claims.
[0121] This application also provides a computer program product, including computer program instructions, which, when executed on a computer, cause the computer to perform the SPI communication recovery method as described in any of the preceding embodiments.
[0122] In this embodiment, the communication status of the target SPI channel is detected. If the communication status of the target SPI channel remains in a Pending state for more than a time threshold, it can be determined that the target DMA channel corresponding to this target SPI channel may be faulty. All SPI communication tasks corresponding to the target DMA channel are suspended. It is determined whether there is any remaining data in the data storage space corresponding to the target DMA channel. If there is remaining data, the remaining data is triggered to continue transmission; if there is no remaining data, the Pending state of the target SPI channel is lifted, and the SPI communication tasks corresponding to the target DMA channel are resumed. This resolves the abnormal SPI communication state caused by incomplete data transmission in the DMA model of the vehicle controller, thus restoring SPI communication.
[0123] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section.
[0124] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.
[0125] It should also be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0126] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0127] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for restoring SPI communication via a serial peripheral interface, characterized in that, The method includes: Detect the communication status of the target SPI channel; If the communication status is in the SPI pending state for more than a time threshold, the target DMA channel corresponding to the target SPI channel is determined to be faulty. Pause the SPI communication task corresponding to the target DMA channel; Determine whether there is any remaining data in the data storage space corresponding to the target DMA channel; If there is remaining data, trigger the transmission of that remaining data. If there is no remaining data, the SPI pending state is lifted, and the SPI communication task corresponding to the target DMA channel is resumed.
2. The method according to claim 1, characterized in that, After determining that the target DMA channel corresponding to the target SPI channel is faulty, the method further includes: Set the fault flag bit of the target DMA channel; Periodically determine whether to set the fault flag bit of the target DMA channel; When it is determined that the fault flag bit of the target DMA channel is set, the SPI communication task corresponding to the target DMA channel is suspended.
3. The method according to claim 2, characterized in that, After resolving the SPI pending state, the method further includes: Clear the fault flag bit of the target DMA channel.
4. The method according to any one of claims 1-3, characterized in that, The method further includes: Set the DMA processing interrupt function for the target DMA channel; The step of determining whether there is remaining data in the data storage space corresponding to the target DMA channel includes: The function for setting a DMA processing interrupt for the target DMA channel is called to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel.
5. The method according to claim 1, characterized in that, The communication status of the detection target's SPI channel includes: Periodically check the communication status of the target SPI channel.
6. The method according to claim 1, characterized in that, If no remaining data exists, the SPI pending state is lifted, and the SPI communication task corresponding to the target DMA channel is resumed, including: If no remaining data is found, the SPI task completion interface is called to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel.
7. The method according to claim 1 or 5, characterized in that, The target SPI channel is an SPI channel whose data transmission volume exceeds a certain threshold.
8. A serial peripheral interface (SPI) communication recovery device, characterized in that, The device includes: The detection unit is used to detect the communication status of the target SPI channel; A determining unit is configured to determine that the target DMA channel corresponding to the target SPI channel is faulty if the communication status is in an SPI pending state for more than a time threshold. A pause unit is used to pause the SPI communication task corresponding to the target DMA channel; The first judgment unit is used to determine whether there is any remaining data in the data storage space corresponding to the target DMA channel; The first triggering unit is used to trigger the continued transmission of the remaining data if the judging unit determines that there is remaining data. The release unit is used to release the SPI pending state and resume the SPI communication task corresponding to the target DMA channel if the judgment unit determines that there is no remaining data.
9. A serial peripheral interface SPI communication recovery device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the SPI communication recovery method as described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions that, when executed on a terminal device, cause the terminal device to perform the SPI communication recovery method as described in any one of claims 1-7.
