I2c device hot plug method, system, device, medium and product

CN115952122BActive Publication Date: 2026-08-28SHANGHAI WINGTECH INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202211674256.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-26
Publication Date
2026-08-28
Estimated Expiration
2042-12-26

AI Technical Summary

Technical Problem

[0005]因此由于现有技术中I2C设备的加载是在系统启动过程中完成的,开机后设备一旦移除就会失效,需要连接后在重新启动系统才能正常使用,也就是说不支持I2C设备的热插拔

Benefits of technology

[0031]The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: In embedded device development, this application fulfills the requirement for hot-plugging of I2C devices by monitoring voltage changes on the ID and GND pins through interrupt handling functions in the monitoring module, thereby identifying the hot-plugging action of the I2C device. This has the advantage of stable identification, prevents misidentification, and protects the device from damage. In terms of software, both the I2C device driver and the I2C bus driver are compiled and implemented as modules, facilitating loading or unloading at any time. Furthermore, it is derived from the native driver, which is simple and convenient, without increasing the complexity or difficulty of the software.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115952122B_ABST
    Figure CN115952122B_ABST
Patent Text Reader

Abstract

The present disclosure relates to an I2C device hot plug method, system, device, medium and product, comprising: monitoring the plug state of the I2C device, the plug state comprising a plug-in state and a plug-out state; when it is determined that the plug state is the plug-in state, sending a plug-in instruction to the control module, controlling the I2C device power-on, I2C bus initialization, and I2C device driver and I2C bus driver loading based on the control module and the plug-in instruction; when it is determined that the plug state is the plug-out state, sending a plug-out instruction to the control module, controlling the I2C device power-off, I2C bus de-initialization, and I2C device driver and I2C bus driver unloading based on the control module and the plug-out instruction, to realize the hot plug function of the I2C device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of device communication technology, and in particular to an I2C device hot-plugging method, system, device, medium and product. Background Technology

[0002] The I2C bus is a common communication interface frequently used in embedded devices. I2C (Inter-Integrated Circuit), developed by Philips, is a simple, bidirectional, two-wire synchronous serial bus that requires only one data line (SDA) and one clock line (SCL) to transmit information between devices connected to the bus. Because embedded devices come in various forms, some applications may require pluggable functionality, and since I2C devices are among the pluggable components, a hot-plugging capability is needed for I2C devices to ensure proper reconnection after removal. In common embedded systems such as Linux (a free and open-source UNIX-like operating system), hot-plugging of I2C devices is not supported by default; therefore, it is necessary to implement hot-plugging functionality for I2C devices in both hardware and software.

[0003] In existing technologies, I2C hardware uses two lines, SCL and SDA, for data communication between the master controller and the slave device. A single I2C bus supports multiple I2C slave devices, each with a different device address. The I2C master controller accesses the designated I2C slave device through its device address. Data transmission between the I2C bus and the devices follows the I2C protocol.

[0004] The implementation of I2C drivers in software varies across different platforms. Generally, they can be categorized into bus drivers and device drivers. Taking Linux, a widely used embedded system, as an example, its I2C architecture consists of three parts: the core framework, the bus driver, and the device driver. The core framework provides interfaces for registering and unregistering bus and device drivers; the bus driver implements the I2C adapter and manages the I2C driver and devices; the device driver implements the specific I2C hardware device and is mounted on the abstract I2C bus. Both the bus driver and device driver are initialized during system boot.

[0005] Therefore, since the loading of I2C devices in the existing technology is completed during the system startup process, the device will become invalid once it is removed after power-on. It needs to be connected and the system restarted to be used normally. In other words, hot-swapping of I2C devices is not supported. Summary of the Invention

[0006] To overcome the problems existing in related technologies, this disclosure provides an I2C device hot-plugging method, system, device, medium, and product.

[0007] According to a first aspect of the present disclosure, an I2C device hot-plugging method is provided. The method is applied to an I2C device hot-plugging system, which 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 via an I2C bus. An I2C device driver is stored on the I2C device, and an I2C bus driver is stored on the I2C bus. Both the I2C device driver and the I2C bus driver are compiled in module form. The method includes:

[0008] Monitor the insertion / removal status of the I2C device, which includes an insertion state and a removal state;

