/* Checks whether the last I2Cx Event is equal to the one passed as parameter.  */
ErrorStatus I2C_CheckEvent(I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
/* Checks whether the last I2Cx Event is equal to the one passed as parameter.  */
ErrorStatus I2C_CheckEvent(I2C_TypeDef *I2Cx, uint32_t I2C_EVENT)
{
  uint32_t lastevent = 0;
  uint32_t flag1 = 0;
  ErrorStatus status = ERROR;
  assert_param(IS_I2C_ALL_PERIPH(I2Cx));
  assert_param(IS_I2C_EVENT(I2C_EVENT));
  if((I2C_EVENT == I2C_EVENT_RX_FULL)&&(I2C_CMD_DIR==0))
  {
    I2C1->IC_DATA_CMD = CMD_READ;
    I2C_CMD_DIR = 1;
  }
  flag1 = I2Cx->IC_RAW_INTR_STAT;
  lastevent = (flag1 ) & I2C_EVENT;
  if (lastevent == I2C_EVENT )
  {
    status = SUCCESS;
  }
  else
  {
    status = ERROR;
  }
  return status;
}