pflib v3.15.1-5-ge6391b0
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
ROC.h
1#ifndef PFLIB_ROC_H_INCLUDED
2#define PFLIB_ROC_H_INCLUDED
3
4#include <iostream>
5#include <map>
6#include <string>
7#include <vector>
8
9#include "pflib/Compile.h"
10#include "pflib/I2C.h"
11#include "pflib/TempParameters.h"
12#include "pflib/logging/Logging.h"
13
14namespace pflib {
15
19class ROC {
20 static const int N_REGISTERS_PER_PAGE = 32;
21
22 public:
23 ROC(std::shared_ptr<I2C> i2c, uint8_t roc_base_addr,
24 const std::string& type_version);
25
26 void setRunMode(bool active = true);
27 bool isRunMode();
28 const std::string& type() const;
29
30 std::vector<uint8_t> readPage(int ipage, int len);
31 void writePage(int ipage, std::vector<uint8_t> vals);
32 uint8_t getValue(int page, int offset);
33 void setValue(int page, int offset, uint8_t value);
34
35 std::vector<std::string> getDirectAccessParameters();
36 bool getDirectAccess(const std::string& name);
37 bool getDirectAccess(int reg, int bit);
38 void setDirectAccess(const std::string& name, bool val);
39 void setDirectAccess(int reg, int bit, bool val);
40
47 void setRegisters(const std::map<int, std::map<int, uint8_t>>& registers);
48
56 const std::map<int, std::map<int, uint8_t>>& selected = {});
57
64
75
88
97 void loadParameters(const std::string& file_path, bool prepend_defaults);
98
107 void loadParameters(const YAML::Node& params);
108
118 void applyParameter(const std::string& page, const std::string& param,
119 const uint64_t& val);
120
130 void dumpSettings(const std::string& filepath, bool decompile, bool use_csv);
131
143 void loadSettings(const std::string& filepath, bool is_csv);
144
166
172 void setBusSpeed(int khz);
173
184 int countI2CErrors(int n_tries);
185
186 private:
188 void setPointer(uint16_t addr);
190 uint8_t roc_base_;
192 int bus_khz_{1400};
193 std::string type_version_;
194 Compiler compiler_;
195 mutable ::pflib::logging::logger the_log_{::pflib::logging::get("roc")};
196};
197
198} // namespace pflib
199
200#endif // PFLIB_ROC_H_INCLUDED
Definition of compiling and decompiling functions between page numbers, register numbers,...
The object that does the compiling.
Definition Compile.h:55
Definition ROC.h:19
std::map< int, std::map< int, uint8_t > > applyParameters(const std::map< std::string, std::map< std::string, uint64_t > > &parameters)
Apply the input parameter mapping onto the chip.
Definition ROC.cxx:434
void loadParameters(const std::string &file_path, bool prepend_defaults)
Load the input parameters onto the chip.
Definition ROC.cxx:486
int bus_khz_
I2C bus speed in kHz.
Definition ROC.h:192
std::map< std::string, uint64_t > getParameters(const std::string &page)
Get the parameters for the input page.
Definition ROC.cxx:408
TempParameters< ROC >::Builder testParameters()
start a set of test parameters
Definition ROC.cxx:589
void setPointer(uint16_t addr)
set the register pointer (R0, R1) and read it back until it matches
Definition ROC.cxx:60
void setRegisters(const std::map< int, std::map< int, uint8_t > > &registers)
set registers on the HGCROC to specific values
Definition ROC.cxx:344
void dumpSettings(const std::string &filepath, bool decompile, bool use_csv)
Dump the settings of the HGCROC into the input filepath.
Definition ROC.cxx:521
void setBusSpeed(int khz)
Set the I2C bus speed used for the transactions with this ROC.
Definition ROC.cxx:43
std::vector< uint8_t > readPage(int ipage, int len)
Definition ROC.cxx:102
int countI2CErrors(int n_tries)
Test the I2C bus to this ROC without retries.
Definition ROC.cxx:73
std::map< std::string, std::map< std::string, uint64_t > > defaults()
Retrieve all of the manual-documented defaults for all parameters.
Definition ROC.cxx:430
std::map< int, std::map< int, uint8_t > > getRegisters(const std::map< int, std::map< int, uint8_t > > &selected={})
get registers from the HGCROC
Definition ROC.cxx:352
void loadSettings(const std::string &filepath, bool is_csv)
load the settings from the input filepath onto the HGCROC
Definition ROC.cxx:384
void writePage(int ipage, std::vector< uint8_t > vals)
Definition ROC.cxx:162
void applyParameter(const std::string &page, const std::string &param, const uint64_t &val)
Short-hand for applying a single parameter.
Definition ROC.cxx:514
Build a TempParameters class parameter by parameters.
Definition TempParameters.h:41
logger get(const std::string &name)
Gets a logger with the input name for its channel.
Definition Logging.cxx:24
This version of the fast control code interfaces with the CMS Fast control library which can be contr...
Definition Backend.cxx:3