[0009] When the insertion state is determined to be the insertion state, an insertion command is sent to the control module. Based on the control module and the insertion command, the I2C device is powered on, the I2C bus is initialized, and the I2C device driver and the I2C bus driver are loaded.

[0010] When the insertion / removal state is determined to be the removal state, a removal command is sent to the control module. Based on the control module and the removal command, the I2C device is powered down, the I2C bus is deinitialized, and the I2C device driver and the I2C bus driver are unloaded.

[0011] In some embodiments, the secondary board is electrically connected to the main board via a terminal block, the terminal block including an ID pin and a GND pin, and the secondary board is also provided with a monitoring module, the monitoring module being used to monitor the insertion and removal status of the I2C device;

[0012] The I2C device's insertion / removal status is monitored, including an insertion state and a removal state, including:

[0013] The monitoring module stores an interrupt handling function, which is used to monitor the level changes of the ID pin and the GND pin to determine the status of the I2C device.

[0014] In some embodiments, the state of the I2C device is determined by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function, including:

[0015] When the interrupt handler detects that the ID pin changes from a floating state to a high level and the GND pin changes from a floating state to a low level, it determines that the state of the I2C device is the insertion state.

[0016] When the interrupt handler detects that the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state, it determines that the state of the I2C device is the unplugged state.

[0017] In some embodiments, the state of the I2C device is determined by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function, further comprising:

[0018] When the ID pin is detected to change from a floating state to a high level, the GND pin changes from a floating state to a low level, or

[0019] When the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state for less than a first preset time, it is determined that the state of the I2C device has not changed.

[0020] In some embodiments, when the insertion / removal state is determined to be the insertion state, an insertion command is sent to the control module, and the control module and the insertion command are used to control the power-on of the I2C device, the initialization of the I2C bus, and the loading of the I2C device driver and the I2C bus driver, including:

[0021] When the state of insertion / removal is the insertion state, the control module first controls the I2C device to power on based on the insertion command, then controls the I2C bus to complete the initialization, so that the I2C device can be normally connected to the motherboard through the I2C bus, and finally loads the I2C device driver and the I2C bus driver.

[0022] In some embodiments, when the insertion / removal state is determined to be the removal state, a removal command is sent to the control module. Based on the control module and the removal command, the I2C device is powered down, the I2C bus is deinitialized, and the I2C device driver and the I2C bus driver are unloaded, including:

[0023] When the state of plugging / unplugging is the unplugged state, the control module first unloads the I2C device driver and the I2C bus driver based on the unplugging command, then controls the I2C bus to complete the deinitialization, so that the I2C device is disconnected from the motherboard, and finally controls the I2C device to power down.

[0024] According to a second aspect of the present disclosure, an I2C device hot-swappable system is provided. The I2C device hot-swappable 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 communicatively connected to the main board via an I2C bus. An I2C device driver is stored on the I2C device, and an I2C bus driver is stored on the I2C bus. Both the I2C device driver and the I2C bus driver are compiled in module form, including:

[0025] The monitoring module is used to monitor the insertion and removal status of I2C devices, which includes insertion status and removal status.

[0026] When the insertion / removal state is determined to be the insertion state, the control module is used to control the power-on of the I2C device, the initialization of the I2C bus, and the loading of the I2C device driver and the I2C bus driver through the insertion command;

[0027] When the insertion / removal state is determined to be the removal state, the control module is used to control the power-down of the I2C device, the deinitialization of the I2C bus, and the unloading of the I2C device driver and the I2C bus driver through the insertion command.

[0028] An embodiment of the third aspect of this application provides an electronic device, including a processor and a memory, wherein the memory stores at least one instruction, at least one program, code set, or instruction set, and the instruction, program, code set, or instruction set is loaded and executed by the processor to implement the I2C device hot-plugging method steps provided by the embodiment of the first aspect of this application described above.

[0029] An embodiment of the fourth aspect of this application provides a non-transitory computer-readable storage medium, wherein when the instructions in the storage medium are executed by the processor of a mobile terminal, the mobile terminal is able to perform the steps of the I2C device hot-plugging method provided in the embodiment of the first aspect of this application described above.

[0030] An embodiment of the fifth aspect of this application provides a computer program product that, when the instructions in the computer program product are executed by the processor of a mobile terminal, enables the mobile terminal to perform the steps of the I2C device hot-plugging method provided by the embodiment of the first aspect of this application described above.

