|
RMM API 2.0.0
|
Class to handle register access over the ESS Readout Master Module. More...
#include <RMMRegisterAccess.h>

Public Types | |
| enum class | RegisterTag { CTRL , ENG , TIME , RING_MST , CMAC , ALL } |
| Enum class representing different register tags. More... | |
Public Member Functions | |
| RMMRegisterAccess (const std::string &serverIP, int serverPort) | |
| Constructor of the RMMRegisterAccess instance. | |
| ~RMMRegisterAccess () | |
| Destructor of the RMMRegisterAccess. | |
| std::unordered_map< RegisterTag, std::unordered_map< std::string, uint32_t > > | fillAllAddressMaps () |
| Fill all address maps. | |
| std::list< std::string > | getAllRegMaps () |
| returns a list of shared pointers to current address maps. | |
| void | addRegMapMutexes (FENRegMap map) |
| Calls regMutex addMap. | |
| unsigned int | addRegsMutexes (std::list< std::string > regs, bool critic=true) |
| Calls regMutex addRegs. | |
| bool | addRegMutex (std::string reg, std::string tag="NoTag", bool critic=true) |
| Calls regMutex addReg. | |
| RegLockGuard | regLockGuard (std::string reg, std::string tag="NoTag") |
| returns a lock guard object for that register mutex. | |
| std::string | addrLookUp (const std::string &name, RegisterTag tag=RegisterTag::ALL) |
| Retrieves the address of a register from the address map. | |
| RMMResult | feaFwRegRead (const std::string ®_name, int ring_id, int node_id, const std::string &tag="") |
| Read a front-end register, calculating the ring/node offset. | |
| RMMResult | feaFwRegWrite (const std::string ®_name, int ring_id, int node_id, uint32_t data, const std::string &tag="") |
| Write in a front-end register, calculating the ring/node offset. | |
| RMMResult | regRead (const std::string ®Name, RegisterTag tag=RegisterTag::ALL) |
| Reads a register value by its name from the register map. | |
| void | regAssert (const std::string ®_name, uint32_t exp_data, RegisterTag tag=RegisterTag::ALL) |
| Check a register matches an expected value, or throw a ValueError exception. | |
| RMMResult | regWrite (const std::string ®Name, uint32_t data, RegisterTag tag=RegisterTag::ALL) |
| Writes a value to a named register. | |
| rmmStatus | regPoll (const std::string ®Name, uint32_t expData, double pollDelay=1.0, uint32_t timeout=0, RegisterTag regTag=RegisterTag::ALL, std::function< bool(uint32_t)> stopCondition=nullptr, std::function< bool()> checkStop=nullptr) |
| Polls a named register until it matches the expected value, or stops based on a custom stop condition or timeout. | |
| RMMResult | fieldRead (const std::string ®, RegisterTag tag, int bitBegin, int bitWidth) |
| Reads a field from a register in the RMM space using a register name. | |
| RMMResult | fieldRead (uint32_t reg, int bitBegin, int bitWidth) |
| Reads a field from a register in the RMM space using a register address. | |
| RMMResult | fieldWrite (const std::string ®, RegisterTag tag, int bitBegin, int bitWidth, uint32_t data) |
| Writes a field to a register in the RMM space using a register name. | |
| RMMResult | fieldWrite (uint32_t reg, int bitBegin, int bitWidth, uint32_t data) |
| Writes a field to a register in the RMM space using a register address. | |
| rmmStatus | i2cWriteByte (int i2c_addr, uint32_t data) |
| Writes a single byte to an I2C address. | |
| rmmStatus | i2cWrite8bReg (int i2c_addr, int reg_addr, uint32_t data) |
| Writes to an 8bit register at an I2C address. | |
| rmmStatus | i2cWrite16bReg (int i2c_addr, int reg_addr, uint32_t data) |
| Writes to a 16bit register at an I2C address. | |
| uint32_t | i2cRead8bRegSi570 (int i2c_addr, int reg_addr) |
| Reads from an 8bit register at an I2C address (Si570 only). | |
| RMMResult | regMaskWrite (const std::string ®Name, uint32_t data, uint32_t mask, RegisterTag tag=RegisterTag::ALL) |
| Writes a value to a register using a bitmask. | |
| rmmStatus | i2cDelay (uint32_t delay) |
| Use the I2C controller to time a delay. | |
| RMMResult | rawRead (const std::string &addr) |
| Performs a read operation from a register address. | |
| RMMResult | rawWrite (const std::string &addr, uint32_t data) |
| Performs a write operation to a register address. | |
| void | requestStop () |
| Requests to stop ongoing operations. | |
| void | resetStop () |
| Resets the stop request flag, allowing operations to continue. | |
| bool | isStopRequested () const |
| Checks if a stop request has been issued. | |
| bool | isLegacyFW () const |
| Checks if the FW version is legagy (Non UDP Core version). | |
Public Attributes | |
| RMMLog | rmmLog |
| Log handler for RMMRegisterAccess messages. | |
Friends | |
| class | I2CMutex |
Class to handle register access over the ESS Readout Master Module.
This class provides methods for reading and writing hardware registers via a network socket.
|
strong |
Enum class representing different register tags.
This enum class is used to identify specific address maps for registers. Each tag corresponds to a particular set of registers in the system.
| Enumerator | |
|---|---|
| CTRL | Control register. |
| ENG | Engineering register. |
| TIME | Time register. |
| RING_MST | Ring master register. |
| CMAC | CMAC register (Used only by nonUDP FW version) |
| ALL | All registers. |
| RMMRegisterAccess::RMMRegisterAccess | ( | const std::string & | serverIP, |
| int | serverPort ) |
Constructor of the RMMRegisterAccess instance.
This constructor initializes the logging system, connects to the specified server via a network socket, and populates the address maps for register access.
| serverIP | The IP address of the Readout Master Module. |
| serverPort | UDP Port of the Readout Master Module Slow Control. |
| RMMRegisterAccess::~RMMRegisterAccess | ( | ) |
Destructor of the RMMRegisterAccess.
This destructor ensures proper cleanup by logging the destruction event and closing the network socket.
| std::string RMMRegisterAccess::addrLookUp | ( | const std::string & | name, |
| RegisterTag | tag = RegisterTag::ALL ) |
Retrieves the address of a register from the address map.
This function searches for the specified register name within the loaded address maps. If a specific RegisterTag is provided, the search is limited to the corresponding address map. If RegisterTag::ALL is specified, it iterates through all available maps and returns the first match found.
| [in] | name | The name of the register to look up. |
| [in] | tag | The tag specifying which address map to search in. |
| RMMResult RMMRegisterAccess::feaFwRegRead | ( | const std::string & | reg_name, |
| int | ring_id, | ||
| int | node_id, | ||
| const std::string & | tag = "" ) |
Read a front-end register, calculating the ring/node offset.
| reg_name | Name of register to read from. |
| ring_id | ring id used to specify the front end we are addressing. |
| node_id | node id used to specify the front end we are addressing. |
| tag | Optional tag to tell us which address map to look in. |
| RMMResult RMMRegisterAccess::feaFwRegWrite | ( | const std::string & | reg_name, |
| int | ring_id, | ||
| int | node_id, | ||
| uint32_t | data, | ||
| const std::string & | tag = "" ) |
Write in a front-end register, calculating the ring/node offset.
| reg_name | Name of register to read from. |
| ring_id | Ring id used to specify the front end we are addressing. |
| node_id | Node id used to specify the front end we are addressing. |
| data | Data to write |
| tag | Optional tag to tell us which address map to look in. |
| RMMResult RMMRegisterAccess::fieldRead | ( | const std::string & | reg, |
| RegisterTag | tag, | ||
| int | bitBegin, | ||
| int | bitWidth ) |
Reads a field from a register in the RMM space using a register name.
This method reads a field from the specified register, identified by its name (reg). The requested field is extracted based on the bit index (bitBegin) and the field width (bitWidth).
| [in] | reg | The name of the register to read from. |
| [in] | tag | The tag identifying which address map to use. Valid values for tag are defined in the RMMRegisterAccess::RegisterTag enum class. |
| [in] | bitBegin | The index of the lowest bit in the register that is part of the field. |
| [in] | bitWidth | The width of the field in bits. |
value: The final register value after modification.status: The status of the operation (e.g., rmmSuccess or an error status). | std::invalid_argument | If any of the following conditions are met:
|
| RMMResult RMMRegisterAccess::fieldRead | ( | uint32_t | reg, |
| int | bitBegin, | ||
| int | bitWidth ) |
Reads a field from a register in the RMM space using a register address.
This method reads a field from the specified register, identified by its numerical address (reg). The requested field is extracted based on the bit index (bitBegin) and the field width (bitWidth).
| [in] | reg | The numerical address of the register to read from. |
| [in] | bitBegin | The index of the lowest bit in the register that is part of the field. |
| [in] | bitWidth | The width of the field in bits. |
value: The final register value after modification.status: The status of the operation (e.g., rmmSuccess or an error status). | std::invalid_argument | If any of the following conditions are met:
|
| RMMResult RMMRegisterAccess::fieldWrite | ( | const std::string & | reg, |
| RegisterTag | tag, | ||
| int | bitBegin, | ||
| int | bitWidth, | ||
| uint32_t | data ) |
Writes a field to a register in the RMM space using a register name.
| [in] | reg | The name of the register to write to. |
| [in] | tag | The tag identifying which address map to use. Valid values for tag are defined in the RMMRegisterAccess::RegisterTag enum class. |
| [in] | bitBegin | The index of the lowest bit in the register that is part of the field. |
| [in] | bitWidth | The width of the field in bits. |
| [in] | data | The data to write to the field. |
value: The final register value after modification.status: The status of the operation (e.g., rmmSuccess or an error status). | std::invalid_argument | If any of the following conditions are met:
|
| RMMResult RMMRegisterAccess::fieldWrite | ( | uint32_t | reg, |
| int | bitBegin, | ||
| int | bitWidth, | ||
| uint32_t | data ) |
Writes a field to a register in the RMM space using a register address.
| [in] | reg | The numerical address of the register to write to. |
| [in] | bitBegin | The index of the lowest bit in the register that is part of the field. |
| [in] | bitWidth | The width of the field in bits. |
| [in] | data | The data to write to the field. |
value: The final register value after modification.status: The status of the operation (e.g., rmmSuccess or an error status). | std::invalid_argument | If any of the following conditions are met:
|
| rmmStatus RMMRegisterAccess::i2cDelay | ( | uint32_t | delay | ) |
Use the I2C controller to time a delay.
| delay | Delay in microseconds |
| uint32_t RMMRegisterAccess::i2cRead8bRegSi570 | ( | int | i2c_addr, |
| int | reg_addr ) |
Reads from an 8bit register at an I2C address (Si570 only).
| i2c_addr | I2C address of target Si570. |
| reg_addr | target register address inside I2C device. |
| rmmStatus RMMRegisterAccess::i2cWrite16bReg | ( | int | i2c_addr, |
| int | reg_addr, | ||
| uint32_t | data ) |
Writes to a 16bit register at an I2C address.
| i2c_addr | I2C address of target. |
| reg_addr | target register address inside I2C device. |
| data | data bytes to write |
| rmmStatus RMMRegisterAccess::i2cWrite8bReg | ( | int | i2c_addr, |
| int | reg_addr, | ||
| uint32_t | data ) |
Writes to an 8bit register at an I2C address.
| i2c_addr | I2C address of target. |
| reg_addr | target register address inside I2C device. |
| data | data bytes to write |
| rmmStatus RMMRegisterAccess::i2cWriteByte | ( | int | i2c_addr, |
| uint32_t | data ) |
Writes a single byte to an I2C address.
Useful for setting I2C muxes.
| i2c_addr | I2C address of target. |
| data | data byte to write. |
| bool RMMRegisterAccess::isLegacyFW | ( | ) | const |
Checks if the FW version is legagy (Non UDP Core version).
| bool RMMRegisterAccess::isStopRequested | ( | ) | const |
Checks if a stop request has been issued.
| RMMResult RMMRegisterAccess::rawRead | ( | const std::string & | addr | ) |
Performs a read operation from a register address.
This method constructs a read packet and sends it via the slow control protocol, then parses the received data to extract the register value.
| [in] | addr | The hexadecimal string representing the register address. |
| RMMResult RMMRegisterAccess::rawWrite | ( | const std::string & | addr, |
| uint32_t | data ) |
Performs a write operation to a register address.
This method constructs a write packet and sends it via the slow control protocol, then parses the received data to verify the success of the operation.
| [in] | addr | The hexadecimal string representing the register address. |
| [in] | data | The 32-bit value to be written to the register. |
| void RMMRegisterAccess::regAssert | ( | const std::string & | reg_name, |
| uint32_t | exp_data, | ||
| RegisterTag | tag = RegisterTag::ALL ) |
Check a register matches an expected value, or throw a ValueError exception.
| [in] | reg_name | Name of register to read from. |
| [in] | exp_data | Expected data. |
| [in] | tag | (Optional) The tag identifying which address map to use. If not specified, RegisterTag::ALL is assumed, and all maps are searched. Valid values for tag are defined in the RegisterTag enum class. |
| RegLockGuard RMMRegisterAccess::regLockGuard | ( | std::string | reg, |
| std::string | tag = "NoTag" ) |
returns a lock guard object for that register mutex.
| [in] | reg | string representing register address to look. |
| RMMResult RMMRegisterAccess::regMaskWrite | ( | const std::string & | regName, |
| uint32_t | data, | ||
| uint32_t | mask, | ||
| RegisterTag | tag = RegisterTag::ALL ) |
Writes a value to a register using a bitmask.
This method reads the current value of the specified register, applies a bitmask to retain or modify specific bits, and then writes the modified value back to the register.
| regName | The name of the register to write to. | |
| data | The 32-bit value to be written. | |
| mask | The bitmask determining which bits should be retained from the original value. Bits set to 1 in the mask remain unchanged, while bits set to 0 are updated. | |
| [in] | tag | (Optional) The tag identifying which address map to use. If not specified, RegisterTag::ALL is assumed, and all maps are searched. Valid values for tag are defined in the RegisterTag enum class. |
| rmmStatus RMMRegisterAccess::regPoll | ( | const std::string & | regName, |
| uint32_t | expData, | ||
| double | pollDelay = 1.0, | ||
| uint32_t | timeout = 0, | ||
| RegisterTag | regTag = RegisterTag::ALL, | ||
| std::function< bool(uint32_t)> | stopCondition = nullptr, | ||
| std::function< bool()> | checkStop = nullptr ) |
Polls a named register until it matches the expected value, or stops based on a custom stop condition or timeout.
This function repeatedly reads the value from the specified register and compares it to the expected value. It allows for custom stop conditions and external interrupt requests, such as when polling needs to be terminated early.
| [in] | regName | Name of the register to read from. |
| [in] | expData | Expected data that the register should match. |
| [in] | pollDelay | Optional delay (in seconds) between polling attempts. Default is 1.0 second if not provided. |
| [in] | timeout | Optional maximum number of polling attempts before giving up. If set to 0, no timeout will be enforced. Default is 0 (no timeout). |
| [in] | regTag | (Optional) The tag identifying which address map to use. If not specified, RegisterTag::ALL is assumed, and all maps are searched. Valid values for tag are defined in the RegisterTag enum class. |
| [in] | stopCondition | Optional custom stop condition, which should return true to stop polling. This function is called with the current register value (tmp_read), and if it returns true, the polling process will stop. |
| [in] | checkStop | Optional function to check for an external stop request. If this function returns true, the polling will be aborted and an exception will be thrown. This can be used to interrupt polling based on an external condition. |
rmmSuccess if the register value matches the expected value (expData) before a stop condition or timeout. rmmError if the timeout is reached before the value matches the expected value. Throws RMMAbortException if the polling is interrupted by an external stop request. | RMMResult RMMRegisterAccess::regRead | ( | const std::string & | regName, |
| RegisterTag | tag = RegisterTag::ALL ) |
Reads a register value by its name from the register map.
This method retrieves the address of the specified register using the register map and performs a raw read operation.
| [in] | regName | The name of the register to read from the register map. |
| [in] | tag | (Optional) The tag identifying which address map to use. If not specified, RegisterTag::ALL is assumed, and all maps are searched. Valid values for tag are defined in the RMMRegisterAccess::RegisterTag enum class. |
RMMResult object containing the register value and the status of the operation. If the register is not found, the value is set to 0, and the status indicates an error. | RMMResult RMMRegisterAccess::regWrite | ( | const std::string & | regName, |
| uint32_t | data, | ||
| RegisterTag | tag = RegisterTag::ALL ) |
Writes a value to a named register.
This method retrieves the address of the specified register using the register map and performs a write operation.
| [in] | regName | The name of the register to write to. |
| [in] | data | The 32-bit value to be written. |
| [in] | tag | (Optional) The tag identifying which address map to use. If not specified, RegisterTag::ALL is assumed, and all maps are searched. Valid values for tag are defined in the RMMRegisterAccess::RegisterTag enum class. |