summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2012-04-22 23:15:02 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2012-04-22 23:15:02 +0200
commitf3b6264feb44628f837552e78102e82d8c986bd0 (patch)
tree7dcb26f7381a373615248f2d9506109975ba8277
parent5cfc464eb5da978b0e839327d655f94df26983f5 (diff)
Enabled accelerometer and magnetometer. Outputting data over usb.
-rw-r--r--main.cpp16
1 files changed, 16 insertions, 0 deletions
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)) {