[0031] The technical solutions provided by the embodiments of this disclosure can include the following beneficial effects: In embedded device development, this application fulfills the requirement for hot-plugging of I2C devices by monitoring voltage changes on the ID and GND pins through interrupt handling functions in the monitoring module, thereby identifying the hot-plugging action of the I2C device. This has the advantage of stable identification, prevents misidentification, and protects the device from damage. In terms of software, both the I2C device driver and the I2C bus driver are compiled and implemented as modules, facilitating loading or unloading at any time. Furthermore, it is derived from the native driver, which is simple and convenient, without increasing the complexity or difficulty of the software.

[0032] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0033] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0034] Figure 1 This is a flowchart illustrating an I2C device hot-plugging method according to an exemplary embodiment.

[0035] Figure 2 This is a hardware schematic diagram of an I2C device hot-plug system according to an exemplary embodiment.

[0036] Figure 3 This is an internal structural diagram of an electronic device according to an exemplary embodiment. Detailed Implementation

[0037] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.

[0038] Figure 1 This is a flowchart illustrating an I2C device hot-plugging method according to an exemplary embodiment, such as... Figure 1As shown, the method is applied to an I2C device hot-swappable system. The I2C device hot-swappable system includes an I2C device, a secondary board, a main board, and a control module. The I2C device and the control module are mounted on the secondary board. The I2C device communicates with the main board via an I2C bus. The I2C device stores an I2C device driver, and the I2C bus stores an I2C bus driver. Both the I2C device driver and the I2C bus driver are compiled as modules, including the following steps:

[0039] S101, Monitor the insertion / removal status of the I2C device, the insertion / removal status includes insertion status and removal status.

[0040] Specifically, to ensure that hot-swapping of I2C devices does not affect other devices, each I2C device has its own dedicated I2C bus, through which it communicates with the motherboard. Hot-swapping is accomplished by monitoring the insertion / removal status of the I2C device and determining whether it is inserted or removed, thereby executing different subsequent operations.

[0041] In some embodiments, the secondary board is electrically connected to the main board via a terminal block, the terminal block including an ID pin and a GND pin, and the secondary board is also provided with a monitoring module, the monitoring module being used to monitor the insertion and removal status of the I2C device;

[0042] The I2C device's insertion / removal status is monitored, including an insertion state and a removal state, including:

[0043] The monitoring module stores an interrupt handling function, which is used to monitor the level changes of the ID pin and the GND pin to determine the status of the I2C device.

[0044] Specifically, since the I2C device is located on the secondary board, which is electrically connected to the motherboard via the ID and GND pins, and the monitoring module is also located on the secondary board, the status of the I2C device is determined by monitoring the level changes of the ID and GND pins through the interrupt handling function stored in the monitoring module. Pulling the interrupt pins (ID and GND pins) high or low will generate an interrupt signal, and the function that handles this interrupt signal is the interrupt handling function. Therefore, by monitoring the level changes of the ID and GND pins through the interrupt handling function, the status changes of the I2C device can be determined.

[0045] In some embodiments, the state of the I2C device is determined by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function, including:

[0046] When the interrupt handler detects that the ID pin changes from a floating state to a high level and the GND pin changes from a floating state to a low level, it determines that the state of the I2C device is the insertion state.

[0047] When the interrupt handler detects that the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state, it determines that the state of the I2C device is the unplugged state.

[0048] Specifically, in this application, the ID pin is pulled high by default, and the GND pin is pulled low by default. I2C devices are left floating when not connected. When an I2C device is inserted, the ID pin is pulled high to generate a high level, and the GND pin is pulled low to generate a low level, which generates an interrupt. When the ID pin is pulled high and the GND pin is pulled low, it indicates that the I2C device is in the inserted state, i.e., an insertion event has occurred. When the ID pin changes from a high level to a floating state, and the GND pin changes from a low level to a floating state, it indicates that the I2C device is in the unplugged state, i.e., an unplugged event has occurred.

[0049] In some embodiments, the state of the I2C device is determined by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function, further comprising:

[0050] When the ID pin is detected to change from a floating state to a high level, the GND pin changes from a floating state to a low level, or

