GPIO

The GPIO component provides an interface to the General Purpose Input/Output (GPIO) pins of the FPGA. The component is implemented as multiple singleton classes, each representing a single GPIO IP-Code of the hardware design.

Classes

Base GPIO Class

class Gpio

Represents a GPIO (General Purpose Input/Output) interface.

This class provides methods to control and access GPIO pins. It prevents move construction and move assignment to ensure proper resource management. The GPIO pins are accessed through a memory map provided by the memorycontrol::MemoryMap class.

Subclassed by nexmess::components::gpio::GpioBLRPreGate, nexmess::components::gpio::GpioEnabled, nexmess::components::gpio::GpioLongGate, nexmess::components::gpio::GpioMeasurementInterrupt, nexmess::components::gpio::GpioMeasurementTime, nexmess::components::gpio::GpioOffset, nexmess::components::gpio::GpioPackageSize, nexmess::components::gpio::GpioPreGate, nexmess::components::gpio::GpioSignalCount, nexmess::components::gpio::GpioTriggerValue

Public Functions

Gpio() = delete
~Gpio() = default
Gpio(const Gpio&) = delete
Gpio(Gpio&&) = delete
Gpio &operator=(Gpio&&) = delete
Gpio(uint32_t register_base, int mem)

Constructs a new Gpio object.

Parameters:
  • register_base – The base address of the GPIO registers.

  • mem – The memory identifier.

void operator=(const Gpio&) = delete
bool has_error() const

Checks if there is any error with the GPIO.

Returns:

true if there is an error, false otherwise.

Protected Functions

void set_value(uint32_t value)

Sets the value of the first data register.

Parameters:

value – The value to be set.

uint32_t get_value()

Gets the value of the first data register.

Returns:

The value of the first data register.

void set_value2(uint32_t value)

Sets the value of the second data register.

Parameters:

value – The value to be set.

uint32_t get_value2()

Gets the value of the second data register.

Returns:

The value of the second data register.

Private Members

memorycontrol::MemoryMap memory_map_

The memory map used to access the GPIO registers.

Enables GPIO Class

class GpioEnabled : public nexmess::components::gpio::Gpio

The GpioEnabled class represents a GPIO interface especially for the GPIO to enable ADC channels.

