This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IWR6843ISK-ODS: I2C driver

Part Number: IWR6843ISK-ODS
Other Parts Discussed in Thread: LP87702, MMWAVEICBOOST, IWR6843,

We use your I2C example then modify it.

We want to control LP87702 (PMIC IC) . But it seems that the program is blocked in I2C_transfer()

Can you help us check what went wrong?

By the way,  i2cSlaveAddress = 0x60<<1   or  0x60   Which one should I use?

Thanks!!

static int32_t i2cReadAddress(I2C_Handle i2cHandle, uint8_t i2cSlaveAddress, uint8_t i2cSlaveRegAddress)
{
bool retVal = false;
int32_t errCode = 0;

/* Reset the transmit and receive buffer */
memset(&rxData, 0, sizeof (rxData));

/* Scan for the slave address */
txData[0] = i2cSlaveRegAddress;
i2cTransaction.slaveAddress = i2cSlaveAddress;
i2cTransaction.writeBuf = txData;
i2cTransaction.writeCount = 1;
i2cTransaction.readBuf = rxData;
i2cTransaction.readCount = 0;

/* Writing to slave address */
retVal = I2C_transfer(i2cHandle, &i2cTransaction);

if (retVal == false)
{
errCode = -1;
}
else
{
/* Read from slave */
i2cTransaction.slaveAddress = i2cSlaveAddress;
i2cTransaction.writeBuf = txData;
i2cTransaction.writeCount = 0;
i2cTransaction.readBuf = rxData;
i2cTransaction.readCount = 4;

retVal = I2C_transfer(i2cHandle, &i2cTransaction);
if (retVal == false)
{
errCode = -1;
}
else
{
errCode = 0;
}
}
return errCode;
}

void Leedarson_I2C_INIT(void)
{
I2C_Handle i2cHandle;
I2C_Params i2cParams;
uint32_t index = 0;
uint8_t i2cSlaveAddress;
uint8_t i2cSlaveRegAddress;
int32_t retVal = 0;
uint32_t slaveFound = 0;

/* Setup the PINMUX to bring out the XWR68xx I2C pins */
Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PINF13_PADAH, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR68XX_PINF13_PADAH, SOC_XWR68XX_PINF13_PADAH_I2C_SDA);

Pinmux_Set_OverrideCtrl(SOC_XWR68XX_PING14_PADAI, PINMUX_OUTEN_RETAIN_HW_CTRL, PINMUX_INPEN_RETAIN_HW_CTRL);
Pinmux_Set_FuncSel(SOC_XWR68XX_PING14_PADAI, SOC_XWR68XX_PING14_PADAI_I2C_SCL);


/* Initializa the I2C driver */
I2C_init();
/* Initialize the I2C driver default parameters */
I2C_Params_init(&i2cParams);
i2cParams.transferMode = I2C_MODE_BLOCKING;
i2cParams.bitRate = I2C_100kHz;
/* Open the I2C driver */
i2cHandle = I2C_open(0, &i2cParams);

if (i2cHandle == NULL)
{
System_printf ("Error: I2C Driver Open failed\n");
return -1;
}


i2cSlaveAddress =0x60<<1;
i2cSlaveRegAddress = 0x00;
System_printf ("Debug: slave address: 0x%x RegAddress: 0x%x ", i2cSlaveAddress ,i2cSlaveRegAddress);
retVal = i2cReadAddress(i2cHandle, i2cSlaveAddress, i2cSlaveRegAddress);
if (retVal == -1)
{
System_printf ("Failed \n");
}
else
{
System_printf ("Passed (0x%x%x%x%x) \n", rxData[3], rxData[2], rxData[1], rxData[0]);
slaveFound++;
}

}