Skip to navigation

hololink::module::SequencerInterfaceV1

View as Markdown

A list of memory operations that an HSB device runs by itself when a trigger event occurs.

A sequencer lets time-critical work (for example reading a sensor’s registers over I2C at the end of every frame) be done by the device hardware at the moment of the trigger, rather than by the host after the fact. Operations are recorded with write_uint32(), read_uint32() and poll(), then loaded onto the device and armed with enable(). Each time the sequencer’s trigger event occurs the device runs the whole list, in the order recorded, without interruption.

Which event triggers a sequencer depends on how it was obtained: each *_sequencer accessor of HololinkInterfaceV1 (software, GPIO, sensor frame start or end) and of the data channel interfaces yields a sequencer for its own event.

Results of read and poll operations are left in the sequencer’s memory on the device. A recorded operation is identified by the index returned when it was added: the index of a 32-bit word in the sequence. The device address of the word at index i is location()`` + 4 * i.

HSB executes sequences one-at-a-time: the current sequence must finish before another event can be handled– so be aware that a long-running poll operation may affect other event handling. Also note that some operations (like I2C transactions) always go through sequencer (to avoid reentrancy), so sequencer occupation may not be entirely obvious.

#include <hololink/module/sequencer.hpp>

Inherits from: hololink::module::Service< SequencerInterfaceV1 > (public)


Methods

write_uint32

virtual unsigned hololink::module::SequencerInterfaceV1::write_uint32(
uint32_t address,
uint32_t data
)

Add a memory write to the sequence.

When the sequence runs, data is written to the HSB local bus at address.

Returns: Index of the word holding data.

Throws: std::runtime_error if enable() has been called.

Parameters

address
uint32_t

Device location to write.

data
uint32_t

Value to write.

read_uint32

virtual unsigned hololink::module::SequencerInterfaceV1::read_uint32(
uint32_t address,
uint32_t initial_value = 0xFFFFFFFFu
)

Add a memory read to the sequence.

When the sequence runs, the memory at address is read and the value stored at the returned index.

Operations can only be added before enable() is called.

Returns: Index at which the value read is stored.

Throws: std::runtime_error if enable() has been called.

Parameters

address
uint32_t

Device memory to read.

initial_value
uint32_tDefaults to 0xFFFFFFFFu

Value held at the returned index until the first time the sequence runs, so that a result that hasn’t been produced yet can be recognized.

poll

virtual unsigned hololink::module::SequencerInterfaceV1::poll(
uint32_t address,
uint32_t mask,
uint32_t match
)

Add a wait to the sequence: the sequence stops at this point until a memory value has the expected value.

When the sequence runs, the memory at address is read repeatedly until (value & mask) == match, and only then does the sequence continue. The poll times out if the match does not occur within the timeout configured on the device.

Operations can only be added before enable() is called.

Returns: Index at which the most recent value read from address is stored.

Throws: std::runtime_error if enable() has been called.

Parameters

address
uint32_t

Device memory to read.

mask
uint32_t

Bits of the value to compare.

match
uint32_t

Value the masked bits must equal.

enable

virtual hololink_module_status_t hololink::module::SequencerInterfaceV1::enable()

Load the sequence onto the device and arm it for its trigger.

Call this once, after the last operation has been added. From then on the device runs the sequence each time the trigger event occurs, and location() can be used.

Returns: HOLOLINK_MODULE_OK or an error status.

Throws: std::runtime_error if the sequencer has already been enabled.

location

virtual uint32_t hololink::module::SequencerInterfaceV1::location()

The device address at which the sequence is stored.

The word for an operation’s index is at this address plus four times the index. Use it to read back results, or to update data to be written.

Returns: The address.

Throws: std::runtime_error if enable() has not been called.

module

std::shared_ptr<Module> hololink::module::ServiceBase::module() const

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

static std::shared_ptr<SequencerInterfaceV1> hololink::module::Service<SequencerInterfaceV1>::get_service(
std::shared_ptr<Module> module,
const char *instance_id,
bool allow_null = false
)

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

module
std::shared_ptr<Module>

Is the shared object that owns the instance we wish to fetch

instance_id
const char *

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).

allow_null
boolDefaults to false

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

static bool hololink::module::Service<SequencerInterfaceV1>::for_each_type_id(
Callback &&cb
)

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.