A dual-machine communication method, device and system
By setting a write queue and a read queue in the application processor, transmitting instruction information to the microcontroller unit according to the communication mode, and storing instruction information in the read queue, the problem of inflexible communication methods in the prior art is solved, and orderly processing and flexible settings are realized under different communication modes.
Patent Information
- Application Number
- CN202111143543.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-28
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2041-09-28
AI Technical Summary
In the communication with the AP, the existing MCU has different processing methods for synchronous communication and asynchronous communication, which leads to the need to develop separately for each communication method during development, and it is impossible to achieve flexible settings of the communication method.
By setting a write queue and a read queue in the application processor, instruction information is transmitted to the microcontroller unit according to the current communication mode (simultaneous communication or asynchronous communication), and instruction information is stored in the read queue until the corresponding processing result is received and then deleted from the read queue.
It realizes orderly processing and flexible setting of instruction information in different communication modes, ensuring that each instruction information can receive the processing results of the microcontroller unit, thereby improving the flexibility and efficiency of communication.
Smart Images

Figure CN113868164B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a dual-machine communication method, device and system. Background Art
[0002] In order to reduce power consumption, current mobile devices use a dual-machine architecture of an application processor (AP) and a microcontroller unit (MCU) to implement basic functions. Mobile devices such as smart watches, smart bracelets, augmented reality (AR) and other devices have smaller battery capacities than other mobile products due to size limitations. AP has better processing performance, but higher power consumption; MCU, as a microcontroller unit, consumes less power, so the dual-machine mode of AP and MCU can better control power consumption while meeting processing requirements, achieving longer-lasting use after a single charge. AR products can also use this architecture to control power consumption due to their high power consumption.
[0003] At present, most MCUs use a "question-and-answer" serial synchronous communication method. In addition, some MCUs can use asynchronous communication to interact with APs. However, the processing methods of synchronous communication and asynchronous communication are completely different, and separate development is required for each MCU. After development, the communication method between AP and MCU is fixed to synchronous communication or asynchronous communication, and flexible setting of the communication method cannot be achieved.
[0004] It can be seen that how to achieve flexible setting of the communication mode is a problem that needs to be solved by those skilled in the art. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a dual-machine communication method, device and system, which can realize flexible setting of the communication mode.
[0006] In order to solve the above technical problems, the present application provides a dual-machine communication method, including:
[0007] The received instruction information is stored in the write queue;
[0008] Based on the current communication mode, the instruction information is transmitted to the micro control unit; and the instruction information is stored in the read queue; wherein the communication mode includes synchronous communication and asynchronous communication;
[0009] In the case that instruction information exists in the read queue, a processing result matching the target instruction information is read from the micro control unit, and the target instruction information is deleted from the read queue.
[0010] Optionally, when the current communication mode is synchronous communication, transmitting instruction information to the micro control unit based on the current communication mode includes:
[0011] Transmitting a command message to the first-in first-out queue of the microcontroller unit;
[0012] Correspondingly, when there is instruction information in the read queue, reading a processing result matching the target instruction information from the micro control unit and deleting the target instruction information from the read queue includes:
[0013] Using a read thread to read a processing result matching the target instruction information from a first-in first-out queue of the microcontroller unit;
[0014] The target instruction information is deleted from the read queue.
[0015] Optionally, after transmitting a piece of instruction information to the first-in-first-out queue of the micro control unit, the method further includes:
[0016] The next instruction information is read from the write queue, and the next instruction information is stored in a preset cache area.
[0017] Optionally, when the current communication mode is asynchronous communication, transmitting the instruction information to the micro control unit based on the current communication mode includes:
[0018] transmitting the instruction information to the instruction queue of the micro control unit in sequence;
[0019] Correspondingly, when there is instruction information in the read queue, reading a processing result matching the target instruction information from the micro control unit and deleting the target instruction information from the read queue includes:
[0020] Determine whether there is instruction information in the read queue;
[0021] If the read queue contains instruction information, the processing result is read from the data queue of the micro control unit by using the read thread;
[0022] Determining whether there is target instruction information matching the processing result in the read queue;
[0023] When target instruction information matching the processing result exists in the read queue, the target instruction information is deleted from the read queue until there is no instruction information in the read queue, and then the operation is terminated.
[0024] Optionally, before determining whether the read queue contains instruction information, the method further includes:
[0025] Determining whether an interrupt request for reading data transmitted by the micro control unit is received;
[0026] If an interrupt request for reading data transmitted by the micro control unit is received, the step of determining whether there is instruction information in the read queue is executed.
[0027] Optionally, after sequentially transmitting the instruction information to the instruction queue of the micro control unit, the method further includes:
[0028] If an interrupt request for stopping sending instructions transmitted by the micro control unit is received, the transmission of instruction information to the instruction queue of the micro control unit is stopped.
[0029] Optionally, before deleting the target instruction information from the read queue, the method further includes:
[0030] Determining whether the target instruction information is an open instruction;
[0031] If the target instruction information is an on instruction, the target instruction information is retained in the read queue; until an off instruction is received, the step of deleting the target instruction information from the read queue is performed.
[0032] Optionally, after reading the processing result matching the target instruction information from the micro control unit, the method further includes:
[0033] Parsing the target instruction information according to the instruction format corresponding to the current communication mode to obtain the initiator address of the target instruction information;
[0034] The processing result of matching the target instruction information is transmitted to the initiator corresponding to the initiator address.
[0035] The embodiment of the present application also provides a dual-machine communication device, including a storage unit, a transmission unit, a reading unit and a deletion unit;
[0036] The storage unit is used to store the received instruction information in the write queue;
[0037] The transmission unit is used to transmit the instruction information to the micro control unit based on the current communication mode;
[0038] The storage unit is used to store the instruction information in a read queue; wherein the communication mode includes synchronous communication and asynchronous communication;
[0039] The reading unit is used to read the processing result matching the target instruction information from the micro control unit when the instruction information exists in the read queue;
[0040] The deleting unit is used to delete the target instruction information from the read queue.
[0041] Optionally, when the current communication mode is synchronous communication, the transmission unit is used to transmit a piece of instruction information to a first-in first-out queue of the micro control unit;
[0042] Correspondingly, the reading unit is used to read the processing result matching the target instruction information from the first-in first-out queue of the micro control unit by using a reading thread;
[0043] The deleting unit is used to delete the target instruction information from the read queue.
[0044] Optionally, a cache unit is also included;
[0045] The cache unit is used to read the next instruction information from the write queue after the step of transmitting a piece of instruction information to the first-in-first-out queue of the micro control unit, and store the next instruction information in a preset cache area.
[0046] Optionally, when the current communication mode is asynchronous communication, the transmission unit is used to transmit the instruction information to the instruction queue of the micro control unit in sequence;
[0047] Correspondingly, the reading unit is used to determine whether there is instruction information in the read queue; if there is instruction information in the read queue, read the processing result from the data queue of the micro control unit using the read thread; determine whether there is target instruction information matching the processing result in the read queue;
[0048] The deleting unit is used to delete the target instruction information from the read queue when there is target instruction information matching the processing result in the read queue; and terminate the operation when there is no instruction information in the read queue.
[0049] Optionally, before determining whether the read queue has instruction information, a determining unit is further included;
[0050] The judgment unit is used to judge whether an interrupt request for reading data transmitted by the micro control unit is received; if an interrupt request for reading data transmitted by the micro control unit is received, the reading unit is triggered to execute the step of judging whether there is instruction information in the read queue.
[0051] Optionally, a stopping unit is further included;
[0052] The stopping unit is used to stop transmitting instruction information to the instruction queue of the micro control unit if an interrupt request for stopping sending instructions transmitted by the micro control unit is received.
[0053] Optionally, it also includes a judging unit and a retaining unit;
[0054] The judging unit is used to judge whether the target instruction information is an open instruction before deleting the target instruction information from the read queue;
[0055] The retaining unit is used to retain the target instruction information in the read queue if the target instruction information is an on instruction; until an off instruction is received, the deleting unit is triggered to execute the step of deleting the target instruction information from the read queue.
[0056] Optionally, a parsing unit is also included;
[0057] The parsing unit is used to parse the target instruction information according to the instruction format corresponding to the current communication mode to obtain the initiator address of the target instruction information;
[0058] The transmission unit is used to transmit the processing result of the target instruction information matching to the initiator corresponding to the initiator address.
[0059] The embodiment of the present application also provides a dual-machine communication system, including an application processor and a micro control unit; wherein the application processor is provided with a read queue and a write queue; the communication mode between the application processor and the micro control unit includes synchronous communication and asynchronous communication; under synchronous communication, the micro control unit sets a queue; under asynchronous communication, the micro control unit sets a queue for storing instructions and a queue for storing data;
[0060] The application processor is connected to the micro control unit, and is used to store the received instruction information in the write queue; based on the current communication mode, transmit the instruction information to the micro control unit; and store the instruction information in the read queue; when there is instruction information in the read queue, read the processing result matching the target instruction information from the micro control unit, and delete the target instruction information from the read queue;
[0061] The micro control unit is used to perform corresponding processing according to the instruction information when receiving the instruction information transmitted by the application processor, and store the processing result in a queue corresponding to the current communication mode.
[0062] It can be seen from the above technical solution that the received instruction information is stored in the write queue; based on the current communication mode, the instruction information is transmitted to the micro control unit; the communication mode may include synchronous communication and asynchronous communication, and the way of transmitting instruction information in different communication modes is different, so the instruction information can be transmitted in the way required by the current communication mode. In order to realize the orderly processing of instruction information in different communication modes, the instruction information can be stored in the read queue after the instruction information is transmitted to the micro control unit. The instruction information stored in the read queue may be the instruction information that has been transmitted to the micro control unit, but the processing result generated by the micro control unit has not been received. Therefore, when there is instruction information in the read queue, it means that the processing result corresponding to the instruction information has not been received. At this time, the processing result matching the target instruction information can be read from the micro control unit, and the target instruction information can be deleted from the read queue. This communication mechanism can meet the requirements of both synchronous communication and asynchronous communication, so that the communication mode can be flexibly set. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0064] Figure 1 A flow chart of a dual-machine communication method provided in an embodiment of the present application;
[0065] Figure 2 A schematic diagram of the structure of a dual-machine communication device provided in an embodiment of the present application;
[0066] Figure 3 A schematic diagram of the structure of a dual-machine communication system provided in an embodiment of the present application. DETAILED DESCRIPTION
[0067] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0068] The terms "including" and "having" and any variations thereof in the specification and claims of this application and the above drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0069] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0070] Next, a dual-machine communication method provided by an embodiment of the present application is described in detail. Figure 1 A flow chart of a dual-machine communication method provided in an embodiment of the present application, the method comprising:
[0071] S101: Store the received instruction information into a write queue.
[0072] In the embodiment of the present application, the dual-machine communication between the application processor (AP) and the micro control unit (MCU) is taken as an example. The application processor can realize the interaction with the external device, and the micro control unit can be used to perform corresponding processing based on the instruction information transmitted by the application processor.
[0073] In order to achieve orderly processing of data tasks, a read queue and a write queue are respectively set in the application processor, and a corresponding read thread is set for the read queue and a corresponding write thread is set for the write queue.
[0074] The instruction information may be a data read instruction or a data write instruction, and the specific form of the instruction information is not limited here.
[0075] Considering that the number of instruction information transmitted by the external device may be large, in an embodiment of the present application, the instruction information can be uniformly stored in a write queue.
[0076] S102: Based on the current communication mode, transmit instruction information to the micro control unit; and store the instruction information in a read queue.
[0077] The communication mode between the AP and the MCU may include synchronous communication and asynchronous communication.
[0078] In synchronous communication mode, the microcontroller unit has only one first-in-first-out queue, which is used to store both data and instruction information. Therefore, the microcontroller unit can only receive one instruction information at a time for processing. When the microcontroller unit receives multiple instruction information, it may cause the loss of instruction information or confusion in processing. Therefore, in synchronous communication mode, the application processor can only transmit one instruction information to the microcontroller unit at a time, and after receiving the processing result of the instruction information feedback from the microcontroller unit, it will transmit the next instruction information to the microcontroller unit.
[0079] In the asynchronous communication mode, the microcontroller unit contains two queues, a data queue for storing data and a command queue for storing command information, so the microcontroller unit can receive multiple command information at a time. Therefore, in the asynchronous communication mode, the application processor can transmit multiple command information to the microcontroller unit in sequence.
[0080] There may be multiple instruction information stored in the write queue of the application processor. For each instruction information, the application processor indicates that the instruction information has been processed only after receiving the processing result fed back by the micro-control unit. After the application processor reads the instruction information from the write queue and sends it to the micro-control unit, the instruction information no longer exists in the write queue. If the application processor transmits multiple instruction information to the micro-control unit, the application processor cannot ensure that the micro-control unit feeds back the processing result for each instruction information. Therefore, in an embodiment of the present application, after the application processor reads the instruction information from the write queue and sends it to the micro-control unit, the instruction information can be stored in its own read queue, so that it can be matched with the instruction information in the read queue after receiving the processing result later, thereby ensuring that each instruction information can receive the processing result fed back by the micro-control unit.
[0081] S103: When there is instruction information in the read queue, a processing result matching the target instruction information is read from the micro control unit, and the target instruction information is deleted from the read queue.
[0082] In actual applications, the application processor actively reads the processing results from the microcontroller unit in the dual-machine communication mode. Therefore, if there is instruction information in the read queue of the application processor, it means that the application processor has not received the processing result corresponding to the instruction information. At this time, the application processor can actively read the processing result from the microcontroller unit. For the sake of distinction, the instruction information matched by the processing result can be called the target instruction information. When the processing result matching the target instruction information is read, the target instruction information can be deleted from the read queue.
[0083] In a specific implementation, an instruction information and a processing result corresponding to the instruction information often contain the same identifier, for example, the same source address, etc. Therefore, the instruction information matched by the processing result can be identified based on the identifiers contained in the instruction information and the processing result.
[0084] It can be seen from the above technical solution that the received instruction information is stored in the write queue; based on the current communication mode, the instruction information is transmitted to the micro control unit; the communication mode may include synchronous communication and asynchronous communication, and the way of transmitting instruction information in different communication modes is different, so the instruction information can be transmitted in the way required by the current communication mode. In order to realize the orderly processing of instruction information in different communication modes, the instruction information can be stored in the read queue after the instruction information is transmitted to the micro control unit. The instruction information stored in the read queue may be the instruction information that has been transmitted to the micro control unit, but the processing result generated by the micro control unit has not been received. Therefore, when there is instruction information in the read queue, it means that the processing result corresponding to the instruction information has not been received. At this time, the processing result matching the target instruction information can be read from the micro control unit, and the target instruction information can be deleted from the read queue. This communication mechanism can meet the requirements of both synchronous communication and asynchronous communication, so that the communication mode can be flexibly set.
[0085] Taking the current communication mode as synchronous communication as an example, the micro control unit is provided with a first-in first-out queue, so the application processor can transmit a command information to the first-in first-out queue of the micro control unit.
[0086] Accordingly, the application processor can use the read thread to read the processing result matching the target instruction information from the first-in first-out queue of the microcontroller unit; after reading the matching processing result, the target instruction information can be deleted from the read queue.
[0087] In an embodiment of the present application, after receiving the processing result that matches the target instruction information, the application processor needs to read the next instruction information from the write queue and transmit it to the micro control unit. It takes some time to read the instruction information from the write queue. In order to improve the processing efficiency of the instruction information, in the synchronous communication mode, a cache area can be set in the application processor. Reading information from the cache area takes less time than reading information from the write queue. Therefore, after the application processor transmits an instruction information to the first-in-first-out queue of the micro control unit, it can read the next instruction information from the write queue and store the next instruction information in a pre-set cache area. After receiving the processing result corresponding to the current instruction information, the application processor can directly transmit the instruction information stored in the cache area to the micro control unit, effectively saving the time spent on reading the instruction information.
[0088] Taking the current communication mode as asynchronous communication as an example, the microcontroller unit is provided with a data queue for storing data and a command queue for storing command information. The microcontroller unit can receive multiple command information in a short time, so in the asynchronous communication mode, the application processor can transmit the command information to the command queue of the microcontroller unit in sequence.
[0089] Accordingly, the application processor can determine whether there is instruction information in the read queue; if there is instruction information in the read queue, the processing result is read from the data queue of the microcontroller unit using the read thread. It is determined whether there is target instruction information matching the processing result in the read queue; if there is target instruction information matching the processing result in the read queue, the target instruction information is deleted from the read queue until there is no instruction information in the read queue, and the operation ends.
[0090] In the embodiment of the present application, the instruction information that has been transmitted to the micro-control unit but has not received the processing result fed back by the micro-control unit is stored in the read queue. When the target instruction information matching the processing result is received, the target instruction information is deleted from the read queue. Whether the processing result corresponding to each instruction information is received is detected by whether the instruction information is included in the read queue, so that it can be accurately detected whether all the instruction information sent to the micro-control unit has received the processing result fed back by the micro-control unit.
[0091] In an embodiment of the present application, after the application processor sends instruction information to the microcontroller unit, the processing result can be read from the application processor after a preset time interval, or the microcontroller unit can actively inform through an interrupt that the processing of the current instruction information has been completed, so that the application processor can read the processing result from the microcontroller unit in a timely manner.
[0092] In a specific implementation, before determining whether there is instruction information in the read queue, the application processor can determine whether it has received an interrupt request for reading data transmitted by the microcontroller unit; if it has received an interrupt request for reading data transmitted by the microcontroller unit, it means that the microcontroller unit has completed processing the instruction information, and the application processor can then execute the step of determining whether there is instruction information in the read queue.
[0093] In the asynchronous communication mode, considering that the instruction queue storage space of the microcontroller unit is limited, there may be too much instruction information transmitted by the application processor to the microcontroller unit, resulting in insufficient instruction queue storage space. Therefore, when the microcontroller unit detects that the remaining storage space of its own instruction queue is insufficient, it can send an interrupt request to stop sending instructions to the application processor. When the application processor receives the interrupt request to stop sending instructions transmitted by the microcontroller unit, it stops transmitting instruction information to the instruction queue of the microcontroller unit.
[0094] Each time the microcontroller completes processing of a piece of instruction information, it can delete the instruction information from the instruction queue. As the instruction information is processed, the instruction information stored in the instruction queue will become less and less, so that the instruction queue can have enough storage space to store the instruction information newly issued by the application processor. Therefore, when the remaining storage space of the instruction queue of the microcontroller is greater than the set space value, the microcontroller can send an interrupt request to the application processor to start sending instructions, and the application processor can resume the process of sending instruction information to the microcontroller.
[0095] In an embodiment of the present application, the microcontroller unit detects the remaining storage space of its own instruction queue. When the remaining storage space is insufficient, the microcontroller unit can promptly provide feedback to the application processor by way of an interrupt, so that the application processor can stop sending instruction information to the microcontroller unit, thereby avoiding congestion or loss of instruction information due to insufficient storage space in the instruction queue of the microcontroller unit.
[0096] Considering the actual application, there may be a situation where the application processor needs to continuously receive the processing results of the microcontroller unit on the instruction information. In the asynchronous communication mode, if the instruction information is directly deleted from the read queue after receiving the processing result of the microcontroller unit on the current instruction information, the application processor needs to resend the instruction information to the microcontroller unit in order to continuously obtain the processing results of the microcontroller unit on the instruction information at different time stages.
[0097] In view of this situation, in the embodiment of the present application, the types of instruction information can be distinguished, and instruction information that can be deleted after receiving a processing result can be regarded as ordinary instruction information. Instruction information that requires receiving processing results within a continuous period of time before deleting the instruction information is regarded as switch instruction information.
[0098] In a specific implementation, in the asynchronous communication mode, the application processor can determine whether the target instruction information is an on instruction before deleting the target instruction information from the read queue. If the target instruction information is an on instruction, it means that the application processor still needs to obtain the processing result of the microcontroller unit on the instruction information. At this time, the target instruction information can be retained in the read queue of the application processor; until the off instruction is received, the step of deleting the target instruction information from the read queue is executed.
[0099] In the embodiment of the present application, by classifying the instruction information into types, different business requirements can be met, thereby increasing the flexibility and efficiency of the interaction between the application processor and the micro control unit.
[0100] When the application processor needs to feed back the processing result to the initiator of the instruction information, it needs to parse out the initiator address carried in the instruction information. Considering that the instruction formats corresponding to synchronous communication and asynchronous communication are different in actual applications, the target instruction information can be parsed according to the instruction format corresponding to the current communication mode to obtain the initiator address of the target instruction information; thus, the processing result matching the target instruction information is transmitted to the initiator corresponding to the initiator address.
[0101] In an embodiment of the present application, by setting the instruction formats corresponding to the synchronous communication mode and the asynchronous communication mode, the needs of parsing processing results in different communication modes can be met, thereby ensuring that the application processor can smoothly feedback the processing results to the initiator regardless of the communication mode.
[0102] Figure 2 A schematic diagram of the structure of a dual-machine communication device provided in an embodiment of the present application, comprising a storage unit 21, a transmission unit 22, a reading unit 23 and a deletion unit 24;
[0103] The storage unit 21 is used to store the received instruction information into the write queue;
[0104] The transmission unit 22 is used to transmit the instruction information to the micro control unit based on the current communication mode;
[0105] The storage unit 21 is used to store the instruction information into the read queue; wherein the communication mode includes synchronous communication and asynchronous communication;
[0106] The reading unit 23 is used to read the processing result matching the target instruction information from the micro control unit when there is instruction information in the read queue;
[0107] The deleting unit 24 is used to delete the target instruction information from the read queue.
[0108] Optionally, when the current communication mode is synchronous communication, the transmission unit is used to transmit a piece of instruction information to a first-in first-out queue of the micro control unit;
[0109] Correspondingly, the reading unit is used to read the processing result matching the target instruction information from the first-in first-out queue of the microcontroller unit using the reading thread;
[0110] The deleting unit is used to delete the target instruction information from the read queue.
[0111] Optionally, a cache unit is also included;
[0112] The cache unit is used to read the next instruction information from the write queue after transmitting a piece of instruction information to the first-in first-out queue of the micro control unit, and store the next instruction information in a preset cache area.
[0113] Optionally, when the current communication mode is asynchronous communication, the transmission unit is used to sequentially transmit instruction information to the instruction queue of the micro control unit;
[0114] Correspondingly, the reading unit is used to determine whether there is instruction information in the reading queue; if there is instruction information in the reading queue, the processing result is read from the data queue of the microcontroller unit by using the reading thread; and whether there is target instruction information matching the processing result in the reading queue;
[0115] The deleting unit is used to delete the target instruction information from the read queue when there is target instruction information matching the processing result in the read queue; the operation ends when there is no instruction information in the read queue.
[0116] Optionally, before determining whether there is instruction information in the read queue, a determination unit is further included;
[0117] The judging unit is used to judge whether an interrupt request for reading data transmitted by the micro control unit is received; if an interrupt request for reading data transmitted by the micro control unit is received, the reading unit is triggered to execute the step of judging whether there is instruction information in the read queue.
[0118] Optionally, a stopping unit is further included;
[0119] The stop unit is used to stop transmitting instruction information to the instruction queue of the micro control unit if an interrupt request of stopping sending instruction transmitted by the micro control unit is received.
[0120] Optionally, it also includes a judging unit and a retaining unit;
[0121] a judging unit, used for judging whether the target instruction information is an open instruction before deleting the target instruction information from the read queue;
[0122] The retaining unit is used to retain the target instruction information in the read queue if the target instruction information is an on instruction; until an off instruction is received, the deleting unit is triggered to execute the step of deleting the target instruction information from the read queue.
[0123] Optionally, a parsing unit is also included;
[0124] A parsing unit, used to parse the target instruction information according to the instruction format corresponding to the current communication mode to obtain the initiator address of the target instruction information;
[0125] The transmission unit is used to transmit the processing result of the target instruction information matching to the initiator corresponding to the initiator address.
[0126] Figure 2 The description of the features in the corresponding embodiments can be found in Figure 1 The relevant descriptions of the corresponding embodiments will not be repeated here one by one.
[0127] It can be seen from the above technical solution that the received instruction information is stored in the write queue; based on the current communication mode, the instruction information is transmitted to the micro control unit; the communication mode may include synchronous communication and asynchronous communication, and the way of transmitting instruction information in different communication modes is different, so the instruction information can be transmitted in the way required by the current communication mode. In order to realize the orderly processing of instruction information in different communication modes, the instruction information can be stored in the read queue after the instruction information is transmitted to the micro control unit. The instruction information stored in the read queue may be the instruction information that has been transmitted to the micro control unit, but the processing result generated by the micro control unit has not been received. Therefore, when there is instruction information in the read queue, it means that the processing result corresponding to the instruction information has not been received. At this time, the processing result matching the target instruction information can be read from the micro control unit, and the target instruction information can be deleted from the read queue. This communication mechanism can meet the requirements of both synchronous communication and asynchronous communication, so that the communication mode can be flexibly set.
[0128] Figure 3 A schematic diagram of the structure of a dual-machine communication system provided in an embodiment of the present application includes an application processor (AP) and a microcontroller unit (MCU); wherein a read queue and a write queue are set in the AP; the communication mode between the AP and the MCU includes synchronous communication and asynchronous communication; under synchronous communication, the MCU sets a queue; under asynchronous communication, the MCU sets a queue for storing instructions and a queue for storing data;
[0129] The AP is connected to the MCU to store the received instruction information in the write queue; based on the current communication mode, transmit the instruction information to the MCU; and store the instruction information in the read queue; when there is instruction information in the read queue, read the processing result matching the target instruction information from the MCU, and delete the target instruction information from the read queue;
[0130] The MCU is used to perform corresponding processing according to the instruction information when receiving the instruction information transmitted by the AP, and store the processing result in the queue corresponding to the current communication mode.
[0131] In actual applications, according to the functions that the AP needs to implement, a Service can be created in the AP to be responsible for dual-machine communication. The Service calls the bus interface to send command information to the MCU. The bus interface can be SPI (Serial Peripheral Interface). Correspondingly, the AP can also obtain processing results from the MCU through SPI.
[0132] The service encapsulates the interface for APP or system calls. The service encapsulates the interface for each instruction and generates instruction information in the interface. The service creates a read thread and a write thread, as well as a read queue (Write Queue) and a write queue (Read Queue). After the service interface generates an instruction, it is added to the write queue. The write thread is used to take out the instruction information from the write queue, send the instruction information to the MCU through SPI, and then save the instruction information to the read queue. The SPI stores the queue address information (FIFO Address) of the MCU, so that the SPI can correctly perform read and write operations with the MCU. The read thread will only perform a read operation when there is instruction information in the read queue. The service can match the processing result (Result) read from the MCU with the instruction information in the read queue, and return it to the interface caller after a successful match. The caller can be other applications (APP) or external devices.
[0133] In actual applications, when the MCU has data to be read by the SPI, an interrupt (Irq) can be sent to the SPI first, and the SPI starts to read data from the MCU after receiving the interrupt. The data can be the processing result of the instruction information.
[0134] Figure 3Conditional writes indicates different processing methods in different communication modes. In asynchronous communication, after transmitting the command information to the MCU, the Service saves the command information to the read queue. Since it is currently in an asynchronous state, there is no need to wait for the MCU to return the processing result. After waiting for the current transmission of the command information to the MCU to be completed, you can continue to write the next command information to the MCU. In synchronous communication, after transmitting the command information to the MCU, the Service saves the command information to the read queue. Since it is currently in a synchronous state, you need to wait for the MCU to return the processing result before writing the next command information.
[0135] In asynchronous communication, if the instruction information is a normal instruction, the instruction information is deleted from the read queue after the processing result is returned; when there is an open instruction in the read queue, the processing result corresponding to the open instruction is read and returned to the interface caller, but the open instruction in the read queue is not deleted. When the Service writes the corresponding close instruction to the MCU, the MCU no longer returns the result data corresponding to the open instruction. The Service sends the close instruction to the read queue, and the read queue performs instruction matching and deletes the open instruction that matches the close instruction.
[0136] In asynchronous communication mode, MCU generally divides the FIFO space into at least two parts, one for storing received instructions, i.e., write FIFO, and the other for storing sent data, i.e., read FIFO. The two addresses of the read FIFO and write FIFO of MCU are configured in SPI, so that SPI can correctly perform read and write operations with MCU.
[0137] In synchronous communication mode, there is only one FIFO of the MCU that supports synchronization, and this space can only be used to store receiving instructions or storing sending data at the same time. Configure the read and write FIFO address of the MCU in SPI so that SPI can correctly perform read and write operations with the MCU. At this time, the read and write are at the same address.
[0138] During synchronous communication, in order to improve the efficiency of synchronous communication, after transmitting a command message to the first-in-first-out queue of the microcontroller unit, the next command message can be read from the write queue and stored in a pre-set cache area. Figure 3 Cmd Save represents the cache area.
[0139] Figure 3 The two-machine communication system shown can support synchronous communication and asynchronous communication.
[0140] Figure 3 The description of the features in the corresponding embodiments can be found in Figure 1 The relevant descriptions of the corresponding embodiments will not be repeated here one by one.
[0141] It can be seen from the above technical solution that the received instruction information is stored in the write queue; based on the current communication mode, the instruction information is transmitted to the micro control unit; the communication mode may include synchronous communication and asynchronous communication, and the way of transmitting instruction information in different communication modes is different, so the instruction information can be transmitted in the way required by the current communication mode. In order to realize the orderly processing of instruction information in different communication modes, the instruction information can be stored in the read queue after the instruction information is transmitted to the micro control unit. The instruction information stored in the read queue may be the instruction information that has been transmitted to the micro control unit, but the processing result generated by the micro control unit has not been received. Therefore, when there is instruction information in the read queue, it means that the processing result corresponding to the instruction information has not been received. At this time, the processing result matching the target instruction information can be read from the micro control unit, and the target instruction information can be deleted from the read queue. This communication mechanism can meet the requirements of both synchronous communication and asynchronous communication, so that the communication mode can be flexibly set.
[0142] The above is a detailed introduction to a dual-machine communication method, device and system provided by the embodiments of the present application. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0143] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0144] The above is a detailed introduction to a dual-machine communication method, device and system provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present invention, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.
Claims
1. A two-machine communication method, characterized in that: include: The received instruction information is stored in the write queue; Based on the current communication mode, transmitting the instruction information to the micro control unit; and storing the instruction information in a read queue; wherein the communication mode includes synchronous communication and asynchronous communication; When there is instruction information in the read queue, the processing result matching the target instruction information is read from the microcontroller unit, and the target instruction information is deleted from the read queue; after the application processor reads the instruction information from the write queue and sends it to the microcontroller unit, the instruction information is stored in its own read queue, so as to match it with the instruction information in the read queue after receiving the processing result, thereby ensuring that each instruction information receives the processing result fed back by the microcontroller unit.
2. The two-machine communication method according to claim 1, characterized in that: When the current communication mode is synchronous communication, transmitting instruction information to the micro control unit based on the current communication mode includes: Transmitting a command message to the first-in first-out queue of the microcontroller unit; Correspondingly, when there is instruction information in the read queue, reading a processing result matching the target instruction information from the micro control unit and deleting the target instruction information from the read queue includes: Using a read thread to read a processing result matching the target instruction information from a first-in first-out queue of the microcontroller unit; The target instruction information is deleted from the read queue.
3. The two-machine communication method according to claim 2, characterized in that: After transmitting a piece of instruction information to the first-in first-out queue of the micro control unit, the method further comprises: The next instruction information is read from the write queue, and the next instruction information is stored in a preset cache area.
4. The two-machine communication method according to claim 1, characterized in that: When the current communication mode is asynchronous communication, transmitting the instruction information to the micro control unit based on the current communication mode includes: transmitting the instruction information to the instruction queue of the micro control unit in sequence; Correspondingly, when there is instruction information in the read queue, reading a processing result matching the target instruction information from the micro control unit and deleting the target instruction information from the read queue includes: Determine whether there is instruction information in the read queue; If the read queue contains instruction information, the processing result is read from the data queue of the micro control unit by using the read thread; Determining whether there is target instruction information matching the processing result in the read queue; When target instruction information matching the processing result exists in the read queue, the target instruction information is deleted from the read queue until there is no instruction information in the read queue, and then the operation is terminated.
5. The two-machine communication method according to claim 4, characterized in that: Before determining whether the read queue has instruction information, the method further includes: Determining whether an interrupt request for reading data transmitted by the micro control unit is received; If an interrupt request for reading data transmitted by the micro control unit is received, the step of determining whether there is instruction information in the read queue is executed.
6. The two-machine communication method according to claim 4, characterized in that: After sequentially transmitting the instruction information to the instruction queue of the micro control unit, the method further includes: If an interrupt request for stopping sending instructions transmitted by the micro control unit is received, the transmission of instruction information to the instruction queue of the micro control unit is stopped.
7. The two-machine communication method according to claim 4, characterized in that: Before deleting the target instruction information from the read queue, the method further includes: Determining whether the target instruction information is an open instruction; If the target instruction information is an on instruction, the target instruction information is retained in the read queue; until an off instruction is received, the step of deleting the target instruction information from the read queue is performed.
8. The two-machine communication method according to any one of claims 1 to 7, characterized in that: After the processing result matching the target instruction information is read from the micro control unit, the method further includes: Parsing the target instruction information according to the instruction format corresponding to the current communication mode to obtain the initiator address of the target instruction information; The processing result of matching the target instruction information is transmitted to the initiator corresponding to the initiator address.
9. A two-machine communication device, characterized in that: It includes a storage unit, a transmission unit, a reading unit and a deletion unit; The storage unit is used to store the received instruction information in the write queue; The transmission unit is used to transmit the instruction information to the micro control unit based on the current communication mode; The storage unit is used to store the instruction information in a read queue; wherein the communication mode includes synchronous communication and asynchronous communication; The reading unit is used to read the processing result matching the target instruction information from the micro control unit when the instruction information exists in the read queue; The deletion unit is used to delete the target instruction information from the read queue; after the application processor reads the instruction information from the write queue and sends it to the micro control unit, the instruction information is stored in its own read queue, so as to match it with the instruction information in the read queue after receiving the processing result, thereby ensuring that each instruction information receives the processing result fed back by the micro control unit.
10. A dual-machine communication system, characterized in that: The invention comprises an application processor and a micro control unit; wherein the application processor is provided with a read queue and a write queue; the communication mode between the application processor and the micro control unit includes synchronous communication and asynchronous communication; under synchronous communication, the micro control unit is provided with a queue; under asynchronous communication, the micro control unit is provided with a queue for storing instructions and a queue for storing data; The application processor is connected to the micro control unit, and is used to store the received instruction information in the write queue; based on the current communication mode, transmit the instruction information to the micro control unit; and store the instruction information in the read queue; when there is instruction information in the read queue, read the processing result matching the target instruction information from the micro control unit, and delete the target instruction information from the read queue; after the application processor reads the instruction information from the write queue and sends it to the micro control unit, the instruction information is stored in its own read queue, so as to match it with the instruction information in the read queue after receiving the processing result, so as to ensure that each instruction information receives the processing result fed back by the micro control unit; The micro control unit is used to perform corresponding processing according to the instruction information when receiving the instruction information transmitted by the application processor, and store the processing result in a queue corresponding to the current communication mode.
Citation Information
Patent Citations
Queue-based AT instruction control method
CN113179227A