el15mh 200929957

Dependencies:   mbed

Committer:
el15mh
Date:
Thu May 04 14:43:29 2017 +0000
Revision:
9:960dfc71c224
Documented using doxygen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el15mh 9:960dfc71c224 1 #ifndef FXOS8700CQ_H
el15mh 9:960dfc71c224 2 #define FXOS8700CQ_H
el15mh 9:960dfc71c224 3
el15mh 9:960dfc71c224 4 #include "mbed.h"
el15mh 9:960dfc71c224 5 #include "math.h"
el15mh 9:960dfc71c224 6
el15mh 9:960dfc71c224 7 // mbed API uses 8-bit addresses so need to left-shift 7-bit addresses by 1
el15mh 9:960dfc71c224 8 #define FXOS8700CQ_ADDR (0x1D << 1) // for K64F board
el15mh 9:960dfc71c224 9 // values from 13.2 datasheet
el15mh 9:960dfc71c224 10 #define FXOS8700CQ_STATUS 0x00
el15mh 9:960dfc71c224 11 #define FXOS8700CQ_WHO_AM_I 0x0D
el15mh 9:960dfc71c224 12 #define FXOS8700CQ_XYZ_DATA_CFG 0x0E
el15mh 9:960dfc71c224 13 #define FXOS8700CQ_CTRL_REG1 0x2A
el15mh 9:960dfc71c224 14 #define FXOS8700CQ_M_CTRL_REG1 0x5B
el15mh 9:960dfc71c224 15 #define FXOS8700CQ_M_CTRL_REG2 0x5C
el15mh 9:960dfc71c224 16 #define FXOS8700CQ_WHO_AM_I_VAL 0xC7
el15mh 9:960dfc71c224 17 #define FXOS8700CQ_READ_LEN 13
el15mh 9:960dfc71c224 18
el15mh 9:960dfc71c224 19 #define PI 3.14159265359f
el15mh 9:960dfc71c224 20 #define RAD2DEG 57.2957795131f
el15mh 9:960dfc71c224 21
el15mh 9:960dfc71c224 22
el15mh 9:960dfc71c224 23 struct Data {
el15mh 9:960dfc71c224 24 float ax;
el15mh 9:960dfc71c224 25 float ay;
el15mh 9:960dfc71c224 26 float az;
el15mh 9:960dfc71c224 27 float mx;
el15mh 9:960dfc71c224 28 float my;
el15mh 9:960dfc71c224 29 float mz;
el15mh 9:960dfc71c224 30 };
el15mh 9:960dfc71c224 31
el15mh 9:960dfc71c224 32 class FXOS8700CQ
el15mh 9:960dfc71c224 33 {
el15mh 9:960dfc71c224 34
el15mh 9:960dfc71c224 35 public:
el15mh 9:960dfc71c224 36 FXOS8700CQ(PinName sda, PinName scl);
el15mh 9:960dfc71c224 37 ~FXOS8700CQ();
el15mh 9:960dfc71c224 38 void init();
el15mh 9:960dfc71c224 39 Data get_values();
el15mh 9:960dfc71c224 40
el15mh 9:960dfc71c224 41 float getPitchAngle();
el15mh 9:960dfc71c224 42 float getRollAngle();
el15mh 9:960dfc71c224 43
el15mh 9:960dfc71c224 44
el15mh 9:960dfc71c224 45 private:
el15mh 9:960dfc71c224 46 I2C* i2c;
el15mh 9:960dfc71c224 47
el15mh 9:960dfc71c224 48 void send_byte_to_reg(char byte,char reg);
el15mh 9:960dfc71c224 49 char read_byte_from_reg(char reg);
el15mh 9:960dfc71c224 50 void read_bytes_from_reg(char reg,int number_of_bytes,char bytes[]);
el15mh 9:960dfc71c224 51 };
el15mh 9:960dfc71c224 52
el15mh 9:960dfc71c224 53 #endif /* FXOS8700_H_ */