Method, device and equipment for configuring communication protocol at slave end and storage medium

By using GPIO detection ports and preset resistors in the slave communication interface, the host communication protocol is automatically identified and configured, solving the problems of space constraints and high maintenance costs for slave devices and simplifying protocol switching.

CN121037152APending Publication Date: 2025-11-28PASSINI ARTIFICIAL INTELLIGENCE TECHNOLOGY (BEIJING) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511045413.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-28
Publication Date
2025-11-28

AI Technical Summary

Technical Problem

In master-slave embedded systems, when slave devices are space-constrained or need to switch communication protocols, existing technologies result in problems such as large size, high maintenance costs, and complex switching.

Method used

By using multiple GPIO interfaces as detection ports in the slave device's communication interface, and combining them with preset resistors, the communication protocol type of the master device can be automatically identified and configured to support the corresponding communication protocol.

Benefits of technology

It enables the slave device to automatically identify and configure the same communication protocol as the master device, avoiding the need to design multiple sets of interfaces or different models, reducing the size and maintenance cost of the slave device, and simplifying the protocol switching process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121037152A_ABST
    Figure CN121037152A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of communication, and relates to a method, a device and equipment for configuring a communication protocol at a slave end and a storage medium, at least two GPIO (General Purpose Input / Output) interfaces of a communication interface of a slave are used as detection ports, and the method for configuring the communication protocol at the slave end comprises the following steps: enabling the slave to enter a power-on state, and setting the communication interface to be in an input mode; reading the levels of all the detection ports; comparing the read levels of all the detection ports with pre-stored level truth value information, wherein the level truth value information comprises the levels of all the detection ports of which the communication interfaces are connected with hosts adopting SPI, UART and I2C communication protocols respectively and which are in an idle state; identifying a communication protocol type currently adopted by the host according to a comparison result; the communication interface is configured to support the identified communication protocol type. According to the technical scheme adopted by the invention, the slave computer can support the SPI, UART and I2C communication protocols without designing a plurality of groups of communication interfaces or carrying out model design on various communication protocols.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of communication technology, and in particular to a method and device for configuring a slave communication protocol, an apparatus and a storage medium. BACKGROUND

[0002] In an embedded system with a master-slave architecture, when the slave is limited in volume or the space where the slave is located is limited, one of three communication protocols, SPI (Serial Peripheral Interface), I2C (Inter-Integrated Circuit) and UART (Universal Asynchronous Receiver / Transmitter), is generally selected as the communication protocol between the slave and the master.

[0003] However, the slave does not know the specific communication protocol used by the master before the slave is connected in communication with the master. Therefore, in order to enable the slave to support as many different types of communication protocols as possible, the following two methods are widely used: 1. a plurality of sets of communication interfaces capable of supporting multiple communication protocols are designed on each slave; and 2. the slave is designed in multiple models, such that each model of slave supports one communication protocol.

[0004] Although the above two methods support multiple communication protocols, they have the following disadvantages: for the first method, since the slave is designed with multiple sets of communication interfaces, i.e., a large number of pins are configured, the slave is prone to be large in volume, which makes the slave unable to be arranged in a small space, resulting in limited use of the slave; and for the second method, since there are many models of slave, the product models to which the slave belongs are also many, which increases the cost of product maintenance in the later stage; for both the first and second methods, when it is necessary to switch to a different type of communication protocol, the communication interface to which the communication harness is connected needs to be replaced, which makes the process of switching the communication protocol complicated, especially after the product is installed. For example, for a product with a haptic sensor as the slave (such as a dexterous hand, a data glove, etc.), after the product is installed, if it is necessary to replace the communication protocol, the haptic sensor needs to be disassembled, and then the communication interface needs to be changed, which makes the process of switching the communication protocol very troublesome. SUMMARY

[0005] The embodiments of the present application aim to provide a method and device for configuring a slave communication protocol, an apparatus and a storage medium, to overcome the above-mentioned defects in the prior art.

[0006] In a first aspect, embodiments of this application provide a method for configuring a slave device communication protocol. The slave device is equipped with a communication interface for establishing a communication connection with a master device. The master device can employ SPI, UART, and I2C communication protocols. The communication interface is configured to support SPI, UART, and I2C communication protocols, and the communication interface consists of multiple GPIO interfaces.

[0007] At least two GPIO interfaces of the communication interface are used as detection ports. Each detection port is connected to a preset resistor, which is a pull-up or pull-down resistor to prevent the detection port from being in a floating state. The voltage levels of all the detection ports are different in four operating states. These four operating states include three states where the communication interface is connected to the host machine using SPI, UART, and I2C communication protocols respectively and is in an idle state, and one state where the communication interface is not connected to the host machine. The method for configuring the slave-side communication protocol includes the following steps:

[0008] Power on the slave device and set the communication interface to input mode;

[0009] Read the level of all the detection ports;

[0010] The read levels of all the detection ports are compared with the pre-stored level truth information, which includes the levels of all the detection ports that are connected to the host using SPI, UART and I2C communication protocols respectively and are in an idle state.

[0011] The type of communication protocol currently used by the host is identified based on the comparison results;

[0012] Configure the communication interface to support the identified communication protocol type.

[0013] Optionally, identifying the communication protocol type currently used by the host based on the comparison result specifically includes the following steps:

[0014] If the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the SPI communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as SPI.

[0015] If the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the UART communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as UART.

[0016] When the comparison result is that the read level of all the detection ports is consistent with the level of all the detection ports of the communication interface connected with the host adopting the I2C communication protocol and in the idle state, it is identified that the communication protocol type currently adopted by the host is I2C.

[0017] Optionally, the communication interface is composed of four GPIO interfaces, the four GPIO interfaces include first and second GPIO interfaces configured as CLK and CS pins respectively when supporting the SPI communication protocol, all the detection ports are the first and second GPIO interfaces, the preset resistance is a weak pull-down resistance, and the host adopting the SPI communication protocol is configured as CPOL=1.

