I am having trouble understanding where am I going wrong . I am using the devacadamy sample with the BME280 sensor and just trying to get the device id for starters .
#include <zephyr.h>
#include <device.h>
#include <devicetree.h>
#include <drivers/i2c.h>
#include <sys/printk.h>
#define BME280_ID_REG 0xD0
#define I2C0_NODE DT_NODELABEL(mysensor)
uint8_t id_read[1] ;
void main(void)
{
static const struct i2c_dt_spec dev_i2c = I2C_DT_SPEC_GET(I2C0_NODE);
if (!device_is_ready(dev_i2c.bus)) {
printk("I2C bus %s is not ready!\n\r",dev_i2c.bus->name);
return;
}
uint8_t id_write[1] = {BME280_ID_REG};
while (1)
{
i2c_write_read_dt(&dev_i2c,&id_write[0],1,&id_read[0],1);
printk("%d\n",id_read[0]);
}
}
----------------------------------------------------------------------------------------------------------
overlay file
&i2c0 {
mysensor: mysensor@76{
compatible = "bosch,bme280";
reg = < 0x76 >;
label = "MYSENSOR";
};
};