[0051] When the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state for less than a first preset time, it is determined that the state of the I2C device has not changed.

[0052] Specifically, to prevent changes in the state of the I2C device due to slight jitter, when the ID pin changes from a floating state to a high level and the GND pin changes from a floating state to a low level, or when the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state for less than a first preset time (e.g., 100ms), it is determined that the I2C device has experienced slight jitter and has not experienced an insertion or removal event. This prevents the I2C device from being powered on when it should be powered off, which could damage the device.

[0053] S102, when the insertion state is determined to be the insertion state, an insertion command is sent to the control module, and the control module and the insertion command are used to control the power-on of the I2C device, the initialization of the I2C bus, and the loading of the I2C device driver and the I2C bus driver.

[0054] Specifically, when the interrupt handling function detects changes in the ID pin and GND pin and determines that the I2C device is in the insertion state, an insertion command is sent to the control module. After receiving the insertion command, the control module controls the specific operations of powering on the I2C device, initializing the I2C bus, and loading the I2C device driver and the I2C bus driver.

[0055] In some embodiments, when the insertion / removal state is determined to be the insertion state, an insertion command is sent to the control module. Based on the control module and the insertion command, the I2C device is powered on, the I2C bus is initialized, and the I2C device driver and the I2C bus driver are loaded, including:

[0056] When the state of insertion / removal is the insertion state, the control module first controls the I2C device to power on based on the insertion command, then controls the I2C bus to complete the initialization, so that the I2C device can be normally connected to the motherboard through the I2C bus, and finally loads the I2C device driver and the I2C bus driver.

[0057] Specifically, the control module first powers on the I2C device, and then controls the I2C bus to complete initialization. Initialization includes registering the bus, defining the data structure of the I2C adapter, and the I2C communication mode of the specific adapter. Initialization can be understood as a series of actions to enable the I2C bus to work normally. Finally, the I2C device driver and I2C bus driver are loaded, so that the I2C device and the motherboard can communicate directly through the I2C bus. After loading the I2C device driver and I2C bus driver, the upper layer is notified to restart the application services or functions related to the I2C device.

[0058] S103, when the insertion / removal state is determined to be the removal state, a removal command is sent to the control module, and based on the control module and the removal command, the I2C device is powered down, the I2C bus is deinitialized, and the I2C device driver and the I2C bus driver are unloaded.

[0059] Specifically, when the interrupt handler detects a change in the ID pin and GND pin and determines that the I2C device is in the unplugged state, an insertion command is sent to the control module. After receiving the insertion command, the control module controls the specific operations of powering down the I2C device, deinitializing the I2C bus, and unloading the I2C device driver and the I2C bus driver.

[0060] In some embodiments, when the insertion / removal state is determined to be the removal state, a removal command is sent to the control module. Based on the control module and the removal command, the I2C device is powered down, the I2C bus is deinitialized, and the I2C device driver and the I2C bus driver are unloaded, including:

[0061] When the state of plugging / unplugging is the unplugged state, the control module first unloads the I2C device driver and the I2C bus driver based on the unplugging command, then controls the I2C bus to complete the deinitialization, so that the I2C device is disconnected from the motherboard, and finally controls the I2C device to power down.

[0062] Specifically, the control module first uninstalls the I2C device driver and the I2C bus driver, disconnects the I2C device from the motherboard via the I2C bus, and then controls the I2C bus to complete deinitialization. Deinitialization is the reverse process of initialization, which can be understood as a series of actions that prevent the I2C bus from working properly. Finally, it controls the I2C device to power down. After powering down, it also notifies the upper layer to close the application services or functions related to the I2C device.

[0063] Figure 2 This is a hardware schematic diagram illustrating an I2C device hot-plugging system according to an exemplary embodiment. (Refer to...) Figure 2 The I2C device hot-swappable system includes an I2C device, a secondary board, a main board, a control module, and a monitoring module. The I2C device, monitoring module, and control module are mounted on the secondary board. The I2C device communicates with the main board via an I2C bus. The I2C device stores an I2C device driver, and the I2C bus stores an I2C bus driver. Both the I2C device driver and the I2C bus driver are compiled in module form, including:

[0064] The monitoring module is used to monitor the insertion and removal status of I2C devices, which includes insertion status and removal status.

