|
DUDS
|
Distributed Update of Data from Something
|
Initial support of the accelerometer and gyroscope on the LSM9DS1. More...
#include <LSM9DS1.hpp>
Classes | |
| union | RawSample |
| Stores the sample data as reported by the device. More... | |
| struct | Settings |
| The various settings for the device packed into an integer to avoid passing a lot of parameters. More... | |
Public Types | |
| enum | AccelRange { AccelRange2g, AccelRange16g, AccelRange4g, AccelRange8g, AccelRange19m61ps2 = 0, AccelRange156m9ps2, AccelRange39m23ps2, AccelRange78m45ps2 } |
| The maximum magnitude options for the accelerometer. More... | |
| typedef duds::data::QuantityXyz | ConvertedQuantity |
| The sample data converted to known units. More... | |
| enum | GyroRange { GyroRange245dps, GyroRange500dps, GyroRange2000dps = 3, GyroRange4r276ps = 0, GyroRange8r727ps, GyroRange34r91ps = 3 } |
| The maximum magnitude options for the gyroscope. More... | |
Public Member Functions | |
| LSM9DS1AccelGyro (std::unique_ptr< duds::hardware::interface::I2c > &i2c) | |
| Attempts to identify the device, then suspends the device's operation. More... | |
| ~LSM9DS1AccelGyro () | |
| Calls suspend(). More... | |
| void | accelerometerQuantity (ConvertedQuantity &ps) const |
| Provides the accelerometer data in meters per second squared. More... | |
| void | configure (float freq, Settings settings) |
| Configures the device. More... | |
| void | gyroscopeQuantity (ConvertedQuantity &ps) const |
| Provides the gyroscope data in radians per second. More... | |
| const RawSample & | rawAccelerometer () const |
| Returns the accelerometer data as read from the device. More... | |
| const RawSample & | rawGyroscope () const |
| void | resume () |
| Resumes operation after a call to suspend(). More... | |
| bool | sample () |
| Reads sampled data from the device. More... | |
| float | sampleRate () const |
| Returns the confiured sampling rate. More... | |
| void | start () |
| Tells the device to start sampling. More... | |
| void | suspend () |
| Suspends operation by putting the device into a low-power mode that discontinues sampling. More... | |
Private Attributes | |
| RawSample | accl |
| The values supplied by the device. More... | |
| std::unique_ptr< duds::hardware::interface::I2c > | agcom |
| The I2C communication interface. More... | |
| float | agdatarate |
| The currently configured sample rate. More... | |
| std::int8_t | agdrval |
| The data rate value given to the device. More... | |
| duds::hardware::interface::Conversation | agsample |
| The conversation used to read in samples from the device. More... | |
| Settings | cfg |
| The current various configuration options. More... | |
| RawSample | gyro |
| duds::hardware::interface::Conversation | initialize |
| The conversation used to initialize the device. More... | |
| duds::hardware::interface::Conversation | statq |
Initial support of the accelerometer and gyroscope on the LSM9DS1.
The magnetometer is supported by LSM9DS1Mag because it acts like an independent device. The documentation makes it seem as though the LSM9DS1 is really two devices stuck together.
The Sparkfun board I've got uses I2C address 0x6B for the accelerometer and gyroscope.
Definition at line 49 of file LSM9DS1.hpp.
| typedef duds::data::QuantityXyz duds::hardware::devices::instruments::LSM9DS1AccelGyro::ConvertedQuantity |
The sample data converted to known units.
The accelerometer data is a bit of a guess since its units are vaugely defined and callibration is done based on the local pull of Earth's gravity.
Definition at line 68 of file LSM9DS1.hpp.
The maximum magnitude options for the accelerometer.
The ordering is strange, but that is how the device does it.
Definition at line 73 of file LSM9DS1.hpp.
The maximum magnitude options for the gyroscope.
Definition at line 98 of file LSM9DS1.hpp.
| duds::hardware::devices::instruments::LSM9DS1AccelGyro::LSM9DS1AccelGyro | ( | std::unique_ptr< duds::hardware::interface::I2c > & | i2c | ) |
Attempts to identify the device, then suspends the device's operation.
This resets the device, which requires 2ms to complete.
Sparkfun's board uses device address 0x6B.
| i2c | The I2C object to use to communicate with the accelerometer/gyroscope part of the device. This LSM9DS1 object will take ownership over the communicator. |
| DeviceMisidentified | The reported device ID is incorrect. |
Definition at line 188 of file LSM9DS1.cpp.
| duds::hardware::devices::instruments::LSM9DS1AccelGyro::~LSM9DS1AccelGyro | ( | ) |
Calls suspend().
Definition at line 232 of file LSM9DS1.cpp.
| void duds::hardware::devices::instruments::LSM9DS1AccelGyro::accelerometerQuantity | ( | ConvertedQuantity & | ps | ) | const |
Provides the accelerometer data in meters per second squared.
Definition at line 352 of file LSM9DS1.cpp.
| void duds::hardware::devices::instruments::LSM9DS1AccelGyro::configure | ( | float | freq, |
| Settings | settings | ||
| ) |
Configures the device.
| freq | The minimum sample frequency. If the rate is too high, LSM9DS1BadDataRate will be thrown. |
| settings | The requested device configuration. |
| LSM9DS1NoInsturment | The configuration does not select either the accelerometer or magnetometer for use. |
| LSM9DS1BadMagnitude | The requested maximum magnetude for the accelerometer is either not supported or an invalid value. |
| LSM9DS1BadDataRate |
Definition at line 236 of file LSM9DS1.cpp.
| void duds::hardware::devices::instruments::LSM9DS1AccelGyro::gyroscopeQuantity | ( | ConvertedQuantity & | ps | ) | const |
Provides the gyroscope data in radians per second.
Definition at line 359 of file LSM9DS1.cpp.
|
inline |
Returns the accelerometer data as read from the device.
The data will be shifted, if needed, so that the LSb of the sample data will be in the LSb of the integers. Otherwise, the data is unchanged from what the device reported.
Definition at line 248 of file LSM9DS1.hpp.
|
inline |
Definition at line 251 of file LSM9DS1.hpp.
|
inline |
Resumes operation after a call to suspend().
Seems to be a nice name that I used with other device drivers, so I put it here until I do more to figure out a consistent interface that I like.
| DeviceUninitalized | init() hasn't been called. |
Definition at line 225 of file LSM9DS1.hpp.
| bool duds::hardware::devices::instruments::LSM9DS1AccelGyro::sample | ( | ) |
Reads sampled data from the device.
Definition at line 333 of file LSM9DS1.cpp.
|
inline |
Returns the confiured sampling rate.
The value will be zero if configure() has not yet been called, or if it failed.
Definition at line 237 of file LSM9DS1.hpp.
|
inline |
Tells the device to start sampling.
Definition at line 209 of file LSM9DS1.hpp.
| void duds::hardware::devices::instruments::LSM9DS1AccelGyro::suspend | ( | ) |
Suspends operation by putting the device into a low-power mode that discontinues sampling.
This may require as much as 300ms to complete if the magnetometer is in use.
Definition at line 322 of file LSM9DS1.cpp.
Referenced by configure(), and ~LSM9DS1AccelGyro().
|
private |
The values supplied by the device.
Definition at line 153 of file LSM9DS1.hpp.
Referenced by accelerometerQuantity(), and sample().
|
private |
The I2C communication interface.
Definition at line 140 of file LSM9DS1.hpp.
Referenced by configure(), LSM9DS1AccelGyro(), sample(), and suspend().
|
private |
The currently configured sample rate.
Definition at line 157 of file LSM9DS1.hpp.
Referenced by configure().
|
private |
The data rate value given to the device.
Definition at line 165 of file LSM9DS1.hpp.
Referenced by configure().
|
private |
The conversation used to read in samples from the device.
Definition at line 149 of file LSM9DS1.hpp.
Referenced by configure(), and sample().
|
private |
The current various configuration options.
Definition at line 161 of file LSM9DS1.hpp.
Referenced by accelerometerQuantity(), configure(), gyroscopeQuantity(), and sample().
|
private |
Definition at line 153 of file LSM9DS1.hpp.
Referenced by gyroscopeQuantity(), and sample().
|
private |
The conversation used to initialize the device.
It is created in init() and held for later use by resume().
Definition at line 145 of file LSM9DS1.hpp.
|
private |
Definition at line 149 of file LSM9DS1.hpp.
Referenced by configure(), and sample().