/*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; }
uint32_t OS_Event_destroy(os_event_handle handle) { event_t* obj = (event_t*) handle; if (kStatus_OSA_Success == OSA_EventDestroy(obj)) { OSA_MemFree(handle); return (uint32_t) OS_EVENT_OK; } else { return (uint32_t) OS_EVENT_ERROR; } }
/*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; }
/*FUNCTION********************************************************************** * * Function Name : SPI_DRV_DmaSlaveDeinit * Description : De-initializes the device. * Clears the control register and turns off the clock to the module. * *END**************************************************************************/ spi_status_t SPI_DRV_DmaSlaveDeinit(uint32_t instance) { spi_dma_slave_state_t * spiState = (spi_dma_slave_state_t *)g_spiStatePtr[instance]; SPI_Type *base = g_spiBase[instance]; assert(instance < SPI_INSTANCE_COUNT); /* Disable SPI interrupt */ INT_SYS_DisableIRQ(g_spiIrqId[instance]); /* Reset the SPI module to its default settings including disabling SPI and its interrupts */ SPI_HAL_Init(base); #if FSL_FEATURE_SPI_16BIT_TRANSFERS if (g_spiFifoSize[instance] != 0) { SPI_HAL_SetFifoIntCmd(base, kSpiRxFifoNearFullInt, false); } /* disable transmit interrupt */ SPI_HAL_SetIntMode(base, kSpiTxEmptyInt, false); #endif /* FSL_FEATURE_SPI_16BIT_TRANSFERS */ /* Free DMA channels */ DMA_DRV_FreeChannel(&spiState->dmaReceive); DMA_DRV_FreeChannel(&spiState->dmaTransmit); /* Disable clock for SPI */ CLOCK_SYS_DisableSpiClock(instance); /* Destroy the event */ OSA_EventDestroy(&spiState->event); /* Clear state pointer */ g_spiStatePtr[instance] = NULL; return kStatus_SPI_Success; }