Example program for the LSM9DS1 SPI library

Dependencies:   LSM9DS1_SPI mbed

Files at this revision

API Documentation at this revision

Comitter:
Anaesthetix
Date:
Wed Oct 18 09:23:32 2017 +0000
Commit message:
First commit

Changed in this revision

LSM9DS1_SPI.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 1b12560a5651 LSM9DS1_SPI.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM9DS1_SPI.lib	Wed Oct 18 09:23:32 2017 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Anaesthetix/code/LSM9DS1_SPI/#dc98084cf6be
diff -r 000000000000 -r 1b12560a5651 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 18 09:23:32 2017 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+#include "LSM9DS1_SPI.h"
+
+SPI spi(p11, p12, p13); //mosi, miso, sclk
+lsm9ds1_spi lsm9ds1(spi, p14, p21); //spi, CS_ag, CS_m
+Serial pc(USBTX, USBRX);
+
+int main() {    
+    float temp = 0;
+    lsm9ds1.init();
+    
+    while(1) {
+        temp = lsm9ds1.read_temp();
+        lsm9ds1.read_all();
+        pc.printf("Accelerometer values: \r\n");
+        pc.printf("x:%.2f     y:%.2f        z:%.2f\r\n", lsm9ds1.accelerometer_data[0], lsm9ds1.accelerometer_data[1], lsm9ds1.accelerometer_data[2]);
+        pc.printf("Gyro values: \r\n");
+        pc.printf("x:%.2f     y:%.2f        z:%.2f\r\n", lsm9ds1.gyroscope_data[0], lsm9ds1.gyroscope_data[1], lsm9ds1.gyroscope_data[2]);
+        pc.printf("Magnetometer values: \r\n");
+        pc.printf("x:%.2f     y:%.2f        z:%.2f\r\n", lsm9ds1.magnetometer_data[0], lsm9ds1.magnetometer_data[1], lsm9ds1.magnetometer_data[2]);
+        pc.printf("And last but not least, it's %.2f degrees celcius.\r\n", temp);
+        wait(1);
+    }
+}
diff -r 000000000000 -r 1b12560a5651 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Oct 18 09:23:32 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/b484a57bc302
\ No newline at end of file