Treehopper C++ API
Lsm303dRegisters.h
Go to the documentation of this file.
1 #pragma once
3 #include "SMBusDevice.h"
6 #include "Libraries/Register.h"
7 
8 using namespace Treehopper::Libraries;
9 
10 namespace Treehopper { namespace Libraries { namespace Sensors { namespace Inertial {
11 
12  enum class OutputDataRates
13  {
14  powerDown = 0,
15  Hz_3_125 = 1,
16  Hz_6_25 = 2,
17  Hz_12_5 = 3,
18  Hz_25 = 4,
19  Hz_50 = 5,
20  Hz_100 = 6,
21  Hz_200 = 7,
22  Hz_400 = 8,
23  Hz_800 = 9,
24  Hz_1600 = 10
25  };
26 
28  {
29  Fs_2g = 0,
30  Fs_4g = 1,
31  Fs_6g = 2,
32  Fs_8g = 3,
33  Fs_16g = 4
34  };
35 
37  {
38  Hz_773 = 0,
39  Hz_194 = 1,
40  Hz_362 = 2,
41  Hz_50 = 3
42  };
43 
44  enum class MagDataRates
45  {
46  Hz_3_125 = 0,
47  Hz_6_25 = 1,
48  Hz_12_5 = 2,
49  Hz_25 = 3,
50  Hz_50 = 4,
51  Hz_100 = 5
52  };
53 
54  enum class MagResolutions
55  {
56  lowResolution = 0,
57  highResolution = 3
58  };
59 
61  {
62  gauss_2 = 0,
63  gauss_4 = 1,
64  gauss_8 = 2,
65  gauss_12 = 3
66  };
67 
68  enum class MagSensorModes
69  {
71  SingleConversion = 1,
72  PowerDown = 2
73  };
74 
75  enum class AccelhighPassModes
76  {
77  Reset = 0,
78  ReferenceSignal = 1,
79  Normal = 2,
81  };
82 
83  enum class FifoModes
84  {
85  Bypass = 0,
86  Fifo = 1,
87  Stream = 2,
88  StreamToFifo = 3,
89  BypassToStream = 4
90  };
91 
92 
93  class Lsm303dRegisters : public RegisterManager
94  {
95  public:
96  class TempOutRegister : public Register
97  {
98  public:
99  TempOutRegister(RegisterManager& regManager) : Register(regManager,0x05, 2, false) { }
100  int value;
101 
102  long getValue() { return ((value & 0xFFF) << 0); }
103  void setValue(long val)
104  {
105  value = (int)(((val >> 0) & 0xFFF) << (32 - 12)) >> (32 - 12);
106  }
107  };
108 
109  class StatusRegister : public Register
110  {
111  public:
112  StatusRegister(RegisterManager& regManager) : Register(regManager,0x07, 1, false) { }
113  int xDataAvailable;
114  int yDataAvailable;
115  int zDataAvailable;
116  int zyxDataAvailable;
117  int xDataOverrun;
118  int yDataOverrun;
119  int zDataOverrun;
120  int zyxDataOverrun;
121 
122  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); }
123  void setValue(long val)
124  {
125  xDataAvailable = (int)((val >> 0) & 0x1);
126  yDataAvailable = (int)((val >> 1) & 0x1);
127  zDataAvailable = (int)((val >> 2) & 0x1);
128  zyxDataAvailable = (int)((val >> 3) & 0x1);
129  xDataOverrun = (int)((val >> 4) & 0x1);
130  yDataOverrun = (int)((val >> 5) & 0x1);
131  zDataOverrun = (int)((val >> 6) & 0x1);
132  zyxDataOverrun = (int)((val >> 7) & 0x1);
133  }
134  };
135 
136  class OutXRegister : public Register
137  {
138  public:
139  OutXRegister(RegisterManager& regManager) : Register(regManager,0x08, 2, false) { }
140  int value;
141 
142  long getValue() { return ((value & 0xFFFF) << 0); }
143  void setValue(long val)
144  {
145  value = (int)((val >> 0) & 0xFFFF);
146  }
147  };
148 
149  class OutYRegister : public Register
150  {
151  public:
152  OutYRegister(RegisterManager& regManager) : Register(regManager,0x0A, 2, false) { }
153  int value;
154 
155  long getValue() { return ((value & 0xFFFF) << 0); }
156  void setValue(long val)
157  {
158  value = (int)((val >> 0) & 0xFFFF);
159  }
160  };
161 
162  class OutZRegister : public Register
163  {
164  public:
165  OutZRegister(RegisterManager& regManager) : Register(regManager,0x0C, 2, false) { }
166  int value;
167 
168  long getValue() { return ((value & 0xFFFF) << 0); }
169  void setValue(long val)
170  {
171  value = (int)((val >> 0) & 0xFFFF);
172  }
173  };
174 
175  class WhoAmIRegister : public Register
176  {
177  public:
178  WhoAmIRegister(RegisterManager& regManager) : Register(regManager,0x0f, 1, false) { }
179  int value;
180 
181  long getValue() { return ((value & 0xFF) << 0); }
182  void setValue(long val)
183  {
184  value = (int)((val >> 0) & 0xFF);
185  }
186  };
187 
188  class IntCtrlRegister : public Register
189  {
190  public:
191  IntCtrlRegister(RegisterManager& regManager) : Register(regManager,0x12, 1, false) { }
192  int magInterruptEnable;
193  int enable4D;
194  int latchInterruptRequest;
195  int interruptPolarity;
196  int interruptPinPushPull;
197  int zInterruptEnable;
198  int yInterruptEnable;
199  int xInterruptEnable;
200 
201  long getValue() { return ((magInterruptEnable & 0x1) << 0) | ((enable4D & 0x1) << 1) | ((latchInterruptRequest & 0x1) << 2) | ((interruptPolarity & 0x1) << 3) | ((interruptPinPushPull & 0x1) << 4) | ((zInterruptEnable & 0x1) << 5) | ((yInterruptEnable & 0x1) << 6) | ((xInterruptEnable & 0x1) << 7); }
202  void setValue(long val)
203  {
204  magInterruptEnable = (int)((val >> 0) & 0x1);
205  enable4D = (int)((val >> 1) & 0x1);
206  latchInterruptRequest = (int)((val >> 2) & 0x1);
207  interruptPolarity = (int)((val >> 3) & 0x1);
208  interruptPinPushPull = (int)((val >> 4) & 0x1);
209  zInterruptEnable = (int)((val >> 5) & 0x1);
210  yInterruptEnable = (int)((val >> 6) & 0x1);
211  xInterruptEnable = (int)((val >> 7) & 0x1);
212  }
213  };
214 
215  class IntSourceRegister : public Register
216  {
217  public:
218  IntSourceRegister(RegisterManager& regManager) : Register(regManager,0x13, 1, false) { }
219  int mint;
220  int measurementRangeOverflow;
221  int negativeThresholdZ;
222  int negativeThresholdY;
223  int negativeThresholdX;
224  int positiveThresholdZ;
225  int positiveThresholdY;
226  int positiveThresholdX;
227 
228  long getValue() { return ((mint & 0x1) << 0) | ((measurementRangeOverflow & 0x1) << 1) | ((negativeThresholdZ & 0x1) << 2) | ((negativeThresholdY & 0x1) << 3) | ((negativeThresholdX & 0x1) << 4) | ((positiveThresholdZ & 0x1) << 5) | ((positiveThresholdY & 0x1) << 6) | ((positiveThresholdX & 0x1) << 7); }
229  void setValue(long val)
230  {
231  mint = (int)((val >> 0) & 0x1);
232  measurementRangeOverflow = (int)((val >> 1) & 0x1);
233  negativeThresholdZ = (int)((val >> 2) & 0x1);
234  negativeThresholdY = (int)((val >> 3) & 0x1);
235  negativeThresholdX = (int)((val >> 4) & 0x1);
236  positiveThresholdZ = (int)((val >> 5) & 0x1);
237  positiveThresholdY = (int)((val >> 6) & 0x1);
238  positiveThresholdX = (int)((val >> 7) & 0x1);
239  }
240  };
241 
242  class IntThresholdRegister : public Register
243  {
244  public:
245  IntThresholdRegister(RegisterManager& regManager) : Register(regManager,0x14, 2, false) { }
246  int value;
247 
248  long getValue() { return ((value & 0xFFFF) << 0); }
249  void setValue(long val)
250  {
251  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
252  }
253  };
254 
255  class OffsetXRegister : public Register
256  {
257  public:
258  OffsetXRegister(RegisterManager& regManager) : Register(regManager,0x16, 2, false) { }
259  int value;
260 
261  long getValue() { return ((value & 0xFFFF) << 0); }
262  void setValue(long val)
263  {
264  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
265  }
266  };
267 
268  class OffsetYRegister : public Register
269  {
270  public:
271  OffsetYRegister(RegisterManager& regManager) : Register(regManager,0x18, 2, false) { }
272  int value;
273 
274  long getValue() { return ((value & 0xFFFF) << 0); }
275  void setValue(long val)
276  {
277  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
278  }
279  };
280 
281  class OffsetZRegister : public Register
282  {
283  public:
284  OffsetZRegister(RegisterManager& regManager) : Register(regManager,0x1A, 2, false) { }
285  int value;
286 
287  long getValue() { return ((value & 0xFFFF) << 0); }
288  void setValue(long val)
289  {
290  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
291  }
292  };
293 
294  class ReferenceXRegister : public Register
295  {
296  public:
297  ReferenceXRegister(RegisterManager& regManager) : Register(regManager,0x1c, 1, false) { }
298  int value;
299 
300  long getValue() { return ((value & 0xFF) << 0); }
301  void setValue(long val)
302  {
303  value = (int)((val >> 0) & 0xFF);
304  }
305  };
306 
307  class ReferenceYRegister : public Register
308  {
309  public:
310  ReferenceYRegister(RegisterManager& regManager) : Register(regManager,0x1d, 1, false) { }
311  int value;
312 
313  long getValue() { return ((value & 0xFF) << 0); }
314  void setValue(long val)
315  {
316  value = (int)((val >> 0) & 0xFF);
317  }
318  };
319 
320  class ReferenceZRegister : public Register
321  {
322  public:
323  ReferenceZRegister(RegisterManager& regManager) : Register(regManager,0x1E, 1, false) { }
324  int value;
325 
326  long getValue() { return ((value & 0xFF) << 0); }
327  void setValue(long val)
328  {
329  value = (int)((val >> 0) & 0xFF);
330  }
331  };
332 
333  class Ctrl0Register : public Register
334  {
335  public:
336  Ctrl0Register(RegisterManager& regManager) : Register(regManager,0x1f, 1, false) { }
337  int hpis2;
338  int hpis1;
339  int hpClick;
340  int fifoThresholdEnable;
341  int fifoEnable;
342  int boot;
343 
344  long getValue() { return ((hpis2 & 0x1) << 0) | ((hpis1 & 0x1) << 1) | ((hpClick & 0x1) << 2) | ((fifoThresholdEnable & 0x1) << 5) | ((fifoEnable & 0x1) << 6) | ((boot & 0x1) << 7); }
345  void setValue(long val)
346  {
347  hpis2 = (int)((val >> 0) & 0x1);
348  hpis1 = (int)((val >> 1) & 0x1);
349  hpClick = (int)((val >> 2) & 0x1);
350  fifoThresholdEnable = (int)((val >> 5) & 0x1);
351  fifoEnable = (int)((val >> 6) & 0x1);
352  boot = (int)((val >> 7) & 0x1);
353  }
354  };
355 
356  class Ctrl1Register : public Register
357  {
358  public:
359  Ctrl1Register(RegisterManager& regManager) : Register(regManager,0x20, 1, false) { }
360  int xEnable;
361  int yEnable;
362  int zEnable;
363  int blockDataUpdate;
364  int outputDataRate;
365  OutputDataRates getOutputDataRate() { return (OutputDataRates)outputDataRate; }
366  void setOutputDataRate(OutputDataRates enumVal) { outputDataRate = (int)enumVal; }
367 
368  long getValue() { return ((xEnable & 0x1) << 0) | ((yEnable & 0x1) << 1) | ((zEnable & 0x1) << 2) | ((blockDataUpdate & 0x1) << 3) | ((outputDataRate & 0xF) << 4); }
369  void setValue(long val)
370  {
371  xEnable = (int)((val >> 0) & 0x1);
372  yEnable = (int)((val >> 1) & 0x1);
373  zEnable = (int)((val >> 2) & 0x1);
374  blockDataUpdate = (int)((val >> 3) & 0x1);
375  outputDataRate = (int)((val >> 4) & 0xF);
376  }
377  };
378 
379  class Ctrl2Register : public Register
380  {
381  public:
382  Ctrl2Register(RegisterManager& regManager) : Register(regManager,0x21, 1, false) { }
383  int spiModeSelection;
384  int accelerationSelfTest;
385  int fullScaleSelection;
386  int antiAliasFilterBandwidth;
387  FullScaleSelections getFullScaleSelection() { return (FullScaleSelections)fullScaleSelection; }
388  void setFullScaleSelection(FullScaleSelections enumVal) { fullScaleSelection = (int)enumVal; }
389  AntiAliasFilterBandwidths getAntiAliasFilterBandwidth() { return (AntiAliasFilterBandwidths)antiAliasFilterBandwidth; }
390  void setAntiAliasFilterBandwidth(AntiAliasFilterBandwidths enumVal) { antiAliasFilterBandwidth = (int)enumVal; }
391 
392  long getValue() { return ((spiModeSelection & 0x1) << 0) | ((accelerationSelfTest & 0x1) << 1) | ((fullScaleSelection & 0x7) << 3) | ((antiAliasFilterBandwidth & 0x3) << 6); }
393  void setValue(long val)
394  {
395  spiModeSelection = (int)((val >> 0) & 0x1);
396  accelerationSelfTest = (int)((val >> 1) & 0x1);
397  fullScaleSelection = (int)((val >> 3) & 0x7);
398  antiAliasFilterBandwidth = (int)((val >> 6) & 0x3);
399  }
400  };
401 
402  class Ctrl3Register : public Register
403  {
404  public:
405  Ctrl3Register(RegisterManager& regManager) : Register(regManager,0x22, 1, false) { }
406  int fifoEmptyOnInt1;
407  int magReadyOnInt1;
408  int accelReadyOnInt1;
409  int magGenOnInt1;
410  int inertialGen2OnInt1;
411  int inertialGen1OnInt1;
412  int clickGenOnInt1;
413  int bootOnInt1;
414 
415  long getValue() { return ((fifoEmptyOnInt1 & 0x1) << 0) | ((magReadyOnInt1 & 0x1) << 1) | ((accelReadyOnInt1 & 0x1) << 2) | ((magGenOnInt1 & 0x1) << 3) | ((inertialGen2OnInt1 & 0x1) << 4) | ((inertialGen1OnInt1 & 0x1) << 5) | ((clickGenOnInt1 & 0x1) << 6) | ((bootOnInt1 & 0x1) << 7); }
416  void setValue(long val)
417  {
418  fifoEmptyOnInt1 = (int)((val >> 0) & 0x1);
419  magReadyOnInt1 = (int)((val >> 1) & 0x1);
420  accelReadyOnInt1 = (int)((val >> 2) & 0x1);
421  magGenOnInt1 = (int)((val >> 3) & 0x1);
422  inertialGen2OnInt1 = (int)((val >> 4) & 0x1);
423  inertialGen1OnInt1 = (int)((val >> 5) & 0x1);
424  clickGenOnInt1 = (int)((val >> 6) & 0x1);
425  bootOnInt1 = (int)((val >> 7) & 0x1);
426  }
427  };
428 
429  class Ctrl4Register : public Register
430  {
431  public:
432  Ctrl4Register(RegisterManager& regManager) : Register(regManager,0x23, 1, false) { }
433  int fifoThresholdOnInt2;
434  int fifoOverrunOnInt2;
435  int magDataReadyOnInt2;
436  int accelDataReadyOnInt2;
437  int magIntOnInt2;
438  int inertialGen2OnInt2;
439  int inertialGen1OnInt2;
440  int clickGenOnInt2;
441 
442  long getValue() { return ((fifoThresholdOnInt2 & 0x1) << 0) | ((fifoOverrunOnInt2 & 0x1) << 1) | ((magDataReadyOnInt2 & 0x1) << 2) | ((accelDataReadyOnInt2 & 0x1) << 3) | ((magIntOnInt2 & 0x1) << 4) | ((inertialGen2OnInt2 & 0x1) << 5) | ((inertialGen1OnInt2 & 0x1) << 6) | ((clickGenOnInt2 & 0x1) << 7); }
443  void setValue(long val)
444  {
445  fifoThresholdOnInt2 = (int)((val >> 0) & 0x1);
446  fifoOverrunOnInt2 = (int)((val >> 1) & 0x1);
447  magDataReadyOnInt2 = (int)((val >> 2) & 0x1);
448  accelDataReadyOnInt2 = (int)((val >> 3) & 0x1);
449  magIntOnInt2 = (int)((val >> 4) & 0x1);
450  inertialGen2OnInt2 = (int)((val >> 5) & 0x1);
451  inertialGen1OnInt2 = (int)((val >> 6) & 0x1);
452  clickGenOnInt2 = (int)((val >> 7) & 0x1);
453  }
454  };
455 
456  class Ctrl5Register : public Register
457  {
458  public:
459  Ctrl5Register(RegisterManager& regManager) : Register(regManager,0x24, 1, false) { }
460  int latchIntOnInt1;
461  int latchIntOnInt2;
462  int magDataRate;
463  int magResolution;
464  int tempEnable;
465  MagDataRates getMagDataRate() { return (MagDataRates)magDataRate; }
466  void setMagDataRate(MagDataRates enumVal) { magDataRate = (int)enumVal; }
467  MagResolutions getMagResolution() { return (MagResolutions)magResolution; }
468  void setMagResolution(MagResolutions enumVal) { magResolution = (int)enumVal; }
469 
470  long getValue() { return ((latchIntOnInt1 & 0x1) << 0) | ((latchIntOnInt2 & 0x1) << 1) | ((magDataRate & 0x7) << 2) | ((magResolution & 0x3) << 5) | ((tempEnable & 0x1) << 7); }
471  void setValue(long val)
472  {
473  latchIntOnInt1 = (int)((val >> 0) & 0x1);
474  latchIntOnInt2 = (int)((val >> 1) & 0x1);
475  magDataRate = (int)((val >> 2) & 0x7);
476  magResolution = (int)((val >> 5) & 0x3);
477  tempEnable = (int)((val >> 7) & 0x1);
478  }
479  };
480 
481  class Ctrl6Register : public Register
482  {
483  public:
484  Ctrl6Register(RegisterManager& regManager) : Register(regManager,0x25, 1, false) { }
485  int magFullScaleSelection;
486  MagFullScaleSelections getMagFullScaleSelection() { return (MagFullScaleSelections)magFullScaleSelection; }
487  void setMagFullScaleSelection(MagFullScaleSelections enumVal) { magFullScaleSelection = (int)enumVal; }
488 
489  long getValue() { return ((magFullScaleSelection & 0x3) << 5); }
490  void setValue(long val)
491  {
492  magFullScaleSelection = (int)((val >> 5) & 0x3);
493  }
494  };
495 
496  class Ctrl7Register : public Register
497  {
498  public:
499  Ctrl7Register(RegisterManager& regManager) : Register(regManager,0x26, 1, false) { }
500  int magSensorMode;
501  int magLowPowerMode;
502  int tempOnly;
503  int filteredAccelData;
504  int accelhighPassMode;
505  MagSensorModes getMagSensorMode() { return (MagSensorModes)magSensorMode; }
506  void setMagSensorMode(MagSensorModes enumVal) { magSensorMode = (int)enumVal; }
507  AccelhighPassModes getAccelhighPassMode() { return (AccelhighPassModes)accelhighPassMode; }
508  void setAccelhighPassMode(AccelhighPassModes enumVal) { accelhighPassMode = (int)enumVal; }
509 
510  long getValue() { return ((magSensorMode & 0x3) << 0) | ((magLowPowerMode & 0x1) << 2) | ((tempOnly & 0x1) << 4) | ((filteredAccelData & 0x1) << 5) | ((accelhighPassMode & 0x3) << 6); }
511  void setValue(long val)
512  {
513  magSensorMode = (int)((val >> 0) & 0x3);
514  magLowPowerMode = (int)((val >> 2) & 0x1);
515  tempOnly = (int)((val >> 4) & 0x1);
516  filteredAccelData = (int)((val >> 5) & 0x1);
517  accelhighPassMode = (int)((val >> 6) & 0x3);
518  }
519  };
520 
521  class StatusARegister : public Register
522  {
523  public:
524  StatusARegister(RegisterManager& regManager) : Register(regManager,0x27, 1, false) { }
525  int accelXAvailable;
526  int accelYAvailable;
527  int accelZAvailable;
528  int accelXYZAvailable;
529  int accelXOverrun;
530  int accelYOverrun;
531  int accelZOverrun;
532  int accelXYZOverrun;
533 
534  long getValue() { return ((accelXAvailable & 0x1) << 0) | ((accelYAvailable & 0x1) << 1) | ((accelZAvailable & 0x1) << 2) | ((accelXYZAvailable & 0x1) << 3) | ((accelXOverrun & 0x1) << 4) | ((accelYOverrun & 0x1) << 5) | ((accelZOverrun & 0x1) << 6) | ((accelXYZOverrun & 0x1) << 7); }
535  void setValue(long val)
536  {
537  accelXAvailable = (int)((val >> 0) & 0x1);
538  accelYAvailable = (int)((val >> 1) & 0x1);
539  accelZAvailable = (int)((val >> 2) & 0x1);
540  accelXYZAvailable = (int)((val >> 3) & 0x1);
541  accelXOverrun = (int)((val >> 4) & 0x1);
542  accelYOverrun = (int)((val >> 5) & 0x1);
543  accelZOverrun = (int)((val >> 6) & 0x1);
544  accelXYZOverrun = (int)((val >> 7) & 0x1);
545  }
546  };
547 
548  class OutAccelXRegister : public Register
549  {
550  public:
551  OutAccelXRegister(RegisterManager& regManager) : Register(regManager,0x28, 2, false) { }
552  int value;
553 
554  long getValue() { return ((value & 0xFFFF) << 0); }
555  void setValue(long val)
556  {
557  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
558  }
559  };
560 
561  class OutAccelYRegister : public Register
562  {
563  public:
564  OutAccelYRegister(RegisterManager& regManager) : Register(regManager,0x2A, 2, false) { }
565  int value;
566 
567  long getValue() { return ((value & 0xFFFF) << 0); }
568  void setValue(long val)
569  {
570  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
571  }
572  };
573 
574  class OutAccelZRegister : public Register
575  {
576  public:
577  OutAccelZRegister(RegisterManager& regManager) : Register(regManager,0x2C, 2, false) { }
578  int value;
579 
580  long getValue() { return ((value & 0xFFFF) << 0); }
581  void setValue(long val)
582  {
583  value = (int)(((val >> 0) & 0xFFFF) << (32 - 16)) >> (32 - 16);
584  }
585  };
586 
587  class FifoControlRegister : public Register
588  {
589  public:
590  FifoControlRegister(RegisterManager& regManager) : Register(regManager,0x2E, 1, false) { }
591  int fifoThreshold;
592  int fifoMode;
593  FifoModes getFifoMode() { return (FifoModes)fifoMode; }
594  void setFifoMode(FifoModes enumVal) { fifoMode = (int)enumVal; }
595 
596  long getValue() { return ((fifoThreshold & 0x1F) << 0) | ((fifoMode & 0x7) << 5); }
597  void setValue(long val)
598  {
599  fifoThreshold = (int)((val >> 0) & 0x1F);
600  fifoMode = (int)((val >> 5) & 0x7);
601  }
602  };
603 
604  class FifoSourceRegister : public Register
605  {
606  public:
607  FifoSourceRegister(RegisterManager& regManager) : Register(regManager,0x2f, 1, false) { }
608  int fifoStoredLevel;
609  int empty;
610  int overrun;
611  int fifoThreshold;
612 
613  long getValue() { return ((fifoStoredLevel & 0x1F) << 0) | ((empty & 0x1) << 5) | ((overrun & 0x1) << 6) | ((fifoThreshold & 0x1) << 7); }
614  void setValue(long val)
615  {
616  fifoStoredLevel = (int)((val >> 0) & 0x1F);
617  empty = (int)((val >> 5) & 0x1);
618  overrun = (int)((val >> 6) & 0x1);
619  fifoThreshold = (int)((val >> 7) & 0x1);
620  }
621  };
622 
623  class InertialIntGen1ConfigRegister : public Register
624  {
625  public:
626  InertialIntGen1ConfigRegister(RegisterManager& regManager) : Register(regManager,0x30, 1, false) { }
627  int xLowInterruptEnable;
628  int xHighInterruptEnable;
629  int yLowInterruptEnable;
630  int yHighInterruptEnable;
631  int zLowInterruptEvent;
632  int zHighInterruptEnable;
633  int detect6D;
634  int andOrInterruptEvents;
635 
636  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); }
637  void setValue(long val)
638  {
639  xLowInterruptEnable = (int)((val >> 0) & 0x1);
640  xHighInterruptEnable = (int)((val >> 1) & 0x1);
641  yLowInterruptEnable = (int)((val >> 2) & 0x1);
642  yHighInterruptEnable = (int)((val >> 3) & 0x1);
643  zLowInterruptEvent = (int)((val >> 4) & 0x1);
644  zHighInterruptEnable = (int)((val >> 5) & 0x1);
645  detect6D = (int)((val >> 6) & 0x1);
646  andOrInterruptEvents = (int)((val >> 7) & 0x1);
647  }
648  };
649 
650  class InertialIntGen1StatusRegister : public Register
651  {
652  public:
653  InertialIntGen1StatusRegister(RegisterManager& regManager) : Register(regManager,0x31, 1, false) { }
654  int xLow;
655  int xHigh;
656  int yLow;
657  int yHigh;
658  int zLow;
659  int zHigh;
660  int intStatus;
661 
662  long getValue() { return ((xLow & 0x1) << 0) | ((xHigh & 0x1) << 1) | ((yLow & 0x1) << 2) | ((yHigh & 0x1) << 3) | ((zLow & 0x1) << 4) | ((zHigh & 0x1) << 5) | ((intStatus & 0x1) << 6); }
663  void setValue(long val)
664  {
665  xLow = (int)((val >> 0) & 0x1);
666  xHigh = (int)((val >> 1) & 0x1);
667  yLow = (int)((val >> 2) & 0x1);
668  yHigh = (int)((val >> 3) & 0x1);
669  zLow = (int)((val >> 4) & 0x1);
670  zHigh = (int)((val >> 5) & 0x1);
671  intStatus = (int)((val >> 6) & 0x1);
672  }
673  };
674 
675  class InertialIntGen1ThresholdRegister : public Register
676  {
677  public:
678  InertialIntGen1ThresholdRegister(RegisterManager& regManager) : Register(regManager,0x32, 1, false) { }
679  int value;
680 
681  long getValue() { return ((value & 0x7F) << 0); }
682  void setValue(long val)
683  {
684  value = (int)((val >> 0) & 0x7F);
685  }
686  };
687 
688  class InertialIntGen1DurationRegister : public Register
689  {
690  public:
691  InertialIntGen1DurationRegister(RegisterManager& regManager) : Register(regManager,0x33, 1, false) { }
692  int value;
693 
694  long getValue() { return ((value & 0x7F) << 0); }
695  void setValue(long val)
696  {
697  value = (int)((val >> 0) & 0x7F);
698  }
699  };
700 
701  class InertialIntGen2ConfigRegister : public Register
702  {
703  public:
704  InertialIntGen2ConfigRegister(RegisterManager& regManager) : Register(regManager,0x34, 1, false) { }
705  int xLowInterruptEnable;
706  int xHighInterruptEnable;
707  int yLowInterruptEnable;
708  int yHighInterruptEnable;
709  int zLowInterruptEvent;
710  int zHighInterruptEnable;
711  int detect6D;
712  int andOrInterruptEvents;
713 
714  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); }
715  void setValue(long val)
716  {
717  xLowInterruptEnable = (int)((val >> 0) & 0x1);
718  xHighInterruptEnable = (int)((val >> 1) & 0x1);
719  yLowInterruptEnable = (int)((val >> 2) & 0x1);
720  yHighInterruptEnable = (int)((val >> 3) & 0x1);
721  zLowInterruptEvent = (int)((val >> 4) & 0x1);
722  zHighInterruptEnable = (int)((val >> 5) & 0x1);
723  detect6D = (int)((val >> 6) & 0x1);
724  andOrInterruptEvents = (int)((val >> 7) & 0x1);
725  }
726  };
727 
728  class InertialIntGen2StatusRegister : public Register
729  {
730  public:
731  InertialIntGen2StatusRegister(RegisterManager& regManager) : Register(regManager,0x35, 1, false) { }
732  int xLow;
733  int xHigh;
734  int yLow;
735  int yHigh;
736  int zLow;
737  int zHigh;
738  int intStatus;
739 
740  long getValue() { return ((xLow & 0x1) << 0) | ((xHigh & 0x1) << 1) | ((yLow & 0x1) << 2) | ((yHigh & 0x1) << 3) | ((zLow & 0x1) << 4) | ((zHigh & 0x1) << 5) | ((intStatus & 0x1) << 6); }
741  void setValue(long val)
742  {
743  xLow = (int)((val >> 0) & 0x1);
744  xHigh = (int)((val >> 1) & 0x1);
745  yLow = (int)((val >> 2) & 0x1);
746  yHigh = (int)((val >> 3) & 0x1);
747  zLow = (int)((val >> 4) & 0x1);
748  zHigh = (int)((val >> 5) & 0x1);
749  intStatus = (int)((val >> 6) & 0x1);
750  }
751  };
752 
753  class InertialIntGen2ThresholdRegister : public Register
754  {
755  public:
756  InertialIntGen2ThresholdRegister(RegisterManager& regManager) : Register(regManager,0x36, 1, false) { }
757  int value;
758 
759  long getValue() { return ((value & 0x7F) << 0); }
760  void setValue(long val)
761  {
762  value = (int)((val >> 0) & 0x7F);
763  }
764  };
765 
766  class InertialIntGen2DurationRegister : public Register
767  {
768  public:
769  InertialIntGen2DurationRegister(RegisterManager& regManager) : Register(regManager,0x37, 1, false) { }
770  int value;
771 
772  long getValue() { return ((value & 0x7F) << 0); }
773  void setValue(long val)
774  {
775  value = (int)((val >> 0) & 0x7F);
776  }
777  };
778 
779  class ClickConfigRegister : public Register
780  {
781  public:
782  ClickConfigRegister(RegisterManager& regManager) : Register(regManager,0x38, 1, false) { }
783  int xSingleClick;
784  int xDoubleClick;
785  int ySingleClick;
786  int yDoubleClick;
787  int zSingleClick;
788  int zDoubleClick;
789 
790  long getValue() { return ((xSingleClick & 0x1) << 0) | ((xDoubleClick & 0x1) << 1) | ((ySingleClick & 0x1) << 2) | ((yDoubleClick & 0x1) << 3) | ((zSingleClick & 0x1) << 4) | ((zDoubleClick & 0x1) << 5); }
791  void setValue(long val)
792  {
793  xSingleClick = (int)((val >> 0) & 0x1);
794  xDoubleClick = (int)((val >> 1) & 0x1);
795  ySingleClick = (int)((val >> 2) & 0x1);
796  yDoubleClick = (int)((val >> 3) & 0x1);
797  zSingleClick = (int)((val >> 4) & 0x1);
798  zDoubleClick = (int)((val >> 5) & 0x1);
799  }
800  };
801 
802  class ClickSourceRegister : public Register
803  {
804  public:
805  ClickSourceRegister(RegisterManager& regManager) : Register(regManager,0x39, 1, false) { }
806  int x;
807  int y;
808  int z;
809  int sign;
810  int singleClickEn;
811  int doubleClickEn;
812  int interruptActive;
813 
814  long getValue() { return ((x & 0x1) << 0) | ((y & 0x1) << 1) | ((z & 0x1) << 2) | ((sign & 0x1) << 3) | ((singleClickEn & 0x1) << 4) | ((doubleClickEn & 0x1) << 5) | ((interruptActive & 0x1) << 6); }
815  void setValue(long val)
816  {
817  x = (int)((val >> 0) & 0x1);
818  y = (int)((val >> 1) & 0x1);
819  z = (int)((val >> 2) & 0x1);
820  sign = (int)((val >> 3) & 0x1);
821  singleClickEn = (int)((val >> 4) & 0x1);
822  doubleClickEn = (int)((val >> 5) & 0x1);
823  interruptActive = (int)((val >> 6) & 0x1);
824  }
825  };
826 
827  class ClickThresholdRegister : public Register
828  {
829  public:
830  ClickThresholdRegister(RegisterManager& regManager) : Register(regManager,0x3A, 1, false) { }
831  int value;
832 
833  long getValue() { return ((value & 0x7F) << 0); }
834  void setValue(long val)
835  {
836  value = (int)((val >> 0) & 0x7F);
837  }
838  };
839 
840  class TimeLimitRegister : public Register
841  {
842  public:
843  TimeLimitRegister(RegisterManager& regManager) : Register(regManager,0x3b, 1, false) { }
844  int value;
845 
846  long getValue() { return ((value & 0x7F) << 0); }
847  void setValue(long val)
848  {
849  value = (int)((val >> 0) & 0x7F);
850  }
851  };
852 
853  class TimeLatencyRegister : public Register
854  {
855  public:
856  TimeLatencyRegister(RegisterManager& regManager) : Register(regManager,0x3c, 1, false) { }
857  int value;
858 
859  long getValue() { return ((value & 0xFF) << 0); }
860  void setValue(long val)
861  {
862  value = (int)((val >> 0) & 0xFF);
863  }
864  };
865 
866  class TimeWindowRegister : public Register
867  {
868  public:
869  TimeWindowRegister(RegisterManager& regManager) : Register(regManager,0x3d, 1, false) { }
870  int value;
871 
872  long getValue() { return ((value & 0xFF) << 0); }
873  void setValue(long val)
874  {
875  value = (int)((val >> 0) & 0xFF);
876  }
877  };
878 
879  class ActivationThresholdRegister : public Register
880  {
881  public:
882  ActivationThresholdRegister(RegisterManager& regManager) : Register(regManager,0x3e, 1, false) { }
883  int value;
884 
885  long getValue() { return ((value & 0xFF) << 0); }
886  void setValue(long val)
887  {
888  value = (int)((val >> 0) & 0xFF);
889  }
890  };
891 
892  class ActivationDurationRegister : public Register
893  {
894  public:
895  ActivationDurationRegister(RegisterManager& regManager) : Register(regManager,0x3f, 1, false) { }
896  int value;
897 
898  long getValue() { return ((value & 0xFF) << 0); }
899  void setValue(long val)
900  {
901  value = (int)((val >> 0) & 0xFF);
902  }
903  };
904 
905  TempOutRegister tempOut;
906  StatusRegister status;
907  OutXRegister outX;
908  OutYRegister outY;
909  OutZRegister outZ;
910  WhoAmIRegister whoAmI;
911  IntCtrlRegister intCtrl;
912  IntSourceRegister intSource;
913  IntThresholdRegister intThreshold;
914  OffsetXRegister offsetX;
915  OffsetYRegister offsetY;
916  OffsetZRegister offsetZ;
917  ReferenceXRegister referenceX;
918  ReferenceYRegister referenceY;
919  ReferenceZRegister referenceZ;
920  Ctrl0Register ctrl0;
921  Ctrl1Register ctrl1;
922  Ctrl2Register ctrl2;
923  Ctrl3Register ctrl3;
924  Ctrl4Register ctrl4;
925  Ctrl5Register ctrl5;
926  Ctrl6Register ctrl6;
927  Ctrl7Register ctrl7;
928  StatusARegister statusA;
929  OutAccelXRegister outAccelX;
930  OutAccelYRegister outAccelY;
931  OutAccelZRegister outAccelZ;
932  FifoControlRegister fifoControl;
933  FifoSourceRegister fifoSource;
934  InertialIntGen1ConfigRegister inertialIntGen1Config;
935  InertialIntGen1StatusRegister inertialIntGen1Status;
936  InertialIntGen1ThresholdRegister inertialIntGen1Threshold;
937  InertialIntGen1DurationRegister inertialIntGen1Duration;
938  InertialIntGen2ConfigRegister inertialIntGen2Config;
939  InertialIntGen2StatusRegister inertialIntGen2Status;
940  InertialIntGen2ThresholdRegister inertialIntGen2Threshold;
941  InertialIntGen2DurationRegister inertialIntGen2Duration;
942  ClickConfigRegister clickConfig;
943  ClickSourceRegister clickSource;
944  ClickThresholdRegister clickThreshold;
945  TimeLimitRegister timeLimit;
946  TimeLatencyRegister timeLatency;
947  TimeWindowRegister timeWindow;
948  ActivationThresholdRegister activationThreshold;
949  ActivationDurationRegister activationDuration;
950 
951  Lsm303dRegisters(SMBusDevice& device) : RegisterManager(device, true), tempOut(*this), status(*this), outX(*this), outY(*this), outZ(*this), whoAmI(*this), intCtrl(*this), intSource(*this), intThreshold(*this), offsetX(*this), offsetY(*this), offsetZ(*this), referenceX(*this), referenceY(*this), referenceZ(*this), ctrl0(*this), ctrl1(*this), ctrl2(*this), ctrl3(*this), ctrl4(*this), ctrl5(*this), ctrl6(*this), ctrl7(*this), statusA(*this), outAccelX(*this), outAccelY(*this), outAccelZ(*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), activationThreshold(*this), activationDuration(*this)
952  {
953  registers.push_back(&tempOut);
954  registers.push_back(&status);
955  registers.push_back(&outX);
956  registers.push_back(&outY);
957  registers.push_back(&outZ);
958  registers.push_back(&whoAmI);
959  registers.push_back(&intCtrl);
960  registers.push_back(&intSource);
961  registers.push_back(&intThreshold);
962  registers.push_back(&offsetX);
963  registers.push_back(&offsetY);
964  registers.push_back(&offsetZ);
965  registers.push_back(&referenceX);
966  registers.push_back(&referenceY);
967  registers.push_back(&referenceZ);
968  registers.push_back(&ctrl0);
969  registers.push_back(&ctrl1);
970  registers.push_back(&ctrl2);
971  registers.push_back(&ctrl3);
972  registers.push_back(&ctrl4);
973  registers.push_back(&ctrl5);
974  registers.push_back(&ctrl6);
975  registers.push_back(&ctrl7);
976  registers.push_back(&statusA);
977  registers.push_back(&outAccelX);
978  registers.push_back(&outAccelY);
979  registers.push_back(&outAccelZ);
980  registers.push_back(&fifoControl);
981  registers.push_back(&fifoSource);
982  registers.push_back(&inertialIntGen1Config);
983  registers.push_back(&inertialIntGen1Status);
984  registers.push_back(&inertialIntGen1Threshold);
985  registers.push_back(&inertialIntGen1Duration);
986  registers.push_back(&inertialIntGen2Config);
987  registers.push_back(&inertialIntGen2Status);
988  registers.push_back(&inertialIntGen2Threshold);
989  registers.push_back(&inertialIntGen2Duration);
990  registers.push_back(&clickConfig);
991  registers.push_back(&clickSource);
992  registers.push_back(&clickThreshold);
993  registers.push_back(&timeLimit);
994  registers.push_back(&timeLatency);
995  registers.push_back(&timeWindow);
996  registers.push_back(&activationThreshold);
997  registers.push_back(&activationDuration);
998  }
999  };
1000  } } } }
MagDataRates
Definition: Lsm303dRegisters.h:44
MagFullScaleSelections
Definition: Lsm303dRegisters.h:60
FullScaleSelections
Definition: Lis3dhRegisters.h:26
Definition: Dm632.h:9
AntiAliasFilterBandwidths
Definition: Lsm303dRegisters.h:36
Definition: Register.h:11
AccelhighPassModes
Definition: Lsm303dlhcAccelRegisters.h:26
Definition: RegisterManager.h:10
FifoModes
Definition: L3gd20Registers.h:20
MagSensorModes
Definition: Lsm303dRegisters.h:68
OutputDataRates
Definition: Lis3dhRegisters.h:42
Definition: AdcPin.h:3
MagResolutions
Definition: Lsm303dRegisters.h:54