hololink::emulation::I2CController
hololink::emulation::I2CController
class that manages virtual I2C peripherals from the host.
This is mostly for the linux emulator where the use case is for virtual sensors
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
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
~I2CController
Methods
attach_i2c_peripheral
python:
def attach_i2c_peripheral(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 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 the I2C controller.
Stops attached peripherals (Linux) and marks the controller not running.
is_running
check if the I2C controller is running.
Returns: true if the I2C controller is running, false otherwise.
reset
Initialize the platform-invariant fields of the already-allocated 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.