[0065] When the insertion / removal state is determined to be the insertion state, the control module is used to control the power-on of the I2C device, the initialization of the I2C bus, and the loading of the I2C device driver and the I2C bus driver through the insertion command;

[0066] When the insertion / removal state is determined to be the removal state, the control module is used to control the power-down of the I2C device, the deinitialization of the I2C bus, and the unloading of the I2C device driver and the I2C bus driver through the insertion command.

[0067] Regarding the system in the above embodiments, the specific manner in which each module performs its operations has been described in detail in the embodiments related to the method, and will not be elaborated upon here.

[0068] In one embodiment, an electronic device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 3 As shown, the electronic device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage medium. The communication interface of the computer device is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements an I2C hot-plugging method. The display screen of the computer device can be an LCD screen or an e-ink display screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad located on the computer device casing, or an external keyboard, touchpad, or mouse.

[0069] Those skilled in the art will understand that Figure 3 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0070] In one embodiment, the I2C device hot-plug system provided in this application can be implemented as a computer program, which can be implemented in the form of, for example... Figure 3 The device operates on the electronic device shown. The memory of the electronic device can store the various program modules that make up the hot-swappable I2C device system.

[0071] The electronic device's memory stores at least one instruction, at least one program, code set, or instruction set. The instruction, program, code set, or instruction set is loaded and executed by the processor to implement the I2C device hot-plugging method according to any of the above embodiments. For example, implementing the I2C device hot-plugging method includes: monitoring the insertion / removal state of the I2C device, the insertion / removal state including an insertion state and a removal state; when the insertion / removal state is determined to be the insertion state, sending an insertion command to the control module, and controlling the I2C device to power on, the I2C bus to initialize, and the I2C device driver and the I2C bus driver to load based on the control module and the insertion command; when the removal / removal state is determined to be the removal state, sending a removal command to the control module, and controlling the I2C device to power off, the I2C bus to deinitialize, and the I2C device driver and the I2C bus driver to unload based on the control module and the removal command.

[0072] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it performs the following steps: monitoring the insertion / removal state of the I2C device, the insertion / removal state including an insertion state and a removal state; when the insertion / removal state is determined to be the insertion state, sending an insertion command to the control module, and controlling the I2C device to power on, the I2C bus to initialize, and the I2C device driver and the I2C bus driver to load based on the control module and the insertion command; when the removal / removal state is determined to be the removal state, sending a removal command to the control module, and controlling the I2C device to power off, the I2C bus to deinitialize, and the I2C device driver and the I2C bus driver to unload based on the control module and the removal command.

[0073] In one embodiment, a computer program product is provided that, when instructions in the computer program product are executed by a processor of a mobile terminal, enables the mobile terminal to perform the following steps: monitoring the insertion / removal state of the I2C device, the insertion / removal state including an insertion state and a removal state; when the insertion / removal state is determined to be the insertion state, sending an insertion command to a control module, and controlling the I2C device to power on, the I2C bus to initialize, and the I2C device driver and the I2C bus driver to load based on the control module and the insertion command; when the removal / removal state is determined to be the removal state, sending a removal command to the control module, and controlling the I2C device to power off, the I2C bus to deinitialize, and the I2C device driver and the I2C bus driver to unload based on the control module and the removal command.

[0074] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the methods described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, or optical storage, etc. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static random access memory (SRAM) and dynamic random access memory (DRAM), etc.

[0075] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0076] The above embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A method for hot-plugging an I2C device, characterized in that, The method is applied to an I2C device hot-swappable system, which includes an I2C device, a secondary board, a main board, and a control module. The I2C device and the control module are mounted on the secondary board. The I2C device communicates with the main board via an I2C bus. The I2C device driver and the I2C bus driver are stored on the I2C bus. Both the I2C device driver and the I2C bus driver are compiled as modules. The secondary board is electrically connected to the main board via terminal blocks, which include ID pins and GND pins. A monitoring module is also provided on the secondary board to monitor the insertion and removal status of the I2C device. The method includes: Monitoring the insertion and removal status of the I2C device, which includes an insertion state and a removal state, includes: the monitoring module stores an interrupt handling function, and the status of the I2C device is determined by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function; When the insertion state is determined to be the insertion state, an insertion command is sent to the control module. Based on the control module and the insertion command, the I2C device is powered on, the I2C bus is initialized, and the I2C device driver and the I2C bus driver are loaded. When the insertion / removal state is determined to be the removal state, a removal command is sent to the control module. Based on the control module and the removal command, the I2C device is powered down, the I2C bus is deinitialized, and the I2C device driver and the I2C bus driver are unloaded.

