Hi All
I am using nRF9160 and read a value from Fuel Gauge IC (LC709203f) via I2C so I use i2c_scaneer sample
so I just a little bit confused what should I change in this I2C_Scanner sample
this is the address of fuel gauge ic read 0x16 and writes address is 0x17
I attach this code
#include <nrf9160.h>
#include <zephyr.h>
#include <misc/printk.h>
#include <i2c.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <gpio.h>
#define I2C_ACCEL_WRITE_ADDR 0x16
#define I2C_ACCEL_READ_ADDR 0x17
struct device * i2c_accel;
uint8_t WhoAmI = 0u;
//static struct device *led_port;
#ifdef CONFIG_SOC_NRF9160
#define I2C_DEV "I2C_3"
#else
#define I2C_DEV "I2C_1"
#endif
void main(void)
{
struct device *i2c_dev;
k_sleep(500);
printk("Starting i2c scanner...\n");
i2c_dev = device_get_binding(I2C_DEV);
if (!i2c_dev) {
printk("I2C: Device driver not found.\n");
return;
}
uint8_t error = 0u;
i2c_configure(i2c_dev, I2C_SPEED_SET(I2C_SPEED_STANDARD));
printk("Value of NRF_TWIM3_NS->PSEL.SCL: %d \n",NRF_TWIM3_NS->PSEL.SCL);
printk("Value of NRF_TWIM3_NS->PSEL.SDA: %d \n",NRF_TWIM3_NS->PSEL.SDA);
printk("Value of NRF_TWIM3_NS->FREQUENCY: %d \n",NRF_TWIM3_NS->FREQUENCY);
printk("26738688 -> 100k\n");
u8_t i = 0x17;
struct i2c_msg msgs[1];
u8_t dst = 1;
/* Send the address to read from */
msgs[0].buf = &dst;
msgs[0].len = 1U;
msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;
error = i2c_transfer(i2c_dev, &msgs[0], 1, i);
if (error == 0) {
printk("0x%2x FOUND\n", i);
}
else {
//printk("error %d \n", error);
}
}
it is overlay file
&i2c3 {
status = "ok";
sda-pin = < 30 >;
scl-pin = < 31 >;
clock-frequency = <I2C_BITRATE_STANDARD>;
};
prj.config CONFIG_TRUSTED_EXECUTION_NONSECURE=y #CONFIG_SERIAL=y #CONFIG_UART_INTERRUPT_DRIVEN=y CONFIG_I2C=y CONFIG_I2C_NRFX=y CONFIG_I2C_3=y CONFIG_I2C_3_NRF_TWIM=y CONFIG_NEWLIB_LIBC=y #CONFIG_LOG=y #CONFIG_I2C_LOG_LEVEL_DBG=y #CONFIG_LOG_BACKEND_UART=y #CONFIG_I2C_INIT_PRIORITY=60