Mu kylong / MPU9250_SPI

Dependents:   MPU9250_SPI_Test MPU9250_SPI_Test ANCHOR_Navigation3 MPU9250_edit ... more

Files at this revision

API Documentation at this revision

Comitter:
kylongmu
Date:
Wed Jun 25 15:41:05 2014 +0000
Parent:
2:f274ea3bced9
Child:
4:79185409730f
Commit message:
It's function now, but Magnetometer part not tested.

Changed in this revision

MPU9250.cpp Show annotated file Show diff for this revision Revisions of this file
MPU9250.h Show annotated file Show diff for this revision Revisions of this file
--- a/MPU9250.cpp	Sat Jun 21 12:39:55 2014 +0000
+++ b/MPU9250.cpp	Wed Jun 25 15:41:05 2014 +0000
@@ -244,7 +244,7 @@
 usage: call this function to read temperature data. 
 returns the value in °C
 -----------------------------------------------------------------------------------------------*/
-float mpu9250_spi::read_temp(){
+void mpu9250_spi::read_temp(){
     uint8_t response[2];
     int16_t bit_data;
     float data;
@@ -252,9 +252,8 @@
 
     bit_data=((int16_t)response[0]<<8)|response[1];
     data=(float)bit_data;
-    data=(data/340)+36.53;
+    Temperature=(data/340)+36.53;
     deselect();
-    return data;
 }
 
 /*-----------------------------------------------------------------------------------------------
--- a/MPU9250.h	Sat Jun 21 12:39:55 2014 +0000
+++ b/MPU9250.h	Wed Jun 25 15:41:05 2014 +0000
@@ -53,12 +53,12 @@
     void ReadRegs( uint8_t ReadAddr, uint8_t *ReadBuf, unsigned int Bytes );
 
     bool init(int sample_rate_div,int low_pass_filter);
+    void read_temp();
     void read_acc();
     void read_rot();
     unsigned int set_gyro_scale(int scale);
     unsigned int set_acc_scale(int scale);
     void calib_acc();
-    float read_temp();
     void select();
     void deselect();
     unsigned int whoami();
@@ -67,6 +67,7 @@
     float gyro_divider;
     
     int calib_data[3];
+    float Temperature;
     float gyroscope_data[3];
     float accelerometer_data[3];