Skip to content

Commit

Permalink
boards: thingy52: add missing mpu9250 support
Browse files Browse the repository at this point in the history
The Thingy:52 has a mpu9250, a 9 axis motion sensor, on the I2C bus.
Add the necessary description on devicetree and config the mpu_pwr regulator.

Signed-off-by: Guilherme S. Salustiano <[email protected]>
  • Loading branch information
guissalustiano committed Nov 1, 2023
1 parent 18a0952 commit 7a97692
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
30 changes: 27 additions & 3 deletions boards/arm/thingy52_nrf52832/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
static const struct gpio_dt_spec ccs_gpio =
GPIO_DT_SPEC_GET(DT_NODELABEL(ccs_pwr), enable_gpios);

static int pwr_ctrl_init(void)
static int ccs_pwr_ctrl_init(void)
{
int ret;

Expand All @@ -24,7 +24,28 @@ static int pwr_ctrl_init(void)
return ret;
}

k_sleep(K_MSEC(1)); /* Wait for the rail to come up and stabilize */
k_sleep(K_MSEC(100)); /* Wait for the rail to come up and stabilize */

return 0;
}

static const struct gpio_dt_spec mpu_gpio =
GPIO_DT_SPEC_GET(DT_NODELABEL(mpu_pwr), enable_gpios);

static int mpu_pwr_ctrl_init(void)
{
int ret;

if (!gpio_is_ready_dt(&imu_gpio)) {
return -ENODEV;
}

ret = gpio_pin_configure_dt(&imu_gpio, GPIO_OUTPUT_HIGH);
if (ret < 0) {
return ret;
}

k_sleep(K_MSEC(100)); /* Wait for the rail to come up and stabilize */

return 0;
}
Expand All @@ -34,5 +55,8 @@ static int pwr_ctrl_init(void)
#error BOARD_CCS_VDD_PWR_CTRL_INIT_PRIORITY must be lower than SENSOR_INIT_PRIORITY
#endif

SYS_INIT(pwr_ctrl_init, POST_KERNEL,
SYS_INIT(ccs_pwr_ctrl_init, POST_KERNEL,
CONFIG_BOARD_CCS_VDD_PWR_CTRL_INIT_PRIORITY);

SYS_INIT(imu_pwr_ctrl_init, POST_KERNEL,
CONFIG_BOARD_CCS_VDD_PWR_CTRL_INIT_PRIORITY);
13 changes: 13 additions & 0 deletions boards/arm/thingy52_nrf52832/thingy52_nrf52832.dts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,19 @@
reset-gpios = <&sx1509b 11 GPIO_ACTIVE_LOW>;
wake-gpios = <&sx1509b 12 GPIO_ACTIVE_LOW>;
};

mpu9250: mpu9250@68 {
compatible = "invensense,mpu9250";
reg = <0x68>;
vin-supply = <&mpu_pwr>;
status = "okay";
irq-gpios = <&gpio0 06 GPIO_ACTIVE_HIGH>;
gyro-sr-div = <10>;
gyro-dlpf = <5>;
gyro-fs = <250>;
accel-fs = <2>;
accel-dlpf="5.05";
};
};

&i2c1 {
Expand Down

0 comments on commit 7a97692

Please sign in to comment.