2. The I2C device hot-plugging method as described in claim 1, characterized in that, The state of the I2C device is determined by monitoring the level changes of the ID pin and the GND pin through the interrupt handling function, including: When the interrupt handler detects that the ID pin changes from a floating state to a high level and the GND pin changes from a floating state to a low level, it determines that the state of the I2C device is the insertion state. When the interrupt handler detects that the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state, it determines that the state of the I2C device is the unplugged state.

3. The I2C device hot-plugging method as described in claim 1, characterized in that, The method of 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 includes: When the ID pin changes from a floating state to a high level and the GND pin changes from a floating state to a low level, or when the ID pin changes from a high level to a floating state and the GND pin changes from a low level to a floating state for less than a first preset time, it is determined that the state of the I2C device has not changed.

4. The I2C device hot-plugging method as described in claim 1, characterized in that, When the insertion / removal state is determined to be the insertion state, an insertion command is sent to the control module. Based on the control module and the insertion command, the I2C device is powered on, the I2C bus is initialized, and the I2C device driver and the I2C bus driver are loaded, including: When the plugging / unplugging state is the insertion state, the control module first controls the I2C device to power on based on the insertion command, and then controls the I2C bus to complete the initialization, so that the I2C device can be normally connected to the motherboard through the I2C bus. Finally, the I2C device driver and the I2C bus driver are loaded.

5. The I2C device hot-plugging method as described in claim 1, characterized in that, When the insertion / removal state is determined to be the removal state, a removal command is sent to the control module. Based on the control module and the removal command, the I2C device is powered down, the I2C bus is deinitialized, and the I2C device driver and the I2C bus driver are unloaded, including: When the plug-in / plug-out state is the unplugged state, the control module first unloads the I2C device driver and the I2C bus driver based on the unplug command, then controls the I2C bus to complete the deinitialization, so that the I2C device is disconnected from the motherboard, and finally controls the I2C device to power down.

6. An I2C device hot-swappable system, characterized in that, The I2C device hot-swappable system includes an I2C device, a secondary board, a main board, a control module, and a monitoring module. The I2C device, monitoring module, and control module are mounted on the secondary board. The I2C device communicates with the main board via an I2C bus. The I2C device stores an I2C device driver, and the I2C bus stores an I2C bus driver. Both the I2C device driver and the I2C bus driver are compiled as modules. The secondary board is electrically connected to the main board via terminal blocks, which include an ID pin and a GND pin. The secondary board also includes a monitoring module for monitoring the insertion / removal status of the I2C device, including: The monitoring module is used to monitor the insertion and removal status of the I2C device. The insertion and removal status includes an insertion state and a removal state. The monitoring module stores an interrupt handling function, and uses the interrupt handling function to monitor the level changes of the ID pin and the GND pin to determine the status of the I2C device. When the insertion / removal state is determined to be the insertion state, the control module is used to control the power-on of the I2C device, the initialization of the I2C bus, and the loading of the I2C device driver and the I2C bus driver through the insertion command; When the insertion / removal state is determined to be the removal state, the control module is used to control the power-down of the I2C device, the deinitialization of the I2C bus, and the unloading of the I2C device driver and the I2C bus driver through the removal command.

7. An electronic device, characterized in that, The device includes a processor and a memory, wherein the memory stores at least one instruction, at least one program, a code set, or an instruction set, and the instruction, program, code set, or instruction set is loaded and executed by the processor to implement the I2C device hot-plugging method according to any one of claims 1-5.

8. A non-transitory computer-readable storage medium, characterized in that, When the instructions in the storage medium are executed by the processor of the mobile terminal, the mobile terminal is able to perform the I2C device hot-plugging method according to any one of claims 1-5.

9. A computer program product, characterized in that, When the instructions in the computer program product are executed by the processor of the mobile terminal, the mobile terminal is enabled to perform the I2C device hot-plugging method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Circuit capable of realizing I2C hot plug and I2C device

    CN202931279U