LSM9DS1 i2c

Dependencies:   mbed

Committer:
antimo8@alice.it
Date:
Sun Jul 08 11:20:11 2018 +0200
Revision:
3:8e50680d6b4e
add files

Who changed what in which revision?

UserRevisionLine numberNew contents of line
antimo8@alice.it 3:8e50680d6b4e 1 /*
antimo8@alice.it 3:8e50680d6b4e 2 * LSM9DS1.h
antimo8@alice.it 3:8e50680d6b4e 3 *
antimo8@alice.it 3:8e50680d6b4e 4 * Created: 05/01/2015 19:49:15
antimo8@alice.it 3:8e50680d6b4e 5 * Author: speirano
antimo8@alice.it 3:8e50680d6b4e 6 */
antimo8@alice.it 3:8e50680d6b4e 7
antimo8@alice.it 3:8e50680d6b4e 8
antimo8@alice.it 3:8e50680d6b4e 9 #ifndef LSM9DS1_SENSOR_H_
antimo8@alice.it 3:8e50680d6b4e 10 #define LSM9DS1_SENSOR_H_
antimo8@alice.it 3:8e50680d6b4e 11
antimo8@alice.it 3:8e50680d6b4e 12 //#include <Arduino.h>
antimo8@alice.it 3:8e50680d6b4e 13 #include <stdbool.h>
antimo8@alice.it 3:8e50680d6b4e 14 #include <stdint-gcc.h>
antimo8@alice.it 3:8e50680d6b4e 15
antimo8@alice.it 3:8e50680d6b4e 16
antimo8@alice.it 3:8e50680d6b4e 17 class LSM9DS1
antimo8@alice.it 3:8e50680d6b4e 18 {
antimo8@alice.it 3:8e50680d6b4e 19
antimo8@alice.it 3:8e50680d6b4e 20 private:
antimo8@alice.it 3:8e50680d6b4e 21 uint8_t _address;
antimo8@alice.it 3:8e50680d6b4e 22
antimo8@alice.it 3:8e50680d6b4e 23 public:
antimo8@alice.it 3:8e50680d6b4e 24 LSM9DS1(unsigned int address);
antimo8@alice.it 3:8e50680d6b4e 25 ~LSM9DS1() {};
antimo8@alice.it 3:8e50680d6b4e 26 virtual bool begin(void)=0;
antimo8@alice.it 3:8e50680d6b4e 27
antimo8@alice.it 3:8e50680d6b4e 28 protected:
antimo8@alice.it 3:8e50680d6b4e 29 uint8_t readRegister(uint8_t slaveAddress, uint8_t regToRead);
antimo8@alice.it 3:8e50680d6b4e 30 bool writeRegister(uint8_t slaveAddress, uint8_t regToWrite, uint8_t dataToWrite);
antimo8@alice.it 3:8e50680d6b4e 31 uint8_t addr(void) {return _address;};
antimo8@alice.it 3:8e50680d6b4e 32 int _x, _y, _z;
antimo8@alice.it 3:8e50680d6b4e 33 unsigned char _ready_reg;
antimo8@alice.it 3:8e50680d6b4e 34 unsigned char _status_reg;
antimo8@alice.it 3:8e50680d6b4e 35 bool readInternal(unsigned char high_reg, unsigned char low_reg, int *value);
antimo8@alice.it 3:8e50680d6b4e 36 };
antimo8@alice.it 3:8e50680d6b4e 37
antimo8@alice.it 3:8e50680d6b4e 38
antimo8@alice.it 3:8e50680d6b4e 39 class LSM9DS1_A : public LSM9DS1
antimo8@alice.it 3:8e50680d6b4e 40 {
antimo8@alice.it 3:8e50680d6b4e 41 public:
antimo8@alice.it 3:8e50680d6b4e 42 LSM9DS1_A(void);
antimo8@alice.it 3:8e50680d6b4e 43 bool activate(void);
antimo8@alice.it 3:8e50680d6b4e 44 bool deactivate(void);
antimo8@alice.it 3:8e50680d6b4e 45 bool begin(void);
antimo8@alice.it 3:8e50680d6b4e 46 int readX();
antimo8@alice.it 3:8e50680d6b4e 47 int readY();
antimo8@alice.it 3:8e50680d6b4e 48 int readZ();
antimo8@alice.it 3:8e50680d6b4e 49
antimo8@alice.it 3:8e50680d6b4e 50 };
antimo8@alice.it 3:8e50680d6b4e 51
antimo8@alice.it 3:8e50680d6b4e 52 class LSM9DS1_G : public LSM9DS1
antimo8@alice.it 3:8e50680d6b4e 53 {
antimo8@alice.it 3:8e50680d6b4e 54 public:
antimo8@alice.it 3:8e50680d6b4e 55 LSM9DS1_G(void);
antimo8@alice.it 3:8e50680d6b4e 56 bool activate(void);
antimo8@alice.it 3:8e50680d6b4e 57 bool begin(void);
antimo8@alice.it 3:8e50680d6b4e 58 bool deactivate(void);
antimo8@alice.it 3:8e50680d6b4e 59 int readX();
antimo8@alice.it 3:8e50680d6b4e 60 int readY();
antimo8@alice.it 3:8e50680d6b4e 61 int readZ();
antimo8@alice.it 3:8e50680d6b4e 62
antimo8@alice.it 3:8e50680d6b4e 63 };
antimo8@alice.it 3:8e50680d6b4e 64 class LSM9DS1_M : public LSM9DS1
antimo8@alice.it 3:8e50680d6b4e 65 {
antimo8@alice.it 3:8e50680d6b4e 66 public:
antimo8@alice.it 3:8e50680d6b4e 67 LSM9DS1_M(void);
antimo8@alice.it 3:8e50680d6b4e 68 bool begin(void);
antimo8@alice.it 3:8e50680d6b4e 69 bool activate(void);
antimo8@alice.it 3:8e50680d6b4e 70 bool deactivate(void);
antimo8@alice.it 3:8e50680d6b4e 71 int readX();
antimo8@alice.it 3:8e50680d6b4e 72 int readY();
antimo8@alice.it 3:8e50680d6b4e 73 int readZ();
antimo8@alice.it 3:8e50680d6b4e 74
antimo8@alice.it 3:8e50680d6b4e 75 };
antimo8@alice.it 3:8e50680d6b4e 76
antimo8@alice.it 3:8e50680d6b4e 77
antimo8@alice.it 3:8e50680d6b4e 78 extern LSM9DS1_A smeAccelerometer;
antimo8@alice.it 3:8e50680d6b4e 79 extern LSM9DS1_M smeMagnetic;
antimo8@alice.it 3:8e50680d6b4e 80 extern LSM9DS1_G smeGyroscope;
antimo8@alice.it 3:8e50680d6b4e 81
antimo8@alice.it 3:8e50680d6b4e 82 #endif /* LSM9DS1_H_ */