compas and acc for my stuents
LSM303D_my.h@0:034b0a5fc70a, 2020-07-15 (annotated)
- Committer:
- docent
- Date:
- Wed Jul 15 07:31:33 2020 +0000
- Revision:
- 0:034b0a5fc70a
for my students
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
docent | 0:034b0a5fc70a | 1 | #ifndef __LSM303D_MY_H |
docent | 0:034b0a5fc70a | 2 | #define __LSM303D_MY_H |
docent | 0:034b0a5fc70a | 3 | |
docent | 0:034b0a5fc70a | 4 | #include "mbed.h" |
docent | 0:034b0a5fc70a | 5 | |
docent | 0:034b0a5fc70a | 6 | #define M_PI 3.14159265358979323846 |
docent | 0:034b0a5fc70a | 7 | //#define RADIAN M_PI/180.0 |
docent | 0:034b0a5fc70a | 8 | |
docent | 0:034b0a5fc70a | 9 | //---------------------ecompas/accelerometer--------------- |
docent | 0:034b0a5fc70a | 10 | #define I2C_ADDR 0x3a |
docent | 0:034b0a5fc70a | 11 | #define WHO_AM_I 0x0F //ID=0x49 |
docent | 0:034b0a5fc70a | 12 | #define CTRL1 0x20 |
docent | 0:034b0a5fc70a | 13 | #define CTRL2 0x21 |
docent | 0:034b0a5fc70a | 14 | //Linear acceleration FS (full-scale) in CTRL2: |
docent | 0:034b0a5fc70a | 15 | // ±2g - 0.061 mg/LSB default |
docent | 0:034b0a5fc70a | 16 | // ±4g 0.122 |
docent | 0:034b0a5fc70a | 17 | // ±6g 0.183 |
docent | 0:034b0a5fc70a | 18 | // ±8g 0.244 |
docent | 0:034b0a5fc70a | 19 | // ±16g 0.732 |
docent | 0:034b0a5fc70a | 20 | #define CTRL3 0x22 |
docent | 0:034b0a5fc70a | 21 | #define CTRL4 0x23 |
docent | 0:034b0a5fc70a | 22 | #define CTRL5 0x24 |
docent | 0:034b0a5fc70a | 23 | #define CTRL6 0x25 |
docent | 0:034b0a5fc70a | 24 | //Magnetic FS (full-scale) in CTRL6: |
docent | 0:034b0a5fc70a | 25 | // ±2gauss 0.080 mgauss/LSB |
docent | 0:034b0a5fc70a | 26 | // ±4gauss 0.160 |
docent | 0:034b0a5fc70a | 27 | // ±8gauss 0.320 |
docent | 0:034b0a5fc70a | 28 | // ±12gauss 0.479 |
docent | 0:034b0a5fc70a | 29 | #define CTRL7 0x26 |
docent | 0:034b0a5fc70a | 30 | |
docent | 0:034b0a5fc70a | 31 | #define STATUS_M 0x07 |
docent | 0:034b0a5fc70a | 32 | #define OUT_X_L_M 0x08 |
docent | 0:034b0a5fc70a | 33 | #define OUT_X_H_M 0x09 |
docent | 0:034b0a5fc70a | 34 | #define OUT_Y_L_M 0x0A |
docent | 0:034b0a5fc70a | 35 | #define OUT_Y_H_M 0x0B |
docent | 0:034b0a5fc70a | 36 | #define OUT_Z_L_M 0x0C |
docent | 0:034b0a5fc70a | 37 | #define OUT_Z_H_M 0x0D |
docent | 0:034b0a5fc70a | 38 | #define OUT_X_L_A 0x28 |
docent | 0:034b0a5fc70a | 39 | #define OUT_Y_L_A 0x2a |
docent | 0:034b0a5fc70a | 40 | #define OUT_Z_L_A 0x2c |
docent | 0:034b0a5fc70a | 41 | |
docent | 0:034b0a5fc70a | 42 | char EcompLSM303D_GetID(I2C *ecomp); |
docent | 0:034b0a5fc70a | 43 | void EcompLSM303D_Ini(I2C *ecomp); |
docent | 0:034b0a5fc70a | 44 | void EcompLSM303D_Get_M_Axis(I2C *ecomp,int16_t* m); |
docent | 0:034b0a5fc70a | 45 | void EcompLSM303D_Get_A_Axis(I2C *ecomp,double* a); |
docent | 0:034b0a5fc70a | 46 | uint16_t CalculateBearing(int x, int y); |
docent | 0:034b0a5fc70a | 47 | #endif |