work nice now
Fork of LSM303DLHC by
Diff: LSM303DLHC.h
- Revision:
- 7:ddd9717cdb71
- Parent:
- 4:612f7d5a822d
diff -r fcf7e9b8ce21 -r ddd9717cdb71 LSM303DLHC.h --- a/LSM303DLHC.h Tue Nov 12 18:30:37 2013 +0000 +++ b/LSM303DLHC.h Sun Nov 17 17:58:43 2013 +0000 @@ -3,7 +3,19 @@ #define __LSM303DLHC_H #include "mbed.h" - + /* --- Mag --- */ +#define CRA_REG_M 0x00 +#define CRB_REG_M 0x01 +#define MR_REG_M 0x02 +#define OUT_X_M 0x03 +#define OUT_Y_M 0x05 +#define OUT_Z_M 0x07 + /* --- Acc --- */ +#define CTRL_REG1_A 0x20 +#define CTRL_REG4_A 0x23 +#define OUT_X_A 0x28 +#define OUT_Y_A 0x2A +#define OUT_Z_A 0x2C class LSM303DLHC { public: @@ -20,8 +32,9 @@ * @param ax,ay,az is the accelerometer 3d vector, written by the function * @param mx,my,mz is the magnetometer 3d vector, written by the function */ - bool read(float *ax, float *ay, float *az, float *mx, float *my, float *mz); - + bool readcomp(float *mx, float *my, float *mz); + bool readacc(float *ax, float *ay, float *az); + bool write_reg(int addr_i2c,int addr_reg, char v); private: I2C _LSM303; @@ -30,7 +43,7 @@ float ax, ay, az; float mx, my, mz; - bool write_reg(int addr_i2c,int addr_reg, char v); + bool read_reg(int addr_i2c,int addr_reg, char *v); bool recv(char sad, char sub, char *buf, int length); };