This class inherits from the Gpio class and provides functionality for controlling GPIO pins to enable ADC channels. It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioEnabled() = delete
GpioEnabled(const GpioEnabled&) = delete
void operator=(const GpioEnabled&) = delete
GpioEnabled(GpioEnabled&&) = delete
GpioEnabled &operator=(GpioEnabled&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GpioEnabled instance with the specified memory address.

Parameters:

mem – The memory address to be used for GPIO operations.

static void deactivate_all()

Deactivates all ADC channels.

static void activate_specific(uint8_t channel_value)

Activates the specified ADC channels for DMA operations.

This function uses a bit mask for the configuration of the ADC channels. The structure is at follows:

  • bit [0]: activate channel 1 for DMA operation

  • bit [1]: activate channel 2 for DMA operation

For example, a mask of 0b00000001 would activate the first channel for DMA operation.

Parameters:

channel_value – A bit mask specifying the ADC channels to be activated.

static uint8_t get_dma_channels()

Gets the channels for DMA operations.

Returns:

The channels for DMA operations.

static uint8_t get_invert_channels()

Gets the channels for inversions.

Returns:

The channels for inversions.

static void set_invert_channels(uint8_t invert_channel_value)

Sets the specified ADC channels to invert.

This function uses a bit mask for the configuration of the ADC channels. The structure is at follows:

  • bit [0]: activate channel 1 inversion

  • bit [1]: activate channel 2 inversion

For example, a mask of 0b00000001 would activate the first channel inversion.

Parameters:

invert_channel_value – A bit mask specifying the ADC channels to be activated.

static uint8_t get_fir_channels()

Gets the channels for FIR operations.

Returns:

The channels for FIR operations.

static void set_fir_channels(uint8_t fir_channel_value)

Sets the specified ADC channels to FIR.

This function uses a bit mask for the configuration of the ADC channels. The structure is at follows:

  • bit [0]: activate channel 1 for FIR operation

  • bit [1]: activate channel 2 for FIR operation

For example, a mask of 0b00000001 would activate the first channel for FIR operation.

Parameters:

fir_channel_value – A bit mask specifying the ADC channels to be activated.

static uint8_t get_blr_channels()

Gets the channels for baseline restoration.

Returns:

The channels for baseline restoration.

static void set_blr_channels(uint8_t blr_channel_value)

Sets the specified ADC channels for baseline restoration.

This function uses a bit mask for the configuration of the ADC channels. The structure is at follows:

  • bit [0]: activate channel 1 for baseline restoration

  • bit [1]: activate channel 2 for baseline restoration

For example, a mask of 0b00000001 would activate the first channel for baseline restoration.

Parameters:

blr_channel_value – A bit mask specifying the ADC channels to be activated.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioEnabled(int mem)

Constructor for the GpioEnabled class.

This constructor initializes a new GpioEnabled object with all ADC channels disabled. This is done to ensure a clean state, preventing potential issues with channels that were left enabled from previous operations.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioEnabled()

Destructor for the GpioEnabled class.

Before the GpioEnabled object is destructed, this destructor disables all ADC channels. This ensures that no ADC channels remain active beyond the lifetime of the GpioEnabled object, preventing potential issues with dangling resources.

Private Members

uint32_t enableds_ = 0

Sets the state of the sensor (0 -> off, 1 -> on).

Each bit is one sensor.

Private Static Functions

static GpioEnabled &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioEnabled &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Long gate GPIO Class

class GpioLongGate : public nexmess::components::gpio::Gpio

The GpioLongGate class represents a GPIO interface especially for the GPIO to set the number of samples to be measured once a trigger occurs.

This class inherits from the Gpio class and provides functionality for setting the long gate. It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioLongGate() = delete
GpioLongGate(const GpioLongGate&) = delete
void operator=(const GpioLongGate&) = delete
GpioLongGate(GpioLongGate&&) = delete
GpioLongGate &operator=(GpioLongGate&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GpioLongGate instance with the specified memory address.

Parameters:

mem – The memory address to be used for GPIO operations.

static void set_long_gates(uint16_t long_gate_c1, uint16_t long_gate_c2)

Sets the long gates of channel 1 and channel 2.

Parameters:
  • long_gate_c1 – The long gate of channel 1 in number of samples.

  • long_gate_c2 – The long gate of channel 2 in number of samples.

static void set_long_gate_c1(uint16_t long_gate_c1)

Sets the long gate of channel 1.

Parameters:

long_gate_c1 – The long gate of channel 1 in number of samples.

static void set_long_gate_c2(uint16_t long_gate_c2)

Sets the long gate of channel 2.

Parameters:

long_gate_c2 – The long gate of channel 2 in number of samples.

static uint32_t get_long_gates()

Gets the long gate configuration of both channels.

Returns:

The long gate configuration of both channels.

static uint16_t get_long_gate_c1()

Gets the long gate of channel 1.

Returns:

The long gate of channel 1 in number of samples.

static uint16_t get_long_gate_c2()

Gets the long gate of channel 2.

Returns:

The long gate of channel 2 in number of samples.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioLongGate(int mem)

Constructor for the GpioLongGate class.

The value is set to 0 by default.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioLongGate()

Destructor for the GpioLongGate class.

Before the GpioLongGate object is destructed, the value is set to 0 in hardware.

Private Members

uint32_t long_gates_ = 0

Number of samples for the long gate.

Private Static Functions

static GpioLongGate &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioLongGate &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Pre gate GPIO Class

class GpioPreGate : public nexmess::components::gpio::Gpio

The GpioPreGate class represents a GPIO interface especially for the GPIO to set the number of samples to be outputted before a trigger occurred.

For each channel an individual pre gate can be set.

This class inherits from the Gpio class and provides functionality for setting the pre gate. It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioPreGate() = delete
GpioPreGate(const GpioPreGate&) = delete
void operator=(const GpioPreGate&) = delete
GpioPreGate(GpioPreGate&&) = delete
GpioPreGate &operator=(GpioPreGate&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GpioPreGate instance with the specified memory address.

Parameters:

mem – The memory address to be used for GPIO operations.

static void set_pre_gates(uint16_t pre_gate_c1, uint16_t pre_gate_c2)

Sets the pre gates of channel 1 and channel 2.

Parameters:
  • pre_gate_c1 – The pre gate of channel 1 in number of samples.

  • pre_gate_c2 – The pre gate of channel 1 in number of samples.

static void set_pre_gate_c1(uint16_t pre_gate_c1)

Sets the pre gate of channel 1.

Parameters:

pre_gate_c1 – The pre gate of channel 1 in number of samples.

static void set_pre_gate_c2(uint16_t pre_gate_c2)

Sets the pre gate of channel 2.

Parameters:

pre_gate_c2 – The pre gate of channel 2 in number of samples.

static uint32_t get_pre_gates()

Gets the pre gate configuration of both channels.

Returns:

The pre gate configuration of both channels.

static uint16_t get_pre_gate_c1()

Gets the pre gate of channel 1.

Returns:

The pre gate of channel 1 in number of samples.

static uint16_t get_pre_gate_c2()

Gets the pre gate of channel 2.

Returns:

The pre gate of channel 2 in number of samples.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioPreGate(int mem)

Constructor for the GpioPreGate class.

The value is set to 0 by default.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioPreGate()

Destructor for the GpioPreGate class.

Before the GpioPreGate object is destructed, the value is set to 0 in hardware.

Private Members

uint32_t pre_gates_ = 0

Number of samples for the pre gate.

Private Static Functions

static GpioPreGate &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioPreGate &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Trigger value GPIO Class

class GpioTriggerValue : public nexmess::components::gpio::Gpio

The GpioTriggerValue class represents a GPIO interface especially for the GPIO to set the trigger value.

This class inherits from the Gpio class and provides functionality for setting the trigger value. The value corresponds to the values given by the ADC. It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioTriggerValue() = delete
GpioTriggerValue(const GpioTriggerValue&) = delete
void operator=(const GpioTriggerValue&) = delete
GpioTriggerValue(GpioTriggerValue&&) = delete
GpioTriggerValue &operator=(GpioTriggerValue&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GpioTriggerValue instance with the specified memory address.

Parameters:

mem – The memory address to be used for GPIO operations.

static void set_trigger_values(int16_t trigger_value_c1, int16_t trigger_value_c2)

Sets the trigger values for channel 1 and channel 2.

Parameters:
  • trigger_value_c1 – The trigger value for channel 1 in units of the ADC.

  • trigger_value_c2 – The trigger value for channel 2 in units of the ADC.

static void set_trigger_value_c1(int16_t trigger_value_c1)

Sets the trigger value of channel 1.

Parameters:

trigger_value_c1 – The trigger value of channel 1 in units of the ADC.

static void set_trigger_value_c2(int16_t trigger_value_c2)

Sets the trigger value of channel 2.

Parameters:

trigger_value_c2 – The trigger value of channel 2 in units of the ADC.

static uint32_t get_trigger_values()

Gets the trigger value configuration of both channels.

Returns:

The trigger value configuration of both channels.

static int16_t get_trigger_value_c1()

Gets the trigger value for channel 1.

Returns:

The trigger value for channel 1 in units of the ADC.

static int16_t get_trigger_value_c2()

Gets the trigger value for channel 2.

Returns:

The trigger value for channel 2 in units of the ADC.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioTriggerValue(int mem)

Constructor for the GpioTriggerValue class.

The value is set to 0 by default.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioTriggerValue()

Destructor for the GpioTriggerValue class.

Before the GpioLongGate object is destructed, the value is set to 0 in hardware.

Private Members

uint32_t trigger_values_ = 0

Trigger value in units of the ADC.

Private Static Functions

static GpioTriggerValue &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioTriggerValue &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Measurement interrupt GPIO Class

class GpioMeasurementInterrupt : public nexmess::components::gpio::Gpio

Represents a GPIO measurement interrupt.

This class extends the Gpio class and provides functionality for handling measurement interrupts.

This class checks if the measurement is stopped and if a DMA transfer is complete. It also provides functionality for preventing further interrupts from being triggered once a measurement is stopped.

It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioMeasurementInterrupt() = delete
GpioMeasurementInterrupt(const GpioMeasurementInterrupt&) = delete
void operator=(const GpioMeasurementInterrupt&) = delete
GpioMeasurementInterrupt(GpioMeasurementInterrupt&&) = delete
GpioMeasurementInterrupt &operator=(GpioMeasurementInterrupt&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GPIO measurement interrupt.

Parameters:

mem – The memory value.

static void check_status()

Checks the status of the GPIO measurement interrupt.

In case a measurement was stopped it sets the 2nd GPIO register to 0 so no further interrupts are triggered!

static bool get_stopped(uint16_t dma_id)

Gets the stopped flag for a specific ID.

Parameters:

dma_id – The ID value.

Returns:

true if the stopped flag is set, false otherwise.

static bool get_dma_interrupt(uint16_t dma_id)

Gets the DMA interrupt for a specific DMA.

Parameters:

dma_id – The ID value.

Returns:

true if the DMA interrupt is set, false otherwise.

static void reset()

Resets the GPIO measurement interrupt.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioMeasurementInterrupt(int mem)

Constructor for the GpioMeasurementInterrupt class.

This constructor initializes a new GpioMeasurementInterrupt object with all ADC channels disabled. This is done to ensure a clean state, preventing potential issues with channels that were left enabled from previous operations.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioMeasurementInterrupt() = default

Destructor for the GpioMeasurementInterrupt class.

Before the GpioMeasurementInterrupt object is destructed, this destructor disables all ADC channels. This ensures that no ADC channels remain active beyond the lifetime of the GpioMeasurementInterrupt object, preventing potential issues with dangling resources.

Private Members

uint32_t measurement_interrupt_status_ = 0

The measurement interrupt status.

The This value represents the following data:

  • bit [0..1]: stopped status of ADC channel 0 and 1

  • bit [2..3]: DMA interrupt status of ADC channel 0 and 1

Private Static Functions

static GpioMeasurementInterrupt &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioMeasurementInterrupt &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Measurement time GPIO Class

class GpioMeasurementTime : public nexmess::components::gpio::Gpio

The GpioMeasurementTime class represents a GPIO interface especially for the GPIO to set the measurement time.

This class inherits from the Gpio class and provides functionality for setting the measurement time in ms. It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioMeasurementTime() = delete
GpioMeasurementTime(const GpioMeasurementTime&) = delete
void operator=(const GpioMeasurementTime&) = delete
GpioMeasurementTime(GpioMeasurementTime&&) = delete
GpioMeasurementTime &operator=(GpioMeasurementTime&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GpioMeasurementTime instance with the specified memory address.

Parameters:

mem – The memory address to be used for GPIO operations.

static void set_time(uint32_t time)

Sets the measurement time.

Parameters:

time – The measurement time in ms. 0 means infinite.

static uint32_t get_time()

Gets the measurement time.

Returns:

The measurement time in ms. 0 means infinite.

static void stop_measurement()

Stops the measurement.

The time is set to 1ms so that the hardware actually triggers the stop.

static void reset_stop_measurement()

Resets the stop measurement.

The time is set to the previous value. This should be called after stop_measurement() once the stop was handled.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioMeasurementTime(int mem)

Constructor for the GpioMeasurementTime class.

This constructor initializes a new GpioMeasurementTime object. The measurement time is initialized to 0.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioMeasurementTime()

Destructor for the GpioMeasurementTime class.

Before the GpioMeasurementTime object is destructed, this destructor resets the measurement time to 0.

Private Members

uint32_t time_ = 0

The measurement time in ms. 0 means infinite.

Private Static Functions

static GpioMeasurementTime &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioMeasurementTime &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Package size GPIO Class

class GpioPackageSize : public nexmess::components::gpio::Gpio

The GpioPackageSize class represents a GPIO interface especially for the GPIO to set the package size for the counter.

This class inherits from the Gpio class and provides functionality for setting the package size. It is a singleton class, meaning that only one instance of this class can exist.

Public Functions

GpioPackageSize() = delete
GpioPackageSize(const GpioPackageSize&) = delete
void operator=(const GpioPackageSize&) = delete
GpioPackageSize(GpioPackageSize&&) = delete
GpioPackageSize &operator=(GpioPackageSize&&) = delete

Public Static Functions

static void init(int mem)

Initializes the GpioPackageSize instance with the specified memory address.

Parameters:

mem – The memory address to be used for GPIO operations.

static void set_package_size_c1(uint32_t package_size)

Sets the package size for channel 1.

Parameters:

package_size – The package size.

static uint32_t get_package_size_c1()

Gets the package size for channel 1.

Returns:

The package size.

static void set_package_size_c2(uint32_t package_size)

Sets the package size for channel 2.

Parameters:

package_size – The package size.

static uint32_t get_package_size_c2()

Gets the package size for channel 2.

Returns:

The package size.

static bool has_error()

Checks if any error has occurred during GPIO operations.

Returns:

true if an error has occurred, false otherwise.

Private Functions

explicit GpioPackageSize(int mem)

Constructor for the GpioPackageSize class.

The value is set to 524288 by default.

Parameters:

mem – The memory address to be used for the GPIO operations.

~GpioPackageSize()

Destructor for the GpioPackageSize class.

Before the GpioPackageSize object is destructed, the value is set to 524288 in hardware.

Private Members

uint32_t package_size_c1_ = kDefaultPackageSize

Package size for channel 1.

uint32_t package_size_c2_ = kDefaultPackageSize

Package size for channel 2.

Private Static Functions

static GpioPackageSize &get_instance_impl(int mem = 0)

The implementation of get_instance with parameters.

This is called once by init()

Parameters:

mem – The memory address to be used for the GPIO operations.

Returns:

The instance of of the GPIO object.

static GpioPackageSize &get_instance()

The implementation of get_instance with parameters.

Returns:

The instance of of the GPIO object.

Signal count GPIO Class

class GpioSignalCount : public nexmess::components::gpio::Gpio

The GpioSignalCount class represents a GPIO interface especially for the GPIO to get the signal count for a specific channel.

This class inherits from the Gpio class and provides functionality for getting the signal count.

Public Functions

GpioSignalCount(uint32_t register_base, int mem)

Constructor for the GpioSignalCount class.

This constructor initializes a new GpioSignalCount. The signal count is initialized to DEFAULT_SIGNAL_COUNT.

Parameters:
  • register_base – The register base address.

  • mem – The memory address to be used for the GPIO operations.

GpioSignalCount(GpioSignalCount&&) = delete
GpioSignalCount &operator=(GpioSignalCount&&) = delete
GpioSignalCount() = delete
GpioSignalCount(const GpioSignalCount&) = delete
void operator=(const GpioSignalCount&) = delete
~GpioSignalCount() = default
uint64_t get_signal_count()

Gets the signal count.

Returns:

The signal count.