/* I2C State Monitoring Functions. 
Checks whether the last I2Cx Event is equal to the one passed as parameter.  */
ErrorStatus I2C_CheckEvent(I2C_Module *I2Cx, uint32_t I2C_EVENT)
/* I2C State Monitoring Functions. 
Checks whether the last I2Cx Event is equal to the one passed as parameter.  */
ErrorStatus I2C_CheckEvent(I2C_Module *I2Cx, uint32_t I2C_EVENT)
{
    uint32_t lastevent = 0;
    uint32_t flag1 = 0, flag2 = 0;
    ErrorStatus status = ERROR;
    assert_param(IS_I2C_PERIPH(I2Cx));
    assert_param(IS_I2C_EVT(I2C_EVENT));
    flag1 = I2Cx->STS1;
    flag2 = I2Cx->STS2;
    flag2 = flag2 << 16;
    lastevent = (flag1 | flag2) & FLAG_MASK;
    if ((lastevent & I2C_EVENT) == I2C_EVENT)
    {
        status = SUCCESS;
    }
    else
    {
        status = ERROR;
    }
    return status;
}