/* Try to wait a status of specified flags.  */
int32_t I2C_WaitStatus(const CM_I2C_TypeDef *I2Cx, uint32_t u32Flag, en_flag_status_t enStatus, uint32_t u32Timeout)
/* Try to wait a status of specified flags.  */
int32_t I2C_WaitStatus(const CM_I2C_TypeDef *I2Cx, uint32_t u32Flag, en_flag_status_t enStatus, uint32_t u32Timeout)
{
    int32_t i32Ret = LL_ERR_TIMEOUT;
    uint32_t u32RegStatusBit;
    DDL_ASSERT(IS_I2C_UNIT(I2Cx));
    DDL_ASSERT(IS_I2C_FLAG(u32Flag));
    DDL_ASSERT(IS_I2C_FLAG_STD(enStatus));
    for (;;) {
        u32RegStatusBit = (READ_REG32_BIT(I2Cx->SR, u32Flag));
        if (((enStatus == SET) && (u32Flag == u32RegStatusBit)) || ((enStatus == RESET) && (0UL == u32RegStatusBit))) {
            i32Ret = LL_OK;
        }
        if ((LL_OK == i32Ret) || (0UL == u32Timeout)) {
            break;
        } else {
            u32Timeout--;
        }
    }
    return i32Ret;
}