Hello Marek,
Here's the PE typical usage example:
volatile bool DataReceivedFlg = FALSE;
volatile bool DataTransmittedFlg = FALSE;
uint8_t OutData[4] = {0x00U, 0x01U, 0x02U, 0x03U}; /* Initialization of output data buffer */
uint8_t InpData[16];
LDD_TError Error;
LDD_TDeviceData *MyI2CPtr;
void main(void) {
MyI2CPtr = I2C2_Init(NULL); /* Initialization of I2C2 component */ /* Configure I2C BUS device(e.g. RTC) - Write Operation */
Error = I2C2_MasterSendBlock(MyI2CPtr, OutData, 4U, LDD_I2C_SEND_STOP);
while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */
I2C2_Main(MyI2CPtr);
}
DataTransmittedFlg = FALSE; /* Read configuration of I2C BUS device(e.g. RTC) - Read Operation */
OutData[0] = 0x00U; /* Initialization of OutData buffer */
Error = I2C2_MasterSendBlock(MyI2CPtr, OutData, 1U, LDD_I2C_NO_SEND_STOP);
while (!DataTransmittedFlg) { /* Wait until OutData are transmitted */
I2C2_Main(MyI2CPtr);
}
DataTransmittedFlg = FALSE;
Error = I2C2_MasterReceiveBlock(MyI2CPtr, InpData, 16U, LDD_I2C_SEND_STOP);
while (!DataReceivedFlg) { /* Wait until InpData are received */
I2C2_Main(MyI2CPtr);
}
DataReceivedFlg = FALSE;
for(;;) {}
}
The problem is DataTransmittedFlg is not changed to true by Events (I2C interrupts disabled) nor I2C_Main function. So the execution is stuck at the first while()
regards,
gaston