walid chebbi
/
LSM9DS1_works_copy
test
main.cpp@0:e8167f37725c, 2015-10-26 (annotated)
- Committer:
- jmar7
- Date:
- Mon Oct 26 14:55:43 2015 +0000
- Revision:
- 0:e8167f37725c
- Child:
- 3:35ac8fecbd90
First Library Commit;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jmar7 | 0:e8167f37725c | 1 | #include "LSM9DS1.h" |
jmar7 | 0:e8167f37725c | 2 | |
jmar7 | 0:e8167f37725c | 3 | DigitalOut myled(LED1); |
jmar7 | 0:e8167f37725c | 4 | Serial pc(USBTX, USBRX); |
jmar7 | 0:e8167f37725c | 5 | |
jmar7 | 0:e8167f37725c | 6 | int main() { |
jmar7 | 0:e8167f37725c | 7 | //LSM9DS1 lol(p9, p10, 0x6B, 0x1E); |
jmar7 | 0:e8167f37725c | 8 | LSM9DS1 lol(p9, p10, 0xD6, 0x3C); |
jmar7 | 0:e8167f37725c | 9 | lol.begin(); |
jmar7 | 0:e8167f37725c | 10 | if (!lol.begin()) { |
jmar7 | 0:e8167f37725c | 11 | pc.printf("Failed to communicate with LSM9DS1.\n"); |
jmar7 | 0:e8167f37725c | 12 | } |
jmar7 | 0:e8167f37725c | 13 | lol.calibrate(); |
jmar7 | 0:e8167f37725c | 14 | while(1) { |
jmar7 | 0:e8167f37725c | 15 | lol.readTemp(); |
jmar7 | 0:e8167f37725c | 16 | lol.readMag(); |
jmar7 | 0:e8167f37725c | 17 | lol.readGyro(); |
jmar7 | 0:e8167f37725c | 18 | |
jmar7 | 0:e8167f37725c | 19 | //pc.printf("%d %d %d %d %d %d %d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz), lol.ax, lol.ay, lol.az, lol.mx, lol.my, lol.mz); |
jmar7 | 0:e8167f37725c | 20 | //pc.printf("%d %d %d\n\r", lol.calcGyro(lol.gx), lol.calcGyro(lol.gy), lol.calcGyro(lol.gz)); |
jmar7 | 0:e8167f37725c | 21 | pc.printf("gyro: %d %d %d\n\r", lol.gx, lol.gy, lol.gz); |
jmar7 | 0:e8167f37725c | 22 | pc.printf("accel: %d %d %d\n\r", lol.ax, lol.ay, lol.az); |
jmar7 | 0:e8167f37725c | 23 | pc.printf("mag: %d %d %d\n\n\r", lol.mx, lol.my, lol.mz); |
jmar7 | 0:e8167f37725c | 24 | myled = 1; |
jmar7 | 0:e8167f37725c | 25 | wait(2); |
jmar7 | 0:e8167f37725c | 26 | myled = 0; |
jmar7 | 0:e8167f37725c | 27 | wait(2); |
jmar7 | 0:e8167f37725c | 28 | } |
jmar7 | 0:e8167f37725c | 29 | } |