[0018] Two of the four GPIO interfaces are configured as TX and RX pins capable of supporting the UART communication protocol, and the other two are configured as SDA and SCL pins capable of supporting the I2C communication protocol; and when the communication interface is configured to support the UART communication protocol, only one of the first and second GPIO interfaces is configured as the TX or RX pin, and when the communication interface is configured to support the I2C communication protocol, only one of the first and second GPIO interfaces is configured as the SDA or SCL pin.

[0019] Optionally, a plurality of slaves are provided, the communication interfaces of the plurality of slaves are connected with the host through the same communication line, and the preset resistance has a resistance value greater than or equal to 560KΩ.

[0020] Optionally, a plurality of slaves are provided, the communication interfaces of the plurality of slaves are connected with the host through the same communication line, and the preset resistance has a resistance value greater than or equal to 560KΩ.

[0021] If it is necessary to configure the communication interface to support the UART communication protocol type, the TX pin is configured as an open-drain output mode and connected with a pull-up resistance;

[0022] If it is necessary to configure the communication interface to support the I2C communication protocol type, the SDA and SCL pins are configured as open-drain output modes and connected with pull-up resistances.

[0023] Optionally, a plurality of slaves are provided, the communication interfaces of the plurality of slaves are connected with the host through the same communication line, the slave is a tactile sensor, and the host is an upper computer of the tactile sensor.

[0024] Optionally, multiple slave devices are provided, and the communication interfaces of the multiple slave devices are connected to the master device through the same communication line. Each slave device is also provided with an address memory, which stores a preset address. The preset address stored in each address memory uniquely corresponds to the slave device in which the address memory is located.

[0025] When the comparison result identifies the communication protocol type currently used by the host as UART, after configuring the communication interface to support the identified communication protocol type, the method for configuring the slave communication protocol further includes the following steps:

[0026] The slave device is configured to continuously detect whether the host is sending data, and extract the address field from the data sent by the host after detecting that the slave device is sending data.

[0027] Determine whether the extracted address field matches the preset address;

[0028] If they match, the slave device responds to the data sent by the master device;

[0029] If there is a discrepancy, the slave device will not respond to the data sent by the master device.

[0030] Secondly, embodiments of this application provide an apparatus for configuring a slave device communication protocol, applied to the slave device in the above-described method for configuring a slave device communication protocol, the apparatus comprising:

[0031] A status setting module is used to enable the slave device to enter the power-on state and set the communication interface to input mode;

[0032] A level reading module is used to read the level of all the detection ports;

[0033] A level comparison module is used to compare the levels of all the detection ports read with pre-stored level truth information, wherein the level truth information includes the levels of all the detection ports connected to the host using SPI, UART and I2C communication protocols respectively and in an idle state;

[0034] The protocol identification module is used to identify the type of communication protocol currently used by the host based on the comparison result;

[0035] The protocol configuration module is used to configure the communication interface to support the identified communication protocol type.

[0036] Thirdly, embodiments of this application provide a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method for configuring a slave communication protocol as described above.

[0037] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for configuring a slave communication protocol as described above.

[0038] Compared with the prior art, the embodiments of this application have the following main advantages:

[0039] The method for configuring the slave communication protocol in this embodiment uses at least two GPIO interfaces of the communication interface as detection ports. Since the voltage levels of all detection ports differ across four operating states, by powering on the slave device and setting the communication interface to input mode, the voltage levels of all detection ports are read. These read voltage levels are then compared with pre-stored voltage truth information. Based on the comparison results, the current communication protocol type used by the host device can be identified. The communication interface can then be configured to support the identified communication protocol type. This allows the slave device to automatically identify the communication protocol type used by the host device and automatically configure itself to match it. This method eliminates the need for multiple communication interfaces or different models for various communication protocols, enabling the slave device to support SPI, UART, and I2C communication protocols. This overcomes the previous drawbacks of larger slave device size, higher maintenance costs, and complex communication protocol switching processes. Attached Figure Description

[0040] To more clearly illustrate the solutions in this application, the accompanying drawings used in the description of the embodiments of this application will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This is a schematic diagram of the communication line connection between the slave device and the master device according to an embodiment of this application;

[0042] Figure 2 A circuit diagram showing the connection of a preset resistor to the communication interface of a slave device according to an embodiment of this application;

[0043] Figure 3 A schematic diagram of the communication line connection between the slave device and the master device provided in another embodiment of this application;

[0044] Figure 4 A schematic diagram of the communication line connection between the slave device and the master device provided in another embodiment of this application;

[0045] Figure 5A schematic diagram of the communication line connection between the slave device and the master device provided in another embodiment of this application;

[0046] Figure 6 A flowchart illustrating a method for configuring a slave communication protocol according to an embodiment of this application;

[0047] Figure 7 A schematic diagram of a device for configuring a slave communication protocol according to an embodiment of this application;

[0048] Figure 8 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application.

[0049] Figure label:

[0050] 100. Device for configuring slave communication protocol; 110. Status setting module; 120. Level reading module; 130. Level comparison module; 140. Protocol identification module; 150. Protocol configuration module;

[0051] 200. Computer equipment; 210. Memory; 220. Processor; 230. Network interface. Detailed Implementation

[0052] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein in the specification of the application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application; the terms "comprising" and "having," and any variations thereof, in the specification, claims, and foregoing drawings of this application, are intended to cover non-exclusive inclusion. The terms "first," "second," etc., in the specification, claims, or foregoing drawings of this application are used to distinguish different objects, not to describe a particular order.

[0053] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.

[0054] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings.

[0055] Please see Figures 1-6The first part of this application provides a method for configuring a slave device communication protocol. The slave device using this method has a communication interface for communicating with a master device. The communication interface consists of multiple GPIO interfaces. The master device corresponding to the slave device can use any one of the three communication protocols: SPI, UART, and I2C. The communication interface of the slave device is configured to support SPI, UART, and I2C communication protocols, so that the slave device can be compatible with masters using different communication protocols.

