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::MemoryMapclass.Subclassed by nexmess::components::gpio::GpioEnabled, nexmess::components::gpio::GpioLongGate, nexmess::components::gpio::GpioMeasurementInterrupt, nexmess::components::gpio::GpioMeasurementTime, nexmess::components::gpio::GpioPreGate, nexmess::components::gpio::GpioTriggerValue
Public Functions
-
Gpio() = delete
-
~Gpio() = default
-
Gpio(uint32_t registerBase, int mem)
Constructs a new Gpio object.
- Parameters:
registerBase – The base address of the GPIO registers.
mem – The memory identifier.
-
bool hasError() const
Checks if there is any error with the GPIO.
- Returns:
trueif there is an error,falseotherwise.
Protected Functions
-
void setValue(uint32_t value)
Sets the value of the first data register.
- Parameters:
value – The value to be set.
-
uint32_t getValue()
Gets the value of the first data register.
- Returns:
The value of the first data register.
-
void setValue2(uint32_t value)
Sets the value of the second data register.
- Parameters:
value – The value to be set.
-
uint32_t getValue2()
Gets the value of the second data register.
- Returns:
The value of the second data register.
-
Gpio() = delete
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
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 deactivateAll()
Deactivates all ADC channels.
-
static void activateSpecific(uint8_t value)
Activates the specified ADC channels.
This function uses a bit mask to specify which ADC channels to activate. Each bit in the mask corresponds to a channel. If a bit is set to 1, the corresponding channel is activated; if it is set to 0, the corresponding channel is not affected.
For example, a mask of 0b00000011 would activate the first two channels (all channels).
- Parameters:
value – A bit mask specifying the ADC channels to be activated.
-
static bool hasError()
Checks if any error has occurred during GPIO operations.
- Returns:
true if an error has occurred, false otherwise.
Private Functions
-
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(GpioEnabled&&) = delete
-
GpioEnabled &operator=(GpioEnabled&&) = delete
-
~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
-
uint16_t mSensorState = 0
Sets the state of the sensor (0 -> off, 1 -> on). Each bit is one sensor.
Private Static Functions
-
static GpioEnabled &getInstanceImpl(int mem = 0)
The implementation of getInstance 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 &getInstance()
The implementation of getInstance with parameters.
- Returns:
The instance of of the GPIO object.
-
GpioEnabled() = delete
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
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 setLongGate(uint32_t longGate)
Sets the long gate.
- Parameters:
longGate – The long gate in in number of samples.
-
static uint32_t getLongGate()
Gets the long gate.
- Returns:
The long gate in number of samples.
-
static bool hasError()
Checks if any error has occurred during GPIO operations.
- Returns:
true if an error has occurred, false otherwise.
Private Functions
-
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(GpioLongGate&&) = delete
-
GpioLongGate &operator=(GpioLongGate&&) = delete
-
~GpioLongGate()
Destructor for the GpioLongGate class.
Before the GpioLongGate object is destructed, the value is set to 0 in hardware.
Private Members
-
uint32_t mLongGate = 0
Number of samples for the long gate.
Private Static Functions
-
static GpioLongGate &getInstanceImpl(int mem = 0)
The implementation of getInstance 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 &getInstance()
The implementation of getInstance with parameters.
- Returns:
The instance of of the GPIO object.
-
GpioLongGate() = delete
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.
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
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 setPreGate(uint32_t preGate)
Sets the pre gate.
- Parameters:
preGate – The pre gate in in number of samples.
-
static uint32_t getPreGate()
Gets the pre gate.
- Returns:
The pre gate in number of samples.
-
static bool hasError()
Checks if any error has occurred during GPIO operations.
- Returns:
true if an error has occurred, false otherwise.
Private Functions
-
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(GpioPreGate&&) = delete
-
GpioPreGate &operator=(GpioPreGate&&) = delete
-
~GpioPreGate()
Destructor for the GpioPreGate class.
Before the GpioPreGate object is destructed, the value is set to 0 in hardware.
Private Members
-
uint32_t mPreGate = 0
Number of samples for the pre gate.
Private Static Functions
-
static GpioPreGate &getInstanceImpl(int mem = 0)
The implementation of getInstance 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 &getInstance()
The implementation of getInstance with parameters.
- Returns:
The instance of of the GPIO object.
-
GpioPreGate() = delete
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
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 setTriggerValue(int16_t triggerValue)
Sets the trigger value.
- Parameters:
triggerValue – The trigger value in units of the ADC.
-
static int16_t getTriggerValue()
Gets the trigger value.
- Returns:
The trigger value in units of the ADC.
-
static bool hasError()
Checks if any error has occurred during GPIO operations.
- Returns:
true if an error has occurred, false otherwise.
Private Functions
-
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(GpioTriggerValue&&) = delete
-
GpioTriggerValue &operator=(GpioTriggerValue&&) = delete
-
~GpioTriggerValue()
Destructor for the GpioTriggerValue class.
Before the GpioLongGate object is destructed, the value is set to 0 in hardware.
Private Members
-
uint32_t mTriggerValue = 0
Trigger value in units of the ADC.
Private Static Functions
-
static GpioTriggerValue &getInstanceImpl(int mem = 0)
The implementation of getInstance 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 &getInstance()
The implementation of getInstance with parameters.
- Returns:
The instance of of the GPIO object.
-
GpioTriggerValue() = delete
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
Public Static Functions
-
static void init(int mem)
Initializes the GPIO measurement interrupt.
- Parameters:
mem – The memory value.
-
static void checkStatus()
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 getStopped(uint16_t id)
Gets the stopped flag for a specific ID.
- Parameters:
id – The ID value.
- Returns:
true if the stopped flag is set, false otherwise.
-
static bool getDmaInterrupt(uint16_t id)
Gets the DMA interrupt for a specific DMA.
- Parameters:
id – The ID value.
- Returns:
true if the DMA interrupt is set, false otherwise.
-
static void reset()
Resets the GPIO measurement interrupt.
-
static bool hasError()
Checks if any error has occurred during GPIO operations.
- Returns:
true if an error has occurred, false otherwise.
Private Functions
-
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(GpioMeasurementInterrupt&&) = delete
-
GpioMeasurementInterrupt &operator=(GpioMeasurementInterrupt&&) = delete
-
~GpioMeasurementInterrupt()
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 m_measurementInterruptStatus = 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 &getInstanceImpl(int mem = 0)
The implementation of getInstance 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 &getInstance()
The implementation of getInstance with parameters.
- Returns:
The instance of of the GPIO object.
-
GpioMeasurementInterrupt() = delete
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
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 setTime(uint32_t time)
Sets the measurement time.
- Parameters:
time – The measurement time in ms. 0 means infinite.
-
static uint32_t getTime()
Gets the measurement time.
- Returns:
The measurement time in ms. 0 means infinite.
-
static void stopMeasurement()
Stops the measurement.
The time is set to 1ms so that the hardware actually triggers the stop.
-
static void resetStopMeasurement()
Resets the stop measurement.
The time is set to the previous value. This should be called after stopMeasurement() once the stop was handled.
-
static bool hasError()
Checks if any error has occurred during GPIO operations.
- Returns:
true if an error has occurred, false otherwise.
Private Functions
-
GpioMeasurementTime(int mem)
Constructor for the GpioMeasurementTime class.
This constructor initializes a new GpioMeasurementTime 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.
-
GpioMeasurementTime(GpioMeasurementTime&&) = delete
-
GpioMeasurementTime &operator=(GpioMeasurementTime&&) = delete
-
~GpioMeasurementTime()
Destructor for the GpioMeasurementTime class.
Before the GpioMeasurementTime object is destructed, this destructor disables all ADC channels. This ensures that no ADC channels remain active beyond the lifetime of the GpioMeasurementTime object, preventing potential issues with dangling resources.
Private Members
-
uint32_t mTime = 0
The measurement time in ms. 0 means infinite.
Private Static Functions
-
static GpioMeasurementTime &getInstanceImpl(int mem = 0)
The implementation of getInstance 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 &getInstance()
The implementation of getInstance with parameters.
- Returns:
The instance of of the GPIO object.
-
GpioMeasurementTime() = delete