@@ -37,8 +37,16 @@ static int addr = 0x68;
3737static void mpu6050_reset () {
3838 // Two byte reset. First byte register, second byte data
3939 // There are a load more options to set up the device in different ways that could be added here
40- uint8_t buf [] = {0x6B , 0x00 };
41- i2c_write_blocking (i2c_default , addr , buf , 2 , false);
40+
41+ /* Register: PWR_MGMT_1 (0x6B), Value: 0x80, Action: Reset all internal registers (of MPU6050) to default values */
42+ uint8_t res [] = {0x6B , 0x80 };
43+ i2c_write_blocking (i2c_default , addr , res , 2 , false);
44+ sleep_ms (200 ); /* Give the device time to perform the reset */
45+
46+ /* Register: PWR_MGMT_1 (0x6B), Value: 0x00, Action: Take MPU6050 out of sleep mode (which is the default state after reset) */
47+ uint8_t wake [] = {0x6B , 0x00 };
48+ i2c_write_blocking (i2c_default , addr , wake , 2 , false);
49+ sleep_ms (200 ); /* Give the device time to get out of the reset */
4250}
4351
4452static void mpu6050_read_raw (int16_t accel [3 ], int16_t gyro [3 ], int16_t * temp ) {
0 commit comments