work nice now
Fork of LSM303DLHC by
LSM303DLHC.h@7:ddd9717cdb71, 2013-11-17 (annotated)
- Committer:
- patsteph
- Date:
- Sun Nov 17 17:58:43 2013 +0000
- Revision:
- 7:ddd9717cdb71
- Parent:
- 4:612f7d5a822d
mbed working with arduino program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bclaus | 4:612f7d5a822d | 1 | |
bclaus | 4:612f7d5a822d | 2 | #ifndef __LSM303DLHC_H |
bclaus | 4:612f7d5a822d | 3 | #define __LSM303DLHC_H |
bclaus | 3:4d9465e7e10e | 4 | #include "mbed.h" |
bclaus | 3:4d9465e7e10e | 5 | |
patsteph | 7:ddd9717cdb71 | 6 | /* --- Mag --- */ |
patsteph | 7:ddd9717cdb71 | 7 | #define CRA_REG_M 0x00 |
patsteph | 7:ddd9717cdb71 | 8 | #define CRB_REG_M 0x01 |
patsteph | 7:ddd9717cdb71 | 9 | #define MR_REG_M 0x02 |
patsteph | 7:ddd9717cdb71 | 10 | #define OUT_X_M 0x03 |
patsteph | 7:ddd9717cdb71 | 11 | #define OUT_Y_M 0x05 |
patsteph | 7:ddd9717cdb71 | 12 | #define OUT_Z_M 0x07 |
patsteph | 7:ddd9717cdb71 | 13 | /* --- Acc --- */ |
patsteph | 7:ddd9717cdb71 | 14 | #define CTRL_REG1_A 0x20 |
patsteph | 7:ddd9717cdb71 | 15 | #define CTRL_REG4_A 0x23 |
patsteph | 7:ddd9717cdb71 | 16 | #define OUT_X_A 0x28 |
patsteph | 7:ddd9717cdb71 | 17 | #define OUT_Y_A 0x2A |
patsteph | 7:ddd9717cdb71 | 18 | #define OUT_Z_A 0x2C |
bclaus | 3:4d9465e7e10e | 19 | |
bclaus | 3:4d9465e7e10e | 20 | class LSM303DLHC { |
bclaus | 3:4d9465e7e10e | 21 | public: |
bclaus | 3:4d9465e7e10e | 22 | /** Create a new interface for an LSM303DLHC |
bclaus | 3:4d9465e7e10e | 23 | * |
bclaus | 3:4d9465e7e10e | 24 | * @param sda is the pin for the I2C SDA line |
bclaus | 3:4d9465e7e10e | 25 | * @param scl is the pin for the I2C SCL line |
bclaus | 3:4d9465e7e10e | 26 | */ |
bclaus | 3:4d9465e7e10e | 27 | LSM303DLHC(PinName sda, PinName scl); |
bclaus | 3:4d9465e7e10e | 28 | |
bclaus | 3:4d9465e7e10e | 29 | |
bclaus | 3:4d9465e7e10e | 30 | /** read the raw accelerometer and compass values |
bclaus | 3:4d9465e7e10e | 31 | * |
bclaus | 3:4d9465e7e10e | 32 | * @param ax,ay,az is the accelerometer 3d vector, written by the function |
bclaus | 3:4d9465e7e10e | 33 | * @param mx,my,mz is the magnetometer 3d vector, written by the function |
bclaus | 3:4d9465e7e10e | 34 | */ |
patsteph | 7:ddd9717cdb71 | 35 | bool readcomp(float *mx, float *my, float *mz); |
patsteph | 7:ddd9717cdb71 | 36 | bool readacc(float *ax, float *ay, float *az); |
patsteph | 7:ddd9717cdb71 | 37 | bool write_reg(int addr_i2c,int addr_reg, char v); |
bclaus | 3:4d9465e7e10e | 38 | |
bclaus | 3:4d9465e7e10e | 39 | private: |
bclaus | 3:4d9465e7e10e | 40 | I2C _LSM303; |
bclaus | 3:4d9465e7e10e | 41 | |
bclaus | 3:4d9465e7e10e | 42 | |
bclaus | 3:4d9465e7e10e | 43 | float ax, ay, az; |
bclaus | 3:4d9465e7e10e | 44 | float mx, my, mz; |
bclaus | 3:4d9465e7e10e | 45 | |
patsteph | 7:ddd9717cdb71 | 46 | |
bclaus | 3:4d9465e7e10e | 47 | bool read_reg(int addr_i2c,int addr_reg, char *v); |
bclaus | 3:4d9465e7e10e | 48 | bool recv(char sad, char sub, char *buf, int length); |
bclaus | 3:4d9465e7e10e | 49 | }; |
bclaus | 4:612f7d5a822d | 50 | |
bclaus | 4:612f7d5a822d | 51 | #endif |