[0056] In the slave device's communication interface, at least two GPIO interfaces are used as detection ports. These detection ports are used to detect voltage levels in the specific steps of configuring the slave device's communication protocol described below. Each detection port is connected to a preset resistor, which is a pull-up or pull-down resistor to prevent the detection port from being in a floating state. The voltage levels of all detection ports are different in the four operating states, so that the voltage levels of all detection ports can correspond to the four operating states. This allows the slave device to determine which of the four operating states it is currently in based on the read voltage levels of all detection ports, and thus identify the communication protocol type currently used by the master device. The four operating states include three operating states where the communication interface is connected to a master device using SPI, UART, and I2C communication protocols respectively and is in an idle state, and one operating state where the communication interface is not connected to the master device.

[0057] Please see Figure 6 The method for configuring the slave communication protocol in this application embodiment includes the following steps:

[0058] S100: Power on the slave device and set the communication interface to input mode;

[0059] S200, Read the level of all the detection ports;

[0060] S300. Compare the read levels of all the detection ports with the pre-stored level truth information, wherein the level truth information includes the levels of all the detection ports that are connected to the host using SPI, UART and I2C communication protocols respectively and are in an idle state.

[0061] S400. Identify the communication protocol type currently used by the host based on the comparison result;

[0062] S500: Configure the communication interface to support the identified communication protocol type.

[0063] It should be noted that step S100, putting the slave device into power-on state, refers to providing power to the slave device, enabling it to enter a state where it can physically connect with the master device and thus potentially receive and transmit electrical signals (i.e., high and low levels). Step S100, setting the communication interface to input mode, specifically means setting each GPIO interface that makes up the communication interface to input mode. The truth value information of the level in step S300 can be obtained through prior experimental measurement or by reasoning based on the specifications of the SPI, UART, and I2C communication protocols. In this embodiment, the idle state refers to the state when the master device does not actively send data and there is no effective communication on the bus. In this embodiment, the connection between the slave device and the master device essentially means that the slave device and the master device are physically connected, that is, the communication interfaces of the master device and the slave device are directly connected through actual electrical lines (such as wires, PCB traces), so that the electrical signals (i.e., high and low levels) generated by the master device can be transmitted to the slave device.

[0064] Understandably, the level of each detection port may be high or low. In this embodiment, at least two GPIO interfaces are used as detection ports, so that the level of all detection ports can have more than four combinations to fully correspond to the four working states. Ultimately, the slave device can identify the communication protocol type currently used by the master device based on the level of all detection ports.

[0065] The method for configuring the slave communication protocol in this embodiment uses at least two GPIO interfaces of the communication interface as detection ports. Since the voltage levels of all detection ports differ across four operating states, by powering on the slave device and setting the communication interface to input mode, the voltage levels of all detection ports are read. These read voltage levels are then compared with pre-stored voltage truth information. Based on the comparison results, the current communication protocol type used by the host device can be identified. The communication interface can then be configured to support the identified communication protocol type. This allows the slave device to automatically identify the communication protocol type used by the host device and automatically configure itself to match it. This method eliminates the need for multiple communication interfaces or different models for various communication protocols, enabling the slave device to support SPI, UART, and I2C communication protocols. This overcomes the previous drawbacks of larger slave device size, higher maintenance costs, and complex communication protocol switching processes.

[0066] It should be particularly noted that the method for configuring the slave communication protocol in this embodiment is executed only on the slave device and does not impose any limitations on the master device. As long as the master device supports any one of the three communication protocols SPI, UART, and I2C, the slave device and the master device can communicate smoothly without any changes to the master device. This has a significant advantage for current application scenarios where the slave device serves the master device. The method for configuring the slave communication protocol in this embodiment can be executed on the processor of the slave device, which can be an ESP32, STM32, or other commonly used MCUs.

[0067] In one embodiment, multiple slave devices are provided, each being a tactile sensor, and the host device is a host computer for the tactile sensor. For example, the host device can be a robot end effector such as a dexterous hand or a mechanical gripper, or a data glove used to collect tactile information.

[0068] Tactile sensors are used to collect tactile information, which typically includes one or more three-dimensional force data. In practical applications, multiple tactile sensors are usually connected to a single host computer in a "master-slave" architecture. However, host computers come in a wide variety of types and models, resulting in different supported communication protocols. For example, a host computer might support SPI, UART, I2C, CAN, USB, Modbus, and EtherCat. However, in practice, the most widely used communication protocols between tactile sensors and host computers remain SPI, UART, and I2C.

[0069] To enable tactile sensors to match the communication protocol types of host computers, two methods are currently widely used: 1. Designing multiple communication interfaces on each tactile sensor to support various communication protocols; 2. Designing tactile sensors in multiple models, with each model supporting a single communication protocol. While both methods support multiple communication protocols, they have the following drawbacks: For the first method, the multiple communication interfaces (i.e., a large number of pins) result in a large sensor size, limiting its usability. For the second method, the numerous sensor models significantly increase maintenance costs. Furthermore, for both methods, switching to different communication protocols requires disassembling the tactile sensor to change the communication interface and replace the communication wiring harness, making the process cumbersome and impractical.

[0070] In this embodiment, by using multiple tactile sensors as slave devices and the host computer of the tactile sensors as the master device, the tactile sensors can automatically identify the communication protocol type used by the host computer and automatically configure themselves to use the same communication protocol type by executing the method for configuring the slave communication protocol. Since the tactile sensors no longer need to design multiple communication interfaces or be designed separately for different communication protocols to support SPI, UART, and I2C, this overcomes the previous disadvantages such as large sensor size, high maintenance costs, and complex communication protocol switching processes.

[0071] In one embodiment, the level truth information also includes the levels of all detection ports when the slave device's communication interface is not connected to the master device. That is, the level truth information fully includes the levels of all detection ports in the four operating states. Step S400 specifically includes the following steps:

[0072] S410. When the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the SPI communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as SPI.

[0073] S420. When the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the UART communication protocol and in an idle state, the communication protocol type currently used by the host is identified as UART.

[0074] S430. When the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the I2C communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as I2C.

[0075] S440. When the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports when the communication interface is not connected to the host, it is identified that the communication interface of the slave is not connected to the host.

