&i2c2 { status = "okay"; mpu6050: mpu6050@68 { compatible = "invensense,mpu6050"; reg = <0x68>; }; };
overlay
{ chosen { zephyr,sram = &sram0_s; zephyr,flash = &flash0; zephyr,code-partition = &slot0_partition; zephyr,sram-secure-partition = &sram0_s; zephyr,sram-non-secure-partition = &sram0_ns; zephyr,i2c-accel = &i2c2; zephyr,console = &uart0; }; };
dts
/* * Copyright (c) 2016 Intel Corporation * * SPDX-License-Identifier: Apache-2.0 */ #include <zephyr/kernel.h> #include <zephyr/drivers/gpio.h> #include <zephyr/drivers/i2c.h> //#include "mpu6050.h" //------------------------------------------------------------------------------------ //#define mpu DT_NODELABEL(mpu6050) #define SLEEP_TIME_MS 1000 #define mpu6050_ADDR 0x68 #define mpu_REG_WAI 0x75 int main(void) { uint8_t who_am_i = 0; const struct device *i2c_dev = DEVICE_DT_GET(DT_NODELABEL(mpu6050)); if (i2c_dev == NULL || !device_is_ready(i2c_dev)) { printf("Could not get I2C device\n"); return; } int ret = i2c_reg_read_byte(i2c_dev, mpu6050_ADDR, mpu_REG_WAI, &who_am_i); if (ret) { printf("Unable get WAI data. (err %i)\n", ret); return; } printf("Who am I: 0x%x\n", who_am_i); }
main.c
I want to use i2c between mpu6050 ot mpu9250 and nrf9160, but I can not. in console