I need to use nRF5240 device to control LED driver IC through I2C interface. And I also need to use I2C 10-bit addressing. How to enable I2C 10-bit addressing on ncs v2.4.2?
I need to use nRF5240 device to control LED driver IC through I2C interface. And I also need to use I2C 10-bit addressing. How to enable I2C 10-bit addressing on ncs v2.4.2?
Thanks for your reply! I can read/write registers now.
static int _lp5861ReadReg(uint16_t regAddr, uint8_t *regVal) { printk("tca6424aReadReg(regAddr=0x%x)\n", regAddr); const uint16_t devAddr = LP5861_CHIP_ADDRESS | _lp5861GetRegAddrHigh(regAddr); const uint8_t startAddr = _lp5861GetRegAddrLow(regAddr); printk("devAddr=0x%x, startAddr=0x%x\n", devAddr, startAddr); uint8_t rbuf[2]; const int ret = i2c_burst_read(_gI2cDev, devAddr, startAddr, rbuf, sizeof(rbuf)); if (ret < 0) { printk("i2c_burst_read(0x%x) failed, ret=%d\n", regAddr, ret); return ERROR_I2C_READ_FAIL; } printk("rbuf[0]=0x%x, rbuf[1]=0x%x\n", rbuf[0], rbuf[1]); *regVal = rbuf[0]; return 0; } static int _lp5861WriteReg(uint16_t regAddr, uint8_t regVal) { printk("tca6424aWriteReg(regAddr=0x%x, regVal0x%x)\n", regAddr, regVal); const uint16_t devAddr = LP5861_CHIP_ADDRESS | _lp5861GetRegAddrHigh(regAddr); const uint8_t startAddr = _lp5861GetRegAddrLow(regAddr); printk("_lp5861GetRegAddrHigh(regAddr)=0x%x\n", _lp5861GetRegAddrHigh(regAddr)); printk("devAddr=0x%x, startAddr=0x%x\n", devAddr, startAddr); const uint8_t wbuf[2] = { regVal, 0x00}; const int ret = i2c_burst_write(_gI2cDev, devAddr, startAddr, wbuf, sizeof(wbuf)); if (ret < 0) { printk("i2c_burst_write(0x%x) failed, ret=%d\n", regAddr, ret); return ERROR_I2C_WRITE_FAIL; } return 0; }