[0076] S450. If the comparison result shows that the level of all the detected ports is other than the specified value, then it is determined that the communication interface of the slave device cannot support the communication protocol type currently used by the host.

[0077] Please see Figures 1-2In one embodiment, considering the two functional pins (TX and RX) required for UART communication, the two functional pins (SDA and SCL) required for I2C communication, and the four functional pins (CLK, CS, MISO, and MOSI) generally required for SPI communication, the communication interface is configured to consist of four GPIO interfaces. These four GPIO interfaces include a first GPIO interface, a second GPIO interface, a third GPIO interface, and a fourth GPIO interface, respectively configured as CLK, CS, SDO (i.e., MISO), and SDI (i.e., MOSI) pins when supporting the SPI communication protocol. The first and second GPIO interfaces form the detection ports; that is, all detection ports are the first and second GPIO interfaces. The host using the SPI communication protocol is configured with CPOL=1, so that the level of the first GPIO interface is high in the idle state; and the chip select signal specified by the SPI communication protocol used by the host is active low, so that the level of the second GPIO interface is high in the idle state. To ensure that the voltage levels of the two detection ports, where the first and second GPIO interfaces are located, remain stable and not floating when the slave device's communication interface is not connected to the host, the preset resistor is set as a pull-down resistor, so that the two detection ports can stably maintain a low level when the slave device's communication interface is not connected to the host. Simultaneously, to prevent the voltage levels of the first and second GPIO interfaces from being affected by the preset resistor in the idle state and thus not reaching a high level, in this embodiment, the preset resistor connecting the first and second GPIO interfaces is set as a weak pull-down resistor. For example, the resistance value of the weak pull-down resistor is set to 560kΩ.

[0078] In some other embodiments, the master using the SPI communication protocol can be configured with CPOL=0, so that the level of the first GPIO interface is low in the idle state. Correspondingly, a weak pull-up resistor needs to be connected to the first GPIO interface, that is, the preset resistor connected to the detection port where the first GPIO interface is located is a weak pull-up resistor, thereby ensuring that the level of the first GPIO interface is high when the slave's communication interface is not connected to the master. In some other embodiments, the SPI communication protocol used by the master can also specify that the chip select signal is active high, so that the level of the second GPIO interface is low in the idle state. Correspondingly, a weak pull-up resistor needs to be connected to the second GPIO interface, that is, the preset resistor connected to the detection port where the second GPIO interface is located is a weak pull-up resistor, thereby ensuring that the level of the second GPIO interface is high when the slave's communication interface is not connected to the master.

[0079] Please see Figure 1In one embodiment, two of the four GPIO interfaces are configured to support the UART communication protocol as TX and RX pins, and the other two interfaces are configured to support the I2C communication protocol as SDA and SCL pins.

[0080] Specifically, two GPIO interfaces that can be multiplexed as TX and RX pins for the UART communication protocol can be selected as two of the four GPIO interfaces, so that two of the four GPIO interfaces can be configured to support the TX and RX pins of the UART communication protocol; two GPIO interfaces that can be multiplexed as SDA and SCL pins for the I2C communication protocol can be selected as the other two of the four GPIO interfaces, so that the other two of the four GPIO interfaces can be configured to support the SDA and SCL pins of the I2C communication protocol; alternatively, the other two GPIO interfaces can be configured to support the SDA and SCL pins of the I2C communication protocol by simulating the timing of the communication protocol through software programming.

[0081] According to the SPI communication protocol, when the slave device's communication interface is configured to support the SPI communication protocol and is connected to a master device using the SPI communication protocol, the CLK pin (first GPIO interface) and CS pin (second GPIO interface) are both at a high level when idle. According to the UART communication protocol, the slave device's communication interface needs to be configured with two interfaces, namely the TX pin and the RX pin, to support the UART communication protocol. When the communication interface is connected to a master device using the UART communication protocol, the TX pin and the RX pin are both at a high level when idle. According to the I2C communication protocol, the slave device's communication interface needs to be configured with two interfaces, namely the SDA pin and the SCL pin, to support the I2C communication protocol. When the communication interface is connected to a master device using the I2C communication protocol, the SDA pin and the SCL pin are both at a high level when idle.

[0082] To avoid the level of the two detection ports (i.e. all detection ports) where the first GPIO interface and the second GPIO interface are located from being repeated in the four working states, thus preventing the smooth execution of steps S300 and S400, when the communication interface is configured to support the UART communication protocol, only one of the first GPIO interface and the second GPIO interface is configured as the TX pin or the RX pin; when the communication interface is configured to support the I2C communication protocol, only one of the first GPIO interface and the second GPIO interface is configured as the SDA pin or the SCL pin.

[0083] For example, please refer toFigure 1 In one embodiment, the communication interface can support the UART communication protocol by configuring the first GPIO interface as the TX pin of the UART communication protocol and the third GPIO interface as the RX pin of the UART communication protocol; similarly, the communication interface can support the I2C communication protocol by configuring the second GPIO interface as the SDA pin of the I2C communication protocol and the fourth GPIO interface as the SCL pin of the I2C communication protocol. In this embodiment, the specific functional pin configurations of the four GPIO interfaces of the communication interface in four operating states are shown in Table 1-1 below, and the corresponding level truth information of all the detection ports is shown in Table 1-2 below.

[0084]

[0085]

[0086] Table 1-1

[0087]

[0088] Table 1-2

[0089] According to Tables 1-1 and 1-2, in this embodiment, the actual execution process of steps S300 and S400 can be summarized as follows: if the levels of all the detected ports read are high and high in the order of the first GPIO interface and the second GPIO, then the communication protocol type currently used by the host is identified as SPI; if the levels of all the detected ports read are high and low in the order of the first GPIO interface and the second GPIO, then the communication protocol type currently used by the host is identified as UART; if the levels of all the detected ports read are low and high in the order of the first GPIO interface and the second GPIO, then the communication protocol type currently used by the host is identified as I2C; if the levels of all the detected ports read are low and low in the order of the first GPIO interface and the second GPIO, then the communication interface of the slave device is not connected to the host.

[0090] In other embodiments, by configuring the four GPIO interfaces in the same way as the case where the TX and RX pins are interchanged in Table 1-1, or by configuring the four GPIO interfaces in the same way as the case where the SDA and SCL pins are interchanged in Table 1-1, the voltage levels of all detection ports can be different in the four operating states. This allows the host to identify its current communication protocol type by comparing the read voltage levels of all detection ports with the corresponding truth values. Since this is similar to the previous embodiment, it will not be described in detail here.

[0091] Please see Figure 2 In one embodiment, in addition to setting the preset resistors connected to the first and second GPIO interfaces as weak pull-down resistors, the communication interface also sets the preset resistors connected to the third and fourth GPIO interfaces as weak pull-down resistors. That is, all four GPIO interfaces of the communication interface are configured to be connected to weak pull-down resistors. This allows for convenient and unified setting of weak pull-down resistors on the communication interface, eliminating the need to set weak pull-down resistors individually for each GPIO interface. Furthermore, according to the SPI communication protocol, the four signal interfaces on the master connected to the first, second, third, and fourth GPIO interfaces are all equipped with pull-up resistors (usually strong pull-up resistors). Therefore, the weak pull-down resistors connected to the four GPIO interfaces of the slave's communication interface will not affect the level of the detection port in the idle state, nor will they affect the data communication between the master and slave via SPI, UART, and I2C protocols.

[0092] In one embodiment, multiple slave devices are provided, and the communication interfaces of the multiple slave devices are connected to the master device through the same communication line. The preset resistor of each slave device is a weak pull-down resistor, and the resistance value of the weak pull-down resistor is set to be greater than or equal to 560kΩ.

[0093] Understandably, in this embodiment, since the communication interfaces of multiple slave devices are connected to the host through the same communication line, that is, multiple slave devices are connected to the host in parallel, the equivalent resistance on the communication line will be small and the current will be large. Therefore, the resistance value of the weak pull-down resistor needs to be set to a large value greater than or equal to 560kΩ in order to achieve the purpose of weak pull-down, so as to ensure that the level of the detection port in the idle state will not be unable to be high due to the influence of the preset resistor.

[0094] In one embodiment, multiple slave devices are configured, and the communication interfaces of the multiple slave devices are connected to the master device through the same communication line. Step S500 specifically includes the following steps:

[0095] S510. If the communication interface needs to be configured to support the UART communication protocol, the TX pin is configured as an open-drain output and a pull-up resistor is connected.

[0096] S520. If the communication interface needs to be configured to support the I2C communication protocol, the SDA pin and the SCL pin are configured as open-drain output mode and connected with pull-up resistors.

[0097] Understandably, when multiple slave devices are configured, and these slave devices are connected to a master device using UART or I2C communication protocols, the different signals emitted by the multiple slave devices may cause signal conflicts and communication line confusion, and may even cause short circuits. In this embodiment, the TX pin on the slave device is configured as an open-drain output mode, or the SDA and SCL pins on the slave device are configured as open-drain output modes. Since open-drain output supports wired-AND logic, the above-mentioned problems can be avoided. Furthermore, since the pins configured as open-drain outputs do not have pull-up capabilities, pull-up resistors must be provided.

[0098] In one embodiment, there are multiple slave devices, and the communication interfaces of the multiple slave devices are connected to the master device through the same communication line. Each slave device is also equipped with an address memory, which stores a preset address. The preset address stored in each address memory corresponds uniquely to the slave device in which the address memory is located.

[0099] When the comparison result identifies that the communication protocol type currently used by the host is UART, after step S500, the method for configuring the slave communication protocol further includes the following steps:

[0100] S610. Configure the slave device to continuously detect whether the host sends data, and extract the address field from the data sent by the host after detecting the data sent by the host.

[0101] S620. Determine whether the extracted address field is consistent with the preset address;

[0102] S630. If they match, the slave device responds to the data sent by the master device.

[0103] S640. If there is a discrepancy, the slave device shall not respond to the data sent by the master device.

[0104] For example, the address memory of the slave device can be a FLASH memory, so that the preset address can be modified at any time when needed.

[0105] Understandably, by setting up an address memory and storing a preset address uniquely corresponding to each slave device, multiple slave devices, when connected to the master, can determine whether to communicate with the master by checking if their preset address matches the address field in the data sent by the master. This effectively allows the master to select a specific slave device to communicate with. By executing the steps S610-S640 above, the slave device can continuously monitor the data sent by the master and extract the address field from it. Furthermore, by checking if the address field matches the preset address, the slave device can choose whether to respond, thus achieving the goal of the master being able to select a specific slave device to communicate with.

[0106] It should be noted that "slave responding to master" in the above steps refers to the slave device's behavior of feeding back status or sending data to the master according to predefined protocol rules after determining that the address field matches the preset address. By enabling the slave device to respond to the master, a two-way confirmation mechanism can be established between the slave device and the master, ensuring the reliability of data transmission. Since the ordinary UART communication protocol is point-to-point and does not distinguish between master and slave, it is not suitable for a "one master, multiple slaves" architecture. Therefore, when multiple slave devices are connected to the master in this embodiment, and the slave device communication interface is configured to support the UART communication protocol type by executing step S500, the above steps S610-S640 must be executed so that the master can select a specific slave device for communication to avoid signal conflicts and confusion. It should also be noted that since the I2C communication protocol mandates the use of an ACK and NACK mechanism, which is part of its core design to ensure the reliability of data transmission, in this embodiment, after executing step S500 to configure the communication interface to support the I2C communication protocol, the above steps S610-S640 do not need to be executed again. Since the SPI communication protocol selects the slave device through the chip select signal, in this embodiment of the application, after executing step S500 to configure the communication interface to support the SPI communication protocol, it is not necessary to execute the above steps S610-S640 again.

