SPI communication method and device, electronic equipment and storage medium
By generating instruction clusters and using DMA channels to send them, the problem of high CPU resource consumption by SPI communication is solved, more efficient communication in the real-time control system is achieved, and the real-time performance and reliability of the system are improved.
Patent Information
- Application Number
- CN202410816701.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-09-10
AI Technical Summary
The existing SPI communication method consumes high CPU resources in real-time control systems, especially when frequent acquisition of ASIC status is required, resulting in an increase in the CPU task load rate and affecting the real-time performance and reliability of the system.
By generating N+1 SPI control instructions to form an instruction cluster, and using the DMA channel to send the instruction cluster to the special integrated circuit chip, it is possible to obtain the execution result of the previous SPI control instruction while controlling the working status of the controller, and reduce the CPU cost. The amount of sending tasks.
It effectively reduces the CPU resource usage of the micro control unit and improves the efficiency of SPI communication and the real-time and reliability of the system, especially in high-precision control scenarios such as hydraulic valve control of intelligent brake controllers and vehicle speed signal reading. The CPU load is significantly reduced during the task.
Smart Images

Figure CN118626430A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of automotive electronic communications, and in particular to an SPI communication method, device, electronic equipment and storage medium. Background Art
[0002] Automotive semiconductors are core components of smart cars and are widely used in various modules of cars, mainly covering five major sectors: body, instrument / infotainment system, chassis / safety system, powertrain system and driver assistance system. In the field of automotive semiconductors, application-specific integrated circuit chips (ASIC, Application-Specific Integrated Circuit) are an important technology. ASIC is an integrated circuit customized for specific use requirements. Its computing performance and efficiency are supported by the underlying algorithm and are the product of fixed algorithm optimization. The utilization rate of ASIC has increased significantly with the increase in demand for edge computing. ASIC usually uses SPI communication to implement ASIC function control and read the internal status of ASIC.
[0003] SPI is a high-speed, full-duplex, synchronous communication bus, and SPI communication only occupies four wires on the chip pins, saving the chip pins. However, SPI is a master-slave communication mechanism, and the slave end will not actively send signals to the master end. When the microcontroller unit (MCU) wants to obtain the ASIC status, it needs to actively send SPI instructions to read the content, and generally needs to send it twice in a row to obtain the required content. In real-time control systems, the existing SPI communication method will consume a lot of CPU computing resources. Summary of the invention
[0004] The present invention provides an SPI communication method, device, electronic equipment and storage medium, which solve the problem of high CPU resource consumption in the existing SPI communication mode.
[0005] In order to achieve the above object, the present invention adopts the following technical scheme:
[0006] In a first aspect, the present invention provides an SPI communication method, the method comprising:
[0007] In response to the control requirements of N controlled devices of the current control task, N+1 SPI control instructions are generated, and the N+1 SPI control instructions are arranged in sequence to form an instruction cluster; each SPI control instruction in the instruction cluster is used to control the working state of the corresponding controlled device, and at the same time obtain the execution result of the previous SPI control instruction;
[0008] The instruction cluster is sent to a dedicated integrated circuit chip.
[0009] In a possible implementation, each of the SPI control instructions includes a control part and a detection part;
[0010] The control part is used to control the working state of the controlled device corresponding to the SPI control instruction;
[0011] The detection part is used to obtain the execution result of the controlled device corresponding to the previous SPI control instruction of the SPI control instruction.
[0012] In a possible implementation, the instruction cluster is sent to a dedicated integrated circuit chip, specifically:
[0013] The microcontroller unit sends the instruction cluster to the application-specific integrated circuit chip according to the arrangement sequence of the SPI control instructions.
[0014] In a possible implementation, the instruction cluster is sent to a dedicated integrated circuit chip, specifically:
[0015] The microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip.
[0016] In a possible implementation, the microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip, specifically including:
[0017] The microcontroller loads a task, and the microcontroller loads the first SPI control instruction in the instruction cluster to the DMA channel;
[0018] DMA data enabling, starting the DMA channel after loading is completed, and sending the SPI control instruction to the ASIC chip;
[0019] The microcontroller task is interrupted, and the interrupt function of the microcontroller is triggered after the transmission is completed, and the next SPI control instruction in the instruction cluster is loaded into the DMA channel in the interrupt function;
[0020] Repeat the above DMA data enabling and microcontroller unit task interruption steps until all SPI control instructions in the instruction cluster are sent.
[0021] In a possible implementation, when there are multiple current control tasks, multiple instruction clusters matching the number of the current control tasks are formed; and sending the instruction clusters to the ASIC chip specifically includes:
[0022] In response to a sending request of an instruction cluster corresponding to a target control task, loading the instruction cluster into a sending queue;
[0023] The sending queue uses a first-in first-out mode to send all SPI control instructions in the instruction cluster to the dedicated integrated circuit chip.
[0024] In a possible implementation, the current control task includes one or a combination of a watchdog feeding management task, a low-side drive control task, an analog conversion result reading task, a vehicle speed signal reading task, and a fault status detection task.
[0025] In a second aspect, the present invention provides an SPI communication device, the device comprising:
[0026] A processing unit, configured to generate N+1 SPI control instructions in response to control requirements of N controlled devices of a current control task, and to arrange the N+1 SPI control instructions in sequence to form an instruction cluster; each SPI control instruction in the instruction cluster is used to control a working state of a corresponding controlled device, and to obtain an execution result of a previous SPI control instruction;
[0027] The execution unit is used to send the instruction cluster to a dedicated integrated circuit chip.
[0028] In one possible implementation, each SPI control instruction generated by the processing unit includes a control part and a detection part;
[0029] The control part is used to control the working state of the controlled device corresponding to the SPI control instruction;
[0030] The detection part is used to obtain the execution result of the controlled device corresponding to the previous SPI control instruction of the SPI control instruction.
[0031] In a possible implementation, the execution unit is configured to execute:
[0032] The microcontroller unit sends the instruction cluster to the application-specific integrated circuit chip according to the arrangement sequence of the SPI control instructions.
[0033] In a possible implementation, the execution unit is configured to execute:
[0034] The microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip.
[0035] In a possible implementation, the execution unit is specifically configured to execute:
[0036] The microcontroller loads a task, and the microcontroller loads the first SPI control instruction in the instruction cluster to the DMA channel;
[0037] DMA data enabling, starting the DMA channel after loading is completed, and sending the SPI control instruction to the ASIC chip;
[0038] The microcontroller task is interrupted, and the interrupt function of the microcontroller is triggered after the transmission is completed, and the next SPI control instruction in the instruction cluster is loaded into the DMA channel in the interrupt function;
[0039] Repeat the above DMA data enabling and microcontroller unit task interruption steps until all SPI control instructions in the instruction cluster are sent.
[0040] In a possible implementation, when there are multiple current control tasks and multiple instruction clusters matching the number of the current control tasks are formed, the execution unit is specifically configured to execute:
[0041] In response to a sending request of an instruction cluster corresponding to a target control task, loading the instruction cluster into a sending queue;
[0042] The sending queue uses a first-in first-out mode to send all SPI control instructions in the instruction cluster to the dedicated integrated circuit chip.
[0043] In one possible implementation, in the processing unit, the current control tasks that respond simultaneously include one or a combination of watchdog feeding management tasks, low-side drive control tasks, analog conversion result reading tasks, vehicle speed signal reading tasks, and fault status detection tasks.
[0044] In a third aspect, the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement any one of the above-mentioned SPI communication methods.
[0045] In a fourth aspect, the present invention provides a computer-readable storage medium having stored thereon at least one instruction, at least one program, a code set or an instruction set, wherein the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by a processor to implement any one of the above-described SPI communication methods.
[0046] When the SPI communication method provided by the embodiment of the present invention is actually applied, N+1 SPI control instructions are generated according to the control requirements of N controlled devices of the current control task, and the N+1 SPI control instructions are sequentially sorted to obtain an instruction cluster. Each SPI control instruction in the instruction cluster can obtain the execution result of the previous SPI control instruction while controlling the working state of the corresponding controlled device, thereby realizing the verification of the execution result of the previous controller for the previous SPI control instruction while controlling the work of the current controlled device; the sending of multiple SPI control instructions can be realized by only one arrangement in the form of an instruction cluster, thereby realizing the control requirements of multiple controlled devices, effectively reducing the sending task amount of the CPU of the microcontroller, thereby reducing the occupancy of the CPU resources of the microcontroller by SPI communication. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A flow chart of the steps of an SPI communication method provided by an embodiment of the present invention;
[0048] Figure 2 A schematic diagram of a loading mechanism of an instruction cluster when a microcontroller unit combines with a DMA channel to send an instruction cluster in an SPI communication method provided by an embodiment of the present invention;
[0049] Figure 3 A structural block diagram of an SPI communication device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0051] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, the use of "based on" or "according to" means openness and inclusiveness, because the process, steps, calculations or other actions "based on" or "according to" one or more of the conditions or values may be based on additional conditions or values beyond the described values in practice.
[0052] In the prior art, in the high-precision control scenario of the real-time control system, how to deal with the resource consumption of SPI communication is a key issue that software developers pay attention to.
[0053] Among them, the real-time control system is realized by using a combination of microcontroller unit and application-specific integrated circuit chip (MCU-ASIC) on the intelligent brake controller. When the high-precision control scenario is the hydraulic valve control scenario of the chassis system, the MCU needs to drive 12 hydraulic valves through the ASIC chip to realize precise real-time control of the brake system drive.
[0054] At the same time, the ASIC chip is also responsible for detecting the vehicle wheel speed sensor signal and the AD conversion of the peripheral circuit. The detected data is parsed and transmitted to the MCU through the SPI bus. In addition, the ASIC is also responsible for providing the power required for the MCU to work. In order to meet the safety requirements of the real-time control system, a watchdog safety mechanism is also set between the ASIC and the MCU; when the MCU operates abnormally and the ASIC is not fed within the preset time, the ASIC will reset the MCU, and the feeding operation between the MCU and the ASIC is also performed through the SPI bus.
[0055] Frequent information exchange and communication is required between MCU and SPI. Due to the safety characteristics of the brake system, the valve control cycle of the hydraulic valve needs to be controlled at 1ms or even a shorter time interval. However, due to the limitations of the physical characteristics of SPI communication itself, even at the highest communication rate that ASIC can support, it still takes at least 10 microseconds to complete the transmission of a 32-bit control instruction, which significantly increases the CPU task load rate of the MCU, thereby greatly affecting the stack usage space of other low-priority tasks, and further causing problems such as poor real-time performance of the operating system, inaccurate task cycle, and abnormal crashes. Among them, the highest communication rate is 10M.
[0056] In a real-time control system, the MCU has five management requirements for the ASIC chip, including: watchdog feeding management, low-side driver control, analog conversion result reading, vehicle speed signal reading, and fault status detection.
[0057] Specifically, taking the MCU controlling the low-side drive of the ASIC chip to control the hydraulic valve as an example, the intelligent brake controller system contains 12 hydraulic valves for dynamically controlling the operating status of the vehicle. Each hydraulic valve is controlled to open or close by the ASIC chip through the low-side drive circuit.
[0058] The ASIC chip determines the opening or closing of each hydraulic valve according to the control instructions sent by the MCU based on the SPI bus. Since the braking system has extremely high dynamic response requirements, the MCU needs to send SPI instructions to the ASIC chip within a 1ms cycle to control the operating status of each hydraulic valve.
[0059] In the traditional SPI communication method, after each application module generates a hydraulic valve control demand, it requires the driver layer to send a control instruction to drive the corresponding hydraulic valve. After that, in order to obtain whether the current control instruction is executed normally, it is necessary to immediately send another control instruction to obtain the execution status of the current control instruction. In other words, two control instructions need to be sent for the control of each hydraulic valve. Therefore, to complete the drive control of all 12 hydraulic valves within 1ms, 24 control instructions need to be sent, which greatly occupies CPU resources.
[0060] When the SPI communication method provided by the embodiment of the present invention is actually applied, N+1 SPI control instructions are generated according to the control requirements of N controlled devices of the current control task, and the N+1 SPI control instructions are sequentially sorted to obtain an instruction cluster. Each SPI control instruction in the instruction cluster can obtain the execution result of the previous SPI control instruction while controlling the working state of the corresponding controlled device, thereby realizing the verification of the execution result of the previous controller for the previous SPI control instruction while controlling the work of the current controlled device; the sending of multiple SPI control instructions can be realized by only one arrangement in the form of an instruction cluster, thereby realizing the control requirements of multiple controlled devices, effectively reducing the sending task amount of the CPU of the microcontroller, thereby reducing the occupancy of the CPU resources of the microcontroller by SPI communication.
[0061] In order to solve the problem of high CPU resource consumption in the existing SPI communication mode, the embodiments of the present invention provide a SPI communication method, device, electronic device and storage medium.
[0062] like Figure 1 As shown, in a first aspect, the present invention provides an SPI communication method, the method comprising:
[0063] Step 101 : generating N+1 SPI control instructions in response to control requirements of N controlled devices of a current control task, and arranging the N+1 SPI control instructions in sequence to form an instruction cluster.
[0064] Each SPI control instruction in the instruction cluster is used to control the working state of the corresponding controlled device and obtain the execution result of the previous SPI control instruction.
[0065] In this embodiment, the current control task is a low-side drive control task, the controlled devices of the task are 12 hydraulic valves, and the control demand is the control requirement for the switch state of each hydraulic valve at the current moment.
[0066] The MCU generates 13 SPI control instructions in response to the control requirements of the low-side driver control task on the switch states of the 12 hydraulic valves, and the 13 SPI control instructions are sorted in sequence to obtain an instruction cluster including the 13 SPI control instructions.
[0067] Each SPI control instruction in the instruction cluster is used to control the corresponding hydraulic valve to open or close, and at the same time, obtain the execution result of the hydraulic valve corresponding to the previous SPI control instruction of the SPI control instruction.
[0068] Since the first SPI control instruction in the instruction cluster does not have a previous SPI control instruction, the first SPI control instruction is only used to control the corresponding hydraulic valve to open or close.
[0069] Since there is no corresponding hydraulic valve for the last SPI control instruction in the instruction cluster, the last SPI control instruction is only used to obtain the execution result of the hydraulic valve corresponding to the previous SPI control instruction of the last SPI control instruction.
[0070] Step 102: Send the instruction cluster to the ASIC chip.
[0071] Specifically, each SPI control instruction is a 32-bit control instruction, and the instruction cluster has 13 32-bit control instructions, that is, the MCU only needs to send 13 control instructions to the dedicated integrated circuit chip to achieve the control requirements of the low-side drive control task.
[0072] Compared with the traditional SPI communication method, which requires sending 24 control instructions to complete the drive control of all 12 hydraulic valves within 1 ms, the SPI communication method of the present invention only requires sending 13 control instructions in sequence to complete the drive control of the same 12 hydraulic valves, effectively reducing the amount of task sending.
[0073] Furthermore, each SPI control instruction includes a control part and a detection part.
[0074] The control part is used to control the working state of the controlled device corresponding to the SPI control instruction.
[0075] The detection part is used to obtain the execution result of the controlled device corresponding to the previous SPI control instruction of the SPI control instruction.
[0076] In the embodiment of the present invention, the working state of the controlled device is whether the controlled hydraulic valve is open or closed; the execution result of the controlled device corresponding to the last SPI control instruction is whether the hydraulic valve corresponding to the last SPI control instruction is correctly executed according to the control instruction.
[0077] For example, when the SPI control instruction is a 32-bit control instruction, the 32-bit control instruction can be decomposed into the first 16 bits and the last 16 bits. The first 16 bits are the control part of the SPI control instruction, and the last 16 bits are the detection part of the SPI control instruction. The first 16 bits are used to control the opening or closing of the hydraulic valve corresponding to the SPI control instruction; the last 16 bits are used to obtain the execution result of the hydraulic valve corresponding to the previous SPI control instruction of the SPI control instruction.
[0078] Furthermore, in one embodiment of the present invention, the instruction cluster is sent to the application specific integrated circuit chip, specifically:
[0079] The microcontroller unit sends the instruction cluster to the ASIC chip according to the arrangement sequence of the SPI control instructions.
[0080] That is to say, when the microcontroller sends the instruction cluster to the ASIC chip, it sends the multiple SPI control instructions to the ASIC chip in sequence according to the arrangement order of the SPI control instructions in the instruction cluster.
[0081] In this embodiment, the microcontroller loads 13 32-bit SPI control instructions to be sent into the queue according to the arrangement order of the SPI control instructions in the cluster, and the queue sends multiple SPI control instructions to the ASIC chip in a first-in-first-out manner.
[0082] Furthermore, in order to further reduce the consumption of CPU resources, in another embodiment of the present invention, the instruction cluster is sent to a dedicated integrated circuit chip, specifically:
[0083] The microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip.
[0084] DMA, or direct memory access, is a mechanism for quickly transferring data. Data can be transferred from an adapter to memory to an adapter, or from one memory segment to another. The CPU does not need to be involved when using the DMA channel to transfer data.
[0085] When the instruction cluster is sent through the microcontroller unit in combination with the DMA channel, the data sending process is executed by the DMA and does not occupy CPU resources, thereby further reducing the task load rate of the CPU within the 1ms time period.
[0086] Furthermore, the micro control unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip, which specifically includes: a micro control unit task loading step, a DMA data enabling step, and a micro control unit task interrupting step.
[0087] Wherein, in the microcontroller task loading step, the microcontroller loads the first SPI control instruction in the instruction cluster to the DMA channel.
[0088] The DMA data enabling step starts the DMA channel after loading is completed and sends the SPI control instructions to the ASIC chip.
[0089] The microcontroller unit task interrupt step triggers the microcontroller unit interrupt function after the transmission is completed, and loads the next SPI control instruction in the instruction cluster into the DMA channel in the interrupt function.
[0090] Finally, the above DMA data enabling and microcontroller unit task interruption steps are repeated until all SPI control instructions in the instruction cluster are sent.
[0091] That is to say, in the process of the microcontroller unit combining with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip, the first SPI control instruction to be sent is first loaded into the DMA send buffer, and the DMA send is started. When the DMA sends the current SPI control instruction, the MCU interrupt is triggered. In the interrupt function, the MCU loads the second send instruction into the DMA send buffer, and then starts the DMA to send data again.
[0092] During the sending process, only the loading of the SPI control instruction is performed within the CPU 1ms cycle task, and the subsequent data transmission is executed by DMA, which will not occupy CPU resources, thereby significantly reducing the CPU task load rate.
[0093] In this embodiment, the process of sending the instruction cluster by the microcontroller unit in combination with the DMA channel is the process of constructing the Sequence sequence. Figure 2 As shown, when constructing a Sequence sequence, the step of loading the first SPI control instruction in the instruction cluster into the Sequence sequence is performed by the CPU within a 1ms task.
[0094] After the SPI control instruction is loaded into the Sequence sequence, the SPI control instruction is sent through the DMA channel via the DMA interrupt (Interrupt1). The data sending process is executed by the DMA and does not occupy CPU resources.
[0095] After the previous SPI control instruction is sent, the interrupt function (Interrupt2) of the microcontroller unit is triggered to load the next SPI control instruction into the Sequence sequence.
[0096] Then, the DMA interrupt (Interrupt1) is used again to utilize the DMA channel to send the SPI control instructions.
[0097] Similarly, through the collaboration between MCU and DMA, the sending of 13 SPI control instructions to be sent in the instruction cluster is completed.
[0098] Furthermore, the current control task includes one or a combination of a watchdog feeding management task, a low-side drive control task, an analog quantity conversion result reading task, a vehicle speed signal reading task, and a fault status detection task.
[0099] That is to say, the MCU can manage one or multiple functional requirements for the ASIC chip at the same time. When the current control task is one, one instruction cluster is generated according to its control requirement. When the current control task is one, multiple instruction clusters are generated according to the control requirement of each task.
[0100] Furthermore, when there are multiple current control tasks, multiple instruction clusters matching the number of current control tasks are formed.
[0101] For example, when the current control tasks include five tasks, namely, watchdog feeding management, low-side driver control, analog conversion result reading, vehicle speed signal reading, and fault status detection, five instruction clusters are generated accordingly.
[0102] Sending the instruction cluster to the ASIC chip specifically includes:
[0103] In response to a sending request of an instruction cluster corresponding to the target control task, the instruction cluster is loaded into a sending queue.
[0104] The sending queue uses a first-in-first-out mode to send all SPI control instructions in the instruction cluster to the dedicated integrated circuit chip.
[0105] Specifically, when each instruction cluster needs to be sent, the MCU responds to the sending request of the instruction cluster, loads the instruction cluster into the queue, and waits for sending in the queue.
[0106] The SPI communication method provided in the embodiment of the present invention is mainly used in the intelligent brake controller of the automobile intelligent chassis. By constructing an instruction cluster and combining the MCU with the DMA instruction cluster sending method, the use of the CPU computing resources and storage resources of the MCU by SPI communication is effectively reduced; the application of the SPI communication method of the present invention can effectively improve the reliability, safety and stability of the control of each hydraulic valve in the brake control system.
[0107] like Figure 3 As shown, an embodiment of the present invention further provides an SPI communication device, the device comprising:
[0108] The processing unit 201 is used to generate N+1 SPI control instructions in response to the control requirements of the N controlled devices of the current control task, and arrange the N+1 SPI control instructions in sequence to form an instruction cluster; each SPI control instruction in the instruction cluster is used to control the working state of the corresponding controlled device, and obtain the execution result of the previous SPI control instruction;
[0109] The execution unit 202 is used to send the instruction cluster to the ASIC chip.
[0110] Further, each SPI control instruction generated by the processing unit 201 includes a control part and a detection part;
[0111] The control part is used to control the working state of the controlled device corresponding to the SPI control instruction;
[0112] The detection part is used to obtain the execution result of the controlled device corresponding to the previous SPI control instruction of the SPI control instruction.
[0113] Furthermore, the execution unit 202 is configured to execute:
[0114] The microcontroller unit sends the instruction cluster to the ASIC chip according to the arrangement sequence of the SPI control instructions.
[0115] Furthermore, the execution unit 202 is configured to execute:
[0116] The microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip.
[0117] Furthermore, the execution unit 202 is specifically configured to execute:
[0118] The microcontroller loads the task, and the microcontroller loads the first SPI control instruction in the instruction cluster to the DMA channel;
[0119] DMA data is enabled, and the DMA channel is started after loading is completed, and the SPI control instructions are sent to the ASIC chip;
[0120] The microcontroller task is interrupted, and the interrupt function of the microcontroller is triggered after the transmission is completed. In the interrupt function, the next SPI control instruction in the instruction cluster is loaded into the DMA channel;
[0121] Repeat the above DMA data enabling and microcontroller unit task interruption steps until all SPI control instructions in the instruction cluster are sent.
[0122] Furthermore, when there are multiple current control tasks and multiple instruction clusters matching the number of current control tasks are formed, the execution unit 202 is specifically configured to execute:
[0123] In response to a sending request of an instruction cluster corresponding to a target control task, loading the instruction cluster into a sending queue;
[0124] The sending queue uses a first-in-first-out mode to send all SPI control instructions in the instruction cluster to the dedicated integrated circuit chip.
[0125] Furthermore, in the processing unit 201, the current control tasks that respond simultaneously include one or a combination of watchdog feeding management tasks, low-side drive control tasks, analog conversion result reading tasks, vehicle speed signal reading tasks, and fault status detection tasks.
[0126] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0127] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, at least one program, a code set or an instruction set is loaded and executed by the processor to implement the SPI communication method in the embodiment of the present invention.
[0128] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, in which at least one instruction, at least one program, code set or instruction set is stored, and at least one instruction, at least one program, code set or instruction set is loaded and executed by a processor to implement the SPI communication method in an embodiment of the present invention.
[0129] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or a data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0130] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. An SPI communication method, characterized in that: include: In response to the control requirements of N controlled devices of the current control task, N+1 SPI control instructions are generated, and the N+1 SPI control instructions are arranged in sequence to form an instruction cluster; each SPI control instruction in the instruction cluster is used to control the working state of the corresponding controlled device, and at the same time obtain the execution result of the previous SPI control instruction; The instruction cluster is sent to a dedicated integrated circuit chip.
2. The SPI communication method according to claim 1, characterized in that: Each of the SPI control instructions includes a control part and a detection part; The control part is used to control the working state of the controlled device corresponding to the SPI control instruction; The detection part is used to obtain the execution result of the controlled device corresponding to the previous SPI control instruction of the SPI control instruction.
3. The SPI communication method according to claim 1, characterized in that: Sending the instruction cluster to the ASIC chip is specifically: The microcontroller unit sends the instruction cluster to the application-specific integrated circuit chip according to the arrangement sequence of the SPI control instructions.
4. The SPI communication method according to claim 1, characterized in that: Sending the instruction cluster to the ASIC chip is specifically: The microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip.
5. The SPI communication method according to claim 4, characterized in that: The microcontroller unit combines with the DMA channel to send the instruction cluster to the dedicated integrated circuit chip, specifically including: The microcontroller loads a task, and the microcontroller loads the first SPI control instruction in the instruction cluster to the DMA channel; DMA data enabling, starting the DMA channel after loading is completed, and sending the SPI control instruction to the ASIC chip; The microcontroller task is interrupted, and the interrupt function of the microcontroller is triggered after the transmission is completed, and the next SPI control instruction in the instruction cluster is loaded into the DMA channel in the interrupt function; Repeat the above DMA data enabling and microcontroller unit task interruption steps until all SPI control instructions in the instruction cluster are sent.
6. The SPI communication method according to claim 1, characterized in that: When there are multiple current control tasks, forming multiple instruction clusters matching the number of the current control tasks; and sending the instruction clusters to the dedicated integrated circuit chip specifically includes: In response to a sending request of an instruction cluster corresponding to a target control task, loading the instruction cluster into a sending queue; The sending queue uses a first-in first-out mode to send all SPI control instructions in the instruction cluster to the dedicated integrated circuit chip.
7. The SPI communication method according to claim 1, characterized in that: The current control task includes one or a combination of a watchdog feeding management task, a low-side drive control task, an analog quantity conversion result reading task, a vehicle speed signal reading task, and a fault status detection task.
8. An SPI communication device, characterized in that: include: A processing unit, configured to generate N+1 SPI control instructions in response to control requirements of N controlled devices of a current control task, and to arrange the N+1 SPI control instructions in sequence to form an instruction cluster; each SPI control instruction in the instruction cluster is used to control a working state of a corresponding controlled device, and to obtain an execution result of a previous SPI control instruction; The execution unit is used to send the instruction cluster to a dedicated integrated circuit chip.
9. An electronic device, characterized in that: The electronic device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the SPI communication method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, at least one program, a code set or an instruction set, and the at least one instruction, the at least one program, the code set or the instruction set is loaded and executed by the processor to implement the SPI communication method as described in any one of claims 1 to 7.
