Modification to FXOS8700Q for use in Data Logger project

Dependencies:   FXOS8700Q MotionSensor

Dependents:   GPS_6Axis_DataLogger_SD_UDP

Fork of FXOS8700Q by Jim Carver

Committer:
JimCarver
Date:
Mon Apr 14 17:13:15 2014 +0000
Revision:
2:ab84f99086e5
Parent:
1:8b53edef272f
Minor feature change

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JimCarver 0:2562215f5bc0 1 #ifndef FXOS8700Q_H
JimCarver 0:2562215f5bc0 2 #define FXOS8700Q_H
JimCarver 0:2562215f5bc0 3
JimCarver 0:2562215f5bc0 4 #include "mbed.h"
JimCarver 0:2562215f5bc0 5 // FXOS8700CQ I2C address
JimCarver 1:8b53edef272f 6 #define FXOS8700CQ_SLAVE_ADDR0 (0x1E<<1) // with pins SA0=0, SA1=0
JimCarver 1:8b53edef272f 7 #define FXOS8700CQ_SLAVE_ADDR1 (0x1D<<1) // with pins SA0=1, SA1=0
JimCarver 1:8b53edef272f 8 #define FXOS8700CQ_SLAVE_ADDR2 (0x1C<<1) // with pins SA0=0, SA1=1
JimCarver 1:8b53edef272f 9 #define FXOS8700CQ_SLAVE_ADDR3 (0x1F<<1) // with pins SA0=1, SA1=1
JimCarver 0:2562215f5bc0 10 // FXOS8700CQ internal register addresses
JimCarver 1:8b53edef272f 11 #define FXOS8700Q_STATUS 0x00
JimCarver 1:8b53edef272f 12 #define FXOS8700Q_OUT_X_MSB 0x01
JimCarver 1:8b53edef272f 13 #define FXOS8700Q_OUT_Y_MSB 0x03
JimCarver 1:8b53edef272f 14 #define FXOS8700Q_OUT_Z_MSB 0x05
JimCarver 1:8b53edef272f 15 #define FXOS8700Q_M_OUT_X_MSB 0x33
JimCarver 1:8b53edef272f 16 #define FXOS8700Q_M_OUT_Y_MSB 0x35
JimCarver 1:8b53edef272f 17 #define FXOS8700Q_M_OUT_Z_MSB 0x37
JimCarver 1:8b53edef272f 18 #define FXOS8700Q_WHOAMI 0x0D
JimCarver 1:8b53edef272f 19 #define FXOS8700Q_XYZ_DATA_CFG 0x0E
JimCarver 1:8b53edef272f 20 #define FXOS8700Q_CTRL_REG1 0x2A
JimCarver 1:8b53edef272f 21 #define FXOS8700Q_M_CTRL_REG1 0x5B
JimCarver 1:8b53edef272f 22 #define FXOS8700Q_M_CTRL_REG2 0x5C
JimCarver 1:8b53edef272f 23 #define FXOS8700Q_WHOAMI_VAL 0xC7
JimCarver 0:2562215f5bc0 24
JimCarver 0:2562215f5bc0 25 class FXOS8700Q
JimCarver 0:2562215f5bc0 26 {
JimCarver 0:2562215f5bc0 27 public:
JimCarver 1:8b53edef272f 28 /**
JimCarver 1:8b53edef272f 29 * FXOS8700Q constructor
JimCarver 1:8b53edef272f 30 *
JimCarver 1:8b53edef272f 31 * @param sda SDA pin
JimCarver 1:8b53edef272f 32 * @param sdl SCL pin
JimCarver 1:8b53edef272f 33 * @param addr addr of the I2C peripheral
JimCarver 1:8b53edef272f 34 */
JimCarver 1:8b53edef272f 35
JimCarver 1:8b53edef272f 36 FXOS8700Q(PinName sda, PinName scl, int addr);
JimCarver 1:8b53edef272f 37
JimCarver 1:8b53edef272f 38 /**
JimCarver 1:8b53edef272f 39 * FXOS8700Q destructor
JimCarver 1:8b53edef272f 40 */
JimCarver 1:8b53edef272f 41 ~FXOS8700Q();
JimCarver 1:8b53edef272f 42
JimCarver 1:8b53edef272f 43 /**
JimCarver 1:8b53edef272f 44 * Get the value of the WHO_AM_I register
JimCarver 1:8b53edef272f 45 *
JimCarver 1:8b53edef272f 46 * @returns WHO_AM_I value
JimCarver 1:8b53edef272f 47 */
JimCarver 1:8b53edef272f 48 uint8_t getWhoAmI();
JimCarver 1:8b53edef272f 49
JimCarver 1:8b53edef272f 50 /**
JimCarver 1:8b53edef272f 51 * Get X axis acceleration
JimCarver 1:8b53edef272f 52 *
JimCarver 1:8b53edef272f 53 * @returns X axis acceleration
JimCarver 1:8b53edef272f 54 */
JimCarver 1:8b53edef272f 55 float getAccX();
JimCarver 0:2562215f5bc0 56
JimCarver 1:8b53edef272f 57 /**
JimCarver 1:8b53edef272f 58 * Get Y axis acceleration
JimCarver 1:8b53edef272f 59 *
JimCarver 1:8b53edef272f 60 * @returns Y axis acceleration
JimCarver 1:8b53edef272f 61 */
JimCarver 1:8b53edef272f 62 float getAccY();
JimCarver 1:8b53edef272f 63
JimCarver 1:8b53edef272f 64 /**
JimCarver 1:8b53edef272f 65 * Get Z axis acceleration
JimCarver 1:8b53edef272f 66 *
JimCarver 1:8b53edef272f 67 * @returns Z axis acceleration
JimCarver 1:8b53edef272f 68 */
JimCarver 1:8b53edef272f 69 float getAccZ();
JimCarver 0:2562215f5bc0 70
JimCarver 1:8b53edef272f 71 /**
JimCarver 1:8b53edef272f 72 * Get XYZ axis acceleration
JimCarver 1:8b53edef272f 73 *
JimCarver 1:8b53edef272f 74 * @param res array where acceleration data will be stored
JimCarver 1:8b53edef272f 75 */
JimCarver 2:ab84f99086e5 76 void enable(void);
JimCarver 1:8b53edef272f 77 void getAccAllAxis(float * res);
JimCarver 1:8b53edef272f 78 void AccXYZraw(int16_t * d);
JimCarver 1:8b53edef272f 79 void MagXYZraw(int16_t * d);
JimCarver 1:8b53edef272f 80 void readRegs(int addr, uint8_t * data, int len);
JimCarver 1:8b53edef272f 81
JimCarver 1:8b53edef272f 82 private:
JimCarver 1:8b53edef272f 83 I2C m_i2c;
JimCarver 1:8b53edef272f 84 int m_addr;
JimCarver 0:2562215f5bc0 85
JimCarver 1:8b53edef272f 86 void writeRegs(uint8_t * data, int len);
JimCarver 1:8b53edef272f 87 int16_t getAccAxis(uint8_t addr);
JimCarver 0:2562215f5bc0 88
JimCarver 0:2562215f5bc0 89 };
JimCarver 0:2562215f5bc0 90
JimCarver 0:2562215f5bc0 91 #endif