Hi, (Help please)
I'm being struggling to get I2C working on nRF52840-DK, I enabled IC2 and I2C_1 on prj.conf
main.c
#include <zephyr.h>
#include <device.h>
#include <drivers/gpio.h>
#include <sys/util.h>
#include <sys/printk.h>
#include <inttypes.h>
#include <drivers/i2c.h>
void main(void)
{
printk("Hello World!\n");
const struct device *i2c_dev;
uint8_t cmp_data[16];
uint8_t data[16];
int i, ret;
i2c_dev = device_get_binding("I2C_1");
if (i2c_dev == NULL)
{
printk("Error: didn't find device\n");/*Failing Here*/
return;
}
data[0] =0x29;
ret = i2c_write(i2c_dev, 0x13, &data[0], 1);
if (ret) {
printk("Error writing to FRAM! error code (%d)\n", ret);
return;
} else {
printk("Wrote 0xAE to address 0x00.\n");
}
}
prj.conf
# GPIO CONFIG_GPIO=y # I2C CONFIG_I2C=y CONFIG_I2C_1=y CONFIG_I2C_NRFX=y
Any help is appreciated