lpcware

I2C Repeated start

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by bobi-one on Mon Oct 27 06:41:33 MST 2014
I Am trying to interface an  accelerometer with LPC1549 and trying to use the LPCOpen library.
Reusing the example for periph_i2cm_interrupt. I noticed that my chip requires repeated start when reading from it.
How can i modify  SetupXferRecAndExecutein order to do such thing?

static void SetupXferRecAndExecute(uint8_t devAddr,
   uint8_t *txBuffPtr,
   uint16_t txSize,
   uint8_t *rxBuffPtr,
   uint16_t rxSize)
{
/* Setup I2C transfer record */
i2cmXferRec.slaveAddr = devAddr;
i2cmXferRec.status = 0;
i2cmXferRec.txSz = txSize;
i2cmXferRec.rxSz = rxSize;
i2cmXferRec.txBuff = txBuffPtr;
i2cmXferRec.rxBuff = rxBuffPtr;

Chip_I2CM_Xfer(LPC_I2C0, &i2cmXferRec);
/* Enable Master Interrupts */
Chip_I2C_EnableInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);
/* Wait for transfer completion */
WaitForI2cXferComplete(&i2cmXferRec);
/* Clear all Interrupts */
Chip_I2C_ClearInt(LPC_I2C0, I2C_INTENSET_MSTPENDING | I2C_INTENSET_MSTRARBLOSS | I2C_INTENSET_MSTSTSTPERR);
}

Outcomes