10 namespace Treehopper {
namespace Libraries {
namespace Sensors {
namespace Inertial {
56 class Ctrl1Register :
public Register 66 void setOutputDataRate(
OutputDataRates enumVal) { outputDataRate = (int)enumVal; }
68 long getValue() {
return ((xEnable & 0x1) << 0) | ((yEnable & 0x1) << 1) | ((zEnable & 0x1) << 2) | ((lowPowerEnable & 0x1) << 3) | ((outputDataRate & 0xF) << 4); }
69 void setValue(
long val)
71 xEnable = (int)((val >> 0) & 0x1);
72 yEnable = (int)((val >> 1) & 0x1);
73 zEnable = (int)((val >> 2) & 0x1);
74 lowPowerEnable = (int)((val >> 3) & 0x1);
75 outputDataRate = (int)((val >> 4) & 0xF);
79 class Ctrl2Register :
public Register 85 int filterDataSelection;
87 int accelhighPassMode;
89 void setAccelhighPassMode(
AccelhighPassModes enumVal) { accelhighPassMode = (int)enumVal; }
91 long getValue() {
return ((hpis & 0x3) << 0) | ((hpClick & 0x1) << 2) | ((filterDataSelection & 0x1) << 3) | ((hpcf & 0x3) << 4) | ((accelhighPassMode & 0x3) << 6); }
92 void setValue(
long val)
94 hpis = (int)((val >> 0) & 0x3);
95 hpClick = (int)((val >> 2) & 0x1);
96 filterDataSelection = (int)((val >> 3) & 0x1);
97 hpcf = (int)((val >> 4) & 0x3);
98 accelhighPassMode = (int)((val >> 6) & 0x3);
102 class Ctrl3Register :
public Register 106 int fifoOverrunOnInt1;
107 int fifoWatermarkOnInt1;
114 long getValue() {
return ((fifoOverrunOnInt1 & 0x1) << 1) | ((fifoWatermarkOnInt1 & 0x1) << 2) | ((drdy2OnInt1 & 0x1) << 3) | ((drdy1OnInt1 & 0x1) << 4) | ((aoi2OnInt1 & 0x1) << 5) | ((aoi1OnInt1 & 0x1) << 6) | ((clickOnInt2 & 0x1) << 7); }
115 void setValue(
long val)
117 fifoOverrunOnInt1 = (int)((val >> 1) & 0x1);
118 fifoWatermarkOnInt1 = (int)((val >> 2) & 0x1);
119 drdy2OnInt1 = (int)((val >> 3) & 0x1);
120 drdy1OnInt1 = (int)((val >> 4) & 0x1);
121 aoi2OnInt1 = (int)((val >> 5) & 0x1);
122 aoi1OnInt1 = (int)((val >> 6) & 0x1);
123 clickOnInt2 = (int)((val >> 7) & 0x1);
127 class Ctrl4Register :
public Register 131 int spiModeSelection;
133 int fullScaleSelection;
137 void setFullScaleSelection(
FullScaleSelections enumVal) { fullScaleSelection = (int)enumVal; }
139 long getValue() {
return ((spiModeSelection & 0x1) << 0) | ((
highResolution & 0x1) << 3) | ((fullScaleSelection & 0x7) << 3) | ((ble & 0x1) << 6) | ((bdu & 0x1) << 7); }
140 void setValue(
long val)
142 spiModeSelection = (int)((val >> 0) & 0x1);
144 fullScaleSelection = (int)((val >> 3) & 0x7);
145 ble = (int)((val >> 6) & 0x1);
146 bdu = (int)((val >> 7) & 0x1);
150 class Ctrl5Register :
public Register 161 long getValue() {
return ((d4dInt2 & 0x1) << 0) | ((lirInt2 & 0x1) << 1) | ((d4dInt1 & 0x1) << 2) | ((lirInt1 & 0x1) << 3) | ((fifoEnable & 0x1) << 6) | ((boot & 0x1) << 7); }
162 void setValue(
long val)
164 d4dInt2 = (int)((val >> 0) & 0x1);
165 lirInt2 = (int)((val >> 1) & 0x1);
166 d4dInt1 = (int)((val >> 2) & 0x1);
167 lirInt1 = (int)((val >> 3) & 0x1);
168 fifoEnable = (int)((val >> 6) & 0x1);
169 boot = (int)((val >> 7) & 0x1);
173 class Ctrl6Register :
public Register 177 int interruptActiveHigh;
184 long getValue() {
return ((interruptActiveHigh & 0x1) << 1) | ((p2Act & 0x1) << 3) | ((bootI1 & 0x1) << 4) | ((i2Int2 & 0x1) << 5) | ((i2Int1 & 0x1) << 6) | ((i2ClickEnable & 0x1) << 7); }
185 void setValue(
long val)
187 interruptActiveHigh = (int)((val >> 1) & 0x1);
188 p2Act = (int)((val >> 3) & 0x1);
189 bootI1 = (int)((val >> 4) & 0x1);
190 i2Int2 = (int)((val >> 5) & 0x1);
191 i2Int1 = (int)((val >> 6) & 0x1);
192 i2ClickEnable = (int)((val >> 7) & 0x1);
196 class ReferenceRegister :
public Register 202 long getValue() {
return ((value & 0xFF) << 0); }
203 void setValue(
long val)
205 value = (int)((val >> 0) & 0xFF);
209 class StatusRegister :
public Register 216 int zyxDataAvailable;
222 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); }
223 void setValue(
long val)
225 xDataAvailable = (int)((val >> 0) & 0x1);
226 yDataAvailable = (int)((val >> 1) & 0x1);
227 zDataAvailable = (int)((val >> 2) & 0x1);
228 zyxDataAvailable = (int)((val >> 3) & 0x1);
229 xDataOverrun = (int)((val >> 4) & 0x1);
230 yDataOverrun = (int)((val >> 5) & 0x1);
231 zDataOverrun = (int)((val >> 6) & 0x1);
232 zyxDataOverrun = (int)((val >> 7) & 0x1);
236 class FifoControlRegister :
public Register 243 void setFifoMode(
FifoModes enumVal) { fifoMode = (int)enumVal; }
245 long getValue() {
return ((fifoThreshold & 0x1F) << 0) | ((fifoMode & 0x7) << 5); }
246 void setValue(
long val)
248 fifoThreshold = (int)((val >> 0) & 0x1F);
249 fifoMode = (int)((val >> 5) & 0x7);
253 class FifoSourceRegister :
public Register 262 long getValue() {
return ((fifoStoredLevel & 0x1F) << 0) | ((empty & 0x1) << 5) | ((overrun & 0x1) << 6) | ((fifoThreshold & 0x1) << 7); }
263 void setValue(
long val)
265 fifoStoredLevel = (int)((val >> 0) & 0x1F);
266 empty = (int)((val >> 5) & 0x1);
267 overrun = (int)((val >> 6) & 0x1);
268 fifoThreshold = (int)((val >> 7) & 0x1);
272 class InertialIntGen1ConfigRegister :
public Register 276 int xLowInterruptEnable;
277 int xHighInterruptEnable;
278 int yLowInterruptEnable;
279 int yHighInterruptEnable;
280 int zLowInterruptEvent;
281 int zHighInterruptEnable;
283 int andOrInterruptEvents;
285 long getValue() {
return ((xLowInterruptEnable & 0x1) << 0) | ((xHighInterruptEnable & 0x1) << 1) | ((yLowInterruptEnable & 0x1) << 2) | ((yHighInterruptEnable & 0x1) << 3) | ((zLowInterruptEvent & 0x1) << 4) | ((zHighInterruptEnable & 0x1) << 5) | ((detect6D & 0x1) << 6) | ((andOrInterruptEvents & 0x1) << 7); }
286 void setValue(
long val)
288 xLowInterruptEnable = (int)((val >> 0) & 0x1);
289 xHighInterruptEnable = (int)((val >> 1) & 0x1);
290 yLowInterruptEnable = (int)((val >> 2) & 0x1);
291 yHighInterruptEnable = (int)((val >> 3) & 0x1);
292 zLowInterruptEvent = (int)((val >> 4) & 0x1);
293 zHighInterruptEnable = (int)((val >> 5) & 0x1);
294 detect6D = (int)((val >> 6) & 0x1);
295 andOrInterruptEvents = (int)((val >> 7) & 0x1);
299 class InertialIntGen1StatusRegister :
public Register 311 long getValue() {
return ((xLow & 0x1) << 0) | ((xHigh & 0x1) << 1) | ((yLow & 0x1) << 2) | ((yHigh & 0x1) << 3) | ((zLow & 0x1) << 4) | ((zHigh & 0x1) << 5) | ((intStatus & 0x1) << 6); }
312 void setValue(
long val)
314 xLow = (int)((val >> 0) & 0x1);
315 xHigh = (int)((val >> 1) & 0x1);
316 yLow = (int)((val >> 2) & 0x1);
317 yHigh = (int)((val >> 3) & 0x1);
318 zLow = (int)((val >> 4) & 0x1);
319 zHigh = (int)((val >> 5) & 0x1);
320 intStatus = (int)((val >> 6) & 0x1);
324 class InertialIntGen1ThresholdRegister :
public Register 330 long getValue() {
return ((value & 0x7F) << 0); }
331 void setValue(
long val)
333 value = (int)((val >> 0) & 0x7F);
337 class InertialIntGen1DurationRegister :
public Register 343 long getValue() {
return ((value & 0x7F) << 0); }
344 void setValue(
long val)
346 value = (int)((val >> 0) & 0x7F);
350 class InertialIntGen2ConfigRegister :
public Register 354 int xLowInterruptEnable;
355 int xHighInterruptEnable;
356 int yLowInterruptEnable;
357 int yHighInterruptEnable;
358 int zLowInterruptEvent;
359 int zHighInterruptEnable;
361 int andOrInterruptEvents;
363 long getValue() {
return ((xLowInterruptEnable & 0x1) << 0) | ((xHighInterruptEnable & 0x1) << 1) | ((yLowInterruptEnable & 0x1) << 2) | ((yHighInterruptEnable & 0x1) << 3) | ((zLowInterruptEvent & 0x1) << 4) | ((zHighInterruptEnable & 0x1) << 5) | ((detect6D & 0x1) << 6) | ((andOrInterruptEvents & 0x1) << 7); }
364 void setValue(
long val)
366 xLowInterruptEnable = (int)((val >> 0) & 0x1);
367 xHighInterruptEnable = (int)((val >> 1) & 0x1);
368 yLowInterruptEnable = (int)((val >> 2) & 0x1);
369 yHighInterruptEnable = (int)((val >> 3) & 0x1);
370 zLowInterruptEvent = (int)((val >> 4) & 0x1);
371 zHighInterruptEnable = (int)((val >> 5) & 0x1);
372 detect6D = (int)((val >> 6) & 0x1);
373 andOrInterruptEvents = (int)((val >> 7) & 0x1);
377 class InertialIntGen2StatusRegister :
public Register 389 long getValue() {
return ((xLow & 0x1) << 0) | ((xHigh & 0x1) << 1) | ((yLow & 0x1) << 2) | ((yHigh & 0x1) << 3) | ((zLow & 0x1) << 4) | ((zHigh & 0x1) << 5) | ((intStatus & 0x1) << 6); }
390 void setValue(
long val)
392 xLow = (int)((val >> 0) & 0x1);
393 xHigh = (int)((val >> 1) & 0x1);
394 yLow = (int)((val >> 2) & 0x1);
395 yHigh = (int)((val >> 3) & 0x1);
396 zLow = (int)((val >> 4) & 0x1);
397 zHigh = (int)((val >> 5) & 0x1);
398 intStatus = (int)((val >> 6) & 0x1);
402 class InertialIntGen2ThresholdRegister :
public Register 408 long getValue() {
return ((value & 0x7F) << 0); }
409 void setValue(
long val)
411 value = (int)((val >> 0) & 0x7F);
415 class InertialIntGen2DurationRegister :
public Register 421 long getValue() {
return ((value & 0x7F) << 0); }
422 void setValue(
long val)
424 value = (int)((val >> 0) & 0x7F);
428 class ClickConfigRegister :
public Register 439 long getValue() {
return ((xSingleClick & 0x1) << 0) | ((xDoubleClick & 0x1) << 1) | ((ySingleClick & 0x1) << 2) | ((yDoubleClick & 0x1) << 3) | ((zSingleClick & 0x1) << 4) | ((zDoubleClick & 0x1) << 5); }
440 void setValue(
long val)
442 xSingleClick = (int)((val >> 0) & 0x1);
443 xDoubleClick = (int)((val >> 1) & 0x1);
444 ySingleClick = (int)((val >> 2) & 0x1);
445 yDoubleClick = (int)((val >> 3) & 0x1);
446 zSingleClick = (int)((val >> 4) & 0x1);
447 zDoubleClick = (int)((val >> 5) & 0x1);
451 class ClickSourceRegister :
public Register 463 long getValue() {
return ((x & 0x1) << 0) | ((y & 0x1) << 1) | ((z & 0x1) << 2) | ((sign & 0x1) << 3) | ((singleClickEn & 0x1) << 4) | ((doubleClickEn & 0x1) << 5) | ((interruptActive & 0x1) << 6); }
464 void setValue(
long val)
466 x = (int)((val >> 0) & 0x1);
467 y = (int)((val >> 1) & 0x1);
468 z = (int)((val >> 2) & 0x1);
469 sign = (int)((val >> 3) & 0x1);
470 singleClickEn = (int)((val >> 4) & 0x1);
471 doubleClickEn = (int)((val >> 5) & 0x1);
472 interruptActive = (int)((val >> 6) & 0x1);
476 class ClickThresholdRegister :
public Register 482 long getValue() {
return ((value & 0x7F) << 0); }
483 void setValue(
long val)
485 value = (int)((val >> 0) & 0x7F);
489 class TimeLimitRegister :
public Register 495 long getValue() {
return ((value & 0x7F) << 0); }
496 void setValue(
long val)
498 value = (int)((val >> 0) & 0x7F);
502 class TimeLatencyRegister :
public Register 508 long getValue() {
return ((value & 0xFF) << 0); }
509 void setValue(
long val)
511 value = (int)((val >> 0) & 0xFF);
515 class TimeWindowRegister :
public Register 521 long getValue() {
return ((value & 0xFF) << 0); }
522 void setValue(
long val)
524 value = (int)((val >> 0) & 0xFF);
528 class OutAccelXRegister :
public Register 534 long getValue() {
return ((value & 0xFFFF) << 0); }
535 void setValue(
long val)
537 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
541 class OutAccelYRegister :
public Register 547 long getValue() {
return ((value & 0xFFFF) << 0); }
548 void setValue(
long val)
550 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
554 class OutAccelZRegister :
public Register 560 long getValue() {
return ((value & 0xFFFF) << 0); }
561 void setValue(
long val)
563 value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
573 ReferenceRegister reference;
574 StatusRegister status;
575 FifoControlRegister fifoControl;
576 FifoSourceRegister fifoSource;
577 InertialIntGen1ConfigRegister inertialIntGen1Config;
578 InertialIntGen1StatusRegister inertialIntGen1Status;
579 InertialIntGen1ThresholdRegister inertialIntGen1Threshold;
580 InertialIntGen1DurationRegister inertialIntGen1Duration;
581 InertialIntGen2ConfigRegister inertialIntGen2Config;
582 InertialIntGen2StatusRegister inertialIntGen2Status;
583 InertialIntGen2ThresholdRegister inertialIntGen2Threshold;
584 InertialIntGen2DurationRegister inertialIntGen2Duration;
585 ClickConfigRegister clickConfig;
586 ClickSourceRegister clickSource;
587 ClickThresholdRegister clickThreshold;
588 TimeLimitRegister timeLimit;
589 TimeLatencyRegister timeLatency;
590 TimeWindowRegister timeWindow;
591 OutAccelXRegister outAccelX;
592 OutAccelYRegister outAccelY;
593 OutAccelZRegister outAccelZ;
595 Lsm303dlhcAccelRegisters(SMBusDevice& device) :
RegisterManager(device, true), ctrl1(*this), ctrl2(*this), ctrl3(*this), ctrl4(*this), ctrl5(*this), ctrl6(*this), reference(*this), status(*this), fifoControl(*this), fifoSource(*this), inertialIntGen1Config(*this), inertialIntGen1Status(*this), inertialIntGen1Threshold(*this), inertialIntGen1Duration(*this), inertialIntGen2Config(*this), inertialIntGen2Status(*this), inertialIntGen2Threshold(*this), inertialIntGen2Duration(*this), clickConfig(*this), clickSource(*this), clickThreshold(*this), timeLimit(*this), timeLatency(*this), timeWindow(*this), outAccelX(*this), outAccelY(*this), outAccelZ(*this)
597 registers.push_back(&ctrl1);
598 registers.push_back(&ctrl2);
599 registers.push_back(&ctrl3);
600 registers.push_back(&ctrl4);
601 registers.push_back(&ctrl5);
602 registers.push_back(&ctrl6);
603 registers.push_back(&reference);
604 registers.push_back(&status);
605 registers.push_back(&fifoControl);
606 registers.push_back(&fifoSource);
607 registers.push_back(&inertialIntGen1Config);
608 registers.push_back(&inertialIntGen1Status);
609 registers.push_back(&inertialIntGen1Threshold);
610 registers.push_back(&inertialIntGen1Duration);
611 registers.push_back(&inertialIntGen2Config);
612 registers.push_back(&inertialIntGen2Status);
613 registers.push_back(&inertialIntGen2Threshold);
614 registers.push_back(&inertialIntGen2Duration);
615 registers.push_back(&clickConfig);
616 registers.push_back(&clickSource);
617 registers.push_back(&clickThreshold);
618 registers.push_back(&timeLimit);
619 registers.push_back(&timeLatency);
620 registers.push_back(&timeWindow);
621 registers.push_back(&outAccelX);
622 registers.push_back(&outAccelY);
623 registers.push_back(&outAccelZ);
FullScaleSelections
Definition: Lis3dhRegisters.h:26
Definition: Register.h:11
AccelhighPassModes
Definition: Lsm303dlhcAccelRegisters.h:26
Definition: RegisterManager.h:10
FifoModes
Definition: L3gd20Registers.h:20
OutputDataRates
Definition: Lis3dhRegisters.h:42