Modification to FXOS8700Q for use in Data Logger project
Dependencies: FXOS8700Q MotionSensor
Dependents: GPS_6Axis_DataLogger_SD_UDP
Fork of FXOS8700Q by
FXOS8700Q.h
- Committer:
- JimCarver
- Date:
- 2014-04-13
- Revision:
- 1:8b53edef272f
- Parent:
- 0:2562215f5bc0
- Child:
- 2:ab84f99086e5
- Child:
- 3:eb1271ef90bc
File content as of revision 1:8b53edef272f:
#ifndef FXOS8700Q_H #define FXOS8700Q_H #include "mbed.h" // FXOS8700CQ I2C address #define FXOS8700CQ_SLAVE_ADDR0 (0x1E<<1) // with pins SA0=0, SA1=0 #define FXOS8700CQ_SLAVE_ADDR1 (0x1D<<1) // with pins SA0=1, SA1=0 #define FXOS8700CQ_SLAVE_ADDR2 (0x1C<<1) // with pins SA0=0, SA1=1 #define FXOS8700CQ_SLAVE_ADDR3 (0x1F<<1) // with pins SA0=1, SA1=1 // FXOS8700CQ internal register addresses #define FXOS8700Q_STATUS 0x00 #define FXOS8700Q_OUT_X_MSB 0x01 #define FXOS8700Q_OUT_Y_MSB 0x03 #define FXOS8700Q_OUT_Z_MSB 0x05 #define FXOS8700Q_M_OUT_X_MSB 0x33 #define FXOS8700Q_M_OUT_Y_MSB 0x35 #define FXOS8700Q_M_OUT_Z_MSB 0x37 #define FXOS8700Q_WHOAMI 0x0D #define FXOS8700Q_XYZ_DATA_CFG 0x0E #define FXOS8700Q_CTRL_REG1 0x2A #define FXOS8700Q_M_CTRL_REG1 0x5B #define FXOS8700Q_M_CTRL_REG2 0x5C #define FXOS8700Q_WHOAMI_VAL 0xC7 class FXOS8700Q { public: /** * FXOS8700Q constructor * * @param sda SDA pin * @param sdl SCL pin * @param addr addr of the I2C peripheral */ FXOS8700Q(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(); /** * Get X axis acceleration * * @returns X axis acceleration */ float getAccX(); /** * Get Y axis acceleration * * @returns Y axis acceleration */ float getAccY(); /** * Get Z axis acceleration * * @returns Z axis acceleration */ float getAccZ(); /** * Get XYZ axis acceleration * * @param res array where acceleration data will be stored */ void getAccAllAxis(float * res); void AccXYZraw(int16_t * d); void MagXYZraw(int16_t * d); void readRegs(int addr, uint8_t * data, int len); private: I2C m_i2c; int m_addr; void writeRegs(uint8_t * data, int len); int16_t getAccAxis(uint8_t addr); }; #endif