[0107] For example, please refer to Figure 3In another embodiment, the difference from the above embodiment is that all detection ports are a first GPIO interface (corresponding to the CLK pin) and a third GPIO interface (corresponding to the MISO pin). To ensure that the level of the detection port where the first GPIO interface is located remains stable and not in a floating state when the slave's communication interface is not connected to the master, the preset resistor connected to the first GPIO interface is set as a weak pull-down resistor, so that the first GPIO interface can remain at a low level when the communication interface is not connected to the master. To ensure that the level of the detection port where the third GPIO interface is located remains stable and not in a floating state when the slave's communication interface is not connected to the master and when the slave's communication interface is connected to a master using the SPI communication protocol, the preset resistor connected to the third GPIO interface is set as a weak pull-down resistor, so that the third GPIO interface can remain at a low level both when the communication interface is not connected to the master and when connected to a master using the SPI communication protocol. It should be noted that since the host can use SPI, UART and I2C communication protocols, the third signal interface connected to the third GPIO interface on the host must be equipped with a pull-up resistor (usually a strong pull-up resistor). When the third GPIO interface of the slave device's communication interface is connected to the third signal interface of the host using UART or I2C communication protocol and is in an idle state, the level detected at the third GPIO interface will still be high due to the combined effect of the strong pull-up resistor and the weak pull-down resistor (i.e., the preset resistor).

[0108] In this embodiment, to avoid the overlap of the voltage levels of the two detection ports containing the first and third GPIO interfaces in the four operating states, which would prevent the successful execution of steps S300 and S400, the third and fourth GPIO interfaces are configured as the TX and RX pins of the UART communication protocol, enabling the communication interface to support the UART communication protocol. Similarly, the first and third GPIO interfaces are configured as the SDA and SCL pins of the I2C communication protocol, enabling the communication interface to support the I2C communication protocol. In this embodiment, the specific functional pin configurations of the four GPIO interfaces in the four operating states are shown in Table 2-1 below, and the corresponding voltage level truth information of all the detection ports is shown in Table 2-2 below.

[0109]

[0110] Table 2-1

[0111]

[0112] Table 2-2

[0113] According to Tables 2-1 and 2-2, in this embodiment, the actual execution process of steps S300 and S400 can be summarized as follows: if the levels of all the detected ports read are high and low in the order of the first GPIO interface and the third GPIO, then the communication protocol type currently used by the host is identified as SPI; if the levels of all the detected ports read are low and high in the order of the first GPIO interface and the third GPIO, then the communication protocol type currently used by the host is identified as UART; if the levels of all the detected ports read are high and high in the order of the first GPIO interface and the third GPIO, then the communication protocol type currently used by the host is identified as I2C; if the levels of all the detected ports read are low and low in the order of the first GPIO interface and the third GPIO, then the communication interface of the slave device is not connected to the host.

[0114] For example, please refer to Figure 4 In another embodiment, the difference from the above embodiments is that all the detection ports are the first GPIO interface (corresponding to the CLK pin) and the fourth GPIO interface (corresponding to the MOSI pin). To ensure that the level of the detection port where the first GPIO interface is located remains stable and not in a floating state when the slave's communication interface is not connected to the master, the preset resistor connected to the first GPIO interface is set as a weak pull-down resistor, so that the first GPIO interface can remain at a low level when the communication interface is not connected to the master; to ensure that the level of the detection port where the fourth GPIO interface is located remains stable and not in a floating state when the slave's communication interface is not connected to the master and when the slave's communication interface is connected to a master using the SPI communication protocol, the preset resistor connected to the fourth GPIO interface is set as a weak pull-down resistor, so that the fourth GPIO interface can remain at a low level when the communication interface is not connected to the master and when connected to a master using the SPI communication protocol. It should be noted that since the host can use SPI, UART and I2C communication protocols, the fourth signal interface connected to the fourth GPIO interface on the host must be equipped with a pull-up resistor (usually a strong pull-up resistor). When the fourth GPIO interface of the slave device's communication interface is connected to the fourth signal interface of the host using UART or I2C communication protocol and is in an idle state, the level detected at the fourth GPIO interface will still be high due to the combined effect of the strong pull-up resistor and the weak pull-down resistor (i.e., the preset resistor).

[0115] In this embodiment, to avoid the overlap of the voltage levels of the two detection ports where the first and fourth GPIO interfaces are located in the four operating states, which would prevent the successful execution of steps S300 and S400, the third and fourth GPIO interfaces are configured as the TX and RX pins of the UART communication protocol, enabling the communication interface to support the UART communication protocol; the first and fourth GPIO interfaces are configured as the SDA and SCL pins of the I2C communication protocol, enabling the communication interface to support the I2C communication protocol. In this embodiment, the specific functional pin configurations of the four GPIO interfaces of the communication interface in the four operating states are shown in Table 3-1 below, and the corresponding voltage level truth information of all the detection ports is shown in Table 3-2 below.

[0116]

[0117] Table 3-1

[0118]

[0119] Table 3-2

[0120] According to Tables 3-1 and 3-2, in this embodiment, the actual execution process of steps S300 and S400 can be summarized as follows: if the levels of all the detected ports read are high and low in the order of the first GPIO interface and the fourth GPIO, then the communication protocol type currently used by the host is identified as SPI; if the levels of all the detected ports read are low and high in the order of the first GPIO interface and the fourth GPIO, then the communication protocol type currently used by the host is identified as UART; if the levels of all the detected ports read are high and high in the order of the first GPIO interface and the fourth GPIO, then the communication protocol type currently used by the host is identified as I2C; if the levels of all the detected ports read are low and low in the order of the first GPIO interface and the fourth GPIO, then the communication interface of the slave device is not connected to the host.

