|
DUDS
|
Distributed Update of Data from Something
|
Initial support of the FXOS8700CQ; a combined triple axis accelerometer and magnetometer. More...
#include <FXOS8700CQ.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 | |
| typedef duds::data::QuantityXyz | ConvertedSample |
| The sample data converted to known units. More... | |
| enum | Magnitude { Magnitude2g, Magnitude4g, Magnitude8g } |
| The magnitude options for the accelerometer. More... | |
| enum | OversampleMode { Normal, LowNoiseLowPower, HighResolution, LowPower } |
Public Member Functions | |
| FXOS8700CQ (std::unique_ptr< duds::hardware::interface::I2c > &i2ccom) | |
| Attempts to identify the device, then suspends the device's operation. More... | |
| ~FXOS8700CQ () | |
| Calls suspend(). More... | |
| void | configure (float freq, Settings settings) |
| Configures the device. More... | |
| const RawSample & | rawAccelerometer () const |
| Returns the accelerometer data as read from the device. More... | |
| const RawSample & | rawMagnetometer () const |
| Returns the magnetometer data as read from the device. More... | |
| 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... | |
| duds::hardware::interface::Conversation | bufq |
| Settings | cfg |
| The current various configuration options. More... | |
| std::unique_ptr< duds::hardware::interface::I2c > | com |
| The I2C communication interface. More... | |
| float | datarate |
| The currently configured sample rate. More... | |
| std::int8_t | drval |
| The data rate value given to the device. More... | |
| duds::hardware::interface::Conversation | initialize |
| The conversation used to initialize the device. More... | |
| duds::hardware::interface::Conversation | input |
| The conversation used to read in samples from the device. More... | |
| RawSample | magn |
Initial support of the FXOS8700CQ; a combined triple axis accelerometer and magnetometer.
Errata document says any communication over I2C will adversely affect any magnetometer sample by as much as 70uT. This likely will be triggered by any use of the I2C bus rather than just communication with the FXOS8700CQ.
Adafruit's board uses device address 0x1F. When using the board with the I2C bus on HDMI from a notebook computer, I found that the reset operation causes the device to ignore all communication until after a power cycle. Not sure why. I also found that with that setup and certain almost but not quite level orientations, the device fails to register gravity. It also has issues with the magnetometer data. Using the same device with a Raspberry Pi resulted in good accelerometer data, but bad magnetometer data. Could just be an issue with the board I have.
Definition at line 56 of file FXOS8700CQ.hpp.
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 75 of file FXOS8700CQ.hpp.
The magnitude options for the accelerometer.
Definition at line 79 of file FXOS8700CQ.hpp.
| Enumerator | |
|---|---|
| Normal | |
| LowNoiseLowPower | |
| HighResolution | |
| LowPower | |
Definition at line 94 of file FXOS8700CQ.hpp.
| duds::hardware::devices::instruments::FXOS8700CQ::FXOS8700CQ | ( | std::unique_ptr< duds::hardware::interface::I2c > & | i2ccom | ) |
Attempts to identify the device, then suspends the device's operation.
This resets the device, which requires 2ms to complete.
Adafruit's board uses device address 0x1F.
| i2ccom | The I2C object to use to communicate with the device. This FXOS8700CQ object will take ownership over i2ccom. |
| DeviceMisidentified | The reported device ID is incorrect. |
Definition at line 88 of file FXOS8700CQ.cpp.
| duds::hardware::devices::instruments::FXOS8700CQ::~FXOS8700CQ | ( | ) |
Calls suspend().
Definition at line 132 of file FXOS8700CQ.cpp.
| void duds::hardware::devices::instruments::FXOS8700CQ::configure | ( | float | freq, |
| Settings | settings | ||
| ) |
Configures the device.
| freq | The minimum sample frequency. If the rate is too high, FXOS8700CQBadDataRate will be thrown. |
| settings | The requested device configuration. |
| FXOS8700CQNoInsturment | The configuration does not select either the accelerometer or magnetometer for use. |
| FXOS8700CQBadMagnitude | The requested maximum magnetude for the accelerometer is either not supported or an invalid value. |
| FXOS8700CQBadDataRate |
Definition at line 148 of file FXOS8700CQ.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 258 of file FXOS8700CQ.hpp.
|
inline |
Returns the magnetometer data as read from the device.
Definition at line 266 of file FXOS8700CQ.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 235 of file FXOS8700CQ.hpp.
| bool duds::hardware::devices::instruments::FXOS8700CQ::sample | ( | ) |
Reads sampled data from the device.
Definition at line 328 of file FXOS8700CQ.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 247 of file FXOS8700CQ.hpp.
| void duds::hardware::devices::instruments::FXOS8700CQ::start | ( | ) |
Tells the device to start sampling.
Definition at line 286 of file FXOS8700CQ.cpp.
| void duds::hardware::devices::instruments::FXOS8700CQ::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 303 of file FXOS8700CQ.cpp.
Referenced by configure(), FXOS8700CQ(), and ~FXOS8700CQ().
|
private |
The values supplied by the device.
Definition at line 172 of file FXOS8700CQ.hpp.
Referenced by sample().
|
private |
Definition at line 168 of file FXOS8700CQ.hpp.
Referenced by configure(), and sample().
|
private |
The current various configuration options.
Definition at line 180 of file FXOS8700CQ.hpp.
Referenced by configure(), FXOS8700CQ(), sample(), start(), and suspend().
|
private |
The I2C communication interface.
Definition at line 159 of file FXOS8700CQ.hpp.
Referenced by configure(), FXOS8700CQ(), sample(), start(), and suspend().
|
private |
The currently configured sample rate.
Definition at line 176 of file FXOS8700CQ.hpp.
Referenced by configure().
|
private |
The data rate value given to the device.
Definition at line 184 of file FXOS8700CQ.hpp.
Referenced by configure(), and start().
|
private |
The conversation used to initialize the device.
It is created in init() and held for later use by resume().
Definition at line 164 of file FXOS8700CQ.hpp.
|
private |
The conversation used to read in samples from the device.
Definition at line 168 of file FXOS8700CQ.hpp.
Referenced by configure(), and sample().
|
private |
Definition at line 172 of file FXOS8700CQ.hpp.
Referenced by sample().