/*!
 * @brief Pass IRQ control to either the master or slave driver.
 *
 * The address of the IRQ handlers are checked to make sure they are non-zero before
 * they are called. If the IRQ handler's address is zero, it means that driver was
 * not present in the link (because the IRQ handlers are marked as weak). This would
 * actually be a program error, because it means the master/slave config for the IRQ
 * was set incorrectly.
 *
 * @param instance   Instance number of the I2C module.
 */
void I2C_DRV_IRQHandler(uint32_t instance)
{
    assert(instance < I2C_INSTANCE_COUNT);
    I2C_Type * base = g_i2cBase[instance];
    if(I2C_HAL_GetStatusFlag(base, kI2CArbitrationLost))
    {
        /* Master mode.*/
        I2C_DRV_MasterIRQHandler(instance);
    }
	else
	{
	    if (I2C_HAL_IsMaster(base))
	    {
	        /* Master mode.*/
	        I2C_DRV_MasterIRQHandler(instance);
	    }
	    else
	    {
	        /* Slave mode.*/
	        I2C_DRV_SlaveIRQHandler(instance);
	    }
	}
}
示例#2
0
/*!
 * @brief Pass IRQ control to either the master or slave driver.
 *
 * The address of the IRQ handlers are checked to make sure they are non-zero before
 * they are called. If the IRQ handler's address is zero, it means that driver was
 * not present in the link (because the IRQ handlers are marked as weak). This would
 * actually be a program error, because it means the master/slave config for the IRQ
 * was set incorrectly.
 *
 * @param instance   Instance number of the I2C module.
 */
void I2C_DRV_IRQHandler(uint32_t instance)
{
    assert(instance < I2C_INSTANCE_COUNT);
    I2C_Type * base = g_i2cBase[instance];

    if (I2C_HAL_IsMaster(base))
    {
         /** Master mode.*/
        I2C_DRV_MasterIRQHandler(instance);
    }
    else
    {
         /** Slave mode.*/
        I2C_DRV_SlaveIRQHandler(instance);
    }
}