Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: LSM9DS1_ADVRO mbed
Revision 0:a78e30188b92, committed 2017-06-21
- Comitter:
- ChangYuHsuan
- Date:
- Wed Jun 21 07:14:46 2017 +0000
- Child:
- 1:182761476d79
- Commit message:
- LSM9DS1 SPI;
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LSM9DS1.lib Wed Jun 21 07:14:46 2017 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/AdvRobot_Team/code/LSM9DS1_ADVRO/#50166e25abb5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Jun 21 07:14:46 2017 +0000
@@ -0,0 +1,51 @@
+#include "LSM9DS1.h"
+
+void timerInterrupt();
+
+DigitalOut myled(LED1);
+Serial pc(USBTX, USBRX);
+
+Ticker timer1;
+#define PERIOD 10000 // unit: us
+
+// IMU in SPI mode
+SPI imuSpi(PC_12, PC_11, PC_10); // MOSI, MISO, SCLK
+DigitalOut agCS(PA_13);
+DigitalOut mCS(PA_14);
+LSM9DS1 imu(&imuSpi, &agCS, &mCS, 0xD6, 0x3C);
+
+float dpsZ = 0.0f, degree = 0.0f;
+
+int main() {
+
+ pc.baud(115200);
+
+ bool status = imu.begin();
+ pc.printf("connect or not: %d\n\r", status);
+
+ imu.calibrate();
+
+ timer1.attach_us(&timerInterrupt, PERIOD);
+
+ while(1) {
+
+ /*myled = 1;
+ imu.readGyro();
+
+ dpsZ = imu.calcGyro(imu.gz);
+ degree += dpsZ * 0.01f;
+ myled = 0;*/
+
+ pc.printf("gryo z: %.3f degree: %.3f \n\r", dpsZ, degree);
+
+ wait(0.01);
+ }
+}
+
+void timerInterrupt()
+{
+ imu.readGyro();
+
+ dpsZ = imu.calcGyro(imu.gz);
+ degree += dpsZ * PERIOD / 1000000.0f;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Jun 21 07:14:46 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/0f02307a0877 \ No newline at end of file