[0121] For example, please refer to Figure 5In another embodiment, the difference from the above embodiments is that all the detection ports are a first GPIO interface (corresponding to the CLK pin), a third GPIO interface (corresponding to the MISO pin), and a fourth GPIO interface (corresponding to the MOSI pin). To ensure that the level of the detection port where the first GPIO interface is located remains stable and not in a floating state when the slave's communication interface is not connected to the master, the preset resistor connected to the first GPIO interface is set as a weak pull-down resistor, so that the first GPIO interface can remain at a low level when the communication interface is not connected to the master. To ensure that the level of the detection port where the third GPIO interface is located remains stable and not in a floating state when the slave's communication interface is not connected to the master and when the slave's communication interface is connected to a master using the SPI communication protocol, the preset resistor connected to the third GPIO interface is set as a weak pull-down resistor, so that the third GPIO interface can remain at a low level both when the communication interface is not connected to the master and when connected to a master using the SPI communication protocol. Set the preset resistor connected to the fourth GPIO interface as a pull-up resistor so that the level of the detection port where the fourth GPIO interface is located can remain stable and not be in a floating state. This ensures that the fourth GPIO interface remains at a high level when the slave's communication interface is not connected to the master and when the slave's communication interface is connected to the master and is in an idle state.

[0122] In this embodiment, to avoid the overlap of voltage levels of the three detection ports (the first, third, and fourth GPIO interfaces) in the four operating states, which would prevent the successful execution of steps S300 and S400, the third and fourth GPIO interfaces are configured as the RX and TX pins of the UART communication protocol, enabling the communication interface to support the UART communication protocol. Similarly, the first and third GPIO interfaces are configured as the SDA and SCL pins of the I2C communication protocol, enabling the communication interface to support the I2C communication protocol. The specific functional pin configurations of the four GPIO interfaces in the four operating states are shown in Table 4-1 below, and the corresponding voltage level truth information of all the detection ports is shown in Table 4-2 below.

[0123]

[0124] Table 4-1

[0125]

[0126] Table 4-2

[0127] According to Tables 4-1 and 4-2, in this embodiment, the actual execution process of steps S300 and S400 can be summarized as follows: If the levels of all the detected ports read are high, low, and high in the order of the first GPIO interface, the third GPIO interface, and the fourth GPIO, then the communication protocol type currently used by the host is identified as SPI; if the levels of all the detected ports read are low, high, and high in the order of the first GPIO interface, the third GPIO interface, and the fourth GPIO, then the communication protocol type currently used by the host is identified as UART; if the levels of all the detected ports read are high, high, and high in the order of the first GPIO interface, the third GPIO interface, and the fourth GPIO, then the communication protocol type currently used by the host is identified as I2C; if the levels of all the detected ports read are low, low, and high in the order of the first GPIO interface, the third GPIO interface, and the fourth GPIO, then the communication interface of the slave device is not connected to the host.

[0128] In other embodiments, the slave device's communication interface can also be configured to include multiple GPIO interfaces supporting the same functional pins. For example, the communication interface can be configured to include two or more GPIO interfaces capable of supporting the CS or CLK pins in the SPI communication protocol, and these multiple GPIO interfaces supporting the same functional pins can be used as some or all of the detection ports. By reading the levels of all detection ports and comparing the read levels with pre-stored level truth information, the method for configuring the slave device's communication protocol provided in this application can also be implemented. This part of the embodiment also falls within the scope of protection of this patent application.

[0129] The second part of this application provides an apparatus for configuring a slave communication protocol, applied to the slave device in the method for configuring a slave communication protocol in the above embodiments. The apparatus 100 includes:

[0130] The status setting module 110 is used to enable the slave device to enter the power-on state and set the communication interface to input mode;

[0131] The level reading module 120 is used to read the level of all the detection ports;

[0132] The level comparison module 130 is used to compare the level of all the detection ports read with the pre-stored level truth information, the level truth information including the level of all the detection ports connected to the host using SPI, UART and I2C communication protocols respectively and in an idle state;

[0133] The protocol identification module 140 is used to identify the communication protocol type currently used by the host based on the comparison result;

[0134] The protocol configuration module 150 is used to configure the communication interface to support the identified communication protocol type.

[0135] Specifically, in one embodiment, the protocol configuration module 150 includes:

[0136] The first open-drain output submodule is used to configure the TX pin in open-drain output mode and connect a pull-up resistor when the communication interface needs to be configured to support the UART communication protocol type.

[0137] The second open-drain output submodule is used to configure the SDA pin and the SCL pin in open-drain output mode and connect pull-up resistors when the communication interface needs to be configured to support the I2C communication protocol type.

[0138] Specifically, in one embodiment, the device 100 for configuring the slave communication protocol further includes:

[0139] The address extraction submodule is configured to continuously detect whether the host sends data, and extract the address field from the data sent by the host after detecting that the slave device has sent data.

[0140] The address determination submodule is used to determine whether the extracted address field is consistent with the preset address;

[0141] The slave response submodule is used to enable the slave to respond to the data sent by the host when it is determined that the extracted address field is consistent with the preset address;

[0142] The slave silence submodule is used to prevent the slave from responding to data sent by the master when it is determined that the extracted address field is inconsistent with the preset address.

[0143] The third part of this application also provides a computer device 200. This computer device 200 can be a terminal or a server. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited herein.

[0144] The computer device 200 includes a memory 210, a processor 220, and a network interface 230 that are interconnected via a system bus. It should be noted that only the computer device 200 with components 210-230 is shown in the figure; however, it should be understood that it is not required to implement all the shown components, and more or fewer components can be implemented alternatively. Those skilled in the art will understand that the computer device 200 described here is a device capable of automatically performing numerical calculations and / or information processing according to pre-set or stored instructions. Its hardware includes, but is not limited to, microprocessors, application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), digital signal processors (DSPs), embedded devices, etc.

[0145] The memory 210 includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 210 may be an internal storage unit of the computer device 200, such as the hard disk or memory of the computer device 200. In other embodiments, the memory 210 may also be an external storage device of the computer device 200, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc. Of course, the memory 210 may also include both internal storage units and external storage devices of the computer device 200. In this embodiment, the memory 210 is typically used to store the operating system and various application software installed on the computer device 200, such as program code for configuring the communication protocol of the slave device. Furthermore, the memory 210 can also be used to temporarily store various types of data that have been output or will be output.

[0146] In some embodiments, the processor 220 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. The processor 220 is typically used to control the overall operation of the computer device 200. In this embodiment, the processor 220 is used to run program code stored in the memory 210 or process data, for example, running program code for configuring a communication protocol on the slave device.

