Hello George,
You must use (call) the I2C2_SlaveReceiveBlock() before the data are being received, i.e. this method sets pointer to your buffer for storing data. See the following example the is available on the Typical Usage page of the I2C_LDD component help.
Please note, that the data are received in the buffer when the I2C3_OnSlaveBlockReceived() event is invoked.
volatile bool DataReceivedFlg = FALSE;
volatile bool DataTransmittedFlg = FALSE;
uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U}; /* Initialization of output data buffer */
uint8_t InpData[4];
LDD_TError Error;
LDD_TDeviceData *MyI2CPtr;
void main(void)
{
. . .
MyI2CPtr = I2C2_Init(NULL); /* Initialization of I2C2 component */
Error = I2C2_SlaveSendBlock(MyI2CPtr, OutData, 4U); /* Send OutData (4bytes) to I2C BUS */
while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */
}
DataTransmittedFlg = FALSE;
Error = I2C2_SlaveReceiveBlock(MyI2CPtr, InpData, 4U); /* Receive InpData (16bytes) from I2C BUS */
while (!DataReceivedFlg) { /* Wait until InpData are received */
}
DataReceivedFlg = FALSE;
for(;;) {}
}
Content of Event.c:
extern volatile bool DataTransmittedFlg;
void I2C3_OnSlaveBlockSent(LDD_TUserData *UserDataPtr)
{
DataTransmittedFlg = TRUE; /* Set DataTransmittedFlg flag */
}
extern volatile bool DataReceivedFlg;
void I2C3_OnSlaveBlockReceived(LDD_TUserData *UserDataPtr)
{
DataReceivedFlg = TRUE; /* Set DataReceivedFlg flag */
}Best Regards,
Marek Neuzil