/**
* @brief This function enables timeout function and configures DIV4 function to support long timeout.
* @param[in] i2c is the base address of I2C module.
* @param[in] u8LongTimeout Enable timeout counter input clock is divide by 4.
* @return none
*/
void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout)
{
if(u8LongTimeout)
i2c->TOUT |= I2C_TOUT_DIV4_Msk;
else
i2c->TOUT &= ~I2C_TOUT_DIV4_Msk;
i2c->TOUT |= I2C_TOUT_TOUTEN_Msk;
}
//interrupt time out
void I2C0_IRQHandler(void)
{
uint32_t u32Status;
// clear interrupt flag
I2C0->INTSTS = I2C_INTSTS_INTSTS_Msk;
u32Status = I2C_GET_STATUS(I2C0);
if (I2C_GET_TIMEOUT_FLAG(I2C0))
{
/* Clear I2C0 Timeout Flag */
I2C_ClearTimeoutFlag(I2C0);
}
else
{
if (s_I2C0HandlerFn != NULL)
s_I2C0HandlerFn(u32Status);
}
}