/* 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, flag2 = 0;
  ErrorStatus status = ERROR;
  assert_param(IS_I2C_ALL_PERIPH(I2Cx));
  assert_param(IS_I2C_EVENT(I2C_EVENT));
  flag1 = I2Cx->SR1;
  flag2 = I2Cx->SR2;
  flag2 = flag2 << 16;
  lastevent = (flag1 | flag2) & FLAG_MASK;
  if ((lastevent & I2C_EVENT) == I2C_EVENT)
  {
    status = SUCCESS;
  }
  else
  {
    status = ERROR;
  }
  return status;
}