CN117978785A - A communication method between MCU and SOC based on SPI communication protocol and protocol construction method - Google Patents

A communication method between MCU and SOC based on SPI communication protocol and protocol construction method Download PDF

Info

Publication number
CN117978785A
CN117978785A CN202410024917.9A CN202410024917A CN117978785A CN 117978785 A CN117978785 A CN 117978785A CN 202410024917 A CN202410024917 A CN 202410024917A CN 117978785 A CN117978785 A CN 117978785A
Authority
CN
China
Prior art keywords
soc
mcu
data
communication protocol
spi communication
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410024917.9A
Other languages
Chinese (zh)
Inventor
徐雷
刘朝阳
马业轩
张明炀
迟桐
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Faw Beijing Software Technology Co ltd
FAW Group Corp
Original Assignee
Faw Beijing Software Technology Co ltd
FAW Group Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Faw Beijing Software Technology Co ltd, FAW Group Corp filed Critical Faw Beijing Software Technology Co ltd
Priority to CN202410024917.9A priority Critical patent/CN117978785A/en
Publication of CN117978785A publication Critical patent/CN117978785A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L65/00Network arrangements, protocols or services for supporting real-time applications in data packet communication
    • H04L65/1066Session management
    • H04L65/1101Session protocols
    • H04L65/1104Session initiation protocol [SIP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/141Setup of application sessions
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • H04L67/143Termination or inactivation of sessions, e.g. event-controlled end of session
    • H04L67/145Termination or inactivation of sessions, e.g. event-controlled end of session avoiding end of session, e.g. keep-alive, heartbeats, resumption message or wake-up for inactive or interrupted session

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Cardiology (AREA)
  • General Health & Medical Sciences (AREA)
  • Business, Economics & Management (AREA)
  • General Business, Economics & Management (AREA)
  • Multimedia (AREA)
  • Communication Control (AREA)

Abstract

The application discloses an MCU and SOC communication method based on SPI communication protocol and a protocol construction method. The MCU and SOC communication method based on the SPI communication protocol comprises the following steps: an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end; and the SOC end generate data according to the SPI communication protocol and mutually send the data. The communication mode adopted by the MCU and SOC communication method based on the SPI communication protocol is SPI communication, the SPI protocol supports a full duplex communication mode, and the communication method based on the SPI communication protocol has the characteristics of simplicity in communication, high transmission rate and the like.

Description

一种基于SPI通信协议的MCU与SOC通信方法及协议构建方法A communication method between MCU and SOC based on SPI communication protocol and protocol construction method

技术领域Technical Field

本申请涉及汽车SPI通信技术领域,具体涉及一种基于SPI通信协议的MCU与SOC通信方法以及SPI通信协议构造方法。The present application relates to the field of automotive SPI communication technology, and in particular to a method for communicating between an MCU and a SOC based on an SPI communication protocol and a method for constructing an SPI communication protocol.

背景技术Background technique

汽车仪表系统多采用MCU+SOC架构,其中MCU侧负责接收CAN信号及硬线信号同时进行显示结果的判定,SOC侧则接收到MCU侧的结果进行显示。所以保证MCU和SOC数据传输的准确性、可靠性及高效性是保证仪表正常显示的关键一环。The automotive instrument system mostly adopts the MCU+SOC architecture, in which the MCU side is responsible for receiving CAN signals and hard-wire signals and determining the display results at the same time, while the SOC side receives the results from the MCU side and displays them. Therefore, ensuring the accuracy, reliability and efficiency of data transmission between the MCU and SOC is the key to ensuring the normal display of the instrument.

传统仪表通信方式多采用UART和I2C,UART通信数据帧最大支持9位数据,传输速度较慢,串行通信中,位发送一个字符需要附加的信息位,如起始位、校验位和停止位等。这些附加信息位不是有效信息本身,属于额外的通信开销。同时I2C也具有传输速率较低的特点。Traditional instrument communication methods mostly use UART and I2C. The UART communication data frame supports a maximum of 9 bits of data and has a slow transmission speed. In serial communication, additional information bits are required to send a character, such as the start bit, check bit, and stop bit. These additional information bits are not valid information itself, but belong to additional communication overhead. At the same time, I2C also has the characteristic of low transmission rate.

因此,希望有一种技术方案来解决或至少减轻现有技术的上述不足。Therefore, it is hoped that a technical solution can be provided to solve or at least alleviate the above-mentioned deficiencies of the prior art.

发明内容Summary of the invention

本发明的目的在于提供一种基于SPI通信协议的MCU与SOC通信方法来至少解决上述的一个技术问题。The object of the present invention is to provide a communication method between MCU and SOC based on SPI communication protocol to at least solve one of the above technical problems.

本发明的一个方面,提供一种基于SPI通信协议的MCU与SOC通信方法,所述基于SPI通信协议的MCU与SOC通信方法包括:One aspect of the present invention provides a method for communicating between an MCU and a SOC based on an SPI communication protocol, the method comprising:

MCU端与SOC端建立基于SPI通信协议的SPI通信系统数据通路;The MCU side and the SOC side establish an SPI communication system data path based on the SPI communication protocol;

SOC端以及SOC端根据所述SPI通信协议生成数据并相互发送数据。The SOC end and the SOC end generate data according to the SPI communication protocol and send the data to each other.

可选地,所述数据包括心跳包,当所述数据为心跳包且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法包括:Optionally, the data includes a heartbeat packet. When the data is a heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端基于SPI通信协议定周期生成并向MCU端发送心跳包,其中,心跳包包括LiveCounter字段,心跳报文为单发送模式;The SOC generates and sends a heartbeat packet to the MCU periodically based on the SPI communication protocol. The heartbeat packet includes a LiveCounter field and the heartbeat message is in a single sending mode.

MCU端获取心跳包并通知所述MCU端的看门狗进行更新。The MCU side obtains the heartbeat packet and notifies the watchdog on the MCU side to update.

可选地,当所述数据为心跳包且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法进一步包括:Optionally, when the data is a heartbeat packet and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes:

当MCU端在预设时间内未收到有效心跳包时,通过EcuM触发SOC重启。When the MCU does not receive a valid heartbeat packet within the preset time, the SOC restart is triggered through EcuM.

可选地,所述数据包括周期型报文,当所述数据为周期型报文且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法包括:Optionally, the data includes a periodic message. When the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:

MCU端根据运行周期,周期型生成待发送的周期型报文,所述周期型报文中包括LiveCounter字段以及checksum字段;The MCU side periodically generates a periodic message to be sent according to the operation cycle, wherein the periodic message includes a LiveCounter field and a checksum field;

MCU端向SOC端发送周期型报文;The MCU sends periodic messages to the SOC.

SOC端接收所述周期型报文并对周期型报文中的LiveCounter字段以及checksum字段进行校验,若校验成功则SOC端进行数据分发。The SOC end receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the verification is successful, the SOC end distributes the data.

可选地,当所述数据为周期型报文且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法进一步包括:Optionally, when the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol further includes:

SOC端接收所述周期型报文并对周期型报文中的LiveCounter字段以及checksum字段进行校验,若LiveCounter字段校验失败或超时则重启SOC通信进程。The SOC receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the LiveCounter field verification fails or times out, the SOC communication process is restarted.

可选地,当所述数据为周期型报文且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法包括:Optionally, when the data is a periodic message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端接收所述周期型报文并对周期型报文中的LiveCounter字段以及checksum字段进行校验,若checksum异常时,舍弃该报文数据。The SOC receives the periodic message and checks the LiveCounter field and the checksum field in the periodic message. If the checksum is abnormal, the message data is discarded.

可选地,所述数据包括事件型报文,当所述数据为事件型报文且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法包括:Optionally, the data includes an event-type message. When the data is an event-type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:

MCU端生成待发送的事件型报文,所述事件型报文中包括LiveCounter字段以及checksum字段;The MCU generates an event message to be sent, wherein the event message includes a LiveCounter field and a checksum field;

MCU端将待发送的事件型报文发送给SOC端;The MCU sends the event message to be sent to the SOC;

SOC端接收所述事件型报文并对事件型报文中的LiveCounter字段以及checksum字段进行校验,若校验成功则SOC端进行数据分发。The SOC end receives the event-type message and verifies the LiveCounter field and the checksum field in the event-type message. If the verification is successful, the SOC end distributes the data.

可选地,当所述数据为事件型报文且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法包括:Optionally, when the data is an event-type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端接收所述事件型报文并对事件型报文中的LiveCounter字段以及checksum字段进行校验,若checksum字段校验失败,则记录NACK数据插入待发送链表。The SOC receives the event-type message and verifies the LiveCounter field and the checksum field in the event-type message. If the checksum field verification fails, the NACK data is recorded and inserted into the to-be-sent linked list.

可选地,当所述数据为事件型报文且为上行数据时,所述基于SPI通信协议的MCU与SOC通信方法包括:Optionally, when the data is an event-type message and is uplink data, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端接收所述事件型报文并对事件型报文中的LiveCounter字段以及checksum字段进行校验,若LiveCounter字段校验失败,则记录异常。The SOC receives the event-type message and verifies the LiveCounter field and the checksum field in the event-type message. If the LiveCounter field verification fails, an exception is recorded.

本申请还提供了一种SPI通信协议构造方法,用于构造SPI通信协议,所述SPI通信协议用于如上所述的基于SPI通信协议的MCU与SOC通信方法,所述SPI通信协议构造方法包括:The present application also provides a SPI communication protocol construction method for constructing an SPI communication protocol, wherein the SPI communication protocol is used for the MCU and SOC communication method based on the SPI communication protocol as described above, and the SPI communication protocol construction method includes:

设置接口、应用层、会话层、传输层、数据链路层以及驱动层;Set up the interface, application layer, session layer, transport layer, data link layer, and driver layer;

定义协议格式;Define the protocol format;

设计状态机。Design a state machine.

有益效果Beneficial Effects

本申请的基于SPI通信协议的MCU与SOC通信方法采用的通信方式为SPI通信,SPI协议支持全双工通信方式,具有通信简单、传输速率快等特点,本申请基于SPI通信方式,在协议内部设计通信协议,同时制定超时重发机制,以及应答检测机制来确保数据传输的稳定与可靠。The communication method adopted by the MCU and SOC communication method based on the SPI communication protocol of the present application is SPI communication. The SPI protocol supports full-duplex communication and has the characteristics of simple communication and fast transmission rate. The present application is based on the SPI communication method, designs the communication protocol within the protocol, and formulates a timeout retransmission mechanism and a response detection mechanism to ensure the stability and reliability of data transmission.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

图1是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的流程示意图。FIG1 is a flow chart of a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图2是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行通路建立流程示意图。FIG. 2 is a schematic diagram of an uplink path establishment process of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图3是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行通路建立异常流程示意图。FIG3 is a schematic diagram of an abnormal process of establishing an uplink path in a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图4是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行心跳包传输正常情况流程示意图。FIG4 is a flow chart of a normal uplink heartbeat packet transmission process of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图5是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行心跳包流程(异常)情况流程示意图。FIG5 is a flow chart of an uplink heartbeat packet process (abnormal) of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图6是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文生成流程示意图。FIG6 is a schematic diagram of an uplink periodic message generation process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图7是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文发送流程示意图。FIG. 7 is a schematic diagram of an uplink periodic message sending process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图8是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文触发流程示意图。FIG8 is a schematic diagram of an uplink periodic message triggering process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图9是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文checksum异常流程示意图。9 is a schematic diagram of an abnormal process of an uplink periodic message checksum in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图10是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文LiveCounter异常流程示意图。10 is a schematic diagram of an abnormal flow of an uplink periodic message LiveCounter of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图11是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文TimeOut异常流程示意图。11 is a schematic diagram of the TimeOut exception process of the uplink periodic message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图12是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行周期型报文SOC端分发流程示意图。12 is a schematic diagram of the SOC-side distribution process of the uplink periodic message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图13是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行事件型报文生成流程示意图。FIG. 13 is a schematic diagram of the uplink event message generation process of the MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图14是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行事件型报文发送流程示意图。FIG. 14 is a schematic diagram of the uplink event message sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图15是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行事件型报文checksum异常流程示意图。15 is a schematic diagram of an uplink event message checksum exception process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图16是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行事件型报文LiveCounter异常流程示意图。16 is a schematic diagram of an abnormal flow of an uplink event-type message LiveCounter of a communication method between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图17是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行事件型报文超时异常流程示意图。17 is a schematic diagram of an uplink event-type message timeout exception process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图18是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行事件型报文SOC端分发流程示意图。18 is a schematic diagram of the SOC-side distribution process of the uplink event-type message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图19是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行ACK数据流程示意图。FIG. 19 is a schematic diagram of an uplink ACK data flow of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图20是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的上行NACK数据流程示意图。FIG. 20 is a schematic diagram of an uplink NACK data flow of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图21是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的周期型报文下行数据生成流程示意图。FIG. 21 is a schematic diagram of a process for generating periodic message downlink data in a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

图22是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的周期型报文下行数据发送流程示意图。FIG. 22 is a schematic diagram of the periodic message downlink data sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图23是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的周期型报文下行数据checksum异常流程示意图。23 is a schematic diagram of a periodic message downlink data checksum exception process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图24是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据周期性报文LiveCounter异常流程示意图。24 is a schematic diagram of the LiveCounter exception process of the downlink data periodic message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图25是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据事件型报文生成流程示意图。FIG. 25 is a schematic diagram of the downlink data event message generation process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图26是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据事件型报文发送流程示意图。FIG. 26 is a schematic diagram of the downlink data event message sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图27是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据事件型报文checksum异常流程示意图。27 is a schematic diagram of a downlink data event message checksum exception process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图28是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据事件型报文LiveCounter异常流程示意图。28 is a schematic diagram of the LiveCounter exception process of the downlink data event message of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图29是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据事件型报文超时异常流程示意图。29 is a schematic diagram of a downlink data event-type message timeout exception process of an MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图30是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据ACK发送流程示意图。FIG. 30 is a schematic diagram of the downlink data ACK sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图31是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的下行数据NACK发送流程示意图。FIG. 31 is a schematic diagram of the downlink data NACK sending process of the MCU and SOC communication method based on the SPI communication protocol in an embodiment of the present application.

图32是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的MCU数据发送流程示意图。Figure 32 is a schematic diagram of the MCU data sending process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图33是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的MCU数据接收流程示意图。Figure 33 is a schematic diagram of the MCU data receiving process of the MCU and SOC communication method based on the SPI communication protocol in one embodiment of the present application.

图34是本申请一实施例中的MCU与SOC数据传输示意图。FIG34 is a schematic diagram of data transmission between MCU and SOC in one embodiment of the present application.

图35是本申请一实施例中的协议格式定义示意图。Figure 35 is a schematic diagram of the protocol format definition in an embodiment of the present application.

图36是本申请一实施例中的状态机设计示意图。Figure 36 is a schematic diagram of the state machine design in one embodiment of the present application.

具体实施方式Detailed ways

为使本申请实施的目的、技术方案和优点更加清楚,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行更加详细的描述。在附图中,自始至终相同或类似的标号表示相同或类似的元件或具有相同或类似功能的元件。所描述的实施例是本申请一部分实施例,而不是全部的实施例。下面通过参考附图描述的实施例是示例性的,旨在用于解释本申请,而不能理解为对本申请的限制。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。下面结合附图对本申请的实施例进行详细说明。In order to make the purpose, technical scheme and advantages of the implementation of this application clearer, the technical scheme in the embodiment of this application will be described in more detail below in conjunction with the drawings in the embodiment of this application. In the drawings, the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The described embodiments are part of the embodiments of this application, not all of them. The embodiments described below with reference to the drawings are exemplary and are intended to be used to explain this application, and should not be construed as limitations on this application. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application. The embodiments of this application are described in detail below in conjunction with the drawings.

图1是本申请一实施例中的基于SPI通信协议的MCU与SOC通信方法的流程示意图。FIG1 is a flow chart of a method for communicating between an MCU and a SOC based on the SPI communication protocol in an embodiment of the present application.

如图1所示的基于SPI通信协议的MCU与SOC通信方法包括:The MCU and SOC communication method based on the SPI communication protocol as shown in Figure 1 includes:

MCU端与SOC端建立基于SPI通信协议的SPI通信系统数据通路;The MCU side and the SOC side establish an SPI communication system data path based on the SPI communication protocol;

SOC端以及SOC端根据所述SPI通信协议生成数据并相互发送数据。The SOC end and the SOC end generate data according to the SPI communication protocol and send the data to each other.

本申请的基于SPI通信协议的MCU与SOC通信方法采用的通信方式为SPI通信,SPI协议支持全双工通信方式,具有通信简单、传输速率快等特点,本申请基于SPI通信方式,在协议内部设计通信协议,同时制定超时重发机制,以及应答检测机制来确保数据传输的稳定与可靠。The communication method adopted by the MCU and SOC communication method based on the SPI communication protocol of the present application is SPI communication. The SPI protocol supports full-duplex communication and has the characteristics of simple communication and fast transmission rate. The present application is based on the SPI communication method, designs the communication protocol within the protocol, and formulates a timeout retransmission mechanism and a response detection mechanism to ensure the stability and reliability of data transmission.

在本实施例中,所述数据包括心跳包,当所述数据为心跳包时,所述基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, the data includes a heartbeat packet. When the data is a heartbeat packet, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端基于SPI通信协议定周期生成并向MCU端发送心跳包,其中,心跳包包括LiveCounter(计数器)字段,心跳报文为单发送模式;The SOC generates and sends a heartbeat packet to the MCU periodically based on the SPI communication protocol. The heartbeat packet includes a LiveCounter field, and the heartbeat message is in a single sending mode.

MCU端获取心跳包并通知所述MCU端的看门狗进行更新。The MCU side obtains the heartbeat packet and notifies the watchdog on the MCU side to update.

在本实施例中,当所述数据为心跳包时,所述基于SPI通信协议的MCU与SOC通信方法进一步包括:In this embodiment, when the data is a heartbeat packet, the MCU and SOC communication method based on the SPI communication protocol further includes:

当MCU端在预设时间内未收到有效心跳包时,通过EcuM(状态管理)触发SOC重启。When the MCU does not receive a valid heartbeat packet within the preset time, the SOC restart is triggered through EcuM (state management).

在本实施例中,所述数据包括周期型报文,当所述数据为周期型报文时,所述基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, the data includes a periodic message. When the data is a periodic message, the MCU and SOC communication method based on the SPI communication protocol includes:

MCU端根据运行周期,周期型生成待发送的周期型报文,所述周期型报文中包括LiveCounter字段以及checksum(校验值)字段;The MCU generates a periodic message to be sent according to the operation cycle, and the periodic message includes a LiveCounter field and a checksum field;

MCU端向SOC端发送周期型报文;The MCU sends periodic messages to the SOC.

SOC端接收所述周期型报文并对周期型报文中的LiveCounter字段以及checksum字段进行校验,若校验成功则SOC端进行数据分发。The SOC end receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the verification is successful, the SOC end distributes the data.

在本实施例中,当所述数据为周期型报文时,所述基于SPI通信协议的MCU与SOC通信方法进一步包括:In this embodiment, when the data is a periodic message, the MCU and SOC communication method based on the SPI communication protocol further includes:

SOC端接收所述周期型报文并对周期型报文中的LiveCounter字段以及checksum字段进行校验,若LiveCounter字段校验失败或超时则重启SOC通信进程。The SOC receives the periodic message and verifies the LiveCounter field and the checksum field in the periodic message. If the LiveCounter field verification fails or times out, the SOC communication process is restarted.

在本实施例中,当所述数据为周期型报文时,所述基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, when the data is a periodic message, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端接收所述周期型报文并对周期型报文中的LiveCounter字段以及checksum字段进行校验,若checksum异常时,舍弃该报文数据。The SOC receives the periodic message and checks the LiveCounter field and the checksum field in the periodic message. If the checksum is abnormal, the message data is discarded.

在本实施例中,所述数据包括事件型报文,当所述数据为事件型报文时,所述基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, the data includes an event-type message. When the data is an event-type message, the MCU and SOC communication method based on the SPI communication protocol includes:

MCU端生成待发送的事件型报文,所述事件型报文中包括LiveCounter字段以及checksum字段;The MCU generates an event message to be sent, wherein the event message includes a LiveCounter field and a checksum field;

MCU端将待发送的事件型报文发送给SOC端;The MCU sends the event message to be sent to the SOC;

SOC端接收所述事件型报文并对事件型报文中的LiveCounter字段以及checksum字段进行校验,若校验成功则SOC端进行数据分发。The SOC end receives the event-type message and verifies the LiveCounter field and the checksum field in the event-type message. If the verification is successful, the SOC end distributes the data.

在本实施例中,当所述数据为事件型报文时,所述基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, when the data is an event-type message, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端接收所述事件型报文并对事件型报文中的LiveCounter字段以及checksum字段进行校验,若checksum字段校验失败,则记录NACK(无应答)数据插入待发送链表。The SOC receives the event message and verifies the LiveCounter field and the checksum field in the event message. If the checksum field verification fails, NACK (no acknowledgement) data is recorded and inserted into the to-be-sent linked list.

在本实施例中,当所述数据为事件型报文时,所述基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, when the data is an event-type message, the MCU and SOC communication method based on the SPI communication protocol includes:

SOC端接收所述事件型报文并对事件型报文中的LiveCounter字段以及checksum字段进行校验,若LiveCounter字段校验失败,则记录异常。The SOC receives the event-type message and verifies the LiveCounter field and the checksum field in the event-type message. If the LiveCounter field verification fails, an exception is recorded.

本申请还提供了一种SPI通信协议构造方法,用于构造SPI通信协议,所述SPI通信协议用于如上所述的基于SPI通信协议的MCU与SOC通信方法,所述SPI通信协议构造方法包括:The present application also provides a SPI communication protocol construction method for constructing an SPI communication protocol, wherein the SPI communication protocol is used for the MCU and SOC communication method based on the SPI communication protocol as described above, and the SPI communication protocol construction method includes:

设置接口、应用层、会话层、传输层、数据链路层以及驱动层;Set up the interface, application layer, session layer, transport layer, data link layer, and driver layer;

定义协议格式;Define the protocol format;

设计状态机。Design a state machine.

下面以举例的方式对本申请进行进一步详细阐述,可以理解的是,该举例并不构成对本申请的任何限制。The present application is further described in detail below by way of examples. It should be understood that the examples do not constitute any limitation to the present application.

参见图34,在本实施例中,MCU与SOC A-core之间通过SPI通信系统进行通信,MCU与M-CORE采用UART通信。Referring to FIG. 34 , in this embodiment, the MCU and the SOC A-core communicate via the SPI communication system, and the MCU and the M-CORE communicate via the UART.

参见图35,图35为本申请的SPI通信协议的用例图。See Figure 35, which is a use case diagram of the SPI communication protocol of the present application.

在本实施例中,本申请的SPI通信协议需要设置接口、应用层、会话层、传输层、数据链路层以及驱动层。In this embodiment, the SPI communication protocol of the present application requires setting up an interface, an application layer, a session layer, a transport layer, a data link layer and a driver layer.

参见下表1:See Table 1 below:

参见图35,本申请的SPI通信协议需要进行协议格式定义,具体定义如图35所示。Referring to FIG. 35 , the SPI communication protocol of the present application requires a protocol format definition, and the specific definition is shown in FIG. 35 .

在本实施例中,协议格式具体说明如下:In this embodiment, the protocol format is specifically described as follows:

在本实施例中,本申请的SPI通信协议需要进行状态机设计,具体设计参见图36。In this embodiment, the SPI communication protocol of the present application requires a state machine design, and the specific design is shown in Figure 36.

在本实施例中,图36所示的状态机中的各个状态说明如下:In this embodiment, each state in the state machine shown in FIG. 36 is described as follows:

状态迁移说明:State transition description:

通过本申请设计的通信协议,通过超时重发机制以及应答检测机制来确保数据传输的稳定,为保证数据稳定可靠传输,均在各个层级之间进行了不同流程的设定,经过实际车型项目验证,基于此协议设计的通信方法,满足实时性要求,可保证数据在MCU和SOC间的稳定传输不出错,可现实连续一个月运行不宕机,稳定性和准确性均满足技术要求。The communication protocol designed in this application ensures the stability of data transmission through a timeout retransmission mechanism and a response detection mechanism. Different processes are set between various levels to ensure stable and reliable data transmission. After verification by actual vehicle project, the communication method designed based on this protocol meets the real-time requirements and can ensure stable and error-free data transmission between the MCU and SOC. It can run continuously for one month without downtime, and its stability and accuracy meet the technical requirements.

在本实施例中,本申请的基于SPI通信协议的MCU与SOC通信方法包括:In this embodiment, the MCU and SOC communication method based on the SPI communication protocol of the present application includes:

MCU端与SOC端建立基于SPI通信协议的SPI通信系统数据通路;The MCU side and the SOC side establish an SPI communication system data path based on the SPI communication protocol;

SOC端以及SOC端根据所述SPI通信协议生成数据并相互发送数据。The SOC end and the SOC end generate data according to the SPI communication protocol and send the data to each other.

在本实施例中,MCU端数据发给SOC A端称之为上行数据,SOC A端数据发送给MCU端则称之为下行数据。In this embodiment, data sent from the MCU end to the SOC A end is called uplink data, and data sent from the SOC A end to the MCU end is called downlink data.

在本实施例中,首先需要建立MCU端与SOC端建立基于SPI通信协议的SPI通信系统数据通路。In this embodiment, it is first necessary to establish an SPI communication system data path based on the SPI communication protocol between the MCU end and the SOC end.

在本实施例中,通信系统数据通路建立流程:通信交互建立,由SOC端服务启动后发起,MCU端应答握手报文为单发送模式,不需要进行ACK(应答)/NACK,LiveCounter/CheckSum等通信机制确保握手阶段报文每10ms由MCU触发一次,期间无握手应答或者报文不匹配时,重新进行报文内容获取。In this embodiment, the communication system data path establishment process: communication interaction establishment is initiated after the SOC-side service is started, and the MCU-side responds to the handshake message in a single-sending mode, without the need for ACK (acknowledgement)/NACK, LiveCounter/CheckSum and other communication mechanisms to ensure that the handshake stage message is triggered by the MCU every 10ms. If there is no handshake response or the message does not match during the period, the message content is obtained again.

为了描述方便,在下述描述中会分别从MCU端以及SOC端进行描述。For the convenience of description, the following description will be made from the MCU side and the SOC side respectively.

具体而言,参见图2,以MCU端描述:Specifically, see Figure 2, which describes the MCU side:

MCU端的MCU_Vehiclelnterface(MCU端的通信协议接口)首先启动并等待SOC端启动,当接收到SOC端发送的GPIO(芯片IO引脚接口)通知后,开启通讯模式,周期性获取SOC端的A-Core,判断是否获取握手报文,若是,则发送握手应答报文给SOC端的A-Core,获取SOC端发送的报文,判断获取的报文是否为握手完成报文,若是,则判断握手完成,进入正常通信状态。The MCU_VehicleInterface (communication protocol interface on the MCU side) on the MCU side is first started and waits for the SOC side to start. After receiving the GPIO (chip IO pin interface) notification sent by the SOC side, the communication mode is turned on, and the A-Core on the SOC side is periodically obtained to determine whether a handshake message is obtained. If so, a handshake response message is sent to the A-Core on the SOC side, and the message sent by the SOC side is obtained to determine whether the obtained message is a handshake completion message. If so, the handshake is determined to be completed and the normal communication state is entered.

参见图2,以SOC端描述:See Figure 2, which describes the SOC side:

SOC端启动完成后向MCU端发送GPIO通知并开始握手,SOC端向MCU端发送握手报文,获取MCU端发送的握手应答报文,判断是否为握手应答,若是,则发送握手完成报文并进入正常通信状态。After the SOC is started, it sends a GPIO notification to the MCU and starts handshaking. The SOC sends a handshake message to the MCU, obtains the handshake response message sent by the MCU, and determines whether it is a handshake response. If so, it sends a handshake completion message and enters the normal communication state.

可以理解的是,有时候可能会出现上行通路建立异常的情况,此时,SOC服务启动,开始计时,5s无法完成握手,需要进行服务重启,重新发起握手,MCU侧,task启动后开始计时,10s无法完成握手,需要进行SOC通信服务重启,重新发起握手。It is understandable that sometimes there may be abnormalities in the establishment of the uplink channel. At this time, the SOC service is started and the timing begins. If the handshake cannot be completed within 5 seconds, the service needs to be restarted and the handshake needs to be reinitiated. On the MCU side, the timing starts after the task is started. If the handshake cannot be completed within 10 seconds, the SOC communication service needs to be restarted and the handshake needs to be reinitiated.

参见图3,以MCU端描述:See Figure 3, which describes the MCU side:

MCU端设置计时器,判断是否在预设时间(例如10秒)内握手完成,若否,则GPIO通知SOC端进行通信服务重启。The MCU sets a timer to determine whether the handshake is completed within a preset time (e.g., 10 seconds). If not, the GPIO notifies the SOC to restart the communication service.

参见图3,以SOC端描述:See Figure 3, which describes the SOC side:

SOC端设置计时器,判断是否在预设时间(例如5秒)内握手完成,若否,则进行通信服务重启。The SOC sets a timer to determine whether the handshake is completed within a preset time (eg, 5 seconds). If not, the communication service is restarted.

在本实施例中,本申请的数据包括心跳包数据。In this embodiment, the data of the present application includes heartbeat packet data.

当是心跳包数据时,本申请具体如下:When it is heartbeat packet data, the application is as follows:

通信交互建立后,由SOC端服务定周期(1s)发送心跳包,心跳包需要包含LiveCounter字段(0-0xF),心跳报文为单发送模式,不需要进行ACK/NACK,LiveCounter/CheckSum等通信机制确保。心跳包LiveCounter错误不需要链路层进行错误记录和重启。After the communication interaction is established, the SOC service sends a heartbeat packet at a fixed period (1s). The heartbeat packet needs to contain the LiveCounter field (0-0xF). The heartbeat message is a single-send mode and does not require ACK/NACK, LiveCounter/CheckSum and other communication mechanisms to ensure. If the LiveCounter of the heartbeat packet is wrong, the link layer does not need to record the error and restart.

参见图4,在本实施例中,以MCU端描述:Referring to FIG. 4 , in this embodiment, the MCU side is used for description:

MCU_Vehiclelnterface在正常通信状态时,提供共通信状态给MCU看门狗并开启通讯模式,周期获取SOC的A-Core数据,判断获取的A-Core数据是否为心跳包,如果是,则通知MCU的看门狗,MCU的看门狗重置计时器。When MCU_VehicleInterface is in normal communication state, it provides the common communication state to the MCU watchdog and starts the communication mode, periodically obtains the A-Core data of the SOC, and determines whether the obtained A-Core data is a heartbeat packet. If so, it notifies the MCU watchdog and the MCU watchdog resets the timer.

参见图5,在本实施例中,以SOC端描述:Referring to FIG. 5 , in this embodiment, the SOC end is used for description:

SOC的A-Core将正常通讯状态发送给A-Core的看门狗。The A-Core of the SOC sends the normal communication status to the watchdog of the A-Core.

当SOC的A-Core的看门狗出发心跳报文发送时,SOC的A-Core更新心跳包中LiveCounter字段并发送给MCU。When the watchdog of the SOC's A-Core starts sending a heartbeat message, the SOC's A-Core updates the LiveCounter field in the heartbeat packet and sends it to the MCU.

参见图5(在进行描述时,只描述与图4中不一样的地方),在本实施例中,如果SPI通信系统心跳包流程(异常),例如,MCU端30s未收到有效心跳包(无通信,或者LiveCounter无变化)时,通过EcuM触发SOC端重启。Referring to FIG. 5 (when describing, only the differences from FIG. 4 are described), in this embodiment, if the SPI communication system heartbeat packet process (abnormal), for example, the MCU end does not receive a valid heartbeat packet for 30 seconds (no communication, or LiveCounter does not change), the SOC end is triggered to restart through EcuM.

在本实施例中,当数据为周期型报文且为上行数据时,MCU各modules调用SPI通信系统接口进行周期型报文数据的更新,周期型报文为静态固定size buffer,接口调用后覆盖填充,无需判断旧数据是否发送完成接口中需要实现数据变化判断,接口调用计数管理,周期型报文协议中,需要包含数据变化字段,接口调用Counter字段,用于确认APP与本系统的调用关系。In this embodiment, when the data is a periodic message and is uplink data, each module of the MCU calls the SPI communication system interface to update the periodic message data. The periodic message is a static fixed size buffer, which is overwritten and filled after the interface is called. There is no need to judge whether the old data has been sent. The interface needs to implement data change judgment and interface call count management. The periodic message protocol needs to include a data change field and an interface call Counter field to confirm the calling relationship between the APP and this system.

参见图6,以MCU端描述:See Figure 6, which describes the MCU side:

MCU_Modules(MCU模块调度)根据运行周期,周期性打包数据并调用数据更新接口;MCU_Modules (MCU module scheduling) periodically packages data and calls the data update interface according to the operating cycle;

MCU_Vehiclelnterface更新接口调用次数计数器,判断数据是否与上次相同,若否,则设定数据变化flg为TRUE,并更新周期型报文数据buff和管理数据。MCU_VehicleInterface updates the interface call count counter to determine whether the data is the same as the last time. If not, it sets the data change flg to TRUE and updates the periodic message data buff and management data.

在本实施例中,周期型报文,按照设计好的发送周期进行定周期发布(静态设计),周期型报文,需要有初始发送时间和周期发送时间两个属性,第一次发送时,使用初始发送时间作为判断是否到达发送周期的标识,发送一次后,重载为周期发送时间,用于启动时的周期报文快速发送。通过静态设计,平均各周期报文发送时间间隔,同一时刻,两条及两条以上周期型报文满足发行要求时,根据报文ID仲裁发送顺序,未发送报文,待链路层下一次调度发送.SPI驱动内部,发送时,需要进行发布buffer的镜像(数据拷贝时DI),保证数据传输过程中,数据buffer不被更新。In this embodiment, the periodic message is released periodically according to the designed sending cycle (static design). The periodic message needs to have two attributes: initial sending time and periodic sending time. When sending for the first time, the initial sending time is used as an identifier to determine whether the sending cycle has been reached. After sending once, it is reloaded as the periodic sending time for fast sending of periodic messages at startup. Through static design, the average sending time interval of each periodic message is used. At the same time, when two or more periodic messages meet the issuance requirements, the sending order is arbitrated according to the message ID. If the message is not sent, it will be sent when the link layer schedules the next time. Inside the SPI driver, when sending, it is necessary to mirror the release buffer (DI when copying data) to ensure that the data buffer is not updated during data transmission.

参见图7,在本实施例中,以MCU端描述:Referring to FIG. 7 , in this embodiment, the MCU side is used for description:

MCU_Vehiclelnterface与SOC建立通信后,对周期报文进行遍历确认是否达到发送周期,若是,则更新数据中的checksum字段,把整理后的数据(周期型报文)发送给SOC的A_Core并更新发送时间以及发送状态。After MCU_VehicleInterface establishes communication with SOC, it traverses the periodic message to confirm whether the sending cycle is reached. If so, it updates the checksum field in the data, sends the sorted data (periodic message) to A_Core of SOC, and updates the sending time and sending status.

参见图7,在本实施例中,以SOC端描述:Referring to FIG. 7 , in this embodiment, the SOC end is used for description:

SOC端获取到周期型报文后,进行数据校验,若校验成功,则周期数据计时重置并进行第一数据分发。After the SOC obtains the periodic message, it performs data verification. If the verification is successful, the periodic data timing is reset and the first data distribution is performed.

在本实施例中,SPI通信系统上行数据发送流程(周期型报文事件触发):周期型报文,针对周期较大的周期型报文允许设定为周期事件型,事件触发后,在下一传输周期内,当作周期到处理,待发送完成后重新进行周期计时。In this embodiment, the uplink data sending process of the SPI communication system (triggered by periodic message event): periodic messages with larger periods are allowed to be set as periodic event types. After the event is triggered, it is treated as a period in the next transmission cycle, and the cycle timing is restarted after the sending is completed.

参见图8,图8中的内容为图7余图6的组合。See Figure 8. The content in Figure 8 is a combination of Figure 7 and Figure 6.

参见图9,在本实施例中,当checksum异常时,舍弃该报文数据Referring to FIG. 9 , in this embodiment, when the checksum is abnormal, the message data is discarded.

在本实施例中,当LiveCounter异常时,则重启SOC端的通信进程。In this embodiment, when the LiveCounter is abnormal, the communication process on the SOC side is restarted.

具体而言,参见图10(仅对SOC端的LiveCounter判断进行描述)。Specifically, see FIG. 10 (only the LiveCounter determination at the SOC end is described).

SOC端判断LiveCounter是否有变化,若否,则判断LiveCounter无变化记录是否超过5次,若是,则重启。The SOC determines whether the LiveCounter has changed. If not, it determines whether the LiveCounter has no change record for more than 5 times. If so, it restarts.

SOC端判断LiveCounter是否有变化,若是,则判断变化是否小于3次,否,则记录LiveCounter异常,重复本条判断,若记录LiveCounter异常超过5次,则重启。The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If not, it records the LiveCounter exception and repeats this judgment. If the LiveCounter exception is recorded more than 5 times, it restarts.

SOC端判断LiveCounter是否有变化,若是,则判断变化是否小于3次,若是,则判断LiveCounter无异常,数据有效。The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If so, it determines that the LiveCounter has no abnormality and the data is valid.

参见图11,在本实施例中,当出现TimeOut异常时,进行重启。Referring to FIG. 11 , in this embodiment, when a TimeOut exception occurs, a restart is performed.

参见图12(只描述与图8不同部分),在本实施例中,SOC端在进行第一数据分发时,SOC端的A_Core的Vehiclelnterface通过进程间通信机制分发给SOC端的A_Core的Modules。Referring to FIG. 12 (only describing the parts different from FIG. 8 ), in this embodiment, when the SOC side performs the first data distribution, the VehicleInterface of A_Core of the SOC side is distributed to the Modules of A_Core of the SOC side through the inter-process communication mechanism.

在本实施例中,本申请的数据包括事件型报文,当数据为事件型报文且为上行数据时,通信交互建立后,各模块根据需要调用数据更新接口,根据各事件报文属性,进行链表管理。In this embodiment, the data of the present application includes event-type messages. When the data is an event-type message and is uplink data, after the communication interaction is established, each module calls the data update interface as needed and performs linked list management according to the attributes of each event message.

参见图13,在本实施例中,MCU端的Modules根据业务逻辑,调用数据更新接口。MCU端的Vehiclelnterface更新接口调用次数计数器,判断是否允许覆盖未发送数据,若是,则在待发送数据链表中查同ID事件报文,若判断有待发送同ID事件报文,则在链表中更新同ID事件报文并更新待发送数据链表。Referring to FIG. 13 , in this embodiment, the Modules on the MCU side call the data update interface according to the business logic. The VehicleInterface on the MCU side updates the interface call count counter to determine whether it is allowed to overwrite the unsent data. If so, the same ID event message is checked in the to-be-sent data linked list. If it is determined that there is an event message with the same ID to be sent, the same ID event message is updated in the linked list and the to-be-sent data linked list is updated.

参见图14,在本实施例中,通信系统上行数据发送流程(事件型报文)具体如下:Referring to FIG. 14 , in this embodiment, the communication system uplink data transmission process (event-type message) is specifically as follows:

以MCU端为例:Take the MCU side as an example:

MCU端的Vehiclelnterface握手完成后,定周期进行检测,对待发送链表进行检索,判断是否有数据要发送,若是,则更新待发送数据中的LiveCounter字段以及checksum字段,把整理后的数据(即事件型报文)发送给SOC并把报文ID放入发送完的待验证链表。After the VehicleInterface handshake on the MCU side is completed, a detection is performed periodically, and the to-be-sent linked list is searched to determine whether there is data to be sent. If so, the LiveCounter field and checksum field in the to-be-sent data are updated, and the sorted data (i.e., event-type message) is sent to the SOC and the message ID is put into the sent to-be-verified linked list.

以SOC端为例:Take the SOC end as an example:

SOC端对LiveCounter字段以及checksum字段进行校验,若校验成功,则进行第二数据分发。The SOC verifies the LiveCounter field and the checksum field. If the verification succeeds, the second data distribution is performed.

参见图15(仅描述与图14区别部分),在本实施例中,若事件型报文checksum异常,则checksum异常记录NACK数据插入待发送链表。Referring to FIG. 15 (only describing the difference from FIG. 14 ), in this embodiment, if the checksum of the event-type message is abnormal, the checksum abnormality record NACK data is inserted into the to-be-sent linked list.

参见图16(仅描述与图14区别部分),在本实施例中,若事件型报文LiveCounter异常,则SOC端判断LiveCounter是否有变化,若否,则判断LiveCounter无变化记录是否超过5次,若是,则重启。Refer to Figure 16 (only the differences from Figure 14 are described). In this embodiment, if the event-type message LiveCounter is abnormal, the SOC determines whether the LiveCounter has changed. If not, it determines whether the LiveCounter has no change record for more than 5 times. If so, it restarts.

SOC端判断LiveCounter是否有变化,若是,则判断变化是否小于3次,否,则记录LiveCounter异常,重复本条判断,若记录LiveCounter异常超过5次,则重启。The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If not, it records the LiveCounter exception and repeats this judgment. If the LiveCounter exception is recorded more than 5 times, it restarts.

SOC端判断LiveCounter是否有变化,若是,则判断变化是否小于3次,若是,则判断LiveCounter无异常,数据有效。The SOC determines whether the LiveCounter has changed. If so, it determines whether the change is less than 3 times. If so, it determines that the LiveCounter has no abnormality and the data is valid.

参见图17,在本实施例中,当出现ACK/NACK超时异常时,进行重启。Referring to FIG. 17 , in this embodiment, when an ACK/NACK timeout exception occurs, a restart is performed.

参见图18,在本实施例中,SPI通信系统上行数据A-CORE分发数据给其他模块流程(事件型报文)。Referring to FIG. 18 , in this embodiment, the SPI communication system uplink data A-CORE distributes data to other module processes (event-type messages).

参见图18,在本实施例中,SOC端在进行第二数据分发时,SOC端的A_Core的Vehiclelnterface通过进程间通信机制分发给SOC端的A_Core的Modules。Referring to FIG. 18 , in this embodiment, when the SOC side performs the second data distribution, the VehicleInterface of the A_Core of the SOC side is distributed to the Modules of the A_Core of the SOC side through the inter-process communication mechanism.

参见图19,在本实施例中,SPI通信系统上行数据发送流程(ACK)具体如下:Referring to FIG. 19 , in this embodiment, the uplink data transmission process (ACK) of the SPI communication system is as follows:

以MCU端为例:Take the MCU side as an example:

获取SOC端传递的报文类型;Get the message type transmitted by the SOC end;

判断是否有ACK应答,若是,则遍历带验证链表找到相同ID的元素,把该元素从链表中清除。Determine whether there is an ACK response. If so, traverse the verification linked list to find the element with the same ID and remove the element from the linked list.

参见图20,在本实施例中,通信系统上行数据发送流程(NACK)具体如下:Referring to FIG. 20 , in this embodiment, the uplink data transmission process (NACK) of the communication system is specifically as follows:

以MCU端为例:Take the MCU side as an example:

获取SOC所传递的报文类型,判断是否获取到NACK应答,若是,则遍历带验证链表找到相同ID的元素并更新retry次数,若retry次数超过3次,则重启通信,若retry次数未超过3次,则把该元素从链表中清除并追加到待发送链表中。Get the message type transmitted by the SOC and determine whether a NACK response is obtained. If so, traverse the verification linked list to find the element with the same ID and update the retry count. If the retry count exceeds 3 times, restart the communication. If the retry count does not exceed 3 times, clear the element from the linked list and append it to the linked list to be sent.

参见图21至30,在本实施例中,上述的周期型报文、事件型报文同时包括下行数据的发送、分发等流程,其发送过程大体与上行数据相同,只是发送方与接收方与上行数据相反,例如,周期型报文在上行数据时,SOC端需要做的事情在下行数据时MCU端来做,而上行数据时MCU端做的事情在下行数据中由SOC端来做,详情请参看图21至32。Referring to Figures 21 to 30, in this embodiment, the above-mentioned periodic messages and event-type messages also include processes such as sending and distributing downlink data. The sending process is generally the same as that of uplink data, except that the sender and the receiver are opposite to those of uplink data. For example, when the periodic message is uplink data, what the SOC side needs to do is done by the MCU side in downlink data, and what the MCU side does in uplink data is done by the SOC side in downlink data. For details, please refer to Figures 21 to 32.

参见图32,在本实施例中,还包括MCU数据发送SOC,具体如下:Referring to FIG. 32 , in this embodiment, an MCU data transmission SOC is also included, as follows:

消息发送之前,需要把Checksum,Livecounter加到包中。其中Livecounter使用4bit,每个Group使用独立的Livecounter编号,0为无效,1~15有效,编号从1开始,循环使用。Before sending a message, you need to add Checksum and Livecounter to the packet. Livecounter uses 4 bits, and each group uses an independent Livecounter number. 0 is invalid, and 1 to 15 are valid. The number starts from 1 and is used cyclically.

Checksum使用16bit,算法为标准算法。The checksum uses 16 bits and the algorithm is the standard algorithm.

另外,数据需要以10ms的周期重复发送,每个新周期都要更新Livecounter。In addition, the data needs to be sent repeatedly in a period of 10ms, and the Livecounter needs to be updated in each new period.

参见图33,在本实施例中,还包括MCU数据接收,具体如下:对需要通过SPI/UART发送的数据,以中断的方式处理接收数据,把数据从DMA搬到系统内容。消息处理线程需要以10ms的周期,对数据进行处理。Referring to FIG. 33 , in this embodiment, MCU data reception is also included, specifically as follows: for data that needs to be sent via SPI/UART, the received data is processed in an interrupt manner, and the data is moved from DMA to the system content. The message processing thread needs to process the data in a cycle of 10ms.

本申请设计及实现了一套完整的通信协议,通过制定数据优先级机制,超时重发机制,以及应答检测机制来确保数据传输的稳定,为保证数据稳定可靠传输,均在各个层级之间进行了不同流程的设定,经过实际车型项目验证,基于此协议设计的通信方法,满足实时性要求,可保证数据在MCU和SOC间的稳定传输不出错,可现实连续一个月运行不宕机,稳定性和准确性均满足技术要求。This application designs and implements a complete set of communication protocols, which ensures the stability of data transmission by formulating data priority mechanism, timeout retransmission mechanism, and response detection mechanism. In order to ensure stable and reliable data transmission, different processes are set between various levels. After verification by actual vehicle project, the communication method designed based on this protocol meets the real-time requirements, and can ensure the stable transmission of data between MCU and SOC without errors. It can run continuously for one month without downtime, and its stability and accuracy meet the technical requirements.

本申请设计并实现了一种通信消息格式,其中包括数据头、消息ID、消息类型、分组ID、报文通信计数、触发计数、数据长度、数据包CRC8校验算法。The present application designs and implements a communication message format, which includes a data header, a message ID, a message type, a packet ID, a message communication count, a trigger count, a data length, and a data packet CRC8 check algorithm.

本申请通过层次划分,明确各层级的职责及功能,使各层级之间各司其职,互不干扰,以达到数据稳定传输。This application clarifies the responsibilities and functions of each level through hierarchical division, so that each level can perform its duties without interfering with each other, so as to achieve stable data transmission.

本申请通过制定数据优先级机制,超时重发机制,以及应答检测机制来确保数据传输的稳定性与可靠性。以防止因数据传输错误导致仪表出现误显示等问题。This application ensures the stability and reliability of data transmission by formulating data priority mechanism, timeout retransmission mechanism, and response detection mechanism, so as to prevent problems such as instrument erroneous display caused by data transmission errors.

此外,显然“包括”一词不排除其他单元或步骤。装置权利要求中陈述的多个单元、模块或装置也可以由一个单元或总装置通过软件或硬件来实现。In addition, it is obvious that the word "comprising" does not exclude other units or steps. Multiple units, modules or devices stated in the device claims can also be implemented by one unit or the overall device through software or hardware.

虽然,上文中已经用一般性说明及具体实施方案对本发明作了详尽的描述,但在本发明基础上,可以对之作一些修改或改进,这对本领域技术人员而言是显而易见的。因此,在不偏离本发明精神的基础上所做的这些修改或改进,均属于本发明要求保护的范围。Although the present invention has been described in detail above with general descriptions and specific embodiments, it is obvious to those skilled in the art that some modifications or improvements can be made to the present invention. Therefore, these modifications or improvements made without departing from the spirit of the present invention all fall within the scope of protection claimed by the present invention.

Claims (10)

1. The MCU and SOC communication method based on the SPI communication protocol is characterized by comprising the following steps of:
an SPI communication system data path based on an SPI communication protocol is established between the MCU end and the SOC end;
and the SOC end generate data according to the SPI communication protocol and mutually send the data.
2. The SPI communication protocol-based MCU and SOC communication method of claim 1, wherein the data includes a heartbeat packet, and when the data is a heartbeat packet and is uplink data, the SPI communication protocol-based MCU and SOC communication method includes:
the SOC end generates and sends a heartbeat packet to the MCU end based on the SPI communication protocol period, wherein the heartbeat packet comprises LiveCounter fields, and the heartbeat packet is in a single sending mode;
and the MCU end acquires the heartbeat packet and informs the watchdog of the MCU end to update.
3. The SPI communication protocol-based MCU and SOC communication method of claim 2, wherein when the data is a heartbeat packet and is uplink data, the SPI communication protocol-based MCU and SOC communication method further comprises:
And triggering the SOC to restart through EcuM when the MCU end does not receive the effective heartbeat packet within the preset time.
4. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 3, wherein the data includes a periodic message, and when the data is a periodic message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol includes:
The MCU end periodically generates a periodic message to be sent according to the operation period, wherein the periodic message comprises LiveCounter fields and a checksum field;
the MCU end sends a periodic message to the SOC end;
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the check is successful, the SOC end distributes data.
5. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 4, wherein when the data is a periodic message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol further comprises:
and the SOC end receives the periodic message and checks LiveCounter fields and a checksum field in the periodic message, and if LiveCounter fields fail to check or are overtime, the SOC communication process is restarted.
6. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 5, wherein when the data is a periodic message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol comprises:
And the SOC end receives the periodic message and checks LiveCounter fields and checksum fields in the periodic message, and if the checksum is abnormal, the message data is discarded.
7. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 6, wherein the data includes an event type message, and when the data is an event type message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol includes:
The method comprises the steps that an MCU end generates an event type message to be sent, wherein the event type message comprises LiveCounter fields and a checksum field;
the MCU end sends an event type message to be sent to the SOC end;
and the SOC receives the event type message, checks LiveCounter fields and checksum fields in the event type message, and distributes data if the check is successful.
8. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 7, wherein when the data is an event type message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol comprises:
And the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if the checksum fields fail to check, the NACK data is recorded and inserted into a linked list to be sent.
9. The method for communicating with an MCU and an SOC based on an SPI communication protocol according to claim 8, wherein when the data is an event type message and is uplink data, the method for communicating with an MCU and an SOC based on an SPI communication protocol comprises:
and the SOC end receives the event type message and checks LiveCounter fields and checksum fields in the event type message, and if LiveCounter fields fail to check, the record is abnormal.
10. A method for constructing an SPI communication protocol for use in the MCU and SOC communication method based on the SPI communication protocol according to any one of claims 1 to 9, the method comprising:
Setting an interface, an application layer, a session layer, a transmission layer, a data link layer and a driving layer;
Defining a protocol format;
The state machine is designed.
CN202410024917.9A 2024-01-08 2024-01-08 A communication method between MCU and SOC based on SPI communication protocol and protocol construction method Pending CN117978785A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410024917.9A CN117978785A (en) 2024-01-08 2024-01-08 A communication method between MCU and SOC based on SPI communication protocol and protocol construction method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410024917.9A CN117978785A (en) 2024-01-08 2024-01-08 A communication method between MCU and SOC based on SPI communication protocol and protocol construction method

Publications (1)

Publication Number Publication Date
CN117978785A true CN117978785A (en) 2024-05-03

Family

ID=90850788

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410024917.9A Pending CN117978785A (en) 2024-01-08 2024-01-08 A communication method between MCU and SOC based on SPI communication protocol and protocol construction method

Country Status (1)

Country Link
CN (1) CN117978785A (en)

Similar Documents

Publication Publication Date Title
US5163055A (en) Communications system using a fault tolerant protocol
JP2707529B2 (en) Data communication system
EP0374132B1 (en) Local area network for digital data processing system
US6574770B1 (en) Error-correcting communication method for transmitting data packets in a network communication system
US4975904A (en) Local area network for digital data processing system including timer-regulated message transfer arrangement
US4975905A (en) Message transmission control arrangement for node in local area network
US4823122A (en) Local area network for digital data processing system
US5933435A (en) Optimized method of data communication and system employing same
EP0377136A2 (en) Adaptive data link protocol
JPH053941B2 (en)
CN114125021A (en) Terminal information issuing system based on Netty message drive
US6452946B1 (en) Apparatus and method for improving performance in master and slave communications systems
JPH09160858A (en) Data retransmission method and server
US7191356B2 (en) Method for asynchronous support of fault-tolerant and adaptive communication
US7178051B2 (en) Method for synchronous support of fault-tolerant and adaptive communication
CN117978785A (en) A communication method between MCU and SOC based on SPI communication protocol and protocol construction method
WO2024131009A1 (en) Inter-chip communication method and storage medium
JPH114259A (en) Virtual connection communication equipment and communication method
CN111597017A (en) Synchronous control method for double microprocessors
JPH0830523A (en) How to communicate online messages
JPS6172432A (en) Communication control method
KR950001520B1 (en) Signalling terminal group bus communication protocol of message transfer part using common channel signalling no.7
JPH09326782A (en) Serial communication method
CN118677865A (en) PDCP packet transmission method, PDCP packet transmission system, electronic device and storage medium
EP2405627A1 (en) Method for operating a remote procedure call handler in a client and a server and computer system comprising the same

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination