10 namespace Treehopper {
namespace Libraries {
namespace Sensors {
namespace Inertial {
33 class WhoAmIRegister :
public Register 39 long getValue() {
return ((value & 0xFF) << 0); }
40 void setValue(
long val)
42 value = (int)((val >> 0) & 0xFF);
46 class CtrlReg1Register :
public Register 57 void setDataRate(
DataRates enumVal) { dataRate = (int)enumVal; }
59 long getValue() {
return ((yEn & 0x1) << 0) | ((xEn & 0x1) << 1) | ((zEn & 0x1) << 2) | ((pd & 0x1) << 3) | ((bandwidth & 0x3) << 4) | ((dataRate & 0x3) << 6); }
60 void setValue(
long val)
62 yEn = (int)((val >> 0) & 0x1);
63 xEn = (int)((val >> 1) & 0x1);
64 zEn = (int)((val >> 2) & 0x1);
65 pd = (int)((val >> 3) & 0x1);
66 bandwidth = (int)((val >> 4) & 0x3);
67 dataRate = (int)((val >> 6) & 0x3);
71 class CtrlReg2Register :
public Register 78 long getValue() {
return ((hpFilterCutoff & 0xF) << 0) | ((hpFilterMode & 0x3) << 4); }
79 void setValue(
long val)
81 hpFilterCutoff = (int)((val >> 0) & 0xF);
82 hpFilterMode = (int)((val >> 4) & 0x3);
86 class CtrlReg3Register :
public Register 99 long getValue() {
return ((i2Empty & 0x1) << 0) | ((i2ORun & 0x1) << 1) | ((i2Wtm & 0x1) << 2) | ((i2Drdy & 0x1) << 3) | ((ppOd & 0x1) << 4) | ((hLactive & 0x1) << 5) | ((i1boot & 0x1) << 6) | ((i1Int1 & 0x1) << 7); }
100 void setValue(
long val)
102 i2Empty = (int)((val >> 0) & 0x1);
103 i2ORun = (int)((val >> 1) & 0x1);
104 i2Wtm = (int)((val >> 2) & 0x1);
105 i2Drdy = (int)((val >> 3) & 0x1);
106 ppOd = (int)((val >> 4) & 0x1);
107 hLactive = (int)((val >> 5) & 0x1);
108 i1boot = (int)((val >> 6) & 0x1);
109 i1Int1 = (int)((val >> 7) & 0x1);
113 class CtrlReg4Register :
public Register 122 long getValue() {
return ((sim & 0x1) << 0) | ((fullScale & 0x3) << 4) | ((bigLittleEndian & 0x1) << 6) | ((blockDataUpdate & 0x1) << 7); }
123 void setValue(
long val)
125 sim = (int)((val >> 0) & 0x1);
126 fullScale = (int)((val >> 4) & 0x3);
127 bigLittleEndian = (int)((val >> 6) & 0x1);
128 blockDataUpdate = (int)((val >> 7) & 0x1);
132 class CtrlReg5Register :
public Register 142 long getValue() {
return ((outSel & 0x3) << 0) | ((int1Sel & 0x3) << 2) | ((hPen & 0x1) << 4) | ((fifoEn & 0x1) << 6) | ((boot & 0x1) << 7); }
143 void setValue(
long val)
145 outSel = (int)((val >> 0) & 0x3);
146 int1Sel = (int)((val >> 2) & 0x3);
147 hPen = (int)((val >> 4) & 0x1);
148 fifoEn = (int)((val >> 6) & 0x1);
149 boot = (int)((val >> 7) & 0x1);
153 class ReferenceDataCaptureRegister :
public Register 159 long getValue() {
return ((value & 0xFF) << 0); }
160 void setValue(
long val)
162 value = (int)((val >> 0) & 0xFF);
166 class OutTempRegister :
public Register 172 long getValue() {
return ((value & 0xFF) << 0); }
173 void setValue(
long val)
175 value = (int)((val >> 0) & 0xFF);
179 class StatusRegister :
public Register 186 int zyxDataAvailable;
192 long getValue() {
return ((xDataAvailable & 0x1) << 0) | ((yDataAvailable & 0x1) << 1) | ((zDataAvailable & 0x1) << 2) | ((zyxDataAvailable & 0x1) << 3) | ((xDataOverrun & 0x1) << 4) | ((yDataOverrun & 0x1) << 5) | ((zDataOverrun & 0x1) << 6) | ((zyxDataOverrun & 0x1) << 7); }
193 void setValue(
long val)
195 xDataAvailable = (int)((val >> 0) & 0x1);
196 yDataAvailable = (int)((val >> 1) & 0x1);
197 zDataAvailable = (int)((val >> 2) & 0x1);
198 zyxDataAvailable = (int)((val >> 3) & 0x1);
199 xDataOverrun = (int)((val >> 4) & 0x1);
200 yDataOverrun = (int)((val >> 5) & 0x1);
201 zDataOverrun = (int)((val >> 6) & 0x1);
202 zyxDataOverrun = (int)((val >> 7) & 0x1);
206 class FifoCtrlRegister :
public Register 210 int watermarkLevelSetting;
213 void setFifoMode(
FifoModes enumVal) { fifoMode = (int)enumVal; }
215 long getValue() {
return ((watermarkLevelSetting & 0x1F) << 0) | ((fifoMode & 0x7) << 5); }
216 void setValue(
long val)
218 watermarkLevelSetting = (int)((val >> 0) & 0x1F);
219 fifoMode = (int)((val >> 5) & 0x7);
223 class FifoSrcRegister :
public Register 227 int fifoStoredDataLevel;
232 long getValue() {
return ((fifoStoredDataLevel & 0x1F) << 0) | ((empty & 0x1) << 5) | ((overrun & 0x1) << 6) | ((watermarkStatus & 0x1) << 7); }
233 void setValue(
long val)
235 fifoStoredDataLevel = (int)((val >> 0) & 0x1F);
236 empty = (int)((val >> 5) & 0x1);
237 overrun = (int)((val >> 6) & 0x1);
238 watermarkStatus = (int)((val >> 7) & 0x1);
242 class IntConfigRegister :
public Register 246 int xLowInterruptEnable;
247 int xHighInterruptEnable;
248 int yLowInterruptEnable;
249 int yHighInterruptEnable;
250 int zLowInterruptEvent;
251 int zHighInterruptEnable;
252 int latchInterruptRequest;
255 long getValue() {
return ((xLowInterruptEnable & 0x1) << 0) | ((xHighInterruptEnable & 0x1) << 1) | ((yLowInterruptEnable & 0x1) << 2) | ((yHighInterruptEnable & 0x1) << 3) | ((zLowInterruptEvent & 0x1) << 4) | ((zHighInterruptEnable & 0x1) << 5) | ((latchInterruptRequest & 0x1) << 6) | ((andOr & 0x1) << 7); }
256 void setValue(
long val)
258 xLowInterruptEnable = (int)((val >> 0) & 0x1);
259 xHighInterruptEnable = (int)((val >> 1) & 0x1);
260 yLowInterruptEnable = (int)((val >> 2) & 0x1);
261 yHighInterruptEnable = (int)((val >> 3) & 0x1);
262 zLowInterruptEvent = (int)((val >> 4) & 0x1);
263 zHighInterruptEnable = (int)((val >> 5) & 0x1);
264 latchInterruptRequest = (int)((val >> 6) & 0x1);
265 andOr = (int)((val >> 7) & 0x1);
269 class Int1SrcRegister :
public Register 281 long getValue() {
return ((xLow & 0x1) << 0) | ((xHigh & 0x1) << 1) | ((yLow & 0x1) << 2) | ((yHigh & 0x1) << 3) | ((zLow & 0x1) << 4) | ((zHigh & 0x1) << 5) | ((interruptActive & 0x1) << 6); }
282 void setValue(
long val)
284 xLow = (int)((val >> 0) & 0x1);
285 xHigh = (int)((val >> 1) & 0x1);
286 yLow = (int)((val >> 2) & 0x1);
287 yHigh = (int)((val >> 3) & 0x1);
288 zLow = (int)((val >> 4) & 0x1);
289 zHigh = (int)((val >> 5) & 0x1);
290 interruptActive = (int)((val >> 6) & 0x1);
294 class Int1ThresholdXRegister :
public Register 300 long getValue() {
return ((value & 0xFFFF) << 0); }
301 void setValue(
long val)
303 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
307 class Int1ThresholdYRegister :
public Register 313 long getValue() {
return ((value & 0xFFFF) << 0); }
314 void setValue(
long val)
316 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
320 class Int1ThresholdZRegister :
public Register 326 long getValue() {
return ((value & 0xFFFF) << 0); }
327 void setValue(
long val)
329 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
333 class Int1DurationRegister :
public Register 340 long getValue() {
return ((duration & 0x7F) << 0) | ((wait & 0x1) << 7); }
341 void setValue(
long val)
343 duration = (int)((val >> 0) & 0x7F);
344 wait = (int)((val >> 7) & 0x1);
348 class OutXRegister :
public Register 354 long getValue() {
return ((value & 0xFFFF) << 0); }
355 void setValue(
long val)
357 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
361 class OutYRegister :
public Register 367 long getValue() {
return ((value & 0xFFFF) << 0); }
368 void setValue(
long val)
370 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
374 class OutZRegister :
public Register 380 long getValue() {
return ((value & 0xFFFF) << 0); }
381 void setValue(
long val)
383 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
387 WhoAmIRegister whoAmI;
388 CtrlReg1Register ctrlReg1;
389 CtrlReg2Register ctrlReg2;
390 CtrlReg3Register ctrlReg3;
391 CtrlReg4Register ctrlReg4;
392 CtrlReg5Register ctrlReg5;
393 ReferenceDataCaptureRegister referenceDataCapture;
394 OutTempRegister outTemp;
395 StatusRegister status;
396 FifoCtrlRegister fifoCtrl;
397 FifoSrcRegister fifoSrc;
398 IntConfigRegister intConfig;
399 Int1SrcRegister int1Src;
400 Int1ThresholdXRegister int1ThresholdX;
401 Int1ThresholdYRegister int1ThresholdY;
402 Int1ThresholdZRegister int1ThresholdZ;
403 Int1DurationRegister int1Duration;
408 L3gd20Registers(SMBusDevice& device) :
RegisterManager(device, true), whoAmI(*this), ctrlReg1(*this), ctrlReg2(*this), ctrlReg3(*this), ctrlReg4(*this), ctrlReg5(*this), referenceDataCapture(*this), outTemp(*this), status(*this), fifoCtrl(*this), fifoSrc(*this), intConfig(*this), int1Src(*this), int1ThresholdX(*this), int1ThresholdY(*this), int1ThresholdZ(*this), int1Duration(*this), outX(*this), outY(*this), outZ(*this)
410 registers.push_back(&whoAmI);
411 registers.push_back(&ctrlReg1);
412 registers.push_back(&ctrlReg2);
413 registers.push_back(&ctrlReg3);
414 registers.push_back(&ctrlReg4);
415 registers.push_back(&ctrlReg5);
416 registers.push_back(&referenceDataCapture);
417 registers.push_back(&outTemp);
418 registers.push_back(&status);
419 registers.push_back(&fifoCtrl);
420 registers.push_back(&fifoSrc);
421 registers.push_back(&intConfig);
422 registers.push_back(&int1Src);
423 registers.push_back(&int1ThresholdX);
424 registers.push_back(&int1ThresholdY);
425 registers.push_back(&int1ThresholdZ);
426 registers.push_back(&int1Duration);
427 registers.push_back(&outX);
428 registers.push_back(&outY);
429 registers.push_back(&outZ);
Definition: Register.h:11
Definition: RegisterManager.h:10
FifoModes
Definition: L3gd20Registers.h:20
DataRates
Definition: L3gd20Registers.h:12