I have a BME688 connected to a NRF52840DK and I cannot get a working I2C communication using Zephyr. Below are all sources:
app.overlay
&pinctrl { i2c0_default: i2c0_default { group1 { psels = <NRF_PSEL(TWIM_SDA, 1, 10)>, <NRF_PSEL(TWIM_SCL, 1, 11)>; }; }; i2c0_sleep: i2c0_sleep { group1 { psels = <NRF_PSEL(TWIM_SDA, 1, 10)>, <NRF_PSEL(TWIM_SCL, 1, 11)>; low-power-enable; }; }; }; &arduino_i2c { bme688: bme688@76{ status = "okay"; reg = < 0x76 >; }; };
main.c
#include <stdlib.h>
#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/i2c.h>
#define BME68X_REG_SOFT_RESET UINT8_C(0xe0)
#define BME68X_SOFT_RESET_CMD UINT8_C(0xb6)
static const struct i2c_dt_spec dev_i2c0 = I2C_DT_SPEC_GET(DT_NODELABEL(bme688));
int main()
{
if (!device_is_ready(dev_i2c0.bus)) {
printk("I2C bus %s is not ready.\n", dev_i2c0.bus->name);
return EXIT_FAILURE;
}
int ret = i2c_reg_write_byte_dt(&dev_i2c0, BME68X_REG_SOFT_RESET, BME68X_SOFT_RESET_CMD);
printk("i2c_reg_write_byte_dt: %d\n", ret);
return EXIT_SUCCESS;
}
prj.conf
CONFIG_MAIN_STACK_SIZE=32768
CONFIG_GPIO=y
CONFIG_LOG=y
CONFIG_LOG_BUFFER_SIZE=32768
CONFIG_LOG_MODE_IMMEDIATE=y
CONFIG_I2C=y
I was wondering, what am I doing wrong.