void I2C1_EventIRQ_Handler(void)
{
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_ADDSEND)){
/* clear the ADDSEND bit */
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_ADDSEND);
}else if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_RBNE)){
/* if reception data register is not empty ,I2C1 will read a data from I2C_DATA */
*i2c_rxbuffer++ = i2c_data_receive(I2C1);
}else if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_STPDET)){
status = SUCCESS;
/* clear the STPDET bit */
i2c_enable(I2C1);
/* disable I2C1 interrupt */
i2c_interrupt_disable(I2C0, I2C_INT_ERR | I2C_INT_BUF | I2C_INT_EV);
}
}
为什么最后一行操作了I2C0,不是I2C1呢?
/*!
\brief handle I2C1 error interrupt request
\param[in] none
\param[out] none
\retval none
*/
void I2C1_ErrorIRQ_Handler(void)
{
/* no acknowledge received */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_AERR)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_AERR);
}
/* SMBus alert */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_SMBALT)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_SMBALT);
}
/* bus timeout in SMBus mode */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_SMBTO)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_SMBTO);
}
/* over-run or under-run when SCL stretch is disabled */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_OUERR)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_OUERR);
}
/* arbitration lost */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_LOSTARB)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_LOSTARB);
}
/* bus error */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_BERR)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_BERR);
}
/* CRC value doesn't match */
if(i2c_interrupt_flag_get(I2C1, I2C_INT_FLAG_PECERR)){
i2c_interrupt_flag_clear(I2C1, I2C_INT_FLAG_PECERR);
}
/* disable the error interrupt */
i2c_interrupt_disable(I2C0,I2C_INT_ERR | I2C_INT_BUF | I2C_INT_EV);
}
也是最后一行为什么操作I2C0不是1呢? |