Skip to content

Commit 84bc03e

Browse files
authored
Merge pull request #1 from akhodeir/akhodeir-patch-1
2 parents a605c65 + 222d57a commit 84bc03e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

i2c/mpu6050_i2c/mpu6050_i2c.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,16 @@ static int addr = 0x68;
3737
static 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

4452
static void mpu6050_read_raw(int16_t accel[3], int16_t gyro[3], int16_t *temp) {

0 commit comments

Comments
 (0)