I2C bus communication control method, system and device
By monitoring the falling edge of the clock signal of the I2C bus and controlling the clock signal according to the status of the slave device, the problem of communication failure caused by clock extension in I2C transparent transmission is solved, and the stability and effectiveness of data transmission are improved.
Patent Information
- Application Number
- CN202110959742.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-20
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2041-08-20
AI Technical Summary
In the case of I2C transparent transmission, since the master device and the slave device are not directly connected, when the slave device initiates clock extension, the master device cannot respond, resulting in communication failure.
By monitoring the falling edge of the clock signal of the master device, the clock signal of the slave device is set to a low level and converted to a high-impedance state after a preset time. The clock signal of the master device is controlled according to the clock signal status of the slave device to avoid clock Communication failed during extension.
Improves the stability and effectiveness of I2C communication, ensuring that the master device and slave device pause communication until the slave device triggers clock stretching until it ends, thereby avoiding communication failure.
Smart Images

Figure CN113656340B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of communication technology, and in particular to a communication control method, system and device for an I2C bus. Background Art
[0002] The Inter-Integrated Circuit (I2C) bus is a common serial communication bus. The I2C serial bus generally has two signal lines, one is a bidirectional data line, and the other is a clock line. The device that controls the data transmission of the bus is called the master device, and the device that receives the command of the master device is called the slave device. The master device can send a clock signal through the clock line output circuit, and decide when to send control instructions based on the level of the clock signal. The slave device usually sends or receives signals on the data line according to the clock signal on the bus, and can also send a low-level signal to the clock line to pull down the clock signal to extend the bus clock signal cycle. The process of the slave device pulling down the clock signal is called clock stretching.
[0003] However, in the case of I2C transparent transmission, since the master device and the slave device are not directly connected, when the slave device initiates clock stretching, the master device cannot respond to the clock stretching and suspends data transmission. If the master device still sends instructions to the slave device at this time, the slave device may not be able to respond to the instruction in time, resulting in communication failure. Summary of the invention
[0004] The present application provides a communication control method, system and device for an I2C bus, which can control the clock signal of a master device according to the clock signal of a slave device in the case of I2C transparent transmission, thereby avoiding communication failure between the master device and the slave device when the slave device triggers clock extension, and improving the stability and effectiveness of data transmission.
[0005] In a first aspect, the present application provides a communication control method for an I2C bus, the method comprising: if a falling edge of a first clock signal corresponding to a master device is monitored, setting the first clock signal and a second clock signal corresponding to a slave device to a low level; after a first preset time period, converting the second clock signal from a low level to a high impedance state, and monitoring the state of the second clock signal; and controlling the state of the first clock signal according to the state of the second clock signal.
[0006] Optionally, controlling the state of the first clock signal according to the state of the second clock signal includes: if it is monitored that the second clock signal is at a low level, setting the first clock signal to a low level.
[0007] Optionally, after setting the first clock signal to a low level, the method further includes: setting the second clock signal to a high impedance state, and continuing to monitor the state of the second clock signal until the second clock signal is at a high level.
[0008] Optionally, controlling the state of the first clock signal according to the state of the second clock signal includes: if it is monitored that the second clock signal is at a high level, setting the first clock signal to a high impedance state.
[0009] Optionally, it also includes: acquiring the first clock signal within a fourth preset time length; determining the duty cycle and period of the first clock signal based on the first clock signal within the fourth preset time length; determining the first preset time length based on the duty cycle and period.
[0010] Optionally, monitoring the state of the second clock signal includes: monitoring the state of the second clock signal after a second preset time period has passed since the second clock signal was set to a high impedance state.
[0011] In a second aspect, the present application provides an I2C bus communication control system, the system comprising: a master device, a control device and a slave device.
[0012] The control device is communicatively connected with the master device and the slave device respectively.
[0013] The master device is used to send a first clock signal to the control device.
[0014] The slave device is used to receive a second clock signal sent by the control device.
[0015] A control device is used to monitor a first clock signal. If a falling edge of the first clock signal is detected, the first clock signal and the second clock signal are set to a low level, and after a first preset time period, the second clock signal is converted from a low level to a high impedance state, the state of the second clock signal is monitored, and the state of the first clock signal is controlled according to the state of the second clock signal.
[0016] Optionally, the control device is specifically configured to set the first clock signal to a low level if it is detected that the second clock signal is at a low level.
[0017] Optionally, the control device is further used to set the second clock signal to a high-impedance state, and continue to monitor the state of the second clock signal until the second clock signal is at a high level.
[0018] Optionally, the control device is specifically configured to set the first clock signal to a high impedance state if it is detected that the second clock signal is at a high level.
[0019] Optionally, the control device is also used to obtain the first clock signal within a fourth preset time length; determine the duty cycle and period of the first clock signal based on the first clock signal within the fourth preset time length; and determine the first preset time length based on the duty cycle and period.
[0020] Optionally, the control device is specifically configured to monitor the state of the second clock signal after a second preset time period has passed since the second clock signal was set to a high impedance state.
[0021] In a third aspect, the present application provides a communication control device for an I2C bus, the device comprising:
[0022] The monitoring module is used to set the first clock signal and the second clock signal corresponding to the slave device to a low level if a falling edge of the first clock signal corresponding to the master device is detected.
[0023] The control module is used to convert the second clock signal from a low level to a high impedance state after a first preset time period.
[0024] The monitoring module is further used to monitor the state of the second clock signal after a second preset time period.
[0025] The control module is further used to control the first clock signal according to the state of the second clock signal.
[0026] Optionally, the control module is specifically configured to set the first clock signal to a low level if it is detected that the second clock signal is at a low level.
[0027] Optionally, the control module is further configured to set the second clock signal to a high impedance state.
[0028] The monitoring module is further used to continue monitoring the state of the second clock signal until the second clock signal is at a high level.
[0029] Optionally, the control module is specifically configured to set the first clock signal to a high impedance state if it is detected that the second clock signal is at a high level.
[0030] Optionally, the control module is also used to obtain the first clock signal within a fourth preset time length; determine the duty cycle and period of the first clock signal based on the first clock signal within the fourth preset time length; and determine the first preset time length based on the duty cycle and period.
[0031] Optionally, the monitoring module is further configured to monitor the state of the second clock signal after a second preset time period has passed since the second clock signal was set to a high impedance state.
[0032] In a fourth aspect, the present application provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to execute a method such as the first aspect or an optional method of the first aspect.
[0033] In a fifth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement a method such as the first aspect or an optional method of the first aspect.
[0034] The present application provides a communication control method, system and device of an I2C bus. The method sets the first clock signal and the second clock signal corresponding to the slave device to a low level if a falling edge of a first clock signal corresponding to a master device is monitored, converts the second clock signal from a low level to a high impedance state after a first preset time period, and monitors the state of the second clock signal; controls the state of the first clock signal according to the state of the second clock signal, and can control the clock signal of the master device according to the clock signal of the slave device, thereby avoiding communication failure between the master device and the slave device when the slave device triggers clock extension, thereby improving the stability and effectiveness of data transmission. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A schematic diagram of an application scenario of an I2C bus communication control method provided in the present application;
[0036] Figure 2 A flow chart of a communication control method of an I2C bus provided in the present application;
[0037] Figure 3 A flow chart of another I2C bus communication control method provided by the present application;
[0038] Figure 4 A timing diagram of an I2C clock signal provided in this application;
[0039] Figure 5 A schematic diagram of the structure of an I2C bus communication control system provided by the present application;
[0040] Figure 6 A schematic diagram of the structure of an I2C bus communication control device provided in this application;
[0041] Figure 7 A schematic diagram of the structure of an electronic device provided in this application.
[0042] The above drawings show clear embodiments of the present disclosure, which will be described in more detail below. These drawings and text descriptions are not intended to limit the scope of the present disclosure in any way, but to illustrate the concepts of the present disclosure to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0043] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0044] The Inter-Integrated Circuit (I2C) is a serial communication bus. The I2C serial bus generally has two signal lines, one is a bidirectional data line, and the other is a bidirectional clock line. As the master device that controls the data transmission of the bus, on the one hand, it sends the clock signal through the clock line output circuit, and on the other hand, it detects the level of the clock signal on the bus to determine when to send the next clock pulse level. As a slave device that accepts the command of the master device, it sends or receives the signal on the data line according to the clock signal on the bus, and can also send a low-level signal to the clock line to extend the bus clock signal cycle. For example, when the slave device needs to perform other tasks, or when the speed of the slave device cannot keep up with the master device, the slave device can pull the clock signal low and suspend the data transmission between the master device until the slave device releases the clock signal, and then resume the data transmission between the master device and the slave device. The process of the slave device pulling down the clock signal is called clock stretching. However, in the case of I2C transparent transmission, since the master device and the slave device are not directly connected, when the slave device initiates clock stretching, the master device cannot respond to the clock stretching and suspends data transmission. If the master device still sends instructions to the slave device at this time, the slave device may not be able to respond to the instruction in time, resulting in communication failure.
[0045] If, when the slave device initiates clock stretching, the clock of the master device can be controlled, the master device can be controlled to suspend data transmission, thereby ensuring the reliability of data transmission between the master device and the slave device.
[0046] Based on this, the present application provides a communication control method of an I2C bus, which is applied to an electronic device, which is connected in series between a master device and a slave device, that is, the electronic device is connected in series between the I2C clock signal port of the master device and the I2C clock signal port of the slave device, and it can realize I2C transparent transmission. After the device is powered on, the port connected to the I2C clock signal of the electronic device and the master device is first set to a high impedance state during initialization to monitor the state of the clock signal of the master device. When the falling edge of the clock signal of the master device is monitored, the clock of the master device and the clock of the slave device are controlled, and the clocks of the master device and the slave device are controlled to be low level, and timing is started. Usually, the clock signal is a square wave signal, half a clock cycle is low level, and half a clock cycle is high level. Therefore, by monitoring whether the clock signal of the slave device jumps to a high point level after half a clock cycle, it can be determined whether the slave device triggers clock extension. Based on this, after half a clock cycle, the electronic device sets the clock of the slave device to a high impedance state, releases the control right of the clock, and monitors the state of the clock signal of the slave device. If the clock signal of the slave device is monitored to be high, it means that the slave device has not stretched the clock, and the clock signal of the master device is set to a high impedance state, releasing the control of the clock signal of the master device; if the clock signal of the slave device is monitored to be low, it means that the slave device has stretched the clock, and the clock signal of the master device is still controlled to be low, and the state of the clock signal of the slave device is continuously monitored until the clock signal of the slave device jumps to a high level, and then the clock signal of the master device is set to a high impedance state, releasing the control of the clock signal of the master device. Through this method, in the case of transparent transmission of I2C by electronic devices, when the slave device triggers clock stretching, the electronic device can timely control the clock signal of the master device to remain in a low level state, thereby suspending the communication between the master device and the slave device, and only when the slave device ends the clock stretching, the control of the clock signal of the master device is released, so that the master device and the slave device resume normal communication.
[0047] Figure 1 A schematic diagram of an application scenario of an I2C bus communication control method provided in this application, such as Figure 1 As shown, the scenario includes: a master device 11, an electronic device 12 and a slave device 13.
[0048] The electronic device 12 is connected to the master device 11 and the slave device 13 via the I2C bus. When the master device 11 and the slave device 13 communicate via the I2C bus, the electronic device 13 can transparently transmit relevant data.
[0049] The electronic device 12 may specifically include a device with a control function, such as a field programmable gate array (FPGA) and a complex programmable logic device (CPLD).
[0050] Figure 2 A flow chart of a communication control method of an I2C bus provided in the present application is provided, and the method is applied to electronic devices, such as Figure 2 As shown, the method includes:
[0051] S201. If a falling edge of a first clock signal corresponding to the master device is detected, the first clock signal and a second clock signal corresponding to the slave device are set to a low level.
[0052] Specifically, a master device generally refers to a device that issues a main command; a slave device generally refers to a device that receives a command.
[0053] The first clock signal is an I2C clock signal corresponding to the master device; the second clock signal is an I2C clock signal corresponding to the slave device.
[0054] S202: After a first preset time period, convert the second clock signal from a low level to a high impedance state, and monitor the state of the second clock signal.
[0055] The first preset duration may be a specific duration set by a user, or may be determined by the electronic device according to the duty cycle and period of the first clock signal. Specifically, the first preset duration may be a duration corresponding to a low level of the clock signal in a clock cycle.
[0056] Usually, the clock signal of the I2C bus is a square wave, and accordingly, the first preset duration is half a clock cycle. The user can complete the time by setting a timer inside the electronic device.
[0057] S203 . Control the state of the first clock signal according to the state of the second clock signal.
[0058] If the second clock signal is at a low level, the first clock signal is controlled to be at a low level; if the second clock signal is at a high level, the first clock signal is controlled to be in a high-impedance state, releasing the control right of the first clock signal, so that the master device can control the state of the first clock signal.
[0059] In the embodiment of the present application, if a falling edge of a first clock signal corresponding to a master device is monitored, the first clock signal and the second clock signal corresponding to a slave device are set to a low level, and after a first preset time period, the second clock signal is converted from a low level to a high impedance state, and the state of the second clock signal is monitored; the state of the first clock signal is controlled according to the state of the second clock signal. In the case of I2C transparent transmission, the clock signal of the master device can be controlled according to the clock signal of the slave device, thereby avoiding communication failure between the master device and the slave device when the slave device triggers clock extension, thereby improving the stability and effectiveness of data transmission.
[0060] Figure 3 A flow chart of another I2C bus communication control method provided by the present application, the method is applied to electronic devices, such as Figure 3 As shown, the method includes:
[0061] S301: If a falling edge of a first clock signal corresponding to a master device is detected, the first clock signal and a second clock signal corresponding to a slave device are set to a low level.
[0062] S301 and S201 have the same technical features. For detailed description, please refer to S201 and will not be repeated here.
[0063] If the electronic device is just powered on, then before executing S301, the first clock signal is set to a high impedance state, that is, the state of the port of the electronic device for receiving the first clock signal corresponding to the master device is set to a high impedance state. Through this setting, the port state of the electronic device will change with the change of the first clock signal corresponding to the master device, and the first clock signal can be monitored.
[0064] If the falling edge of the first signal is monitored, it indicates that the first clock signal will enter a low level state, so the states of the first clock signal and the second clock signal are both set to a low level.
[0065] Figure 4 A timing diagram of an I2C clock signal provided in this application, such as Figure 4 As shown, if the falling edge of the first clock signal corresponding to the master device is monitored, the first clock signal and the second clock signal corresponding to the slave device are both set to a low level.
[0066] S302: After a first preset time period, convert the second clock signal from a low level to a high impedance state, and monitor the state of the second clock signal.
[0067] S302 and S202 have the same technical features. For detailed description, please refer to S202 and will not be repeated here.
[0068] The clock signal is usually a high-low level alternating signal, and the first preset duration is specifically the duration of the first clock signal being low level within a clock cycle. Usually, the clock signal is a square wave signal with a duty cycle of 50%, based on which, the first preset duration can be set to half a clock cycle.
[0069] The duty cycle of the clock signal is different, and the corresponding duration of being in the low level state is also different.
[0070] Optionally, the method also includes: acquiring the first clock signal within a fourth preset time length; determining the duty cycle and period of the first clock signal based on the first clock signal within the fourth preset time length; and determining the first preset time length based on the duty cycle and period.
[0071] Specifically, the fourth preset duration should be greater than the period of the first clock signal.
[0072] The method can be used to determine the period and duty cycle of the first clock signal, and then the corresponding first preset duration can be determined according to the period and duty cycle.
[0073] Optionally, monitoring the state of the second clock signal includes: monitoring the state of the second clock signal after a second preset time period after the second clock signal is set to a high impedance state.
[0074] By setting the second preset duration, a time margin can be reserved for the slave device to pull down the clock signal, thereby improving the accuracy of the monitoring result and improving the accuracy of the control.
[0075] Setting the second clock signal to a high impedance state actually means that the electronic device sets the port connected to the second clock signal corresponding to the slave device to a high impedance state, so that the state of the port can change with the change of the second clock signal, that is, the state of the second clock signal can be monitored.
[0076] Continue to see Figure 4 , Figure 4 The second preset duration is one eighth of a clock cycle, that is, 1 / 8Tscl. After the electronic device sets the second clock signal to a high impedance state for a duration of 1 / 8Tscl, it monitors the state of the second clock signal.
[0077] S303: If the second clock signal is detected to be at a low level, execute S304; if the second clock signal is detected to be at a high level, execute S306.
[0078] S304 , continue to set the first clock signal to a low level.
[0079] S305 , setting the second clock signal to a high impedance state, and continuing to monitor the state of the second clock signal until the second clock signal is at a high level.
[0080] Continue to see Figure 4 Assuming that the first preset duration is half a clock cycle, after half a clock cycle, that is, after 1 / 2Tscl, if the second clock signal is still detected to be at a low level, it indicates that the slave device has pulled down the clock signal, that is, the slave device has triggered clock stretching, and the state of the first clock signal is not changed, and the first clock signal is still set to a low level. When the second clock signal jumps from a low level to a high level, it indicates that the slave device has ended clock stretching.
[0081] S306: Set the first clock signal to a high impedance state.
[0082] Continue to see Figure 4 If the second clock signal is detected to be high, it indicates that the slave device has not pulled down the clock signal, and the first clock signal is set to a high impedance state, releasing the control of the state of the first clock signal, and the master device controls the state of the first clock signal. The master device can continue to communicate with the slave device. The electronic device sets the first clock signal to a high impedance state to detect the state of the first clock signal. When the next falling edge of the first clock signal is detected, the above steps are re-executed to perform a new round of control on the first clock signal.
[0083] The present application is implemented on the basis of the above-mentioned embodiments, and further sets the second clock signal to a high-impedance state if it is monitored that the second clock signal is at a low level, and continues to detect the state of the second clock signal until the second clock signal is at a high level, so that when the slave device triggers clock extension, the clock signal of the master device can be controlled to a low level, thereby suspending the communication between the master device and the slave device; if it is monitored that the second clock signal is at a high level, the first clock signal is set to a high-impedance state to release the control over the first clock signal, so that the master device controls the state of the first clock signal, and then the master device and the slave device can continue to communicate, thereby avoiding communication failure due to the slave device triggering clock extension during the communication between the master device and the slave device in the case of transparent transmission, thereby improving the stability and effectiveness of data transmission.
[0084] Figure 5 A schematic diagram of the structure of an I2C bus communication control system provided in this application, such as Figure 5 As shown, the system includes: a master device 51, a control device 52 and a slave device 53.
[0085] The control device 52 is communicatively connected to the master device 51 and the slave device 53 respectively.
[0086] The master device 51 is configured to send a first clock signal to the control device 52 .
[0087] The slave device 51 is used to receive the second clock signal sent by the control device 52.
[0088] The control device 52 is used to monitor the first clock signal. If the falling edge of the first clock signal is detected, the first clock signal and the second clock signal are set to a low level, and after a first preset time period, the second clock signal is converted from a low level to a high impedance state, the state of the second clock signal is monitored, and the state of the first clock signal is controlled according to the state of the second clock signal.
[0089] Optionally, the control device 52 is specifically configured to continue setting the first clock signal to a low level if it is detected that the second clock signal is at a low level.
[0090] Optionally, the control device 52 is further configured to set the second clock signal to a high impedance state, and continue to monitor the state of the second clock signal until the second clock signal is at a high level.
[0091] Optionally, the control device 52 is specifically configured to set the first clock signal to a high impedance state if it is detected that the second clock signal is at a high level.
[0092] Optionally, the control device 52 is also used to obtain the first clock signal within a fourth preset time length; determine the duty cycle and period of the first clock signal based on the first clock signal within the fourth preset time length; and determine the first preset time length based on the duty cycle and period.
[0093] Optionally, the control device 52 is specifically configured to monitor the state of the second clock signal after a second preset time period has passed since the second clock signal was set to the high impedance state.
[0094] The system can implement the above method, and its content and effects can be referred to the method embodiment part, which will not be described in detail.
[0095] Figure 6 A schematic diagram of the structure of an I2C bus communication control device provided in this application, such as Figure 6 As shown, the device comprises:
[0096] The monitoring module 61 is used to set the first clock signal and the second clock signal corresponding to the slave device to a low level if a falling edge of the first clock signal corresponding to the master device is detected.
[0097] The control module 62 is used to convert the second clock signal from a low level to a high impedance state after a first preset time period.
[0098] The monitoring module 61 is further configured to monitor the state of the second clock signal after a second preset time period.
[0099] The control module 62 is further configured to control the first clock signal according to the state of the second clock signal.
[0100] Optionally, the control module 62 is specifically configured to continue setting the first clock signal to a low level if it is detected that the second clock signal is at a low level.
[0101] Optionally, the control module 62 is further configured to set the second clock signal to a high impedance state.
[0102] The monitoring module 61 is further configured to continue monitoring the state of the second clock signal until the second clock signal is at a high level.
[0103] Optionally, the control module 62 is specifically configured to set the first clock signal to a high impedance state if it is detected that the second clock signal is at a high level.
[0104] Optionally, the control module 62 is further used to obtain the first clock signal within a fourth preset time length; determine the duty cycle and period of the first clock signal according to the first clock signal within the fourth preset time length; and determine the first preset time length according to the duty cycle and period.
[0105] Optionally, the monitoring module 62 is further configured to monitor the state of the second clock signal after a second preset time period has passed since the second clock signal was set to a high impedance state.
[0106] The device can execute the above method, and its content and effects can be referred to the method embodiment part, which will not be described in detail.
[0107] Figure 7 A schematic diagram of the structure of an electronic device provided in this application, such as Figure 7 As shown, the electronic device includes: a processor 71 and a memory 72; the processor 71 is in communication connection with the memory 72. The memory 72 is used to store computer programs. The processor 71 is used to call the computer program stored in the memory 72 to implement the method in the above method embodiment.
[0108] Optionally, the electronic device further includes: a transceiver 73 for communicating with other devices.
[0109] The electronic device can execute the above method, and its content and effects can be referred to the method embodiment part, which will not be described in detail.
[0110] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the above method.
[0111] The computer executable instructions stored in the computer readable storage medium can implement the above method when executed by the processor. The content and effect thereof can be referred to in the method embodiment part, which will not be described in detail.
[0112] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are considered to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims. It should be understood that the present disclosure is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A communication control method for an I2C bus, characterized in that: include: If a falling edge of the first clock signal corresponding to the master device is detected, the first clock signal and the second clock signal corresponding to the slave device are set to a low level; After a first preset time duration, converting the second clock signal from the low level to a high impedance state, and monitoring the state of the second clock signal, wherein the first preset time duration is determined according to a duty cycle and a period of the first clock signal; Controlling the state of the first clock signal according to the state of the second clock signal, wherein the state of the second clock signal is used to indicate whether the slave device triggers clock stretching; The controlling the state of the first clock signal according to the state of the second clock signal comprises: if it is detected that the second clock signal is at a low level, continuing to set the first clock signal to a low level; setting the second clock signal to a high impedance state, and after a second preset time after the second clock signal is set to the high impedance state, monitoring the state of the second clock signal until the second clock signal is at a high level; If it is detected that the second clock signal is at a high level, the first clock signal is set to a high impedance state.
2. The method according to claim 1, characterized in that Also includes: Acquire the first clock signal within a fourth preset time length; Determining a duty cycle and a period of the first clock signal according to the first clock signal within the fourth preset time length; The first preset duration is determined according to the duty cycle and the period.
3. A communication control system of I2C bus, characterized in that: include: Master, control and slave devices; The control device is communicatively connected with the master device and the slave device respectively; The master device is used to send a first clock signal to the control device; The slave device is used to receive a second clock signal sent by the control device; The control device is used to monitor the first clock signal, and if a falling edge of the first clock signal is detected, the first clock signal and the second clock signal are set to a low level, and after a first preset time, the second clock signal is converted from the low level to a high impedance state, wherein the first preset time is determined according to the duty cycle and period of the first clock signal; monitor the state of the second clock signal, and control the state of the first clock signal according to the state of the second clock signal, wherein the state of the second clock signal is used to indicate whether the slave device triggers clock stretching; The control device is specifically used to: if the second clock signal is monitored to be at a low level, continue to set the first clock signal to a low level; set the second clock signal to a high-impedance state, and after a second preset time after the second clock signal is set to the high-impedance state, monitor the state of the second clock signal until the second clock signal is at a high level; if the second clock signal is monitored to be at a high level, set the first clock signal to a high-impedance state.
4. A communication control device for an I2C bus, characterized in that: include: A monitoring module, configured to set the first clock signal and the second clock signal corresponding to the slave device to a low level if a falling edge of the first clock signal corresponding to the master device is detected; A control module, configured to convert the second clock signal from the low level to a high impedance state after a first preset time period, wherein the first preset time period is determined according to the duty cycle and period of the first clock signal; and after a second preset time period, monitor the state of the second clock signal, and control the state of the first clock signal according to the state of the second clock signal, wherein the state of the second clock signal is used to indicate whether the slave device triggers clock stretching; The control module is specifically used for: if the second clock signal is monitored to be at a low level, then continue to set the first clock signal to a low level; set the second clock signal to a high-impedance state, and after a second preset time after the second clock signal is set to the high-impedance state, monitor the state of the second clock signal until the second clock signal is at a high level; if the second clock signal is monitored to be at a high level, then set the first clock signal to a high-impedance state.
5. A control device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to claim 1 or 2.
6. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to claim 1 or 2 is implemented.
