예제 #1
0
/* Implementation of I2C handler named in startup code. */
void I2C0_I2C1_IRQHandler(void)
{
    for(uint32_t i=0; i < I2C_INSTANCE_COUNT; i++)
    {
        if (CLOCK_SYS_GetI2cGateCmd(i))
        {
            I2C_DRV_IRQHandler(i);
        }
    }
}
예제 #2
0
/*FUNCTION**********************************************************************
 *
 * Function Name : I2C_DRV_SlaveDeinit
 * Description   : Shuts down the I2C slave driver.
 * This function will clear the control register and turn off the clock to the
 * module.
 *
 *END*/
i2c_status_t I2C_DRV_SlaveDeinit(uint32_t instance)
{
    assert(instance < I2C_INSTANCE_COUNT);

     /** Exit if current instance is already de-initialized or is gated.*/
    if ((!g_i2cStatePtr[instance]) || (!CLOCK_SYS_GetI2cGateCmd(instance)))
    {
        return kStatus_I2C_Fail;
    }

    I2C_Type * base = g_i2cBase[instance];
    i2c_slave_state_t * i2cSlaveState = (i2c_slave_state_t *)g_i2cStatePtr[instance];

#if FSL_FEATURE_I2C_HAS_START_STOP_DETECT
     /** Disable I2C START&STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStartStopIntCmd(base,false);
#endif
#if FSL_FEATURE_I2C_HAS_STOP_DETECT
     /** Disable STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStopIntCmd(base,false);
#endif

     /** Disable I2C interrupt. */
    I2C_HAL_SetIntCmd(base, false);

     /** Turn off I2C.*/
    I2C_HAL_Disable(base);

     /** Disable clock for I2C.*/
    CLOCK_SYS_DisableI2cClock(instance);

     /** Disable I2C NVIC interrupt */
    INT_SYS_DisableIRQ(g_i2cIrqId[instance]);

     /** Destroy sema. */
    OSA_EventDestroy(&i2cSlaveState->irqEvent);

     /** Clear runtime structure poniter.*/
    g_i2cStatePtr[instance] = NULL;

    return kStatus_I2C_Success;
}