/*FUNCTION********************************************************************** * * Function Name : LPSCI_DRV_Deinit * Description : This function shuts down the LPSCI by disabling interrupts * and the transmitter/receiver. * *END**************************************************************************/ void LPSCI_DRV_Deinit(uint32_t instance) { assert(instance < HW_UART0_INSTANCE_COUNT); uint32_t baseAddr = g_lpsciBaseAddr[instance]; lpsci_state_t * lpsciState = (lpsci_state_t *)g_lpsciStatePtr[instance]; /* Wait until the data is completely shifted out of shift register */ while(!(LPSCI_HAL_IsTxComplete(baseAddr))) { } /* Disable the interrupt */ INT_SYS_DisableIRQ(g_lpsciRxTxIrqId[instance]); /* Disable TX and RX */ LPSCI_HAL_DisableTransmitter(baseAddr); LPSCI_HAL_DisableReceiver(baseAddr); /* Destroy TX and RX sema. */ OSA_SemaDestroy(&lpsciState->txIrqSync); OSA_SemaDestroy(&lpsciState->rxIrqSync); /* Cleared state pointer. */ g_lpsciStatePtr[instance] = NULL; /* Gate LPSCI module clock */ CLOCK_SYS_DisableUartClock(instance); }
/*FUNCTION********************************************************************** * * Function Name : LPUART_DRV_Deinit * Description : This function shuts down the UART by disabling interrupts and * transmitter/receiver. * *END**************************************************************************/ lpuart_status_t LPUART_DRV_Deinit(uint32_t instance) { assert(instance < LPUART_INSTANCE_COUNT); /* Exit if current instance is already de-initialized or is gated.*/ if ((!g_lpuartStatePtr[instance]) || (!CLOCK_SYS_GetLpuartGateCmd(instance))) { return kStatus_LPUART_Fail; } LPUART_Type * base = g_lpuartBase[instance]; lpuart_state_t * lpuartState = (lpuart_state_t *)g_lpuartStatePtr[instance]; /* Wait until the data is completely shifted out of shift register */ while (!LPUART_BRD_STAT_TC(base)) {} /* Disable LPUART interrupt. */ INT_SYS_DisableIRQ(g_lpuartRxTxIrqId[instance]); /* disable tx and rx */ LPUART_HAL_SetTransmitterCmd(base, false); LPUART_HAL_SetReceiverCmd(base, false); /* Destroy TX and RX sema. */ OSA_SemaDestroy(&lpuartState->txIrqSync); OSA_SemaDestroy(&lpuartState->rxIrqSync); /* Clear our saved pointer to the state structure */ g_lpuartStatePtr[instance] = NULL; /* gate lpuart module clock */ CLOCK_SYS_DisableLpuartClock(instance); return kStatus_LPUART_Success; }
/*FUNCTION********************************************************************** * * Function Name : TSI_DRV_DeInit * Description : De initialize whole the TSI peripheral and driver to be ready * for any future use and don't load the system. * *END**************************************************************************/ tsi_status_t TSI_DRV_DeInit(uint32_t instance) { assert(instance < TSI_INSTANCE_COUNT); TSI_Type * base = g_tsiBase[instance]; tsi_state_t * tsiState = g_tsiStatePtr[instance]; if (tsiState == NULL) { return kStatus_TSI_Error; } TSI_HAL_DisableInterrupt(base); tsiState->opModesData[tsiState->opMode].enabledElectrodes = 0; TSI_HAL_ClearOutOfRangeFlag(base); TSI_HAL_ClearEndOfScanFlag(base); TSI_HAL_DisableModule(base); /* Disable the interrupt */ INT_SYS_DisableIRQ(g_tsiIrqId[instance]); /* Destroy the interrupt synch object*/ OSA_SemaDestroy(&tsiState->irqSync); /* Clear runtime structure pointer.*/ tsiState = NULL; /* Gate TSI module clock */ CLOCK_SYS_DisableTsiClock(instance); return kStatus_TSI_Success; }
/*FUNCTION********************************************************************** * * Function Name : DSPI_DRV_DmaMasterDeinit * Description : Shuts down a DSPI instance with DMA support. * * This function resets the DSPI peripheral, gates its clock, disables any used interrupts to * the core, and releases any used DMA channels. * *END**************************************************************************/ dspi_status_t DSPI_DRV_DmaMasterDeinit(uint32_t instance) { /* instantiate local variable of type dspi_dma_master_state_t and point to global state */ dspi_dma_master_state_t * dspiDmaState = (dspi_dma_master_state_t *)g_dspiStatePtr[instance]; SPI_Type *base = g_dspiBase[instance]; /* First stop transfers */ DSPI_HAL_StopTransfer(base); /* Restore the module to defaults then power it down. This also disables the DSPI module.*/ DSPI_HAL_Init(base); /* destroy the interrupt sync object.*/ OSA_SemaDestroy(&dspiDmaState->irqSync); /* disable the interrupt*/ INT_SYS_DisableIRQ(g_dspiIrqId[instance]); /* Gate the clock for DSPI.*/ CLOCK_SYS_DisableSpiClock(instance); /* Release all of the DMA channels used in the driver. DMA channel structures are stored in * the run-time state structure. */ DMA_DRV_FreeChannel(&dspiDmaState->dmaTxDataChannel); DMA_DRV_FreeChannel(&dspiDmaState->dmaTxCmdChannel); DMA_DRV_FreeChannel(&dspiDmaState->dmaRxChannel); /* Clear state pointer. */ g_dspiStatePtr[instance] = NULL; return kStatus_DSPI_Success; }
/*FUNCTION********************************************************************** * * Function Name : SPI_DRV_DmaMasterDeinit * Description : Shuts down a SPI instance with DMA support. * * This function resets the SPI peripheral, gates its clock, disables any used interrupts to * the core, and releases any used DMA channels. * *END**************************************************************************/ spi_status_t SPI_DRV_DmaMasterDeinit(uint32_t instance) { /* instantiate local variable of type spi_dma_master_state_t and point to global state */ spi_dma_master_state_t * spiDmaState = (spi_dma_master_state_t *)g_spiStatePtr[instance]; SPI_Type *base = g_spiBase[instance]; /* Restore the module to defaults which includes disabling the SPI then power it down.*/ SPI_HAL_Init(base); /* destroy the interrupt sync object.*/ OSA_SemaDestroy(&spiDmaState->irqSync); /* Disable SPI interrupt.*/ INT_SYS_DisableIRQ(g_spiIrqId[instance]); /* Gate the clock for SPI.*/ CLOCK_SYS_DisableSpiClock(instance); /* Free DMA channels */ DMA_DRV_FreeChannel(&spiDmaState->dmaReceive); DMA_DRV_FreeChannel(&spiDmaState->dmaTransmit); /* Clear state pointer. */ g_spiStatePtr[instance] = NULL; return kStatus_SPI_Success; }
/*FUNCTION********************************************************************** * * Function Name : DSPI_DRV_MasterDeinit * Description : Shutdown a DSPI instance. * This function resets the DSPI peripheral, gates its clock, and disables the interrupt to * the core. * *END**************************************************************************/ dspi_status_t DSPI_DRV_MasterDeinit(uint32_t instance) { /* instantiate local variable of type dspi_master_state_t and point to global state */ dspi_master_state_t * dspiState = (dspi_master_state_t *)g_dspiStatePtr[instance]; SPI_Type *base = g_dspiBase[instance]; /* First stop transfers */ DSPI_HAL_StopTransfer(base); /* Restore the module to defaults then power it down. This also disables the DSPI module.*/ DSPI_HAL_Init(base); /* destroy the interrupt sync object.*/ OSA_SemaDestroy(&dspiState->irqSync); /* disable the interrupt*/ INT_SYS_DisableIRQ(g_dspiIrqId[instance]); /* Gate the clock for DSPI.*/ CLOCK_SYS_DisableSpiClock(instance); /* Clear state pointer. */ g_dspiStatePtr[instance] = NULL; return kStatus_DSPI_Success; }
uint32_t OS_Sem_destroy(os_sem_handle handle) { if (kStatus_OSA_Success == OSA_SemaDestroy((semaphore_t*) handle)) { OSA_MemFree(handle); return (uint32_t) OS_SEM_OK; } else { return (uint32_t) OS_SEM_ERROR; } }
/*FUNCTION********************************************************************** * * Function Name : UART_DRV_DmaDeinit * Description : This function shuts down the UART by disabling UART DMA and * the transmitter/receiver. * *END**************************************************************************/ uart_status_t UART_DRV_DmaDeinit(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_dma_state_t * uartDmaState = (uart_dma_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. */ DMA_DRV_FreeChannel(&uartDmaState->dmaUartRx); DMA_DRV_FreeChannel(&uartDmaState->dmaUartTx); /* Disable TX and RX */ UART_HAL_DisableTransmitter(base); UART_HAL_DisableReceiver(base); /* Destroy TX and RX sema. */ OSA_SemaDestroy(&uartDmaState->txIrqSync); OSA_SemaDestroy(&uartDmaState->rxIrqSync); /* Cleared state pointer. */ g_uartStatePtr[instance] = NULL; /* Gate UART module clock */ CLOCK_SYS_DisableUartClock(instance); return kStatus_UART_Success; }
/*FUNCTION********************************************************************** * * Function Name : LPSCI_DRV_DmaDeinit * Description : This function shuts down the LPSCI by disabling LPSCI DMA and * the transmitter/receiver. * *END**************************************************************************/ lpsci_status_t LPSCI_DRV_DmaDeinit(uint32_t instance) { assert(instance < UART0_INSTANCE_COUNT); /* Exit if current instance is already de-initialized or is gated.*/ if ((!g_lpsciStatePtr[instance]) || (!CLOCK_SYS_GetLpsciGateCmd(instance))) { return kStatus_LPSCI_Fail; } UART0_Type * base = g_lpsciBase[instance]; lpsci_dma_state_t * lpsciDmaState = (lpsci_dma_state_t *)g_lpsciStatePtr[instance]; /* Wait until the data is completely shifted out of shift register */ while(!(UART0_BRD_S1_TC(base))) { } LPSCI_HAL_SetTxDmaCmd(base, false); LPSCI_HAL_SetRxDmaCmd(base, false); /* Release DMA channel. */ DMA_DRV_FreeChannel(&lpsciDmaState->dmaLpsciRx); DMA_DRV_FreeChannel(&lpsciDmaState->dmaLpsciTx); /* Disable TX and RX */ LPSCI_HAL_DisableTransmitter(base); LPSCI_HAL_DisableReceiver(base); /* Destroy TX and RX sema. */ OSA_SemaDestroy(&lpsciDmaState->txIrqSync); OSA_SemaDestroy(&lpsciDmaState->rxIrqSync); /* Cleared state pointer. */ g_lpsciStatePtr[instance] = NULL; /* Gate LPSCI module clock */ CLOCK_SYS_DisableLpsciClock(instance); return kStatus_LPSCI_Success; }
/*FUNCTION********************************************************************** * * Function Name : LPUART_DRV_EdmaDeinit * Description : This function shuts down the LPUART by disabling LPUART DMA and * the transmitter/receiver. * *END**************************************************************************/ lpuart_status_t LPUART_DRV_EdmaDeinit(uint32_t instance) { assert(instance < LPUART_INSTANCE_COUNT); /* Exit if current instance is already de-initialized or is gated.*/ if ((!g_lpuartStatePtr[instance]) || (!CLOCK_SYS_GetLpuartGateCmd(instance))) { return kStatus_LPUART_Fail; } LPUART_Type * base = g_lpuartBase[instance]; lpuart_edma_state_t * lpuartEdmaState = (lpuart_edma_state_t *)g_lpuartStatePtr[instance]; /* Wait until the data is completely shifted out of shift register */ while(!(LPUART_BRD_STAT_TC(base))) { } LPUART_HAL_SetTxDmaCmd(base, false); LPUART_HAL_SetRxDmaCmd(base, false); /* Release DMA channel. */ EDMA_DRV_ReleaseChannel(&lpuartEdmaState->edmaLpuartRx); EDMA_DRV_ReleaseChannel(&lpuartEdmaState->edmaLpuartTx); /* Disable TX and RX */ LPUART_HAL_SetTransmitterCmd(base, false); LPUART_HAL_SetReceiverCmd(base, false); /* Destroy TX and RX sema. */ OSA_SemaDestroy(&lpuartEdmaState->txIrqSync); OSA_SemaDestroy(&lpuartEdmaState->rxIrqSync); /* Cleared state pointer. */ g_lpuartStatePtr[instance] = NULL; /* Gate LPUART module clock */ CLOCK_SYS_DisableLpuartClock(instance); return kStatus_LPUART_Success; }
/*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; }
static int nio_dummy_deinit(void *dev_context, int *error) { OSA_SemaDestroy(&((NIO_DUMMY_DEV_CONTEXT_STRUCT*)dev_context)->lock); OSA_MemFree(dev_context); return 0; }
/*FUNCTION********************************************************************** * * Function Name : OSA_MsgQDestroy * Description : This function is used to destroy the message queue. * Return kStatus_OSA_Success if the message queue is destroyed successfully, * otherwise return kStatus_OSA_Error. * *END**************************************************************************/ osa_status_t OSA_MsgQDestroy(msg_queue_handler_t handler) { assert(handler); return OSA_SemaDestroy(&handler->queueSem); }