CN115952122A - I2C device hot plug method, system, device, medium and product - Google Patents
I2C device hot plug method, system, device, medium and product Download PDFInfo
- Publication number
- CN115952122A CN115952122A CN202211674256.1A CN202211674256A CN115952122A CN 115952122 A CN115952122 A CN 115952122A CN 202211674256 A CN202211674256 A CN 202211674256A CN 115952122 A CN115952122 A CN 115952122A
- Authority
- CN
- China
- Prior art keywords
- state
- plugging
- bus
- equipment
- control module
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Power Sources (AREA)
Abstract
The present disclosure relates to a method, system, device, medium and product for hot-plugging an I2C device, comprising: monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state; when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction; and when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered off, the I2C bus to be reversely initialized, the I2C equipment drive and the I2C bus drive to be unloaded based on the control module and the plugging instruction, so as to realize the hot plugging function of the I2C equipment.
Description
Technical Field
The present disclosure relates to the field of device communication technologies, and in particular, to a method, a system, a device, a medium, and a product for hot plug of an I2C device.
Background
The I2C bus is a common communication interface, which is often used in embedded devices. I2C: (Inter-Integrated Circuit), a simple, bi-directional two-wire synchronous serial bus developed by Philips corporation, which requires only one data line SDA and one clock line SCL to transfer information between devices connected to the bus. Because embedded devices are different in form, a plugging function may be required in some application scenarios, and a plugged portion has an I2C device, so that the I2C device is required to have a hot-plugging function, so that the reconnection function can be normally used after being unplugged, in a common embedded system such as Linux, linux: a UNIX-like operating system for free use and free propagation. The hot plug of the I2C device is not supported by default, so that the hot plug function of the I2C device is required to be realized from software and hardware.
In the prior art, an I2C uses two lines, namely SCL and SDA, to perform data communication between a master controller and a slave computer on hardware, one I2C bus supports mounting of a plurality of I2C slave devices, different I2C slave devices have different device addresses, and an I2C master controller accesses a designated I2C slave device through the device address. Data transfer between the I2C bus and the devices complies with the I2C protocol.
The I2C driver in software may be implemented differently in different platforms, and may generally include a bus driver and a device driver, and for example, an embedded Linux system that is widely applied is taken as an example, and an I2C architecture thereof is divided into a core framework, a bus driver, and a device driver. The core frame provides interfaces for management such as bus drive and device drive registration and cancellation; the bus driver is used for realizing the I2C adapter and managing the I2C driver and equipment; the device driver is an implementation of a concrete I2C hardware device, mounted on an abstract I2C bus. The bus driver and the device driver are initialized in the system starting process.
Therefore, in the prior art, the loading of the I2C device is completed during the system startup process, and once the device is removed after startup, the device will fail, and the device needs to be connected and then the system is restarted for normal use, that is, the hot plug of the I2C device is not supported.
Disclosure of Invention
To overcome the problems in the related art, the present disclosure provides a method, system, device, medium, and product for hot-plugging an I2C device.
According to a first aspect of the embodiments of the present disclosure, an I2C device hot plug method is provided, where the method is applied to an I2C device hot plug system, the I2C device hot plug system includes an I2C device, a secondary board, a main board, and a control module, the I2C device and the control module are disposed on the secondary board, the I2C device is in communication connection with the main board through an I2C bus, an I2C device driver is stored on the I2C device, an I2C bus driver is stored on the I2C bus, and the I2C device driver and the I2C bus driver are compiled in a module form, and the method includes:
monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state;
when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction;
and when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus based on the control module and the plugging instruction.
In some embodiments, the secondary board is electrically connected to the main board through a connection terminal, the connection terminal includes an ID pin and a GND pin, and the secondary board is further provided with a monitoring module for monitoring a plugging state of the I2C device;
monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state, and the monitoring method comprises the following steps:
an interrupt processing function is stored in the monitoring module, and the state of the I2C equipment is judged by monitoring the level change of the ID pin and the GND pin through the interrupt processing function.
In some embodiments, monitoring level changes of the ID pin and the GND pin by the interrupt handling function to determine a state of the I2C device includes:
when the interrupt processing function monitors that the ID pin is changed from a suspension state to a high level and the GND pin is changed from the suspension state to a low level, judging that the state of the I2C equipment is the insertion state;
and when the interrupt processing function monitors that the ID pin changes from a high level state to a suspended state and the GND pin changes from a low level state to the suspended state, judging that the state of the I2C equipment is the pull-out state.
In some embodiments, monitoring level changes of the ID pin and the GND pin by the interrupt handling function to determine a state of the I2C device further includes:
when the ID pin is monitored to be changed from a suspended state to a high level, the GND pin is changed from the suspended state to the low level, or
And when the ID pin is changed from a high level state to a suspended state and the GND pin is changed from a low level state to the suspended state for a first preset time, judging that the state of the I2C equipment is not changed.
In some embodiments, when it is determined that the plugging state is the plugging state, sending a plugging instruction to the control module, and controlling, based on the control module and the plugging instruction, the I2C device to be powered on, the I2C bus to be initialized, and the I2C device driver and the I2C bus driver to be loaded, includes:
when the state plugging state is the plugging state, the control module controls the I2C device to complete power-on based on the plugging instruction, then controls the I2C bus to complete initialization, enables the I2C device to be normally connected with the mainboard through the I2C bus, and finally loads the I2C device driver and the I2C bus driver.
In some embodiments, when it is determined that the plugging state is the plugging state, a plugging instruction is sent to the control module, and the I2C device is controlled to power down, I2C bus is controlled to be initialized reversely, and the I2C device driver and the I2C bus driver are controlled to be unloaded based on the control module and the plugging instruction, including:
when the state plugging state is a plugging state, the control module unloads the I2C device driver and the I2C bus driver based on the plugging instruction, then controls the I2C bus to complete reverse initialization, disconnects the I2C device from the mainboard, and finally controls the I2C device to complete power-off.
According to a second aspect of the embodiments of the present disclosure, an I2C device hot plug system is provided, the I2C device hot plug system includes an I2C device, a secondary board, a main board, a control module, and a monitoring module, the I2C device, the monitoring module, and the control module are disposed on the secondary board, the I2C device is connected to the main board through an I2C bus, an I2C device driver is stored on the I2C device, an I2C bus driver is stored on the I2C bus, the I2C device driver and the I2C bus driver are compiled in a module form, including:
the monitoring module is used for monitoring the plugging and unplugging state of the I2C equipment, and the plugging and unplugging state comprises a plugging state and a unplugging state;
when the plugging state is determined to be the plugging state, the control module is used for controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading through a plugging instruction;
and when the plugging state is determined to be the plugging state, the control module is used for controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus through an insertion instruction.
Embodiments of the third aspect of the present application provide an electronic device, including a processor and a memory, where the memory stores at least one instruction, at least one program, a set of codes, or a set of instructions, and the instruction, the program, the set of codes, or the set of instructions is loaded and executed by the processor to implement the steps of the I2C device hot plug method provided in the embodiments of the first aspect of the present application.
Embodiments of the fourth aspect of the present application provide a non-transitory computer-readable storage medium, and when executed by a processor of a mobile terminal, enable the mobile terminal to perform the steps of the I2C device hot plug method provided in the embodiments of the first aspect of the present application described above.
Embodiments of the fifth aspect of the present application provide a computer program product, where instructions of the computer program product, when executed by a processor of a mobile terminal, enable the mobile terminal to perform steps of implementing the I2C device hot plug method provided in the foregoing embodiments of the first aspect of the present application.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects: the demand of realizing I2C equipment hot plug in embedded equipment development of this application, thereby the hot plug action of discernment I2C equipment is monitored to the voltage variation who monitors ID pin and GND pin through the interrupt processing function in the monitoring module, has the advantage of stable discernment, prevents the misidentification, also can protect the device not damaged. The I2C device driver and the I2C bus driver are compiled and realized in a module form in software, so that loading or unloading can be conveniently carried out at any time, derivation is carried out by depending on a primary driver, simplicity and convenience are realized, and the complexity and difficulty of the software cannot be increased.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
FIG. 1 is a flowchart illustrating an I2C device hot plug method according to an example embodiment.
FIG. 2 is a hardware schematic diagram illustrating an I2C device hot plug system according to an example embodiment.
Fig. 3 is an internal block diagram of an electronic device shown in accordance with an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. The following description refers to the accompanying drawings in which 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 invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
Fig. 1 is a flowchart illustrating an I2C device hot plug method according to an exemplary embodiment, where as shown in fig. 1, the method is applied to an I2C device hot plug system, where the I2C device hot plug system includes an I2C device, a secondary board, a main board, and a control module, the I2C device and the control module are disposed on the secondary board, the I2C device is communicatively connected to the main board through an I2C bus, the I2C device stores an I2C device driver, the I2C bus stores an I2C bus driver, and both the I2C device driver and the I2C bus driver are compiled in a module form, and the method includes the following steps:
s101, monitoring the plugging and unplugging state of the I2C equipment, wherein the plugging and unplugging state comprises a plugging state and a unplugging state.
Specifically, in order to realize that hot plug of the I2C device does not affect other devices, the I2C device solely shares an I2C bus, and the I2C device is in communication connection with the motherboard through the I2C bus. The hot plug of the I2C equipment is completed by monitoring the plug state of the I2C equipment and judging whether the plug state is the plug-in state or the plug-out state so as to execute different subsequent operations.
In some embodiments, the secondary board is electrically connected to the main board through a connection terminal, the connection terminal includes an ID pin and a GND pin, and the secondary board is further provided with a monitoring module for monitoring a plugging state of the I2C device;
monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state, and the monitoring method comprises the following steps:
an interrupt processing function is stored in the monitoring module, and the state of the I2C equipment is judged by monitoring the level change of the ID pin and the GND pin through the interrupt processing function.
Specifically, the I2C device is arranged on the secondary board, the secondary board is electrically connected with the main board through the ID pin and the GND pin, the monitoring module is also arranged on the secondary board, the monitoring module stores an interrupt processing function to monitor the level change of the ID pin and the GND pin so as to judge the state of the I2C device, the interrupt pins (the ID pin and the GND pin) are pulled up or pulled down to generate an interrupt signal, and the function for processing the interrupt signal is the interrupt processing function, so that the state change of the I2C device can be judged by monitoring the level change of the ID pin and the GND pin through the interrupt processing function.
In some embodiments, monitoring level changes of the ID pin and the GND pin by the interrupt handling function to determine a state of the I2C device includes:
when the interrupt processing function monitors that the ID pin is changed from a suspension state to a high level and the GND pin is changed from the suspension state to a low level, judging that the state of the I2C equipment is the insertion state;
and when the interrupt processing function monitors that the ID pin changes from a high level state to a suspended state and the GND pin changes from a low level state to the suspended state, judging that the state of the I2C equipment is the pull-out state.
Specifically, the ID pin in the application is pulled high by default, the GND pin is pulled low by default, the I2C device is suspended when not connected, the ID pin is pulled high to generate a high level after the I2C device is inserted, the GND pin is pulled low to generate a low level, an interrupt is generated at the moment, the ID pin is pulled high to generate a high level when the I2C device is judged, and the state of the I2C device at the moment is indicated to be an insertion state when the GND pin is pulled low to generate a low level, namely, an insertion event occurs. When the ID pin changes from a high level state to a suspended state and the GND pin changes from a low level state to a suspended state, the state of the I2C device is judged to be a pull-out state, and a pull-out event occurs.
In some embodiments, monitoring level changes of the ID pin and the GND pin by the interrupt handling function to determine a state of the I2C device further includes:
when it is monitored that the ID pin changes from a suspended state to a high level, the GND pin changes from the suspended state to a low level, or
And when the ID pin is changed from a high level state to a suspended state and the GND pin is changed from a low level state to the suspended state for a first preset time, judging that the state of the I2C equipment is not changed.
Specifically, in order to avoid a change in the state of the I2C device due to slight jitter of the I2C device, when it is monitored that the ID pin changes from a floating state to a high level, the GND pin changes from a floating state to a low level or the ID pin changes from a high level state to a floating state, and the change of the GND pin from a low level to a floating state is lower than a first preset time (for example, 100 ms), it is determined that the I2C device slightly jitters and is not an insertion or extraction event, thereby avoiding the damage to the device due to power-on of the I2C device when the I2C device is powered off.
And S102, when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction.
Specifically, when the ID pin and the GND pin are monitored to change through the interrupt processing function and it is determined that the plugging state of the I2C device at this time is the plugging state, a plugging instruction is generated to the control module, and the control module receives the plugging instruction and then controls specific operations of powering on the I2C device, initializing the I2C bus, driving the I2C device, and loading the I2C bus driver.
In some embodiments, when it is determined that the plugging state is the plugging state, sending a plugging instruction to the control module, and controlling, based on the control module and the plugging instruction, power-on of the I2C device, initialization of an I2C bus, and loading of an I2C device driver and the I2C bus driver, includes:
when the state plugging state is a plugging state, the control module controls the I2C device to complete power-on based on the plugging instruction, then controls the I2C bus to complete initialization, enables the I2C device to be normally connected with the mainboard through the I2C bus, and finally loads the I2C device driver and the I2C bus driver.
Specifically, the control module first controls the I2C device to be powered on, then controls the I2C bus to complete initialization, where the initialization specifically includes registering a bus, defining a data structure of an I2C adapter, an I2C communication mode of a specific adapter, and the like, and the initialization may be understood as a series of actions that the I2C bus can normally work, and finally, an I2C device driver and an I2C bus driver are loaded, so that the I2C device and a motherboard can directly communicate through the I2C bus, and after the I2C device driver and the I2C bus driver are loaded, an upper layer is informed to restart an application service or function related to the I2C device.
S103, when the plugging state is determined to be the unplugging state, a unplugging instruction is sent to the control module, and the I2C equipment is controlled to be powered off, the I2C bus is controlled to be initialized reversely, the I2C equipment is controlled to be driven and the I2C bus is controlled to be unloaded based on the control module and the unplugging instruction.
Specifically, when the ID pin and the GND pin are monitored to change through the interrupt processing function and it is determined that the plugging state of the I2C device at this time is the plugging state, an insertion instruction is generated to the control module, and the control module receives the insertion instruction and then controls specific operations of powering off the I2C device, performing I2C bus reverse initialization, and performing I2C device driving and I2C bus driving unloading.
In some embodiments, when it is determined that the plugging state is the plugging state, a plugging instruction is sent to the control module, and the I2C device is controlled to power down, I2C bus is controlled to be initialized reversely, and the I2C device driver and the I2C bus driver are controlled to be unloaded based on the control module and the plugging instruction, including:
when the state plugging state is a plugging state, the control module firstly unloads the I2C device driver and the I2C bus driver based on the plugging instruction, then controls the I2C bus to complete reverse initialization, so that the I2C device is disconnected with the mainboard, and finally controls the I2C device to complete power down.
Specifically, the control module unloads the I2C device driver and the I2C bus driver, disconnects the communication between the I2C device and the motherboard through the I2C bus, then controls the I2C bus to complete the reverse initialization, which is the reverse process of the initialization, and can be understood as a series of actions that the I2C bus cannot work normally, and finally controls the I2C device to complete power down, and after the power down is completed, the upper layer is notified to close the application service or function related to the I2C device.
FIG. 2 is a hardware schematic diagram of an I2C device hot plug system shown in accordance with an example embodiment. Referring to fig. 2, the I2C device hot plug system includes an I2C device, a secondary board, a main board, a control module, and a monitoring module, where the I2C device, the monitoring module, and the control module are disposed on the secondary board, the I2C device is in communication connection with the main board through an I2C bus, the I2C device is stored with an I2C device driver, the I2C bus is stored with an I2C bus driver, and the I2C device driver and the I2C bus driver are compiled in a module form, which includes:
the monitoring module is used for monitoring the plugging and unplugging state of the I2C equipment, and the plugging and unplugging state comprises a plugging state and a unplugging state;
when the plugging state is determined to be the plugging state, the control module is used for controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading through a plugging instruction;
and when the plugging state is determined to be the plugging state, the control module is used for controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus through an inserting instruction.
With respect to the system in the above embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated herein.
In one embodiment, an electronic device is provided, which may be a terminal, and the internal structure thereof may be as shown in fig. 3. The electronic device comprises a processor, a memory, a communication interface, a display screen and an input device which are connected through a system bus. Wherein the processor of the electronic device is configured to provide computing and control capabilities. The memory of the electronic equipment comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and the computer program to run on the non-volatile storage medium. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, an operator network, near Field Communication (NFC) or other technologies. The computer program is executed by a processor to implement an I2C device hot plug method. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the configuration shown in fig. 3 is a block diagram of only a portion of the configuration associated with the present application, and is not intended to limit the computing device to which the present application may be applied, and that a particular computing device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, the I2C device hot plug system provided herein may be implemented in the form of a computer program that is executable on an electronic device as shown in fig. 3. The memory of the electronic device can store various program modules which form the hot plug system of the I2C device.
At least one instruction, at least one section of program, a set of codes, or a set of instructions is stored in a memory of the electronic device, and the instruction, the program, the set of codes, or the set of instructions is loaded and executed by the processor to implement the I2C device hot plug method according to any of the above embodiments. For example, the method for implementing hot plug of the I2C device includes: monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state; when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction; and when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the power-off of the I2C equipment, the I2C bus reverse initialization, the I2C equipment drive and the I2C bus drive unloading based on the control module and the plugging instruction.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of: monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state; when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction; and when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus based on the control module and the plugging instruction.
In one embodiment, a computer program product is provided, the instructions in which, when executed by a processor of a mobile terminal, enable the mobile terminal to perform the steps of: monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state; when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction; and when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus based on the control module and the plugging instruction.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware related to instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, databases, or other media used in the embodiments provided herein can include at least one of non-volatile and volatile memory. Non-volatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile Memory can include Random Access Memory (RAM) or external cache Memory. By way of illustration and not limitation, RAM is available in many forms, such as Static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), and the like.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.
Claims (10)
1. The I2C device hot plug method is applied to an I2C device hot plug system, the I2C device hot plug system comprises an I2C device, a secondary board, a main board and a control module, the I2C device and the control module are arranged on the secondary board, the I2C device is in communication connection with the main board through an I2C bus, an I2C device driver is stored on the I2C device, an I2C bus driver is stored on the I2C bus, and the I2C device driver and the I2C bus driver are compiled in a module form, and the method comprises the following steps:
monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state;
when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading based on the control module and the plugging instruction;
and when the plugging state is determined to be the plugging state, sending a plugging instruction to the control module, and controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus based on the control module and the plugging instruction.
2. The I2C device hot plug method according to claim 1, wherein the secondary board is electrically connected with the main board through a connection terminal, the connection terminal comprises an ID pin and a GND pin, and the secondary board is further provided with a monitoring module for monitoring the plugging and unplugging state of the I2C device;
monitoring the plugging state of the I2C equipment, wherein the plugging state comprises a plugging state and a unplugging state, and the monitoring method comprises the following steps:
an interrupt processing function is stored in the monitoring module, and the state of the I2C equipment is judged by monitoring the level change of the ID pin and the GND pin through the interrupt processing function.
3. The I2C device hot plug method of claim 2, wherein determining the state of the I2C device by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function comprises:
when the interrupt processing function monitors that the ID pin is changed from a suspension state to a high level and the GND pin is changed from the suspension state to a low level, judging that the state of the I2C equipment is the insertion state;
and when the interrupt processing function monitors that the ID pin changes from a high level state to a suspended state and the GND pin changes from a low level state to the suspended state, judging that the state of the I2C equipment is the pull-out state.
4. The I2C device hot plug method of claim 2, wherein determining the state of the I2C device by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function further comprises:
when it is monitored that the ID pin changes from a suspended state to a high level, the GND pin changes from the suspended state to a low level, or
And when the ID pin is changed from a high level state to a suspended state and the GND pin is changed from a low level state to the suspended state for a first preset time, judging that the state of the I2C equipment is not changed.
5. The I2C device hot plug method according to claim 1, wherein when it is determined that the plugging state is the plugging state, sending a plugging instruction to the control module, and controlling, based on the control module and the plugging instruction, power-on of the I2C device, I2C bus initialization, and loading of an I2C device driver and the I2C bus driver, comprises:
when the state plugging state is a plugging state, the control module controls the I2C device to complete power-on based on the plugging instruction, then controls the I2C bus to complete initialization, enables the I2C device to be normally connected with the mainboard through the I2C bus, and finally loads the I2C device driver and the I2C bus driver.
6. The I2C device hot plug method according to claim 1, wherein when it is determined that the plugging state is the plugging state, sending a plugging instruction to the control module, and controlling the I2C device to power down, I2C bus reinitialization, I2C device driving, and I2C bus driving unloading based on the control module and the plugging instruction, comprises:
when the state plugging state is a plugging state, the control module firstly unloads the I2C device driver and the I2C bus driver based on the plugging instruction, then controls the I2C bus to complete reverse initialization, so that the I2C device is disconnected with the mainboard, and finally controls the I2C device to complete power down.
7. The utility model provides a I2C equipment hot plug system, its characterized in that, I2C equipment hot plug system includes I2C equipment, time board, mainboard, control module, monitoring module, I2C equipment, monitoring module with control module sets up on the time board, I2C equipment passes through I2C bus and mainboard communication connection, the storage has I2C equipment drive on the I2C equipment, the storage has I2C bus drive on the I2C bus, I2C equipment drive with I2C bus drive all compiles with the module form, includes:
the monitoring module is used for monitoring the plugging and unplugging state of the I2C equipment, and the plugging and unplugging state comprises a plugging state and a unplugging state;
when the plugging state is determined to be the plugging state, the control module is used for controlling the I2C equipment to be powered on, I2C bus initialization, I2C equipment driving and I2C bus driving loading through a plugging instruction;
and when the plugging state is determined to be the plugging state, the control module is used for controlling the power-off of the I2C equipment, the reverse initialization of the I2C bus, the driving of the I2C equipment and the unloading of the driving of the I2C bus through an insertion instruction.
8. An electronic device comprising a processor and a memory, the memory having stored therein at least one instruction, at least one program, a set of codes, or a set of instructions, the instruction, the program, the set of codes, or the set of instructions being loaded and executed by the processor to implement the I2C device hot plug method according to any of claims 1-6.
9. A non-transitory computer readable storage medium, wherein instructions in the storage medium, when executed by a processor of a mobile terminal, enable the mobile terminal to perform the I2C device hot plug method of any of claims 1-6.
10. A computer program product, wherein instructions in the computer program product, when executed by a processor of a mobile terminal, enable the mobile terminal to perform the I2C device hot plug method according to any of claims 1-6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211674256.1A CN115952122A (en) | 2022-12-26 | 2022-12-26 | I2C device hot plug method, system, device, medium and product |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211674256.1A CN115952122A (en) | 2022-12-26 | 2022-12-26 | I2C device hot plug method, system, device, medium and product |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115952122A true CN115952122A (en) | 2023-04-11 |
Family
ID=87290740
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211674256.1A Pending CN115952122A (en) | 2022-12-26 | 2022-12-26 | I2C device hot plug method, system, device, medium and product |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115952122A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116644011A (en) * | 2023-05-31 | 2023-08-25 | 合芯科技有限公司 | Quick identification method, device and equipment of I2C equipment and storage medium |
-
2022
- 2022-12-26 CN CN202211674256.1A patent/CN115952122A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116644011A (en) * | 2023-05-31 | 2023-08-25 | 合芯科技有限公司 | Quick identification method, device and equipment of I2C equipment and storage medium |
CN116644011B (en) * | 2023-05-31 | 2023-11-03 | 合芯科技有限公司 | Quick identification method, device and equipment of I2C equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107423169B (en) | Method and system for testing high speed peripheral device interconnection equipment | |
US10783253B2 (en) | Hardware structure of a trusted computer and trusted booting method for a computer | |
US11314665B2 (en) | Information processing system, information processing device, BIOS updating method for information processing device, and BIOS updating program for information processing device | |
CN103345407B (en) | Control circuit, connection controller, connection control method and mainboard | |
US20170255585A1 (en) | Method and system for switching role of usb otg device and otg device thereof | |
US10656676B2 (en) | Docking device, electrical device, and MAC address cloning method | |
US20120151231A1 (en) | Power supply switching device, a power supply switching device control method and a power supply control program | |
US20180210783A1 (en) | Information processing apparatus, control method of the same, and storage medium | |
JP2013164842A (en) | Electronic device having restoration function of bmc firmware and restoration method of the same | |
US9009376B2 (en) | Electronic device and electronic device system | |
TW201602911A (en) | A bridge module for updating basic input/output system and updating method thereof | |
CN115952122A (en) | I2C device hot plug method, system, device, medium and product | |
CN117744061A (en) | Memory bank processing method and device, storage medium and electronic equipment | |
CN112732616A (en) | BMC starting method, device and equipment based on SPI controller | |
US20170116146A1 (en) | Control method and control device for a mobile terminal | |
TWI515551B (en) | Computer stick expansion system and power management method thereof | |
CN113946530A (en) | Control method and device of expansion card and nonvolatile storage medium | |
US7523336B2 (en) | Controlled power sequencing for independent logic circuits that transfers voltage at a first level for a predetermined period of time and subsequently at a highest level | |
CN114461286B (en) | Server starting method and device, electronic equipment and readable storage medium | |
CN114185720B (en) | Method, device, equipment and storage medium for dynamic hot backup of server | |
CN116360570A (en) | Control method and control device for CPU power-on time sequence and electronic equipment | |
CN109408418B (en) | USB mode switching device and method and USB equipment | |
US20210096624A1 (en) | Electronic apparatus and operation information output method | |
CN112948315A (en) | Storage area sharing method, storage medium and electronic device | |
CN118331647B (en) | Hot-drawing tube management method, cash register and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |