summaryrefslogtreecommitdiff
path: root/main.cpp
diff options
context:
space:
mode:
authorAtle H. Havsø <atle@havso.net>2014-07-31 22:36:52 +0200
committerAtle H. Havsø <atle@havso.net>2014-07-31 22:36:52 +0200
commit8dfd4d6e87a150bd3bc2f023cb4be8d84f7ef6de (patch)
treebbaff889889cf68cbe004a5d45ae7c06c4a893d2 /main.cpp
parent5b0cb66688d5621171abc9ceb7c1747736d1d6a1 (diff)
Added driver to grab accel and gyro data from the MPU-6000 chip.
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/main.cpp b/main.cpp
index 6a698bc..08072f7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -8,6 +8,7 @@
#include <usb/descriptor.h>
#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));
}
}