hololink::module::I2cInterfaceV1
hololink::module::I2cInterfaceV1
Provides access to I2C controllers instantiated within an HSB device.
You can request an immediate I2C transaction (with i2c_transaction) or one that is downloaded and triggered by a specific event (using encode_i2c_request).
In some cases (specifically the default I2C configuration within the HSB IP core) a single I2C controller is muxed between different output pins, providing hardware with different I2C buses, but requiring that the host serialize access to each. When this serialization is required, it’s managed automatically within the module– so application code doesn’t have to know that.
Inherits from: hololink::module::Service< I2cInterfaceV1 > (public)
Methods
i2c_transaction
Execute an I2C transaction.
Writes write_bytes to the peripheral, then reads back as many bytes as read_bytes is configured to hold; size it to zero for a write-only transaction.
Returns: HOLOLINK_MODULE_OK or an error status.
Parameters
Address of the peripheral on this bus.
Bytes sent to the peripheral.
Sized by the caller to the number of bytes to read; receives them.
Example
encode_i2c_request
Encode an I2C transaction into a sequencer.
Sequencers cache a list of local bus transactions, after that cache is written to an HSB device, and the trigger activates, the HSB IP will execute that transaction list. This API appends an I2C transaction to the sequencer cache. The bytes to be written to I2C are included in the call (in write_bytes); when reading from I2C, the list of HSB IP local bus addresses where the cached data can be found are put in out_read_indexes. Each location has 4 bytes; the last bytes (when read_byte_count isn’t an even 32-bits) are undefined.
Returns: HOLOLINK_MODULE_OK or an error status.
Parameters
Sequencer to encode into.
Address of the peripheral on this bus.
Bytes to send to the peripheral.
Bytes to read back from the peripheral.
Where the bytes to send are encoded.
Where the bytes read back are deposited.
Where the transaction’s status is deposited.
module
The Module that this service was published from.
The service holds no strong reference to its Module, so this does not extend the Module’s lifetime.
Returns: The owning Module, or an empty pointer if the service has not been published or its Module no longer exists.
Static methods
get_service
Type-safe way to fetch a std::shared_ptr to an instance of <Derived> from a Module.
Note that Module usually caches instances, it’s likely that calls to get_service with the same locator_id will return pointers to the same implementation object.
Returns: A shared pointer to the service instance.
Parameters
Is the shared object that owns the instance we wish to fetch
Names the specific object, usually expressed as a set of “name=value;…” pairs, as defined by the implementations themselves. This name is normally fetched by calling Derived::locator_id(enumeration_metadata).
The default value of false causes this routine to throw a std::runtime_error if the service cannot be found within the module; this would be expected to terminate the calling program. If the application wants to handle the error, pass in true here and get_service will return nullptr when this module doesn’t provide the requested service.
for_each_type_id
Iterate over every type_id supported by this instance.
The callback signature is bool(const char*) — returning false halts the walk; true continues. Iteration is depth-first, so you’ll see the most specific implementation types first.