i2c trial - does'nt work
Dependencies: ACD_ePaper aconno_I2C aconno_bsp mbed
Fork of acd52832_LSM9DS1 by
LSM9DS1/LSM9DS1.h@1:e97c56fb9629, 2018-02-14 (annotated)
- Committer:
- med2017
- Date:
- Wed Feb 14 21:16:43 2018 +0000
- Revision:
- 1:e97c56fb9629
testing
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
med2017 | 1:e97c56fb9629 | 1 | |
med2017 | 1:e97c56fb9629 | 2 | |
med2017 | 1:e97c56fb9629 | 3 | #ifndef LSM9DS1_H |
med2017 | 1:e97c56fb9629 | 4 | #define LSM9DS1_H |
med2017 | 1:e97c56fb9629 | 5 | |
med2017 | 1:e97c56fb9629 | 6 | #include "mbed.h" |
med2017 | 1:e97c56fb9629 | 7 | #include "aconno_i2c.h" |
med2017 | 1:e97c56fb9629 | 8 | #include "LSM9DS1_regs.h" |
med2017 | 1:e97c56fb9629 | 9 | #include "LSM9DS1_defVals.h" |
med2017 | 1:e97c56fb9629 | 10 | |
med2017 | 1:e97c56fb9629 | 11 | |
med2017 | 1:e97c56fb9629 | 12 | //TO DO: once i2c sucessfully works come back to this for fine tuning data |
med2017 | 1:e97c56fb9629 | 13 | |
med2017 | 1:e97c56fb9629 | 14 | |
med2017 | 1:e97c56fb9629 | 15 | |
med2017 | 1:e97c56fb9629 | 16 | enum Mode{ |
med2017 | 1:e97c56fb9629 | 17 | HIGH_RES = 0, |
med2017 | 1:e97c56fb9629 | 18 | NORMAL, |
med2017 | 1:e97c56fb9629 | 19 | LOW_POWER, |
med2017 | 1:e97c56fb9629 | 20 | }; |
med2017 | 1:e97c56fb9629 | 21 | |
med2017 | 1:e97c56fb9629 | 22 | enum Axis{ |
med2017 | 1:e97c56fb9629 | 23 | X_axis = 0x01, |
med2017 | 1:e97c56fb9629 | 24 | Y_axis = 0x02, |
med2017 | 1:e97c56fb9629 | 25 | Z_axis = 0x04, |
med2017 | 1:e97c56fb9629 | 26 | }; |
med2017 | 1:e97c56fb9629 | 27 | |
med2017 | 1:e97c56fb9629 | 28 | enum Odr{ |
med2017 | 1:e97c56fb9629 | 29 | PowerDown = 0x00, |
med2017 | 1:e97c56fb9629 | 30 | ODR_1Hz = 0x01, |
med2017 | 1:e97c56fb9629 | 31 | ODR_10Hz = 0x02, |
med2017 | 1:e97c56fb9629 | 32 | ODR_25Hz = 0x03, |
med2017 | 1:e97c56fb9629 | 33 | ODR_50Hz = 0x04, |
med2017 | 1:e97c56fb9629 | 34 | ODR_100Hz = 0x05, |
med2017 | 1:e97c56fb9629 | 35 | ODR_200Hz = 0x06, |
med2017 | 1:e97c56fb9629 | 36 | ODR_400Hz = 0x07, |
med2017 | 1:e97c56fb9629 | 37 | ODR_1620Hz = 0x08, |
med2017 | 1:e97c56fb9629 | 38 | ODR_Max = 0x09, // HighRes/Normal -> 1.344kHz, LowPower -> 5.376kHz |
med2017 | 1:e97c56fb9629 | 39 | }; |
med2017 | 1:e97c56fb9629 | 40 | |
med2017 | 1:e97c56fb9629 | 41 | enum Scale{ |
med2017 | 1:e97c56fb9629 | 42 | _2g = 0x00, |
med2017 | 1:e97c56fb9629 | 43 | _4g = 0x01, |
med2017 | 1:e97c56fb9629 | 44 | _8g = 0x02, |
med2017 | 1:e97c56fb9629 | 45 | _16g = 0x03, |
med2017 | 1:e97c56fb9629 | 46 | }; |
med2017 | 1:e97c56fb9629 | 47 | |
med2017 | 1:e97c56fb9629 | 48 | |
med2017 | 1:e97c56fb9629 | 49 | class LSM9DS1{ |
med2017 | 1:e97c56fb9629 | 50 | public: |
med2017 | 1:e97c56fb9629 | 51 | LSM9DS1(I2C *i2c_, char address); |
med2017 | 1:e97c56fb9629 | 52 | uint8_t whoIAm(); |
med2017 | 1:e97c56fb9629 | 53 | uint8_t setMode(Mode mode); |
med2017 | 1:e97c56fb9629 | 54 | uint8_t enableAxes(Axis axis); |
med2017 | 1:e97c56fb9629 | 55 | uint8_t disableAxes(Axis axis); |
med2017 | 1:e97c56fb9629 | 56 | int16_t readXAxis(); |
med2017 | 1:e97c56fb9629 | 57 | int16_t readYAxis(); |
med2017 | 1:e97c56fb9629 | 58 | int16_t readZAxis(); |
med2017 | 1:e97c56fb9629 | 59 | uint8_t setODR(Odr odr); |
med2017 | 1:e97c56fb9629 | 60 | uint8_t setScale(Scale scale); |
med2017 | 1:e97c56fb9629 | 61 | uint8_t int1Setup(uint8_t setup); |
med2017 | 1:e97c56fb9629 | 62 | uint8_t int1Latch(uint8_t enable); |
med2017 | 1:e97c56fb9629 | 63 | uint8_t int1Duration(uint8_t duration); |
med2017 | 1:e97c56fb9629 | 64 | uint8_t int1Threshold(uint8_t threshold); |
med2017 | 1:e97c56fb9629 | 65 | uint8_t int1Config(uint8_t config); |
med2017 | 1:e97c56fb9629 | 66 | void clearIntFlag(); |
med2017 | 1:e97c56fb9629 | 67 | |
med2017 | 1:e97c56fb9629 | 68 | /* |
med2017 | 1:e97c56fb9629 | 69 | public: |
med2017 | 1:e97c56fb9629 | 70 | LSM9DS1(I2C i2c); |
med2017 | 1:e97c56fb9629 | 71 | void startMag(void); |
med2017 | 1:e97c56fb9629 | 72 | void readMag(int16_t *results); |
med2017 | 1:e97c56fb9629 | 73 | void startAcc(void); |
med2017 | 1:e97c56fb9629 | 74 | void readAcc(int16_t *results); |
med2017 | 1:e97c56fb9629 | 75 | void startGyro(void); |
med2017 | 1:e97c56fb9629 | 76 | void readGyro(int16_t *results); |
med2017 | 1:e97c56fb9629 | 77 | */ |
med2017 | 1:e97c56fb9629 | 78 | private: |
med2017 | 1:e97c56fb9629 | 79 | aconno_i2c i2c; |
med2017 | 1:e97c56fb9629 | 80 | |
med2017 | 1:e97c56fb9629 | 81 | }; |
med2017 | 1:e97c56fb9629 | 82 | |
med2017 | 1:e97c56fb9629 | 83 | |
med2017 | 1:e97c56fb9629 | 84 | #endif |
med2017 | 1:e97c56fb9629 | 85 |