[0147] The network interface 230 may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the computer device 200 and other electronic devices.

[0148] This application also provides a computer-readable storage medium storing a control program for the method of configuring the communication protocol of the slave device. The control program for the method of configuring the communication protocol of the slave device can be executed by at least one processor to cause the at least one processor to perform the steps of the method of configuring the communication protocol of the slave device as described above.

[0149] Obviously, the embodiments described above are only some embodiments of this application, not all embodiments. The accompanying drawings show preferred embodiments of this application, but do not limit the patent scope of this application. This application can be implemented in many different forms; rather, the purpose of providing these embodiments is to provide a more thorough and comprehensive understanding of the disclosure of this application. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing specific embodiments, or make equivalent substitutions for some of the technical features. Any equivalent structures made using the content of this application's specification and drawings, directly or indirectly applied to other related technical fields, are similarly within the scope of patent protection of this application.

Claims

1. A method for configuring a slave device communication protocol, wherein the slave device has a communication interface for establishing a communication connection with a master device, the master device can use SPI, UART, and I2C communication protocols, the communication interface is configured to support SPI, UART, and I2C communication protocols, and the communication interface consists of multiple GPIO interfaces, characterized in that, At least two GPIO interfaces of the communication interface are used as detection ports. Each detection port is connected to a preset resistor, which is a pull-up or pull-down resistor to prevent the detection port from being in a floating state. The voltage levels of all the detection ports are different in four operating states. These four operating states include three states where the communication interface is connected to the host machine using SPI, UART, and I2C communication protocols respectively and is in an idle state, and one state where the communication interface is not connected to the host machine. The method for configuring the slave-side communication protocol includes the following steps: Power on the slave device and set the communication interface to input mode; Read the level of all the detection ports; The read levels of all the detection ports are compared with the pre-stored level truth information, which includes the levels of all the detection ports that are connected to the host using SPI, UART and I2C communication protocols respectively and are in an idle state. The type of communication protocol currently used by the host is identified based on the comparison results; Configure the communication interface to support the identified communication protocol type.

2. The method for configuring the slave communication protocol according to claim 1, characterized in that, The step of identifying the communication protocol type currently used by the host based on the comparison result specifically includes the following steps: If the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the SPI communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as SPI. If the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the UART communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as UART. If the comparison result shows that the level of all the detected ports read is consistent with the level of all the detected ports connected to the host using the I2C communication protocol and in an idle state, then the communication protocol type currently used by the host is identified as I2C.

3. The method for configuring the slave communication protocol according to claim 1, characterized in that, The communication interface consists of four GPIO interfaces, including a first GPIO interface and a second GPIO interface that are respectively configured as CLK pin and CS pin when supporting the SPI communication protocol. All the detection ports are the first GPIO interface and the second GPIO interface. The preset resistor is a weak pull-down resistor. The host using the SPI communication protocol is configured with CPOL=1. Two of the four GPIO interfaces are configured to support the UART communication protocol as TX and RX pins, and the other two interfaces are configured to support the I2C communication protocol as SDA and SCL pins. When the communication interface is configured to support the UART communication protocol, only one of the first GPIO interface and the second GPIO interface is configured as either the TX pin or the RX pin. When the communication interface is configured to support the I2C communication protocol, only one of the first GPIO interface and the second GPIO interface is configured as either the SDA pin or the SCL pin.

4. The method for configuring the slave communication protocol according to claim 3, characterized in that, The slave device is provided in multiple ways, and the communication interfaces of the multiple slave devices are connected to the master device through the same communication line. The resistance value of the preset resistor is greater than or equal to 560KΩ.

5. The method for configuring the slave communication protocol according to claim 3, characterized in that, The slave devices are configured in multiple ways, and their communication interfaces are connected to the host device through the same communication line. Configuring the communication interface to support the identified communication protocol type specifically includes the following steps: If the communication interface needs to be configured to support the UART communication protocol, then the TX pin should be configured as an open-drain output and a pull-up resistor should be connected. If the communication interface needs to be configured to support the I2C communication protocol, then the SDA pin and the SCL pin should be configured as open-drain output mode and connected with pull-up resistors.

6. The method for configuring the slave communication protocol according to claim 1, characterized in that, The system is configured with multiple slave devices, and the communication interfaces of the multiple slave devices are connected to the host through the same communication line. The slave devices are tactile sensors, and the host is the host computer of the tactile sensors.

7. The method for configuring the slave communication protocol according to claim 1, characterized in that, The slave device is provided in multiple ways, and the communication interfaces of the multiple slave devices are connected to the master device through the same communication line. Each slave device is also provided with an address memory, which stores a preset address. The preset address stored in each address memory corresponds uniquely to the slave device in which the address memory is located. When the comparison result identifies the communication protocol type currently used by the host as UART, after configuring the communication interface to support the identified communication protocol type, the method for configuring the slave communication protocol further includes the following steps: The slave device is configured to continuously detect whether the host is sending data, and extract the address field from the data sent by the host after detecting that the slave device is sending data. Determine whether the extracted address field matches the preset address; If they match, the slave device responds to the data sent by the master device; If there is a discrepancy, the slave device will not respond to the data sent by the master device.

8. An apparatus for configuring a slave communication protocol, applied to the slave device in the method for configuring a slave communication protocol according to any one of claims 1-7, characterized in that, The device includes: A status setting module is used to enable the slave device to enter the power-on state and set the communication interface to input mode; A level reading module is used to read the level of all the detection ports; A level comparison module is used to compare the levels of all the detection ports read with pre-stored level truth information, wherein the level truth information includes the levels of all the detection ports connected to the host using SPI, UART and I2C communication protocols respectively and in an idle state; The protocol identification module is used to identify the type of communication protocol currently used by the host based on the comparison result; The protocol configuration module is used to configure the communication interface to support the identified communication protocol type.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of configuring the slave communication protocol as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method for configuring a slave communication protocol as described in any one of claims 1 to 7.