10 namespace Treehopper {
namespace Libraries {
namespace IO {
namespace Adc {
58 class ConversionRegister :
public Register 64 long getValue() {
return ((value & 0xFFFF) << 0); }
65 void setValue(
long val)
67 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
71 class ConfigRegister :
public Register 76 int latchingComparator;
77 int comparatorPolarity;
83 int operationalStatus;
85 void setComparatorQueue(
ComparatorQueues enumVal) { comparatorQueue = (int)enumVal; }
87 void setDataRate(
DataRates enumVal) { dataRate = (int)enumVal; }
89 void setPga(
Pgas enumVal) { pga = (int)enumVal; }
91 void setMux(
Muxes enumVal) { mux = (int)enumVal; }
93 long getValue() {
return ((comparatorQueue & 0x3) << 0) | ((latchingComparator & 0x1) << 2) | ((comparatorPolarity & 0x1) << 3) | ((comparatorMode & 0x1) << 4) | ((dataRate & 0x7) << 5) | ((operatingMode & 0x1) << 8) | ((pga & 0x7) << 9) | ((mux & 0x7) << 12) | ((operationalStatus & 0x1) << 15); }
94 void setValue(
long val)
96 comparatorQueue = (int)((val >> 0) & 0x3);
97 latchingComparator = (int)((val >> 2) & 0x1);
98 comparatorPolarity = (int)((val >> 3) & 0x1);
99 comparatorMode = (int)((val >> 4) & 0x1);
100 dataRate = (int)((val >> 5) & 0x7);
101 operatingMode = (int)((val >> 8) & 0x1);
102 pga = (int)((val >> 9) & 0x7);
103 mux = (int)((val >> 12) & 0x7);
104 operationalStatus = (int)((val >> 15) & 0x1);
108 class LowThresholdRegister :
public Register 114 long getValue() {
return ((value & 0xFFFF) << 0); }
115 void setValue(
long val)
117 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
121 class HighThresholdRegister :
public Register 127 long getValue() {
return ((value & 0xFFFF) << 0); }
128 void setValue(
long val)
130 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
134 ConversionRegister conversion;
135 ConfigRegister config;
136 LowThresholdRegister lowThreshold;
137 HighThresholdRegister highThreshold;
139 Ads1115Registers(SMBusDevice& device) :
RegisterManager(device, true), conversion(*this), config(*this), lowThreshold(*this), highThreshold(*this)
141 registers.push_back(&conversion);
142 registers.push_back(&config);
143 registers.push_back(&lowThreshold);
144 registers.push_back(&highThreshold);
Definition: Register.h:11
Muxes
Definition: Ads1115Registers.h:42
Definition: RegisterManager.h:10
ComparatorQueues
Definition: Ads1115Registers.h:12
DataRates
Definition: Ads1115Registers.h:20
Pgas
Definition: Ads1115Registers.h:32