From 8dfd4d6e87a150bd3bc2f023cb4be8d84f7ef6de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atle=20H=2E=20Havs=C3=B8?= Date: Thu, 31 Jul 2014 22:36:52 +0200 Subject: Added driver to grab accel and gyro data from the MPU-6000 chip. --- main.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp index 6a698bc..08072f7 100644 --- a/main.cpp +++ b/main.cpp @@ -8,6 +8,7 @@ #include #include "hmc5983.h" +#include "mpu6000.h" Pin usb_vbus = GPIOB[5]; Pin usb_dm = GPIOA[11]; @@ -58,6 +59,7 @@ class USB_TM : public USB_class_driver { USB_TM usb_tm(usb); HMC5983 magn(mag_cs, SPI2); +MPU6000 mpu(mpu_cs, SPI2); int main() { rcc_init(); @@ -96,19 +98,27 @@ int main() { flash_cs.on(); magn.init(); - float buf[3] = {0,0,0}; + mpu.init(); + float buf[9] = {0,0,0,0,0,0,0,0,0}; while(1) { usb.process(); uint8_t magn_status = magn.update(); + mpu.update(); buf[0] = magn.x; buf[1] = magn.y; buf[2] = magn.z; - + buf[3] = mpu.gyro[0]; + buf[4] = mpu.gyro[1]; + buf[5] = mpu.gyro[2]; + buf[6] = mpu.accel[0]; + buf[7] = mpu.accel[1]; + buf[8] = mpu.accel[2]; if(usb.ep_ready(1)) { usb.write(1, (uint32_t*)buf, sizeof(buf)); + //usb.write(1, (uint32_t*)mpu.gyro, sizeof(mpu.gyro)); //usb.write(1, (uint32_t*)&magn_status, sizeof(magn_status)); } } -- cgit v1.2.3