2017年度の製作を開始します。

Dependencies:   BufferedSoftSerial2 SDFileSystem-RTOS mbed mbed-rtos INA226_ver1

Fork of keiki2016ver5 by albatross

Branch:
Thread-gyogetsuMPU
Revision:
34:c46f2f687c7b
Parent:
26:50272431cd1e
Child:
48:2160c28d02f8
--- a/MPU6050.h	Sat Feb 18 03:03:25 2017 +0000
+++ b/MPU6050.h	Sat Feb 18 06:45:59 2017 +0000
@@ -331,7 +331,7 @@
   writeByte(MPU6050_ADDRESS, MOT_THR, 0x80); // Set motion detection to 0.256 g; LSB = 2 mg
   writeByte(MPU6050_ADDRESS, MOT_DUR, 0x01); // Set motion detect duration to 1  ms; LSB is 1 ms @ 1 kHz rate
   
-  wait(0.1);  // Add delay for accumulation of samples
+  Thread::wait(100);  // Add delay for accumulation of samples
   
   c = readByte(MPU6050_ADDRESS, ACCEL_CONFIG);
   writeByte(MPU6050_ADDRESS, ACCEL_CONFIG, c & ~0x07); // Clear high-pass filter bits [2:0]
@@ -351,7 +351,7 @@
 void resetMPU6050() {
   // reset device
   writeByte(MPU6050_ADDRESS, PWR_MGMT_1, 0x80); // Write a one to bit 7 reset bit; toggle reset device
-  wait(0.1);
+  Thread::wait(100);
   }
   
   
@@ -360,7 +360,7 @@
  // Initialize MPU6050 device
  // wake up device
   writeByte(MPU6050_ADDRESS, PWR_MGMT_1, 0x00); // Clear sleep mode bit (6), enable all sensors 
-  wait(0.1); // Delay 100 ms for PLL to get established on x-axis gyro; should check for PLL ready interrupt  
+  Thread::wait(100); // Delay 100 ms for PLL to get established on x-axis gyro; should check for PLL ready interrupt  
 
  // get stable time source
   writeByte(MPU6050_ADDRESS, PWR_MGMT_1, 0x01);  // Set clock source to be PLL with x-axis gyroscope reference, bits 2:0 = 001
@@ -404,13 +404,13 @@
   
 // reset device, reset all registers, clear gyro and accelerometer bias registers
   writeByte(MPU6050_ADDRESS, PWR_MGMT_1, 0x80); // Write a one to bit 7 reset bit; toggle reset device
-  wait(0.1);  
+  Thread::wait(100);  
    
 // get stable time source
 // Set clock source to be PLL with x-axis gyroscope reference, bits 2:0 = 001
   writeByte(MPU6050_ADDRESS, PWR_MGMT_1, 0x01);  
   writeByte(MPU6050_ADDRESS, PWR_MGMT_2, 0x00); 
-  wait(0.2);
+  Thread::wait(200);
   
 // Configure device for bias calculation
   writeByte(MPU6050_ADDRESS, INT_ENABLE, 0x00);   // Disable all interrupts
@@ -419,7 +419,7 @@
   writeByte(MPU6050_ADDRESS, I2C_MST_CTRL, 0x00); // Disable I2C master
   writeByte(MPU6050_ADDRESS, USER_CTRL, 0x00);    // Disable FIFO and I2C master modes
   writeByte(MPU6050_ADDRESS, USER_CTRL, 0x0C);    // Reset FIFO and DMP
-  wait(0.015);
+  Thread::wait(15);
   
 // Configure MPU6050 gyro and accelerometer for bias calculation
   writeByte(MPU6050_ADDRESS, CONFIG, 0x01);      // Set low-pass filter to 188 Hz
@@ -433,7 +433,7 @@
 // Configure FIFO to capture accelerometer and gyro data for bias calculation
   writeByte(MPU6050_ADDRESS, USER_CTRL, 0x40);   // Enable FIFO  
   writeByte(MPU6050_ADDRESS, FIFO_EN, 0x78);     // Enable gyro and accelerometer sensors for FIFO  (max size 1024 bytes in MPU-6050)
-  wait(0.08); // accumulate 80 samples in 80 milliseconds = 960 bytes
+  Thread::wait(80); // accumulate 80 samples in 80 milliseconds = 960 bytes
 
 // At end of sample accumulation, turn off FIFO sensor read
   writeByte(MPU6050_ADDRESS, FIFO_EN, 0x00);        // Disable gyro and accelerometer sensors for FIFO
@@ -550,7 +550,7 @@
    // Configure the accelerometer for self-test
    writeByte(MPU6050_ADDRESS, ACCEL_CONFIG, 0xF0); // Enable self test on all three axes and set accelerometer range to +/- 8 g
    writeByte(MPU6050_ADDRESS, GYRO_CONFIG,  0xE0); // Enable self test on all three axes and set gyro range to +/- 250 degrees/s
-   wait(0.25);  // Delay a while to let the device execute the self-test
+   Thread::wait(250);  // Delay a while to let the device execute the self-test
    rawData[0] = readByte(MPU6050_ADDRESS, SELF_TEST_X); // X-axis self-test results
    rawData[1] = readByte(MPU6050_ADDRESS, SELF_TEST_Y); // Y-axis self-test results
    rawData[2] = readByte(MPU6050_ADDRESS, SELF_TEST_Z); // Z-axis self-test results