hololink::module::SequencerInterfaceV1
hololink::module::SequencerInterfaceV1
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.
Inherits from: hololink::module::Service< SequencerInterfaceV1 > (public)
Methods
write_uint32
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
Device location to write.
Value to write.
read_uint32
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
Device memory to read.
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
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
Device memory to read.
Bits of the value to compare.
Value the masked bits must equal.
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
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
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.