diff options
author | Atle H. Havsø <atle@havso.net> | 2014-07-31 22:36:52 +0200 |
---|---|---|
committer | Atle H. Havsø <atle@havso.net> | 2014-07-31 22:36:52 +0200 |
commit | 8dfd4d6e87a150bd3bc2f023cb4be8d84f7ef6de (patch) | |
tree | bbaff889889cf68cbe004a5d45ae7c06c4a893d2 /main.cpp | |
parent | 5b0cb66688d5621171abc9ceb7c1747736d1d6a1 (diff) |
Added driver to grab accel and gyro data from the MPU-6000 chip.
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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)); } } |