/*FUNCTION**********************************************************************
 *
 * Function Name : QSPI_DRV_Deinit
 * Description   : Deinit the QSPI module, close the clock source.
 *
 *END**************************************************************************/
qspi_status_t QSPI_DRV_Deinit(uint32_t instance)
{
    QuadSPI_Type * base = g_qspiBase[instance];
    /* Disable the QSPI module */
    QSPI_HAL_DisableModule(base);
    /* If use edma, release channel*/
    if (g_qspiState[instance]->txUseDma)
    {
        EDMA_DRV_ReleaseChannel(&g_qspiState[instance]->txEdmaChn);
    }
    if (g_qspiState[instance]->rxUseDma)
    {
        EDMA_DRV_ReleaseChannel(&g_qspiState[instance]->rxEdmaChn);
    }
    g_qspiState[instance] = NULL;
    CLOCK_SYS_DisableQspiClock(instance);
    return kStatus_QSPI_Success;
}
Ejemplo n.º 2
0
/*FUNCTION**********************************************************************
 *
 * Function Name : UART_DRV_EdmaDeinit
 * Description   : This function shuts down the UART by disabling UART DMA and
 *                 the transmitter/receiver.
 *
 *END**************************************************************************/
uart_status_t UART_DRV_EdmaDeinit(uint32_t instance)
{
    assert(instance < UART_INSTANCE_COUNT);
    assert(g_uartBase[instance]);

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

    UART_Type * base = g_uartBase[instance];
    uart_edma_state_t * uartEdmaState = (uart_edma_state_t *)g_uartStatePtr[instance];

    /* Wait until the data is completely shifted out of shift register */
    while(!(UART_BRD_S1_TC(base))) { }

    UART_HAL_SetTxDmaCmd(base, false);
    UART_HAL_SetRxDmaCmd(base, false);

    /* Release DMA channel. */
    EDMA_DRV_ReleaseChannel(&uartEdmaState->edmaUartRx);
    EDMA_DRV_ReleaseChannel(&uartEdmaState->edmaUartTx);

    /* Disable TX and RX */
    UART_HAL_DisableTransmitter(base);
    UART_HAL_DisableReceiver(base);

    /* Destroy TX and RX sema. */
    OSA_SemaDestroy(&uartEdmaState->txIrqSync);
    OSA_SemaDestroy(&uartEdmaState->rxIrqSync);

    /* Cleared state pointer. */
    g_uartStatePtr[instance] = NULL;

    /* Gate UART module clock */
    CLOCK_SYS_DisableUartClock(instance);

    return kStatus_UART_Success;
}
/*FUNCTION*********************************************************************
 *
 * Function Name : FLEXIO_Camera_DRV_DeinitEdmaRx
 * Description   : Shotdowns the flexio_camera_edma device. It would release
 * the EDMA channel used in flexio_camera_edma device and stop to generate
 * DMA trigger from flexio_camera interface.
 *
 *END*************************************************************************/
flexio_camera_status_t FLEXIO_Camera_DRV_DeinitEdmaRx(
        flexio_camera_edma_handler_t *handler)
{
    uint32_t ret;

    ret = EDMA_DRV_ReleaseChannel(&handler->rxEdmaChnState);
    if (ret == kEDMAInvalidChannel)
    {
        return kStatus_FlexIO_Camera_Failed;
    }
    memset(&handler, 0, sizeof(flexio_camera_edma_handler_t)); /* Reset the handler. */

    return kStatus_FlexIO_Camera_Success;
}
Ejemplo n.º 4
0
/*FUNCTION*********************************************************************
*
* Function Name : SND_RxDeinit
* Description	: Deinit the rx soundcard.
*  The soundcard includes a controller and a codec.
*END**************************************************************************/
snd_status_t SND_RxDeinit(sound_card_t *card)
{
    audio_controller_t *ctrl = &card->controller;
    audio_codec_t *codec = &card->codec;
    audio_buffer_t *buffer = &card->buffer;
    /* Call the deinit function of the ctrl and codec. */
    ctrl->ops->Ctrl_RxDeinit(ctrl->instance);
    codec->ops->Codec_Deinit((void *)codec->handler);
#if USEDMA
    /* Deinit the dma resource */
    EDMA_DRV_StopChannel(&ctrl->dma_channel);
    EDMA_DRV_ReleaseChannel(&ctrl->dma_channel);
#endif
    OSA_SemaDestroy(&buffer->sem);
#if !SOUNDCARD_USE_STATIC_MEM
    /* Free the tx and rx buffer. */
    OSA_MemFree(buffer->buff);
#endif
    return kStatus_SND_Success;
}