Hi, I am new to nordic and zephyr and I have a sensor (Melexis - MLX90641) and I would like to test it on a custom board using nRF9160.. I add the sensor into the dts files and I have done all the necessary configuration including I2C and I was able to bind it. now I would like to use the I2C functions to read and write .. but the sensor library is written to work with Mbed OS not zephyr. how can I modify the below functions to work with Zephyr?
I mean the equivalent functions for (i2c.stop , i2c.write, i2c.frequency, i2c.read) for the below example ?
int MLX90641_I2CWrite(uint8_t slaveAddr, uint16_t writeAddress, uint16_t data)
{
uint8_t sa;
int ack = 0;
char cmd[4] = {0,0,0,0};
static uint16_t dataCheck;
sa = (slaveAddr << 1);
cmd[0] = writeAddress >> 8;
cmd[1] = writeAddress & 0x00FF;
cmd[2] = data >> 8;
cmd[3] = data & 0x00FF;
i2c.stop();
wait_us(5);
ack = i2c.write(sa, cmd, 4, 0);
if (ack != 0x00)
{
return -1;
}
i2c.stop();
MLX90641_I2CRead(slaveAddr,writeAddress,1, &dataCheck);
if ( dataCheck != data)
{
return -2;
}
return 0;
}
Melexis MLX90641 library: https://github.com/melexis/mlx90641-library