pflib v3.13.3-1-gf856638
Pretty Fine HGCROC Interaction Library
Loading...
Searching...
No Matches
Bias.h
1#ifndef PFLIB_MAX5825_H_
2#define PFLIB_MAX5825_H_
3
4#include <unistd.h>
5
6#include <optional>
7#include <vector>
8
9#include "pflib/I2C.h"
10
11namespace pflib {
12
30class MAX5825 {
31 public:
32 // Board Commands
33 static const uint8_t WDOG;
34
35 // DAC Commands
36 // add the DAC selection to these commands
37 // to get the full command byte
38 static const uint8_t RETURNn;
39 static const uint8_t CODEn;
40 static const uint8_t LOADn;
41 static const uint8_t CODEn_LOADALL;
42 static const uint8_t CODEn_LOADn;
43 static const uint8_t REFn;
44 static const uint8_t POWERn;
45
46 public:
51 MAX5825(std::shared_ptr<I2C> i2c, uint8_t max_addr);
52
59 void reset();
60
69 std::vector<uint8_t> get(uint8_t channel);
70
83 void set(uint8_t channel, uint16_t data_bytes);
84
90 void setRefVoltage(int level);
91
92 private:
96 uint8_t our_addr_;
97}; // MAX5825
98
115class Bias {
116 public:
117 static const int N_CHANNELS = 16;
118 static const uint8_t ADDR_LED_0;
119 static const uint8_t ADDR_LED_1;
120 static const uint8_t ADDR_SIPM_0;
121 static const uint8_t ADDR_SIPM_1;
122
123 public:
137 bool use_cache);
138
140 Bias(const Bias&) = delete;
142 Bias& operator=(const Bias&) = delete;
143
147 void initialize();
148
152 double readTemp();
153
154 std::optional<int> readSiPM(uint8_t i_sipm);
155 std::optional<int> readLED(uint8_t i_led);
156 void setSiPM(uint8_t i_sipm, uint16_t code);
157 void setLED(uint8_t i_led, uint16_t code);
158
159 private:
174}; // Bias
175
176} // namespace pflib
177
178#endif // PFLIB_MAX5825_H_
The HGC ROC has 4 MAX5825 chips doing the DAC for the bias voltages.
Definition Bias.h:115
Bias(std::shared_ptr< I2C > bias_i2c, std::shared_ptr< I2C > board_i2c, bool use_cache)
Wrap I2C objects for communicating with all the DAC chips.
Definition Bias.cxx:71
std::array< std::optional< int >, N_CHANNELS > sipm_cache_
cache of sipm settings
Definition Bias.h:171
Bias & operator=(const Bias &)=delete
dont copy assign this class
std::array< std::optional< int >, N_CHANNELS > led_cache_
cache of led settings
Definition Bias.h:173
bool use_cache_
whether to use the software cache of the settings
Definition Bias.h:169
std::shared_ptr< I2C > i2c_bias_
I2C comms with bias DACs MAX5825.
Definition Bias.h:161
std::vector< MAX5825 > led_
LED bias chips.
Definition Bias.h:165
std::shared_ptr< I2C > i2c_board_
I2C comms with HGCROC board periferials.
Definition Bias.h:163
Bias(const Bias &)=delete
dont copy construct this class
std::vector< MAX5825 > sipm_
SiPM bias chips.
Definition Bias.h:167
void initialize()
Initialize to standard settings.
Definition Bias.cxx:80
static const uint8_t ADDR_LED_0
DAC chip addresses taken from HGCROC specs.
Definition Bias.h:118
double readTemp()
Read the temperature from the temp sensor on the HGCROC board.
Definition Bias.cxx:114
Class representing communication with the Digital-Analog Converter on the HGC ROC.
Definition Bias.h:30
uint8_t our_addr_
our addr on the chip
Definition Bias.h:96
std::shared_ptr< I2C > i2c_
our connection
Definition Bias.h:94
void setRefVoltage(int level)
Set reference voltage.
Definition Bias.cxx:50
void set(uint8_t channel, uint16_t data_bytes)
Write a setting for the DACs on this MAX.
Definition Bias.cxx:39
std::vector< uint8_t > get(uint8_t channel)
Get the settings for the DACs on this MAX.
Definition Bias.cxx:25
MAX5825(std::shared_ptr< I2C > i2c, uint8_t max_addr)
Wrap an I2C class for communicating with the MAX5825.
Definition Bias.cxx:22
void reset()
send the SW_RESET command to the MAX5825
Definition Bias.cxx:34
This version of the fast control code interfaces with the CMS Fast control library which can be contr...
Definition Backend.cxx:3