> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sensor-bridge/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sensor-bridge/_mcp/server.

# hololink::emulation::I2CController

> class that manages virtual I2C peripherals from the host.

class that manages virtual I2C peripherals from the host.

This is mostly for the linux emulator where the use case is for virtual sensors

```cpp showLineNumbers={false}
#include <hololink/emulation/hsb_emulator.hpp>
```

This should not be instantiated directly by user code. Use HSBEmulator::get\_i2c() instead. The default and primary `I2CController` is at address hololink::I2C\_CTRL.

***

## Constructors

### I2CController \[#i2ccontroller]

```cpp showLineNumbers={false}
hololink::emulation::I2CController::I2CController(
    HSBEmulator &hsb_emulator,
    uint32_t controller_address
)
```

construct an I2C controller on HSB Emulator at the specified address.

**Parameters**

The HSB emulator to attach to.

The address of the I2C controller.

### Destructor \[#destructor]

### \~I2CController

```cpp showLineNumbers={false}
hololink::emulation::I2CController::~I2CController()
```

***

## Methods

### attach\_i2c\_peripheral \[#attachi2cperipheral]

```cpp showLineNumbers={false}
void hololink::emulation::I2CController::attach_i2c_peripheral(
    uint32_t bus_address,
    uint16_t peripheral_address,
    I2CPeripheral *peripheral
)
```

python:

`def `[`attach_i2c_peripheral`](#attachi2cperipheral)`(self: hemu.I2CController, bus_address: int, peripheral_address: int, peripheral: hemu.I2CPeripheral)`

attach an I2C peripheral as a callback on the specified (bus address, peripheral address) pair.

**Parameters**

The bus address of the peripheral. For multiplexing or bus expanded addressing, this is the bus address of the peripheral.

The peripheral address of the peripheral.

The peripheral to attach. This is a pointer to the peripheral object. The caller is responsible for managing the lifetime of the peripheral object.

### start \[#start]

```cpp showLineNumbers={false}
void hololink::emulation::I2CController::start()
```

start the I2C controller.

Initializes the underlying I2C hardware (STM32) or attached peripherals (Linux) and marks the controller running. No worker thread is launched: host-driven I2C transactions execute synchronously inside the i2c\_configure\_cb control-plane callback via the free-function i2c\_transaction().

### stop \[#stop]

```cpp showLineNumbers={false}
void hololink::emulation::I2CController::stop()
```

stop the I2C controller.

Stops attached peripherals (Linux) and marks the controller not running.

### is\_running \[#isrunning]

```cpp showLineNumbers={false}
bool hololink::emulation::I2CController::is_running()
```

check if the I2C controller is running.

**Returns:** true if the I2C controller is running, false otherwise.

### reset \[#reset]

```cpp showLineNumbers={false}
void hololink::emulation::I2CController::reset(
    uint32_t controller_address
)
```

Initialize the platform-invariant fields of the already-allocated [I2CControllerCtxt](../structs/i2ccontrollerctxt) the subclass-shared ctxt\_ points at.

Wires control/data addresses, zeroes the register + data scratch, sets the back-pointer, and marks the controller stopped. Called by the platform-specific `I2CController` constructor right after it claims a ctxt slot.

**Parameters**

Base address of the I2C controller in the host register space. Matched against the address the host writes to trigger each I2C transaction.

***

## Member variables

| Name    | Type                                    | Description |
| ------- | --------------------------------------- | ----------- |
| `ctxt_` | `UniqueDel< struct I2CControllerCtxt >` |             |