Modification to FXOS8700Q for use in Data Logger project
Dependencies: FXOS8700Q MotionSensor
Dependents: GPS_6Axis_DataLogger_SD_UDP
Fork of FXOS8700Q by
Diff: FXOS8700Q.h
- Revision:
- 6:cdc362f08339
- Parent:
- 5:c4176a12f7d5
- Child:
- 9:5553a64d0762
--- a/FXOS8700Q.h Wed Apr 23 17:12:15 2014 +0000 +++ b/FXOS8700Q.h Thu Apr 24 16:30:31 2014 +0000 @@ -58,16 +58,16 @@ * PwmOut bled(LED_BLUE); * * while (true) { -* rled = 1.0 - combo(acc.getAccX()); -* gled = 1.0 - combo(acc.getAccY()); -* bled = 1.0 - combo(acc.getAccZ()); +* rled1.0 - combo(acc.getAccX()); +* gled1.0 - combo(acc.getAccY()); +* bled1.0 - combo(acc.getAccZ()); * wait(0.1); * } * } * @endcode */ -class FXOS8700Q : public MotionSensor +class FXOS8700Q_acc : public MotionSensor { public: /** @@ -78,76 +78,62 @@ * @param addr addr of the I2C peripheral */ - FXOS8700Q(PinName sda, PinName scl, int addr); + FXOS8700Q_acc(PinName sda, PinName scl, int addr); /** * FXOS8700Q destructor */ - ~FXOS8700Q(); - - /** - * Get the value of the WHO_AM_I register - * - * @returns WHO_AM_I value - */ - uint8_t getWhoAmI(); + ~FXOS8700Q_acc(); - /** - * Get X axis acceleration - * - * @returns X axis acceleration - */ - float getAccX(); + void enable(void); + void disable(void); + uint32_t sampleRate(uint32_t frequency); + uint32_t whoAmI(void); + uint32_t dataReady(void); + void getX(int16_t * x); + void getY(int16_t * y); + void getZ(int16_t * z); + void getX(float * x); + void getY(float * y); + void getZ(float * z); + void getAxis(MotionSensorDataCounts &data); + void getAxis(MotionSensorDataUnits &data); + + void readRegs(int addr, uint8_t * data, int len); + +private: + I2C m_i2c; + int m_addr; - /** - * Get Y axis acceleration - * - * @returns Y axis acceleration - */ - float getAccY(); + void writeRegs(uint8_t * data, int len); + int16_t getAccAxis(uint8_t addr); + +}; - /** - * Get Z axis acceleration - * - * @returns Z axis acceleration - */ - float getAccZ(); +class FXOS8700Q_mag : public MotionSensor +{ +public: + FXOS8700Q_mag(PinName sda, PinName scl, int addr); /** - * Get XYZ axis acceleration in G's - * - * @param res array where acceleration data will be stored - */ - void getAccAllAxis(float * res); - - /** - * Get XYZ axis magnetic readings in micro-teslas - * - * @param res array where acceleration data will be stored - */ - void getMagAllAxis(float * res); + * FXOS8700Q destructor + */ + ~FXOS8700Q_mag(); + + void enable(void); + void disable(void); + uint32_t sampleRate(uint32_t fequency); + uint32_t whoAmI(void); + uint32_t dataReady(void); + void getX(int16_t * x); + void getY(int16_t * y); + void getZ(int16_t * z); + void getX(float * x); + void getY(float * y); + void getZ(float * z); + void getAxis(MotionSensorDataCounts &data); + void getAxis(MotionSensorDataUnits &data); - /** - * Get XYZ axis acceleration, signed 16 bit values - * - * @param res array where acceleration data will be stored - */ - void AccXYZraw(int16_t * d); - - /** - * Get XYZ axis magnetometer readings, signed 16 bit values - * - * @param res array where acceleration data will be stored - */ - void MagXYZraw(int16_t * d); - - /** - * Read FXOS8700Q internal registers - * - * @param Register Address - * @param Pointer to whare results will be stored - * @param Number of registers to read - */ void readRegs(int addr, uint8_t * data, int len); private: