10 namespace Treehopper {
namespace Libraries {
namespace Sensors {
namespace Optical {
52 class CommandRegister :
public Register 57 int proxPeriodicEnable;
58 int alsPeriodicEnable;
59 int proxOnDemandStart;
65 long getValue() {
return ((selfTimedEnable & 0x1) << 0) | ((proxPeriodicEnable & 0x1) << 1) | ((alsPeriodicEnable & 0x1) << 2) | ((proxOnDemandStart & 0x1) << 3) | ((alsOnDemandStart & 0x1) << 4) | ((proxDataReady & 0x1) << 5) | ((alsDataReady & 0x1) << 6) | ((configLock & 0x1) << 7); }
66 void setValue(
long val)
68 selfTimedEnable = (int)((val >> 0) & 0x1);
69 proxPeriodicEnable = (int)((val >> 1) & 0x1);
70 alsPeriodicEnable = (int)((val >> 2) & 0x1);
71 proxOnDemandStart = (int)((val >> 3) & 0x1);
72 alsOnDemandStart = (int)((val >> 4) & 0x1);
73 proxDataReady = (int)((val >> 5) & 0x1);
74 alsDataReady = (int)((val >> 6) & 0x1);
75 configLock = (int)((val >> 7) & 0x1);
79 class ProductIdRegister :
public Register 86 long getValue() {
return ((revisionId & 0xF) << 0) | ((productId & 0xF) << 4); }
87 void setValue(
long val)
89 revisionId = (int)((val >> 0) & 0xF);
90 productId = (int)((val >> 4) & 0xF);
94 class ProximityRateRegister :
public Register 100 void setRate(
Rates enumVal) { rate = (int)enumVal; }
102 long getValue() {
return ((rate & 0xF) << 0); }
103 void setValue(
long val)
105 rate = (int)((val >> 0) & 0xF);
109 class LedCurrentRegister :
public Register 113 int irLedCurrentValue;
116 long getValue() {
return ((irLedCurrentValue & 0x3F) << 0) | ((fuseProgId & 0x3) << 6); }
117 void setValue(
long val)
119 irLedCurrentValue = (int)((val >> 0) & 0x3F);
120 fuseProgId = (int)((val >> 6) & 0x3);
124 class AmbientLightParametersRegister :
public Register 128 int averagingSamples;
129 int autoOffsetCompensation;
131 int continuousConversionMode;
133 void setAlsRate(
AlsRates enumVal) { alsRate = (int)enumVal; }
135 long getValue() {
return ((averagingSamples & 0x7) << 0) | ((autoOffsetCompensation & 0x1) << 3) | ((alsRate & 0x7) << 4) | ((continuousConversionMode & 0x1) << 7); }
136 void setValue(
long val)
138 averagingSamples = (int)((val >> 0) & 0x7);
139 autoOffsetCompensation = (int)((val >> 3) & 0x1);
140 alsRate = (int)((val >> 4) & 0x7);
141 continuousConversionMode = (int)((val >> 7) & 0x1);
145 class AmbientLightResultRegister :
public Register 151 long getValue() {
return ((value & 0xFFFF) << 0); }
152 void setValue(
long val)
154 value = (int)((val >> 0) & 0xFFFF);
158 class ProximityResultRegister :
public Register 164 long getValue() {
return ((value & 0xFFFF) << 0); }
165 void setValue(
long val)
167 value = (int)((val >> 0) & 0xFFFF);
171 class InterruptControlRegister :
public Register 175 int interruptThresholdSelect;
176 int interruptThresholdEnable;
177 int interruptAlsReadyEnable;
180 void setIntCountExceed(
IntCountExceeds enumVal) { intCountExceed = (int)enumVal; }
182 long getValue() {
return ((interruptThresholdSelect & 0x1) << 0) | ((interruptThresholdEnable & 0x1) << 1) | ((interruptAlsReadyEnable & 0x1) << 2) | ((intCountExceed & 0x7) << 5); }
183 void setValue(
long val)
185 interruptThresholdSelect = (int)((val >> 0) & 0x1);
186 interruptThresholdEnable = (int)((val >> 1) & 0x1);
187 interruptAlsReadyEnable = (int)((val >> 2) & 0x1);
188 intCountExceed = (int)((val >> 5) & 0x7);
192 class LowThresholdRegister :
public Register 198 long getValue() {
return ((value & 0xFFFF) << 0); }
199 void setValue(
long val)
201 value = (int)((val >> 0) & 0xFFFF);
205 class HighThresholdRegister :
public Register 211 long getValue() {
return ((value & 0xFFFF) << 0); }
212 void setValue(
long val)
214 value = (int)((val >> 0) & 0xFFFF);
218 class InterruptStatusRegister :
public Register 222 int intThresholdHighExceeded;
223 int intThresholdLowExceeded;
227 long getValue() {
return ((intThresholdHighExceeded & 0x1) << 0) | ((intThresholdLowExceeded & 0x1) << 1) | ((intAlsReady & 0x1) << 2) | ((intProxReady & 0x1) << 3); }
228 void setValue(
long val)
230 intThresholdHighExceeded = (int)((val >> 0) & 0x1);
231 intThresholdLowExceeded = (int)((val >> 1) & 0x1);
232 intAlsReady = (int)((val >> 2) & 0x1);
233 intProxReady = (int)((val >> 3) & 0x1);
237 class ProxModulatorTimingAdustmentRegister :
public Register 241 int modulationDeadTime;
242 int proximityFrequency;
243 int modulationDelayTime;
245 long getValue() {
return ((modulationDeadTime & 0x7) << 0) | ((proximityFrequency & 0x3) << 3) | ((modulationDelayTime & 0x7) << 5); }
246 void setValue(
long val)
248 modulationDeadTime = (int)((val >> 0) & 0x7);
249 proximityFrequency = (int)((val >> 3) & 0x3);
250 modulationDelayTime = (int)((val >> 5) & 0x7);
254 CommandRegister command;
255 ProductIdRegister productId;
256 ProximityRateRegister proximityRate;
257 LedCurrentRegister ledCurrent;
258 AmbientLightParametersRegister ambientLightParameters;
259 AmbientLightResultRegister ambientLightResult;
260 ProximityResultRegister proximityResult;
261 InterruptControlRegister interruptControl;
262 LowThresholdRegister lowThreshold;
263 HighThresholdRegister highThreshold;
264 InterruptStatusRegister interruptStatus;
265 ProxModulatorTimingAdustmentRegister proxModulatorTimingAdustment;
267 Vcnl4010Registers(SMBusDevice& device) :
RegisterManager(device, true), command(*this), productId(*this), proximityRate(*this), ledCurrent(*this), ambientLightParameters(*this), ambientLightResult(*this), proximityResult(*this), interruptControl(*this), lowThreshold(*this), highThreshold(*this), interruptStatus(*this), proxModulatorTimingAdustment(*this)
269 registers.push_back(&command);
270 registers.push_back(&productId);
271 registers.push_back(&proximityRate);
272 registers.push_back(&ledCurrent);
273 registers.push_back(&ambientLightParameters);
274 registers.push_back(&ambientLightResult);
275 registers.push_back(&proximityResult);
276 registers.push_back(&interruptControl);
277 registers.push_back(&lowThreshold);
278 registers.push_back(&highThreshold);
279 registers.push_back(&interruptStatus);
280 registers.push_back(&proxModulatorTimingAdustment);
IntCountExceeds
Definition: Vcnl4010Registers.h:36
AlsRates
Definition: Vcnl4010Registers.h:24
Definition: Register.h:11
Rates
Definition: Vcnl4010Registers.h:12
Definition: RegisterManager.h:10