File bits_utils.h

FileList > midas_fe > bits_utils.h

Go to the source code of this file

Utility for bitwise parameter encoding in bit-pattern buffers. More...

  • #include <stdlib.h>
  • #include <cstdint>
  • #include <vector>

Public Functions

Type Name
uint32_t setParameter (uint8_t * bitpattern_w, uint32_t value, uint32_t offset, uint32_t nbits, bool inverted)
Set a value into a bit pattern buffer at a specific bit offset.

Detailed Description

This header defines a function for writing integer values into a bitfield buffer, which is useful in applications like hardware register configuration or slow control settings for DAQ systems.

The setParameter function encodes a given value into a byte array at a specific bit offset, handling arbitrary bit lengths and bit order inversion.

Public Functions Documentation

function setParameter

Set a value into a bit pattern buffer at a specific bit offset.

uint32_t setParameter (
    uint8_t * bitpattern_w,
    uint32_t value,
    uint32_t offset,
    uint32_t nbits,
    bool inverted
) 

This function encodes a value of length nbits into the buffer bitpattern_w starting at the given offset. If inverted is true, the bits are written in reverse order (MSB first).

Parameters:

  • bitpattern_w Target buffer (must be pre-allocated).
  • value Integer value to encode.
  • offset Starting bit offset in the buffer.
  • nbits Number of bits used to encode the value.
  • inverted Whether to reverse bit order (MSB-first).

Returns:

uint32_t The new bit offset after writing.



The documentation for this class was generated from the following file midas_fe/bits_utils.h