/* Poll on RxNE Flag */
while ((I2C_GetFlagStatus(I2C1, I2C_FLAG_RXNE) == RESET));
/* Read a byte from the Slave */
RxBuffer[Rx_Idx] = I2C_ReceiveData(I2C1);
/* Point to the next location where the byte read will be saved */
Rx_Idx++;
/* Decrement the read bytes counter */
ByteToRead--;
}
/* Test on EV7 and clear it */
if (I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_RECEIVED) )
{
/* Read a byte */
RxBuffer[Rx_Idx] = I2C_ReceiveData(I2C1);
/* Point to the next location where the byte read will be saved */
Rx_Idx++;
/* Decrement the read bytes counter */
ByteToRead--;
}