DUDS
Distributed Update of Data from Something
duds::hardware::devices::instruments::FXOS8700CQ Class Reference

Initial support of the FXOS8700CQ; a combined triple axis accelerometer and magnetometer. More...

#include <FXOS8700CQ.hpp>

Inheritance diagram for duds::hardware::devices::instruments::FXOS8700CQ:
Collaboration diagram for duds::hardware::devices::instruments::FXOS8700CQ:

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 RawSamplerawAccelerometer () const
 Returns the accelerometer data as read from the device. More...
 
const RawSamplerawMagnetometer () 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::I2ccom
 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
 

Detailed Description

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.

Author
Jeff Jackowski

Definition at line 56 of file FXOS8700CQ.hpp.

Member Typedef Documentation

◆ ConvertedSample

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.

Member Enumeration Documentation

◆ Magnitude

The magnitude options for the accelerometer.

Enumerator
Magnitude2g 

Selects the +/-2g accelerometer range.

Magnitude4g 

Selects the +/-4g accelerometer range.

Magnitude8g 

Selects the +/-8g accelerometer range.

Cannot be used with the low-noise operating mode.

Definition at line 79 of file FXOS8700CQ.hpp.

◆ OversampleMode

Enumerator
Normal 
LowNoiseLowPower 
HighResolution 
LowPower 

Definition at line 94 of file FXOS8700CQ.hpp.

Constructor & Destructor Documentation

◆ FXOS8700CQ()

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.

Parameters
i2ccomThe I2C object to use to communicate with the device. This FXOS8700CQ object will take ownership over i2ccom.
Exceptions
DeviceMisidentifiedThe reported device ID is incorrect.

Definition at line 88 of file FXOS8700CQ.cpp.

◆ ~FXOS8700CQ()

duds::hardware::devices::instruments::FXOS8700CQ::~FXOS8700CQ ( )

Calls suspend().

Definition at line 132 of file FXOS8700CQ.cpp.

Member Function Documentation

◆ configure()

void duds::hardware::devices::instruments::FXOS8700CQ::configure ( float  freq,
Settings  settings 
)

Configures the device.

Postcondition
The device will be suspended.
Parameters
freqThe minimum sample frequency. If the rate is too high, FXOS8700CQBadDataRate will be thrown.
settingsThe requested device configuration.
Exceptions
FXOS8700CQNoInsturmentThe configuration does not select either the accelerometer or magnetometer for use.
FXOS8700CQBadMagnitudeThe requested maximum magnetude for the accelerometer is either not supported or an invalid value.
FXOS8700CQBadDataRate

Definition at line 148 of file FXOS8700CQ.cpp.

◆ rawAccelerometer()

const RawSample& duds::hardware::devices::instruments::FXOS8700CQ::rawAccelerometer ( ) const
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.

Note
The values will change when the device is sampled and the accelerometer is in use.

Definition at line 258 of file FXOS8700CQ.hpp.

◆ rawMagnetometer()

const RawSample& duds::hardware::devices::instruments::FXOS8700CQ::rawMagnetometer ( ) const
inline

Returns the magnetometer data as read from the device.

Note
The values will change when the device is sampled and the magnetometer is in use.

Definition at line 266 of file FXOS8700CQ.hpp.

◆ resume()

void duds::hardware::devices::instruments::FXOS8700CQ::resume ( )
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.

Exceptions
DeviceUninitalizedinit() hasn't been called.

Definition at line 235 of file FXOS8700CQ.hpp.

◆ sample()

bool duds::hardware::devices::instruments::FXOS8700CQ::sample ( )

Reads sampled data from the device.

Returns
True if the device had new data.

Definition at line 328 of file FXOS8700CQ.cpp.

◆ sampleRate()

float duds::hardware::devices::instruments::FXOS8700CQ::sampleRate ( ) const
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.

◆ start()

void duds::hardware::devices::instruments::FXOS8700CQ::start ( )

Tells the device to start sampling.

Precondition
configure() has been called and succeeded.

Definition at line 286 of file FXOS8700CQ.cpp.

◆ suspend()

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().

Member Data Documentation

◆ accl

RawSample duds::hardware::devices::instruments::FXOS8700CQ::accl
private

The values supplied by the device.

Definition at line 172 of file FXOS8700CQ.hpp.

Referenced by sample().

◆ bufq

duds::hardware::interface::Conversation duds::hardware::devices::instruments::FXOS8700CQ::bufq
private

Definition at line 168 of file FXOS8700CQ.hpp.

Referenced by configure(), and sample().

◆ cfg

Settings duds::hardware::devices::instruments::FXOS8700CQ::cfg
private

The current various configuration options.

Definition at line 180 of file FXOS8700CQ.hpp.

Referenced by configure(), FXOS8700CQ(), sample(), start(), and suspend().

◆ com

std::unique_ptr<duds::hardware::interface::I2c> duds::hardware::devices::instruments::FXOS8700CQ::com
private

The I2C communication interface.

Definition at line 159 of file FXOS8700CQ.hpp.

Referenced by configure(), FXOS8700CQ(), sample(), start(), and suspend().

◆ datarate

float duds::hardware::devices::instruments::FXOS8700CQ::datarate
private

The currently configured sample rate.

Definition at line 176 of file FXOS8700CQ.hpp.

Referenced by configure().

◆ drval

std::int8_t duds::hardware::devices::instruments::FXOS8700CQ::drval
private

The data rate value given to the device.

Definition at line 184 of file FXOS8700CQ.hpp.

Referenced by configure(), and start().

◆ initialize

duds::hardware::interface::Conversation duds::hardware::devices::instruments::FXOS8700CQ::initialize
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.

◆ input

duds::hardware::interface::Conversation duds::hardware::devices::instruments::FXOS8700CQ::input
private

The conversation used to read in samples from the device.

Definition at line 168 of file FXOS8700CQ.hpp.

Referenced by configure(), and sample().

◆ magn

RawSample duds::hardware::devices::instruments::FXOS8700CQ::magn
private

Definition at line 172 of file FXOS8700CQ.hpp.

Referenced by sample().


The documentation for this class was generated from the following files: