Project tested on all Nucleo boards updated to firmware 2j23m6 with LED blinking and I2C magnetometer heading ok.
Dependencies: L3GD20 LSM303DLH mbed-src
Revision 0:234c3e7cbd28, committed 2014-10-15
- 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
diff -r 000000000000 -r 234c3e7cbd28 L3GD20.lib --- /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
diff -r 000000000000 -r 234c3e7cbd28 LSM303DLH.lib --- /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
diff -r 000000000000 -r 234c3e7cbd28 main.cpp --- /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); + } +}
diff -r 000000000000 -r 234c3e7cbd28 mbed-src.lib --- /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