Library for read the sensor LSM303D by I2C and configure the sensor for measure with frecuency 100Hz and range +-2g

Dependents:   1-K64F_with_5_acel

Fork of LSM303D by brian claus

Committer:
vinajarr
Date:
Thu Jan 18 07:52:30 2018 +0000
Revision:
2:fcd607760ee8
Parent:
1:27d47f5de82c
implement interrupt

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bclaus 0:5b930e09bd6e 1
bclaus 0:5b930e09bd6e 2 #ifndef __LSM303D_H
bclaus 0:5b930e09bd6e 3 #define __LSM303D_H
bclaus 0:5b930e09bd6e 4 #include "mbed.h"
bclaus 0:5b930e09bd6e 5
bclaus 0:5b930e09bd6e 6
vinajarr 2:fcd607760ee8 7 #define addr_acc_mag 0x3C
bclaus 0:5b930e09bd6e 8
bclaus 0:5b930e09bd6e 9 class LSM303D {
bclaus 0:5b930e09bd6e 10 public:
bclaus 0:5b930e09bd6e 11 /** Create a new interface for an LSM303D
bclaus 0:5b930e09bd6e 12 *
bclaus 0:5b930e09bd6e 13 * @param sda is the pin for the I2C SDA line
bclaus 0:5b930e09bd6e 14 * @param scl is the pin for the I2C SCL line
bclaus 0:5b930e09bd6e 15 */
vinajarr 2:fcd607760ee8 16 LSM303D(I2C * puntero);
bclaus 0:5b930e09bd6e 17
bclaus 0:5b930e09bd6e 18
bclaus 0:5b930e09bd6e 19 /** read the raw accelerometer and compass values
bclaus 0:5b930e09bd6e 20 *
bclaus 0:5b930e09bd6e 21 * @param ax,ay,az is the accelerometer 3d vector, written by the function
bclaus 0:5b930e09bd6e 22 * @param mx,my,mz is the magnetometer 3d vector, written by the function
bclaus 0:5b930e09bd6e 23 */
vinajarr 2:fcd607760ee8 24 bool read(double *ax, double *ay, double *az, double *mx, double *my, double *mz);
vinajarr 1:27d47f5de82c 25 bool readA(double *ax, double *ay, double *az);
vinajarr 2:fcd607760ee8 26 bool read_reg(int addr_i2c,int addr_reg, char *v);
vinajarr 2:fcd607760ee8 27
bclaus 0:5b930e09bd6e 28 private:
vinajarr 2:fcd607760ee8 29 I2C *_LSM303;
bclaus 0:5b930e09bd6e 30
bclaus 0:5b930e09bd6e 31
bclaus 0:5b930e09bd6e 32 float ax, ay, az;
bclaus 0:5b930e09bd6e 33 float mx, my, mz;
bclaus 0:5b930e09bd6e 34
bclaus 0:5b930e09bd6e 35 bool write_reg(int addr_i2c,int addr_reg, char v);
bclaus 0:5b930e09bd6e 36 bool recv(char sad, char sub, char *buf, int length);
bclaus 0:5b930e09bd6e 37 };
bclaus 0:5b930e09bd6e 38
bclaus 0:5b930e09bd6e 39 #endif