From f3b6264feb44628f837552e78102e82d8c986bd0 Mon Sep 17 00:00:00 2001 From: Vegard Storheil Eriksen Date: Sun, 22 Apr 2012 23:15:02 +0200 Subject: Enabled accelerometer and magnetometer. Outputting data over usb. --- main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.cpp b/main.cpp index 656e82d..2dda662 100644 --- a/main.cpp +++ b/main.cpp @@ -9,6 +9,8 @@ #include "usb.h" #include "i2c.h" +#include "lsm303dlm.h" + static Pin& led_status = PA4; static Pin& led_error = PC4; @@ -279,6 +281,9 @@ uint32_t usb_stack[1024]; Thread usb_thread(usb_stack, sizeof(usb_stack), usb_main); +LSM303DLM_A accel(I2C2); +LSM303DLM_M magn(I2C2); + int main() { // Initialize system timer. STK.LOAD = 168000000 / 8 / 1000; // 1000 Hz. @@ -304,11 +309,22 @@ int main() { usb_thread.start(); + accel.init(); + magn.init(); + while(1) { led_error.toggle(); Time::sleep(100); + accel.update(); + magn.update(); int16_t buf[] = { + accel.x, + accel.y, + accel.z, + magn.x, + magn.y, + magn.z, }; if(usb_ep_ready(1)) { -- cgit v1.2.3