提升出现在了:
/*---------------------------------------------------------------------------------------------------------*/
/* I2C Tx Callback Function */
/*---------------------------------------------------------------------------------------------------------*/
void I2C_MasterTx(uint32_t u32Status)
{
if (u32Status == 0x08) /* START has been transmitted */
{
I2C_SET_DATA(I2C2, g_u8DeviceAddr << 1); /* Write SLA+W to Register I2CDAT */
I2C_SET_CONTROL_REG(I2C2, I2C_CTL_SI);
}
else if (u32Status == 0x18) /* SLA+W has been transmitted and ACK has been received */
{
I2C_SET_DATA(I2C2, g_au8TxData[g_u8DataLen++]);
I2C_SET_CONTROL_REG(I2C2, I2C_CTL_SI);
}
else if (u32Status == 0x20) /* SLA+W has been transmitted and NACK has been received */
{
I2C_SET_CONTROL_REG(I2C2, I2C_CTL_STA | I2C_CTL_STO | I2C_CTL_SI);
}
else if (u32Status == 0x28) /* DATA has been transmitted and ACK has been received */
{
if (g_u8DataLen != 3)
{
I2C_SET_DATA(I2C2, g_au8TxData[g_u8DataLen++]);
I2C_SET_CONTROL_REG(I2C2, I2C_CTL_SI);
}
else
{
I2C_SET_CONTROL_REG(I2C2, I2C_CTL_STO | I2C_CTL_SI);
g_u8EndFlag = 1;
}
}
else
{
/* TO DO */
printf("I2C_MasterTx 0x%x is NOT processed\n", u32Status);
}
}
|