本帖最后由 sunmonth 于 2009-12-31 16:44 编辑
这是库函数:
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 )
{
status = SUCCESS;
}
else
{
status = ERROR;
}
return status;
}
将lastevent = (flag1 | flag2) & FLAG_Mask;改为:lastevent = (flag1 | flag2) & I2C_EVENT;行不行? |