hololink::emulation::I2CControllerCtxt

View as Markdown

Common, target-invariant per-I2CController context.

Each platform defines its own extension struct (LinuxI2CControllerCtxt, STM32I2CControllerCtxt) with struct ``I2CControllerCtxt`` base as its first member. Standard-layout C++ guarantees &ext->base == reinterpret_cast<I2CControllerCtxt*>(ext), so the I2CController class can hold an I2CControllerCtxt* without knowing the platform extension, and platform code downcasts back via reinterpret_cast<LinuxI2CControllerCtxt*> (or STM32 equivalent) to reach the platform extras.

running is a bare bool: I2C transactions execute synchronously inside the host control-plane callback (i2c_configure_cb -> i2c_transaction), there is no worker thread to coordinate. The Linux extension still carries an i2c_mutex because attach_i2c_peripheral() can be called from the application thread while the control-plane callback is running on its own thread; STM32 is single-threaded and needs no mutex.

#include <hololink/emulation/hsb_emulator.hpp>

Member variables

NameTypeDescription
i2c_controllerI2CController *
registersuint32_t
datauint32_t
control_addressuint32_t
data_addressuint32_t
statusuint32_t
runningbool