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

LSM303D.h

Committer:
vinajarr
Date:
2016-12-01
Revision:
1:27d47f5de82c
Parent:
0:5b930e09bd6e
Child:
2:fcd607760ee8

File content as of revision 1:27d47f5de82c:


#ifndef __LSM303D_H
#define __LSM303D_H
#include "mbed.h"



class LSM303D {
    public:
        /** Create a new interface for an LSM303D
         *
         * @param sda is the pin for the I2C SDA line
         * @param scl is the pin for the I2C SCL line
         */
        LSM303D(PinName sda, PinName scl);

  
        /** read the raw accelerometer and compass values
         *
         * @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 readA(double *ax, double *ay, double *az);

    private:
        I2C _LSM303;

         
        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);
};

#endif