コード例 #1
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**************************************************************************/
void I2C_DRV_SlaveDeinit(uint32_t instance)
{
    assert(instance < HW_I2C_INSTANCE_COUNT);

    uint32_t baseAddr = g_i2cBaseAddr[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(baseAddr,false);
#endif
#if FSL_FEATURE_I2C_HAS_STOP_DETECT
    /* Disable STOP signal detect interrupt in the peripheral.*/
    I2C_HAL_SetStopIntCmd(baseAddr,false);
#endif

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

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

    /* 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;
}
コード例 #2
0
ファイル: fsl_i2c_slave_driver.c プロジェクト: Btar/HEXIWEAR
/*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;
}