Program for testing development of BMI160 Library

Dependencies:   BMI160 max32630fthr mbed

Revision:
2:0d7433075663
Parent:
1:a3fa54415b4e
Child:
3:250503cb7cb3
--- a/main.cpp	Wed Dec 14 23:56:30 2016 +0000
+++ b/main.cpp	Tue Dec 20 00:11:10 2016 +0000
@@ -41,9 +41,6 @@
 void printRegister(BMI160 &imu, BMI160::Registers reg);
 void printBlock(BMI160 &imu, BMI160::Registers startReg, BMI160::Registers stopReg);
 
-typedef int32_t (MAX32630FTHR::*GetVoltageMbrFxPointer_t)(float *);
-void printVoltage(const char *msg, MAX32630FTHR &pegasus, GetVoltageMbrFxPointer_t mbrFxPtr);
-
 
 int main()
 {
@@ -56,66 +53,26 @@
     
     I2C i2cBus(P5_7, P6_0);
     BMI160_I2C imu(i2cBus, BMI160_I2C::I2C_ADRS_SDO_LO);
-    dumpImuRegisters(imu);
-    
-    uint32_t loopCnt = 0;
     
     imu.setSensorPowerMode(BMI160::GYRO, BMI160::NORMAL);
     wait_ms(100);
     imu.setSensorPowerMode(BMI160::ACC, BMI160::NORMAL);
-    wait_ms(5);
-    printRegister(imu, BMI160::PMU_STATUS);
+    wait_ms(100);
     
     float imuTemperature;
+    BMI160::SensorData accData;
+    //BMI160::SensorData gyroData;
     
     while(1)
     {
-        if(loopCnt == 0)
-        {
-            printf("/***********************/\n\n");
-            printVoltage(" Battery voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getBatteryVoltage);
-            printVoltage(" System  voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getSysVoltage);
-            printVoltage(" Buck1   voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getBuck1Voltage);
-            printVoltage(" Buck2   voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getBuck2Voltage);
-            printVoltage(" LDO1    voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getLDO1Voltage);
-            printVoltage(" LDO2    voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getLDO2Voltage);
-            printVoltage(" LDO3    voltage = %05.3f\n\n", pegasus, &MAX32630FTHR::getLDO3Voltage);
-            
-            if(imu.getTemperature(&imuTemperature) == BMI160::RTN_NO_ERROR)
-            {
-                printf("IMU temperature = %05.3f\n\n", imuTemperature);
-            }
-            else
-            {
-                printf("Failed to read temperature.\n\n");
-            }
-            
-            printf("/***********************/\n\n\n\n");
-        }
+        imu.getTemperature(&imuTemperature);
+        imu.getAccXYZ(accData);
         
-        wait(1.0);
-        bLED = !bLED;
-        loopCnt++;
-        if(loopCnt >= 5)
-        {
-            loopCnt = 0;
-        }
-    }
-}
-
-
-//*****************************************************************************
-void printVoltage(const char *msg, MAX32630FTHR &pegasus, GetVoltageMbrFxPointer_t mbrFxPtr)
-{
-    float volts;
-    
-    if((pegasus.*mbrFxPtr)(&volts) == 0)
-    {
-        printf(msg, volts);
-    }
-    else
-    {
-        printf("Failed to get voltage\n\n");
+        printf("Sensor Temperature = %5.3f\n", imuTemperature);
+        printf("ACC xAxis = %s%4.3f\n", "\033[K", accData.xAxis.scaled);
+        printf("ACC yAxis = %s%4.3f\n", "\033[K", accData.yAxis.scaled);
+        printf("ACC zAxis = %s%4.3f\n", "\033[K", accData.zAxis.scaled);
+        printf("\033[H");  //home
     }
 }