Project tested on all Nucleo boards updated to firmware 2j23m6 with LED blinking and I2C magnetometer heading ok.

Dependencies:   L3GD20 LSM303DLH mbed-src

Files at this revision

API Documentation at this revision

Comitter:
paulcox
Date:
Wed Oct 15 15:03:11 2014 +0000
Commit message:
Tested as working on all Nucleo boards updated to firmware 2j23m6: led blinks and I2C magnetometer heading received properly

Changed in this revision

L3GD20.lib Show annotated file Show diff for this revision Revisions of this file
LSM303DLH.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-src.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/L3GD20.lib	Wed Oct 15 15:03:11 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/bclaus/code/L3GD20/#62dfce144cf7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM303DLH.lib	Wed Oct 15 15:03:11 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/paulcox/code/LSM303DLH/#9c3f240d14bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Oct 15 15:03:11 2014 +0000
@@ -0,0 +1,51 @@
+#include "mbed.h"
+#include "L3GD20.h"
+#include "LSM303DLH.h"
+//PwmOut mypwm(PWM_OUT);
+
+DigitalOut myled(LED1);
+//I2C i2c(PB_9, PB_8);
+L3GD20 gyro(PB_9, PB_8);
+LSM303DLH magacc(PB_9, PB_8);
+   
+int main() {
+    
+//    mypwm.period_ms(10);
+ //   mypwm.pulsewidth_ms(1);
+
+ 
+ //   int address = 0xd6;
+ //   int whoami = 0x0f;
+ //   int temp = 0x26;
+ //   char data[2];
+ //   char cmd[1];
+ //   cmd[0] = whoami;   
+//    i2c.frequency(100000); 
+    //magacc.frequency(100000);
+   
+    float x,y,z;
+    float hdg;
+    int accs[3];
+    vector a,m;
+    magacc.setOffset(29.50, -0.50, 4.00); // example calibration
+    magacc.setScale(1.00, 1.03, 1.21);    // example calibration  
+    
+    while(1) {
+        myled = !myled;
+        wait(0.5);
+        //i2c.write(address, cmd, 1, true);
+        //i2c.read(address, data, 1);
+        //printf("I2C data: %x \r\n", data[0]);
+        gyro.read(&x,&y,&z);
+        printf("x:%f y:%f z:%f\r\n",x,y,z);
+        //hdg = magacc.heading();
+        //printf("heading: %.2f\r\n",hdg);
+        //magacc.read(a,m);
+        //magacc.readAcc(accs);
+        //printf("Ax %d,Ay %d,Az %d\r\n",accs[0],accs[1],accs[2]);
+        //printf("Ax %f,Ay %f,Az %f\r\n",a.x,a.y,a.z);
+        hdg = magacc.heading();
+        printf("Heading: %.2f\r\n", hdg);
+        //printf("Mx %f,My %f,Mz %f\r\n",m.x,m.y,m.z);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-src.lib	Wed Oct 15 15:03:11 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/mbed-src/#098575c6d2c8