Method and communication system compatible with integrated service digital network (SDN) communication and inter-integrated circuit (I2C) communication
By designing methods and systems that are compatible with One-line Communication and I2C communication in the communication system, protocol mode switching and address configuration are realized, which solves the additional cost problem caused by different protocols in the existing technology and improves system compatibility and flexibility.
Patent Information
- Application Number
- CN202410752326.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-12
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-06-12
AI Technical Summary
In existing communication systems, the chips of each communication device need to be developed in different versions according to different communication protocols, resulting in additional costs and a lack of control logic compatible with different communication protocols.
Design a method and system that is compatible with one-line communication and I2C communication, communicate through the IO port and I2C bus between the master device and the slave device, realize the switching of protocol modes and address configuration, and ensure that the master device and the slave device communicate in different protocol modes. The slave device can communicate normally.
It effectively improves the compatibility of the communication system, reduces product development and system costs, improves the flexibility and adaptability of the system, and avoids the need to develop different versions of chips for different protocols.
Smart Images

Figure CN118740957A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a method and a communication system compatible with I2C communication. Background Art
[0002] Generally, in a communication system, there are various communication protocols for communication between chips of various communication devices. Commonly used communication protocols include the one-line communication protocol and the I2C (Inter-Integrated Circuit) communication protocol. In the related art, there is no communication control logic compatible with different communication protocols. In order to match the communication protocols used by each system, the same functional chip needs to be manufactured in versions corresponding to different communication protocols according to the protocols used by the system, resulting in additional costs. Summary of the invention
[0003] The present invention provides a method and a communication system compatible with I2C communication to improve the compatibility of the communication system, and it is unnecessary to develop different protocols and configure different versions of chips in the device, which can effectively reduce product development costs and system costs.
[0004] In a first aspect, an embodiment of the present invention provides a method for compatible one-line communication and I2C communication, wherein the communication system includes a master device and multiple slave devices; the master device includes multiple IO ports, each corresponding to each of the slave devices, and the master device is connected to each of the slave devices through an I2C bus;
[0005] The method for being compatible with I2C communication includes:
[0006] If the communication system operates in a one-line protocol mode, the master device communicates with the slave device connected to the IO port through the IO port based on the one-line communication protocol;
[0007] If the communication system operates in I2C protocol mode, the master device selects a slave device capable of communicating with the master device by controlling the potential of the IO port, and the master device communicates with the slave device through the I2C bus based on the I2C communication protocol.
[0008] Optionally, when the communication system operates in the I2C protocol mode, before the master device communicates with the slave device, it further includes:
[0009] The master device configures the address of each slave device through the IO port and the I2C bus.
[0010] Optionally, the process of the master device performing address configuration on any slave device to be configured includes:
[0011] The master device controls the IO port connected to the slave device to be configured to be at a valid potential, so that the slave device to be configured can perform signal interaction with the master device through the I2C bus;
[0012] The master device broadcasts the address configuration command of the slave device to be configured to all the slave devices through the I2C bus;
[0013] The slave device to be configured responds to the address configuration command, stores a corresponding configuration address according to the address configuration command, and feeds back an address configuration confirmation signal to the master device via the I2C bus;
[0014] When the master device receives the address configuration confirmation signal, it confirms that the address configuration of the slave device to be configured is completed.
[0015] Optionally, the method for compatible one-line communication and I2C communication further includes:
[0016] If the master device does not receive the address configuration confirmation signal, the master device broadcasts the address configuration command of the slave device to be configured to all the slave devices again through the I2C bus.
[0017] Optionally, after the master device receives the address configuration confirmation signal, the method further includes:
[0018] If the configuration address of the slave device to be configured needs to be changed, the master device broadcasts the changed address configuration command of the slave device to be configured to all the slave devices via the I2C bus.
[0019] Optionally, the method for compatible one-line communication and I2C communication also includes: when the communication system switches from the one-line protocol mode to the I2C protocol mode, during the process of the master device configuring the address of each of the slave devices, each of the slave devices maintains the working state corresponding to the working configuration instruction last issued by the master device based on the one-line communication protocol before the protocol mode is switched.
[0020] Optionally, the communication system operates in the one-line protocol mode when the master device is powered on; the method for being compatible with one-line communication and I2C communication further includes:
[0021] After the master device is powered on, determining whether the communication system needs to switch to the I2C communication mode;
[0022] If so, the master device selects a slave device capable of communicating with the master device by controlling the potential of the IO port, and the master device communicates with the slave device through the I2C bus based on the I2C communication protocol;
[0023] If not, the master device communicates with the slave device connected to the IO port through the IO port based on a one-line communication protocol.
[0024] Optionally, the method for compatible one-line communication and I2C communication further includes: when the communication system switches from the one-line protocol mode to the I2C protocol mode, the slave device stores the working configuration instruction last issued by the master device in the one-line protocol mode;
[0025] When the communication system switches from the I2C protocol mode to the one-line protocol mode, the slave device runs the stored working configuration instruction last issued by the master device in the last one-line protocol mode.
[0026] Optionally, the method for compatible one-line communication and I2C communication further includes:
[0027] In the I2C protocol mode, the master device controls the slave device connected to the IO port to communicate with the master device by controlling the IO port to be a valid potential; the master device controls the slave device connected to the IO port to stop communicating with the master device by controlling the IO port to be an invalid potential;
[0028] and / or,
[0029] In the I2C protocol mode, the instructions sent by the master device to the slave device via the I2C bus include: a power-on instruction and / or a power-off instruction.
[0030] In the second aspect, an embodiment of the present invention further provides a communication system, comprising: a master device and multiple slave devices; the master device comprises multiple IO ports, which are respectively connected to the multiple slave devices, and the master device is connected to each of the slave devices via an I2C bus; the master device and each of the slave devices communicate with each other using the method compatible with one-line communication and I2C communication provided in any embodiment of the present invention.
[0031] The technical solution of the embodiment of the present invention provides communication logic for a communication system running in an I2C protocol mode and an I2C protocol mode respectively, and provides a method for using a master device and a slave device compatible with the two communication protocols, so that the master device can communicate with the slave device based on the corresponding communication protocol in different protocol modes, realize the coexistence of the two communication protocols, and effectively improve the compatibility of the communication system. At the same time, a communication system is built using master and slave devices compatible with the two communication protocols. By adding communication-related logic control methods inside the device chip, it is not necessary to develop for different protocols and configure different versions of chips in the device, which can effectively reduce product development costs and system costs. In addition, by switching the protocol mode through software logic, the master and slave devices can adapt to different working environments and equipment requirements, thereby improving the flexibility and adaptability of the system.
[0032] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0034] Figure 1 A schematic diagram of the structure of a communication system provided by an embodiment of the present invention;
[0035] Figure 2 A flowchart of a method for compatible one-line communication and I2C communication provided by an embodiment of the present invention;
[0036] Figure 3 A schematic diagram of a process of configuring an address of a slave device by a master device according to an embodiment of the present invention;
[0037] Figure 4 A timing diagram of a master device executing an address configuration command in a communication system provided by an embodiment of the present invention;
[0038] Figure 5 A timing diagram of a communication system in a protocol mode switching process provided by an embodiment of the present invention;
[0039] Figure 6 A flowchart of another method for compatible one-line communication and I2C communication provided by an embodiment of the present invention;
[0040] Figure 7A communication timing diagram of a communication system provided by an embodiment of the present invention;
[0041] Figure 8 A flowchart of another method for compatible one-line communication and I2C communication provided by an embodiment of the present invention;
[0042] Fig. 9 A schematic diagram of the structure of another communication system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0044] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0045] The embodiment of the present invention provides a method for compatible one-line communication and I2C communication, which can be applied to a communication system configured with two communication protocols, one-line communication protocol and the other I2C communication protocol. Figure 1 , briefly describe the structure of the communication system.
[0046] Figure 1 A schematic diagram of a communication system according to an embodiment of the present invention is provided. Figure 1 The communication system provided by the embodiment of the present invention includes a master device 10 and multiple slave devices; the master device 10 includes multiple IO ports, which are respectively connected to each slave device, and the master device 10 is connected to each slave device through an I2C bus. Figure 1Exemplarily, five slave devices are shown, including slave device 21, slave device 22, slave device 23, slave device 24 and slave device 25, and correspondingly, five IO ports of master device 10 are shown, namely I / O 1, I / O 2, I / O 3, I / O 4 and I / O 5. Exemplarily, the number of slave devices can be set according to the number of IO ports configured by the master device. The I2C bus may include a serial data line SDA (Serial Data Line) and a serial clock line SCL (Serial Clock Line). Figure 1 For example, the wiring of the IO port is represented by a short dashed line, the serial data line SDA is represented by a solid line, and the serial clock line SCL is represented by a dotted dashed line. The master device 10 is connected to each slave device through the IO port and the I2C bus respectively; the master device 10 may have a built-in microprocessor, and the microprocessor chip includes a plurality of functional pins for connecting the master device IO port and for connecting the I2C bus; the slave device may have a built-in processing chip, and the processing chip includes a plurality of functional pins for connecting the master device IO port and for connecting the I2C bus. The master device 10 and the slave device are both compatible with the one-line communication protocol and the I2C communication protocol, and the master device and the slave device communicate through the communication strategy given by the method for compatible one-line communication and I2C communication provided in an embodiment of the present invention. The method is described below.
[0047] Figure 2 A flowchart of a method for compatible one-line communication and I2C communication provided by an embodiment of the present invention, referring to Figure 2 , methods compatible with I2C communication include:
[0048] S200: If the communication system operates in the one-line protocol mode, the master device communicates with the slave device connected to the IO port through the IO port based on the one-line communication protocol.
[0049] Among them, the one-line communication protocol is a protocol that allows high-speed communication through a single cable, using only one signal line at the physical layer. In the embodiment of the present invention, the signal line is a signal line connected between the IO port of the master device and the slave device.
[0050] Specifically, when the communication system operates in the one-line protocol mode, the master device and the slave device communicate using the one-line communication protocol. Since the master device is connected to each slave device one-to-one through each IO port, the master device can directly communicate with the slave device that needs to communicate through the corresponding IO port. The master device can specifically transmit communication instructions to the corresponding slave device through the IO port based on the one-line communication protocol. The communication instructions include, for example, the working configuration parameters of the slave device. In this mode, the I2C bus can be idle; or, when the communication system also includes other functional devices connected to the I2C bus that are only configured with the I2C communication protocol, the master device can also normally control the operating status of other functional devices through the I2C bus.
[0051] S201. If the communication system operates in I2C protocol mode, the master device selects a slave device capable of communicating with the master device by controlling the potential of the IO port, and the master device communicates with the slave device through the I2C bus based on the I2C communication protocol.
[0052] Among them, under the I2C communication protocol, the master device is the device that initializes the data transmission of the bus and generates a clock signal that allows transmission. Each slave device has a unique address to identify the slave device.
[0053] Specifically, when the communication system operates in the I2C protocol mode, the master device and the slave device communicate using the I2C communication protocol. In this mode, the master device can communicate with the slave device through the I2C bus based on the I2C communication protocol; specifically, the master device can identify the slave device that communicates with the master device in the I2C protocol mode through the address information of the slave device, and send communication instructions to the corresponding slave device based on the address information of the slave device. And, in this mode, the IO port does not transmit communication instructions, but can be used as a switch function. Specifically, the master device can select the slave device through the IO port, for example, by controlling the potential of the IO port to control whether the corresponding slave device is turned on and can interact with the master device through the I2C bus. For example, when a valid potential is transmitted on the IO port, the slave device receiving the valid potential is turned on, and communicates with the master device through the I2C bus based on the I2C communication protocol; when an invalid potential is transmitted on the IO port, the slave device receiving the invalid potential is turned off and does not work, and cannot communicate with the master device. The effective potential is different from the invalid potential. For example, the effective potential is a high potential (or a low potential), and the corresponding invalid potential is a low potential (or a high potential).
[0054] The technical solution of the embodiment of the present invention provides communication logic for the communication system to run in the one-line protocol mode and the I2C protocol mode respectively, and provides a method for using a master device and a slave device compatible with the two communication protocols, so that the master device can communicate with the slave device based on the corresponding communication protocol in different protocol modes, realize the coexistence of the two communication protocols, and effectively improve the compatibility of the communication system. At the same time, by using a master-slave device compatible with the two communication protocols to build a communication system, by adding communication-related logic control methods inside the device chip, it is not necessary to develop for different protocols and configure different versions of chips in the device, which can effectively reduce product development costs and system costs, and by switching the protocol mode through software logic, the master and slave devices can adapt to different working environments and equipment requirements, and improve the flexibility and adaptability of the system.
[0055] Based on the above implementations, optionally, there are multiple ways to configure the address of the slave device, which are described below respectively.
[0056] In one embodiment, the address of the slave device may be fixed, and each slave device may be assigned a fixed address when it leaves the factory. It is understandable that the address of each slave device is unique, and different slave devices have different addresses, so that the master device can identify the slave device based on the address to avoid address conflicts.
[0057] In another implementation, the master device may optionally dynamically allocate addresses of the slave devices according to requirements, so that the selection of physical addresses is no longer limited by physical wiring, thereby improving the flexibility of address allocation.
[0058] Exemplarily, when the communication system operates in I2C protocol mode, before the master device communicates with the slave device, the method for compatible one-line communication and I2C communication also includes: the master device configures the address of each slave device through the IO port and the I2C bus.
[0059] Specifically, when the communication system is running in the I2C protocol mode, the master device broadcasts the address configuration command to all slave devices connected to the I2C bus through the I2C bus, and due to the chip selection function of the IO port, the selected slave device (i.e., the slave device connected to the IO port that outputs the effective potential) can continuously monitor the address configuration command of the master device, and respond when the address configuration command appears. The address-related data in the address configuration command is stored in the built-in memory of the slave device as the communication address of the subsequent slave device. Exemplarily, the master device can select each slave device one by one through each IO port, and configure the address to each slave device. It can be understood that the master device configures different addresses to different slave devices, which can ensure that each slave device has a unique address, avoid address conflicts, and thus enhance the reliability and stability of the communication system.
[0060] The technical solution provided by the embodiment of the present invention is that when the communication system needs to run in the I2C protocol mode, the master device configures the address of each slave device through the IO port and the I2C bus, and the address configuration command is broadcast on the I2C bus by the master device. By using the chip selection function of the IO port, the selected slave device can continuously monitor and identify the configuration command sent by the master device, and the unselected slave device does not receive the command broadcast on the I2C bus. Based on this, the address of each slave device can be configured one by one, and the efficiency of configuration can be improved and the communication delay between the master device and the slave device can be reduced. At the same time, the master device can dynamically allocate addresses according to situational requirements, and the selection of physical addresses is no longer limited by physical wiring, which improves the flexibility of address allocation.
[0061] Optionally, the master device also includes a memory for storing relevant information such as address configuration. The master device is responsible for providing one-line communication control and working clock synchronization and address configuration functions of I2C bus communication, and is also responsible for implementing related functions of address conflict processing, so that the master device can communicate with the slave device based on different communication protocols.
[0062] Figure 3 A schematic diagram of a process of configuring an address of a slave device by a master device according to an embodiment of the present invention, referring to Figure 3 Based on the above embodiments, optionally, the process of the master device performing address configuration on any slave device to be configured includes:
[0063] S301 , the master device controls the IO port connected to the slave device to be configured to be at a valid potential, so that the slave device to be configured can perform signal exchange with the master device through the I2C bus.
[0064] Specifically, since the IO port has a chip select function, the master device selects the slave device by controlling the potential of the IO port connected to the slave device. For example, when the potential of the IO port connected to the slave device is at a valid potential, the slave device is selected as the slave device to be configured. The slave device to be configured will continue to listen to the configuration command of the master device and respond when the configuration command appears.
[0065] S302: The master device broadcasts address configuration commands of the slave devices to be configured to all slave devices via the I2C bus.
[0066] Specifically, the master device broadcasts the address configuration command to all slave devices connected to the I2C bus through the I2C bus. Only the slave device selected by the effective potential of the IO port (i.e., the slave device to be configured) can receive and respond to the address configuration command, and other slave devices do not respond to the address configuration command.
[0067] S303: The slave device to be configured responds to the address configuration command, stores the corresponding configuration address according to the address configuration command, and feeds back an address configuration confirmation signal to the master device via the I2C bus.
[0068] Specifically, the address configuration confirmation signal may be an address response frame, which indicates that the slave device to be configured has detected the broadcast of the address configuration command of the master device and has completed the address configuration. The configuration address is stored in the built-in memory of the slave device to be configured as the subsequent communication address of the slave device.
[0069] S304: When the master device receives the address configuration confirmation signal, it confirms that the address configuration of the slave device to be configured is completed.
[0070] Specifically, the master device receives the address response frame of the slave device to be configured through the I2C bus, and confirms that the address configuration of the slave device to be configured is completed.
[0071] This embodiment illustrates the process of the master device performing address configuration on a slave device to be configured through S301-S304. The address configuration process of the master device on each slave device can refer to the above steps. After the master device completes the address configuration of each slave device, the I2C communication process can be executed. During the I2C communication process, each IO port can maintain an effective potential so that each slave device can continue to receive relevant instructions and commands broadcast by the master device on the I2C bus.
[0072] On the basis of the above embodiments, optionally, in the process of the master device performing address configuration on the slave device, an address conflict, a configuration error, or a failure of the slave device to respond normally may occur, so that the master device cannot receive the address configuration confirmation signal fed back by the slave device. Then, when the master device does not receive the address configuration confirmation signal, the master device may broadcast the address configuration command of the slave device to be configured to all slave devices through the I2C bus again, and the master device and the slave device may repeat the above S302-S304 process to complete the address configuration of the slave device.
[0073] On the basis of the above-mentioned embodiments, optionally, for any slave device to be configured, after completing the address configuration process of S301-S304 once, that is, after the master device receives the address configuration confirmation signal of the slave device, if the configuration address of the slave device needs to be changed, the master device broadcasts the address configuration command of the replaced slave device to be configured to all slave devices through the I2C bus, and executes the process of S302-S304 again based on the replaced address configuration command to complete the address change of the slave device. Exemplarily, the reason for changing the configuration address may be: the slave device to be configured has a hardware or software failure, and its configuration address may need to be changed to solve the problem; or there is an address conflict between devices, so in order to avoid conflicts and network confusion, the address of the device to be configured needs to be changed; or the system needs to expand or add new slave devices, so the address is reallocated to ensure the uniqueness of all devices in the network. The function of the master device dynamically adjusting the address configuration of the slave device can ensure the normal operation, security and maintainability of the system.
[0074] On the basis of the above-mentioned embodiments, optionally, when the communication system switches from the one-line protocol mode to the I2C protocol mode, in the process of the master device performing address configuration on each slave device, each slave device maintains the working state corresponding to the working configuration instruction last issued by the master device based on the one-line communication protocol before the protocol mode is switched, so as to ensure the stability of the working state of the slave device during the protocol mode switching process. Exemplarily, the process of the master device performing address configuration on each slave device may include: the initial address configuration process, and the subsequent address configuration process caused by a fault or an address change.
[0075] Specifically, Figure 4 A timing diagram of a master device executing an address configuration command in a communication system provided by an embodiment of the present invention, Figure 4 An example of a slave device related timing is given in the reference Figure 4, in the process of switching the Singer WireCAN (SWC) protocol mode to the I2C protocol mode, the potential of the IO port is in an effective potential (here exemplarily a high potential) so that the slave device is selected and can receive signals from the I2C bus. Specifically, first, the communication system operates in the Singer WireCAN protocol mode, and the master device transmits communication instructions to the slave device through the IO port. Exemplarily, in the Singer WireCAN protocol mode, the working configuration instruction last transmitted by the master device controls the working configuration of the slave device to be configuration 3. When the communication system switches from the Singer WireCAN protocol mode to the I2C protocol mode, the master device configures the address to the slave device, and the master device transmits the address configuration command through the I2C bus. After the slave device parses the command and completes the configuration, for example, the stored configuration address is address 4. In this address configuration process, the working configuration of the slave device is maintained in configuration 3. That is, in the switching process between the two protocol modes, the working mode of the slave device is the working state corresponding to the working configuration instruction last issued based on the Singer WireCAN communication protocol. Exemplarily, the working configuration instruction can be stored in the memory of the slave device so that when the protocol mode is switched, the processing chip of the slave device reads and executes the instruction from the memory.
[0076] Furthermore, if after configuring address 4, the master device does not receive a feedback confirmation signal from the slave device or needs to change the address, the master device resets the address to the slave device. Taking the need to change the address as an example, the communication system can switch from the I2C protocol mode to the one-line protocol mode to prepare for resetting the address. At this time, the working configuration of the slave device is still maintained in configuration 3. During the reset process, the IO port is a valid potential so that the slave device is selected. The master device transmits the changed address configuration command through the I2C bus. After the slave device parses the command and completes the configuration, for example, the stored configuration address is address 2. During the address reset process, the working configuration of the slave device is still maintained in configuration 3.
[0077] To sum up, when the system needs to run in I2C protocol mode, during its pre-processing process, that is, various address configuration processes, the working configuration of the slave device can be stabilized at the configuration last issued in the one-line protocol mode, and the address configuration process will not affect the working configuration of the slave device, thereby ensuring the stability of the system operation.
[0078] Based on the above embodiments, optionally, when the system switches from the I2C protocol mode to the one-line protocol mode, the slave device can restore the last working configuration when the one-line protocol mode was last run, which is conducive to the stable operation of the system after the protocol mode is switched.
[0079] Specifically, when the communication system switches from the one-line protocol mode to the I2C protocol mode, the slave device can store the last working configuration instruction issued by the master device in the one-line protocol mode. When the communication system switches from the I2C protocol mode to the one-line protocol mode again, the slave device runs the last working configuration instruction issued by the master device in the last one-line protocol mode.
[0080] Figure 5 A timing diagram of a communication system in a protocol mode switching process provided by an embodiment of the present invention, Figure 5 An example of a slave device related timing is given in the reference Figure 5 , the system first runs in the one-line protocol mode. For example, in the one-line protocol mode, the working configuration instruction last transmitted by the master device controls the working configuration of the slave device to configuration 7; wherein the working configuration instruction corresponding to configuration 7 is stored by the slave device. When the communication system switches to the I2C protocol mode, after the address configuration is completed, during the I2C communication process, the master device transmits communication instructions to the slave device through the I2C bus. The communication instructions include, for example, parameter configuration commands and configuration protocol commands, etc. The above communication instructions can be used to adjust the working configuration of the slave device; in the I2C protocol mode, the master device adjusts the working configuration of the slave device to, for example, configuration 5. When the system is adjusted from the I2C protocol mode to the one-line protocol mode again, the slave device synchronously restores the last working configuration in the last one-line protocol mode, that is, configuration 7.
[0081] The technical solution provided in this embodiment is that when the communication protocol of the communication system is switched, the working configuration of the slave device changes synchronously, which can ensure the stability of the working state of the slave device and improve the stability and reliability of the communication system.
[0082] Based on the above embodiments, optionally, the communication system may run in a one-line protocol mode by default when the master device is powered on. Figure 6 A flowchart of another method for compatible one-line communication and I2C communication provided by an embodiment of the present invention, referring to Figure 6 , methods compatible with I2C communication include:
[0083] S601. The main device is powered on, and the communication system runs in a one-line protocol mode.
[0084] S602, determine whether the communication system needs to switch to the I2C communication mode; if so, execute S603; if not, execute S604.
[0085] The master device may receive communication-related commands from a user or other controller to learn the protocol mode in which the communication system needs to operate.
[0086] S603: The master device selects a slave device and sends an address configuration command.
[0087] The step specifically includes: the master device configures the address of each slave device through the IO port and the I2C bus. After all slave devices receive the corresponding address configuration command and feedback to confirm that the address configuration is completed, the master device communicates with each slave device through the I2C bus based on the I2C communication protocol.
[0088] S604, the master device communicates with the slave device connected to the IO port through the IO port based on a one-line communication protocol.
[0089] Based on the above implementations, optionally, in the I2C protocol mode, there are multiple ways for the master device to control whether the slave device is turned on, and several of them are described below, but they are not intended to limit the present invention.
[0090] In one embodiment, optionally, in the I2C protocol mode, the master device controls the IO port to be a valid potential, thereby controlling the slave device connected to the IO port to communicate with the master device; the master device controls the IO port to be an invalid potential, thereby controlling the slave device connected to the IO port to stop communicating with the master device.
[0091] Specifically, Figure 7 A communication timing diagram of a communication system provided by an embodiment of the present invention, referring to Figure 7 , when the communication system operates in the one-line protocol mode, the IO port of the master device has the communication function and transmits the communication instructions. When the communication system operates in the I2C protocol mode, the communication function is undertaken by the I2C bus related structure; the IO port of the master device no longer has the communication function, but the device switch function can be configured. Exemplarily, the master device can control the IO port to be at a high potential as a valid potential, and control the IO port to be at a low potential as an invalid potential. Or the master device can control the IO port to be at a high potential as an invalid potential, and control the IO port to be at a low potential as a valid potential. In this embodiment, exemplarily, when the communication system is in the I2C protocol mode, the high potential of the IO port is a valid potential, and the slave device is controlled to communicate with the master device; the low potential of the IO port is an invalid potential, and the slave device is in a shutdown (OFF) state, and stops communicating with the master device. The technical solution provided in this embodiment, by setting the master device IO port to have a switch function under the I2C protocol and a communication function under the one-line protocol, can make the communication system adapt to different usage scenarios and enhance the flexibility of the system.
[0092] In another embodiment, optionally, in the I2C protocol mode, the master device sends a power-on / off state-related instruction to the slave device via the I2C bus to control the power-on / off state of the slave device. Specifically, the power-on / off state-related instruction may include: a power-on instruction for controlling the slave device to be powered on and turned on (ON), and / or a power-off instruction for controlling the slave device to be powered off and turned off. Figure 7 , when the communication system is in I2C protocol mode and the IO port is at a valid potential, if the instruction sent by the master device to the slave device through the I2C bus is a power-off instruction, then when the power-off instruction ends, the device state of the slave device switches to shutdown OFF; if the instruction sent by the master device to the slave device through the I2C bus is a power-on instruction, then when the power-on instruction ends, the device state of the slave device switches to power-on ON. It can be understood that during the period when the master device sends instructions to the slave device through the I2C bus, the device state of the slave device remains in the state before the instruction is sent, and after the instruction ends, the device state of the slave device changes with the instruction.
[0093] In another embodiment, optionally, the system may simultaneously configure the above two types of functions for controlling whether the slave device is turned on, so as to support the system to use I2C instructions and IO ports to control the switch of the slave device according to the usage scenario.
[0094] Figure 8 A flowchart of another method for compatible one-line communication and I2C communication provided by an embodiment of the present invention, referring to Figure 8 , exemplarily, the method for making compatible one-line communication and I2C communication includes:
[0095] S801. The communication system operates in a one-line protocol mode.
[0096] When the main device is powered on, the communication system may be operated in a one-line protocol mode by default.
[0097] S802, determine whether the communication system needs to switch to the I2C protocol mode; if so, execute S803; if not, execute S812.
[0098] This determination step may be performed by the master device.
[0099] S803, the master device selects the slave device and address.
[0100] This step is specifically as follows: the master device selects a slave device that can communicate with the master device by controlling the potential of the IO port, and the master device determines the address that needs to be configured for each slave device.
[0101] S804: The master device assembles an address configuration command and broadcasts it to each slave device.
[0102] This step is specifically as follows: the master device broadcasts the address configuration command of the selected slave device to be configured to all slave devices via the I2C bus.
[0103] S805, determine whether the slave device responds; if so, execute S806; if not, execute S808.
[0104] This determination step may be performed by the master device.
[0105] S806: The master device confirms that the slave device has stored the configuration address.
[0106] Among them, the slave device responds to the address configuration command, stores the corresponding configuration address according to the address configuration command, and then feeds back the address configuration confirmation signal to the master device through the I2C bus; when the master device receives the address configuration confirmation signal, it confirms that the slave device has stored the configuration address and completes the address configuration of the slave device.
[0107] S807, the master device determines whether to change the address of the slave device; if so, execute S808; if not, execute S809.
[0108] S808: The master device reassembles the address configuration command and broadcasts it to each slave device.
[0109] S809, I2C communication is running.
[0110] That is, the master device and the slave device communicate based on the I2C communication protocol.
[0111] S810, determine whether the communication system needs to switch to the one-line protocol mode; if so, execute S811; if not, execute S809.
[0112] This determination step may be performed by the master device.
[0113] S811. The master device assembles a configuration command and sends it to the slave device.
[0114] The configuration command may be a command related to enabling the one-line communication protocol, and the master device may transmit the configuration command to the slave device via the IO port.
[0115] S812, One-line communication is running.
[0116] That is, the master device and the slave device communicate with each other based on a one-line communication protocol.
[0117] Based on steps S801-S812, this embodiment provides a specific communication control process of the communication system, which can ensure that the communication system can switch smoothly between different protocol modes and improve the flexibility and adaptability of the system.
[0118] The embodiment of the present invention further provides a communication system, including: a master device and multiple slave devices; the master device and each slave device communicate with each other using the method provided by any of the above embodiments that is compatible with I2C communication, and has the beneficial effects provided by any of the above embodiments. Fig. 9 A schematic diagram of another communication system provided in an embodiment of the present invention, referring to Fig. 9 The master device 10 includes a plurality of IO ports I / O, each corresponding to a plurality of slave devices 20, and the master device 10 is connected to each slave device 20 via an I2C bus. The I2C bus may specifically include a serial data line SDA and a serial clock line SCL.
[0119] Continue to refer Fig. 9 On the basis of the above embodiments, optionally, the communication system may further include other functional devices 30 that are originally configured with only I2C communication function in the system, connected to the I2C bus. The master device 10 may also control the working state of the other functional devices 30 normally through the I2C bus based on the I2C communication protocol. It is understandable that the address of the other functional device 30 is different from the address of the slave device 20, so that the master device 10 can identify different devices.
[0120] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0121] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for compatible one-line communication and I2C communication, characterized in that: The communication system includes a master device and a plurality of slave devices; the master device includes a plurality of IO ports, which are respectively connected to the slave devices, and the master device is connected to the slave devices via an I2C bus; The method for being compatible with I2C communication includes: If the communication system operates in a one-line protocol mode, the master device communicates with the slave device connected to the IO port through the IO port based on the one-line communication protocol; If the communication system operates in I2C protocol mode, the master device selects a slave device capable of communicating with the master device by controlling the potential of the IO port, and the master device communicates with the slave device through the I2C bus based on the I2C communication protocol.
2. The method for compatible one-line communication and I2C communication according to claim 1, characterized in that: When the communication system operates in the I2C protocol mode, before the master device communicates with the slave device, it also includes: The master device configures the address of each slave device through the IO port and the I2C bus.
3. The method for compatible one-line communication and I2C communication according to claim 2, characterized in that: The process of the master device performing address configuration on any slave device to be configured includes: The master device controls the IO port connected to the slave device to be configured to be at a valid potential, so that the slave device to be configured can perform signal interaction with the master device through the I2C bus; The master device broadcasts the address configuration command of the slave device to be configured to all the slave devices through the I2C bus; The slave device to be configured responds to the address configuration command, stores a corresponding configuration address according to the address configuration command, and feeds back an address configuration confirmation signal to the master device via the I2C bus; When the master device receives the address configuration confirmation signal, it confirms that the address configuration of the slave device to be configured is completed.
4. The method for compatible one-line communication and I2C communication according to claim 3, characterized in that: Also includes: If the master device does not receive the address configuration confirmation signal, the master device broadcasts the address configuration command of the slave device to be configured to all the slave devices again through the I2C bus.
5. The method for compatible one-line communication and I2C communication according to claim 3, characterized in that: After the master device receives the address configuration confirmation signal, the method further includes: If the configuration address of the slave device to be configured needs to be changed, the master device broadcasts the changed address configuration command of the slave device to be configured to all the slave devices via the I2C bus.
6. The method for compatible one-line communication and I2C communication according to claim 2, characterized in that: Also includes: When the communication system switches from the one-line protocol mode to the I2C protocol mode, during the process of the master device configuring the address of each slave device, each slave device maintains the working state corresponding to the working configuration instruction last issued by the master device based on the one-line communication protocol before the protocol mode is switched.
7. The method for compatible one-line communication and I2C communication according to claim 1, characterized in that: The communication system operates in the one-line protocol mode when the master device is powered on; The method for compatible one-line communication and I2C communication also includes: After the master device is powered on, determining whether the communication system needs to switch to the I2C communication mode; If so, the master device selects a slave device capable of communicating with the master device by controlling the potential of the IO port, and the master device communicates with the slave device through the I2C bus based on the I2C communication protocol; If not, the master device communicates with the slave device connected to the IO port through the IO port based on a one-line communication protocol.
8. The method for compatible one-line communication and I2C communication according to any one of claims 1 to 7, characterized in that: Also includes: When the communication system switches from the one-line protocol mode to the I2C protocol mode, the slave device stores the working configuration instruction last issued by the master device in the one-line protocol mode; When the communication system switches from the I2C protocol mode to the one-line protocol mode, the slave device runs the stored working configuration instruction last issued by the master device in the last one-line protocol mode.
9. The method for compatible one-line communication and I2C communication according to claim 1, characterized in that: Also includes: In the I2C protocol mode, the master device controls the slave device connected to the IO port to communicate with the master device by controlling the IO port to be at a valid potential; The master device controls the slave device connected to the IO port to stop communicating with the master device by controlling the IO port to be an invalid potential; and / or, In the I2C protocol mode, the instructions sent by the master device to the slave device via the I2C bus include: a power-on instruction and / or a power-off instruction.
10. A communication system, characterized in that: include: A master device and multiple slave devices; the master device includes multiple IO ports, which are respectively connected to the multiple slave devices, and the master device is connected to each of the slave devices via an I2C bus; The master device communicates with each of the slave devices using a method compatible with one-line communication and I2C communication as described in any one of claims 1 to 9.
Citation Information
Patent Citations
System and method for realizing communication by adopting dynamic I2C bus
CN102012885A
I2C device expansion method and device and system
CN105404604A
A single-wire shared bus protocol system and a working method
CN109873741A
Communication integration system for encapsulation circuit containing SPI communication protocol and I2C communication protocol
CN114048161A
Interface module and data transmission method for compatibly realizing SPI (Serial Peripheral Interface) or I2C slave
CN114996184A
Cited By
Two-in-one communication method and system based on integrated service digital network and USART (Universal Synchronous Asynchronous Receiver Transmitter)
CN119788763A
A two-in-one communication method and system based on one-line communication and USART
CN119788763B
