DUDS
Distributed Update of Data from Something
LSM9DS1.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of the DUDS project. It is subject to the BSD-style
3  * license terms in the LICENSE file found in the top-level directory of this
4  * distribution and at https://github.com/jjackowski/duds/blob/master/LICENSE.
5  * No part of DUDS, including this file, may be copied, modified, propagated,
6  * or distributed except according to the terms contained in the LICENSE file.
7  *
8  * Copyright (C) 2017 Jeff Jackowski
9  */
14 
15 namespace duds { namespace hardware { namespace devices { namespace instruments {
16 
34 
35 typedef boost::error_info<struct Info_UpdateRate, float> RequestedUpdateRate;
36 
49 class LSM9DS1AccelGyro : boost::noncopyable {
50 public:
55  union RawSample {
56  std::int16_t vals[3];
57  struct {
58  std::int16_t x;
59  std::int16_t y;
60  std::int16_t z;
61  };
62  };
73  enum AccelRange {
90  AccelRange19m61ps2 = 0,
94  };
98  enum GyroRange {
101  GyroRange2000dps = 3,
102  GyroRange4r276ps = 0,
104  GyroRange34r91ps = 3,
105  };
110  struct Settings {
115  unsigned int accelerometer : 1;
120  unsigned int gyroscope : 1;
133  unsigned int gyroLowPower : 1;
134  unsigned int gyroHighPass : 1;
135  };
136 private:
140  std::unique_ptr<duds::hardware::interface::I2c> agcom;
157  float agdatarate;
165  std::int8_t agdrval;
166 public:
184  std::unique_ptr<duds::hardware::interface::I2c> &i2c
185  );
189  ~LSM9DS1AccelGyro();
204  void configure(float freq, Settings settings);
209  void start() {
210  // oops.
211  }
217  void suspend();
225  void resume() {
226  start();
227  }
232  bool sample();
237  float sampleRate() const {
238  return agdatarate;
239  }
248  const RawSample &rawAccelerometer() const {
249  return accl;
250  }
251  const RawSample &rawGyroscope() const {
252  return gyro;
253  }
257  void accelerometerQuantity(ConvertedQuantity &ps) const;
261  void gyroscopeQuantity(ConvertedQuantity &ps) const;
262 };
263 
264 
282 class LSM9DS1Mag : boost::noncopyable {
283 public:
288  union RawSample {
289  std::int16_t vals[3];
290  struct {
291  std::int16_t x;
292  std::int16_t y;
293  std::int16_t z;
294  };
295  };
303  enum MagRange {
307  MagRange1600uT
308  };
313  enum MagAxesMode {
330  AxesHighPerformance
331  };
336  struct Settings {
341  unsigned int magnetometer : 1;
352  unsigned int magLowPower : 1;
365  unsigned int magTempComp : 1;
366  };
367 private:
371  std::unique_ptr<duds::hardware::interface::I2c> magcom;
388  float mdatarate;
396  std::int8_t mdrval;
397 public:
413  LSM9DS1Mag(
414  std::unique_ptr<duds::hardware::interface::I2c> &i2c
415  );
419  ~LSM9DS1Mag();
434  void configure(float freq, Settings settings);
439  void start() {
440  // oops.
441  }
447  void suspend();
455  void resume() {
456  start();
457  }
462  bool sample();
467  float sampleRate() const {
468  return mdatarate;
469  }
475  const RawSample &rawSample() const {
476  return magn;
477  }
478  void quantity(ConvertedQuantity &ps) const;
479 };
480 
481 } } } }
Called medium performance in the doc; renamed to avoid buzzwords.
Definition: LSM9DS1.hpp:322
MagAxesMode zMagMode
Operating mode for the Z axis.
Definition: LSM9DS1.hpp:360
MagRange magRange
The maximum magnetude setting.
Definition: LSM9DS1.hpp:345
duds::hardware::interface::Conversation statq
Definition: LSM9DS1.hpp:380
AccelRange
The maximum magnitude options for the accelerometer.
Definition: LSM9DS1.hpp:73
float mdatarate
The currently configured sample rate.
Definition: LSM9DS1.hpp:388
The requested data rate is unsupported.
Definition: LSM9DS1.hpp:24
Stores the sample data as reported by the device.
Definition: LSM9DS1.hpp:288
Initial support of the magnetometer of the LSM9DS1.
Definition: LSM9DS1.hpp:282
unsigned int accelerometer
Flag to use the accelerometer.
Definition: LSM9DS1.hpp:115
const RawSample & rawSample() const
Returns the magnetometer data as read from the device.
Definition: LSM9DS1.hpp:475
duds::hardware::interface::Conversation initialize
The conversation used to initialize the device.
Definition: LSM9DS1.hpp:376
float agdatarate
The currently configured sample rate.
Definition: LSM9DS1.hpp:157
GyroRange gyroRange
The maximum magnetude setting for the gyroscope.
Definition: LSM9DS1.hpp:128
unsigned int magTempComp
Enables temperature compensation using a temperature sensor inside the device.
Definition: LSM9DS1.hpp:365
boost::error_info< struct Info_UpdateRate, float > RequestedUpdateRate
Definition: FXOS8700CQ.hpp:35
MagAxesMode
Selects an operation mode for the axes.
Definition: LSM9DS1.hpp:313
Stores the sample data as reported by the device.
Definition: LSM9DS1.hpp:55
unsigned int gyroLowPower
Enable the low-power mode of the gyroscope.
Definition: LSM9DS1.hpp:133
Base class for all LSM9DS1 specific errors.
Definition: LSM9DS1.hpp:20
Initial support of the accelerometer and gyroscope on the LSM9DS1.
Definition: LSM9DS1.hpp:49
unsigned int magLowPower
A low-power mode that forces the 0.625Hz sample rate.
Definition: LSM9DS1.hpp:352
duds::data::QuantityXyz ConvertedQuantity
The sample data converted to Tesla.
Definition: LSM9DS1.hpp:299
std::unique_ptr< duds::hardware::interface::I2c > magcom
The I2C communication interface.
Definition: LSM9DS1.hpp:371
unsigned int magnetometer
Flag to use the magnetometer.
Definition: LSM9DS1.hpp:341
MagAxesMode xyMagMode
Operating mode for the X and Y axes.
Definition: LSM9DS1.hpp:356
AccelRange accelRange
The maximum magnetude setting for the accelerometer.
Definition: LSM9DS1.hpp:124
duds::hardware::interface::Conversation statq
Definition: LSM9DS1.hpp:149
std::unique_ptr< duds::hardware::interface::I2c > agcom
The I2C communication interface.
Definition: LSM9DS1.hpp:140
void resume()
Resumes operation after a call to suspend().
Definition: LSM9DS1.hpp:225
void start()
Tells the device to start sampling.
Definition: LSM9DS1.hpp:439
float sampleRate() const
Returns the confiured sampling rate.
Definition: LSM9DS1.hpp:237
duds::data::QuantityXyz ConvertedQuantity
The sample data converted to known units.
Definition: LSM9DS1.hpp:68
duds::hardware::interface::Conversation initialize
The conversation used to initialize the device.
Definition: LSM9DS1.hpp:145
The various settings for the device packed into an integer to avoid passing a lot of parameters...
Definition: LSM9DS1.hpp:110
std::int8_t mdrval
The data rate value given to the device.
Definition: LSM9DS1.hpp:396
Settings cfg
The current various configuration options.
Definition: LSM9DS1.hpp:392
void resume()
Resumes operation after a call to suspend().
Definition: LSM9DS1.hpp:455
RawSample magn
The values supplied by the device.
Definition: LSM9DS1.hpp:384
unsigned int gyroscope
Flag to use the gyroscope.
Definition: LSM9DS1.hpp:120
Header for Conversarion; includes ConversationVector.hpp and ConversationExternal.hpp.
std::int8_t agdrval
The data rate value given to the device.
Definition: LSM9DS1.hpp:165
A QuantityArray for the common usage of a three dimentional coordinate or a triple axis sample...
The configuration requested that neither the accelerometer or magnetometer be used.
Definition: LSM9DS1.hpp:33
Settings cfg
The current various configuration options.
Definition: LSM9DS1.hpp:161
The base type for errors from devices.
const RawSample & rawAccelerometer() const
Returns the accelerometer data as read from the device.
Definition: LSM9DS1.hpp:248
GyroRange
The maximum magnitude options for the gyroscope.
Definition: LSM9DS1.hpp:98
The requested maximum magnitude is either unsupported or an invalid value.
Definition: LSM9DS1.hpp:28
float sampleRate() const
Returns the confiured sampling rate.
Definition: LSM9DS1.hpp:467
MagRange
The maximum magnitude options for the magnetometer.
Definition: LSM9DS1.hpp:303
Represents a two-way conversation with a device.
Called high performance in the doc; renamed to avoid buzzwords.
Definition: LSM9DS1.hpp:326
The various settings for the device packed into an integer to avoid passing a lot of parameters...
Definition: LSM9DS1.hpp:336
void start()
Tells the device to start sampling.
Definition: LSM9DS1.hpp:209