void stop_edma_loop_putsem(void *parameter, edma_chn_status_t status) { /* Stop eDMA channel transfers. */ EDMA_DRV_StopChannel((edma_chn_state_t *)parameter); /* Increase semaphore to indicate an eDMA channel has completed transfer. */ mico_rtos_set_semaphore( &spi_transfer_finished_semaphore ); }
void stop_rx_edma(void *parameter, edma_chn_status_t status) { spi_dma_sem = 1; /* Stop eDMA channel transfers. */ EDMA_DRV_StopChannel((edma_chn_state_t *)parameter); }
void stop_edma_loop(void *parameter, edma_chn_status_t status) { /* Increase semaphore to indicate an eDMA channel has completed transfer. */ OSA_SemaPost(&g_statusSem); /* Stop eDMA channel transfers. */ EDMA_DRV_StopChannel((edma_chn_state_t *)parameter); }
void disable_edma_loop(edma_loop_setup_t *loopSetup) { EDMA_DRV_StopChannel(loopSetup->dmaCh); #if (defined(__ICCARM__) || defined(__CC_ARM)) free_align(loopSetup->dmaChStcd); #elif defined(__GNUC__) //OSA_MemFree(loopSetup->dmaChStcd); #endif print_edma_ch_erq(DMA0, loopSetup->dmaChanNum); //OSA_MemFree(loopSetup); }
/*FUNCTION********************************************************************* * * Function Name : FLEXIO_Camera_DRV_ResetEdmaRx * Description : Reset the EDMA transfer loop's destination address and loop * counter, which means the EDMA transfer would be reset to the initialized state. * This API would be called when VSYNC event happenned to make sure the data * from camera would not be misplaced. However, if there is other application * configuration can do the same thing, this API would not be necessary. * *END*************************************************************************/ flexio_camera_status_t FLEXIO_Camera_DRV_ResetEdmaRx( flexio_camera_edma_handler_t *handler) { uint32_t ret; edma_transfer_config_t rxEdmeConfigStruct; edma_software_tcd_t rxEdmaChnStcd[2]; flexio_camera_dev_t *flexioCameraHwConfigPtr = &(handler->flexioCameraHwConfig); EDMA_DRV_StopChannel(&handler->rxEdmaChnState); /* 3. Configure the channel. */ rxEdmeConfigStruct.srcAddr = FLEXIO_Camera_HAL_GetRxBufferAddr(flexioCameraHwConfigPtr); rxEdmeConfigStruct.destAddr = handler->userBufAddr; rxEdmeConfigStruct.srcTransferSize = kEDMATransferSize_32Bytes; rxEdmeConfigStruct.destTransferSize = kEDMATransferSize_32Bytes; rxEdmeConfigStruct.srcOffset = 0; rxEdmeConfigStruct.destOffset = 4U * (flexioCameraHwConfigPtr->shifterCount); /* 4 byte per shifter, typically 32 byte for 8 shifters. */ rxEdmeConfigStruct.srcLastAddrAdjust = 0; rxEdmeConfigStruct.destLastAddrAdjust = -(int32_t)(handler->userBufLenByte); rxEdmeConfigStruct.srcModulo = kEDMAModuloDisable; rxEdmeConfigStruct.destModulo = kEDMAModuloDisable; rxEdmeConfigStruct.minorLoopCount = rxEdmeConfigStruct.destOffset; /* the minor loop would read all the data in shifters one time per trigger. */ rxEdmeConfigStruct.majorLoopCount = (handler->userBufLenByte)/(rxEdmeConfigStruct.minorLoopCount); ret = EDMA_DRV_PrepareDescriptorTransfer( &handler->rxEdmaChnState, rxEdmaChnStcd, &rxEdmeConfigStruct, false, /* Always disable transfer done interrupt. */ false /* Always disable auto shutdown req. */ ); if (ret == kEDMAInvalidChannel) { return kStatus_FlexIO_Camera_Failed; } ret = EDMA_DRV_PushDescriptorToReg( &handler->rxEdmaChnState, rxEdmaChnStcd); if (ret == kEDMAInvalidChannel) { return kStatus_FlexIO_Camera_Failed; } EDMA_DRV_StartChannel(&handler->rxEdmaChnState); return kStatus_FlexIO_Camera_Success; }
/*FUNCTION********************************************************************** * * Function Name : UART_DRV_EdmaCompleteReceiveData * Description : Finish up a receive by completing the process of receiving data * and disabling the interrupt. * This is not a public API as it is called from other driver functions. * *END**************************************************************************/ static void UART_DRV_EdmaCompleteReceiveData(uint32_t instance) { assert(instance < UART_INSTANCE_COUNT); uart_edma_state_t * uartEdmaState = (uart_edma_state_t *)g_uartStatePtr[instance]; /* Stop DMA channel. */ EDMA_DRV_StopChannel(&uartEdmaState->edmaUartRx); /* Signal the synchronous completion object. */ if (uartEdmaState->isRxBlocking) { OSA_SemaPost(&uartEdmaState->rxIrqSync); } /* Update the information of the module driver state */ uartEdmaState->isRxBusy = false; }
/*FUNCTION********************************************************************** * * Function Name : LPUART_DRV_EdmaCompleteSendData * Description : Finish up a transmit by completing the process of sending * data and disabling the interrupt. * This is not a public API as it is called from other driver functions. * *END**************************************************************************/ static void LPUART_DRV_EdmaCompleteSendData(uint32_t instance) { assert(instance < LPUART_INSTANCE_COUNT); lpuart_edma_state_t * lpuartEdmaState = (lpuart_edma_state_t *)g_lpuartStatePtr[instance]; /* Stop DMA channel. */ EDMA_DRV_StopChannel(&lpuartEdmaState->edmaLpuartTx); /* Signal the synchronous completion object. */ if (lpuartEdmaState->isTxBlocking) { OSA_SemaPost(&lpuartEdmaState->txIrqSync); } /* Update the information of the module driver state */ lpuartEdmaState->isTxBusy = false; }
/*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; }
/*FUNCTION********************************************************************** * * Function Name : UART_DRV_EdmaSendDataBlocking * Description : Sends (transmits) data out through the UART-DMA module * using a blocking method. * *END**************************************************************************/ uart_status_t UART_DRV_EdmaSendDataBlocking(uint32_t instance, const uint8_t * txBuff, uint32_t txSize, uint32_t timeout) { assert(txBuff); assert(instance < UART_INSTANCE_COUNT); uart_edma_state_t * uartEdmaState = (uart_edma_state_t *)g_uartStatePtr[instance]; uart_status_t retVal = kStatus_UART_Success; osa_status_t syncStatus; /* Indicates current transaction is blocking. */ uartEdmaState->isTxBlocking = true; /* Start the transmission process */ retVal = UART_DRV_EdmaStartSendData(instance, txBuff, txSize); if (retVal == kStatus_UART_Success) { /* Wait until the transmit is complete. */ do { syncStatus = OSA_SemaWait(&uartEdmaState->txIrqSync, timeout); }while(syncStatus == kStatus_OSA_Idle); if (syncStatus != kStatus_OSA_Success) { /* Stop DMA channel. */ EDMA_DRV_StopChannel(&uartEdmaState->edmaUartTx); /* Update the information of the module driver state */ uartEdmaState->isTxBusy = false; retVal = kStatus_UART_Timeout; } } return retVal; }
/*FUNCTION********************************************************************** * * Function Name : UART_DRV_EdmaReceiveDataBlocking * Description : This function gets (receives) data from the UART module using * a blocking method. A blocking (also known as synchronous) function means that * the function does not return until the receive is complete. This blocking * function is used to send data through the UART port. * *END**************************************************************************/ uart_status_t UART_DRV_EdmaReceiveDataBlocking(uint32_t instance, uint8_t * rxBuff, uint32_t rxSize, uint32_t timeout) { assert(rxBuff); assert(instance < UART_INSTANCE_COUNT); uart_edma_state_t * uartEdmaState = (uart_edma_state_t *)g_uartStatePtr[instance]; uart_status_t retVal = kStatus_UART_Success; osa_status_t syncStatus; /* Indicates current transaction is blocking. */ uartEdmaState->isRxBlocking = true; retVal = UART_DRV_EdmaStartReceiveData(instance, rxBuff, rxSize); if (retVal == kStatus_UART_Success) { /* Wait until all the data is received or for timeout.*/ do { syncStatus = OSA_SemaWait(&uartEdmaState->rxIrqSync, timeout); }while(syncStatus == kStatus_OSA_Idle); if (syncStatus != kStatus_OSA_Success) { /* Stop DMA channel. */ EDMA_DRV_StopChannel(&uartEdmaState->edmaUartRx); /* Update the information of the module driver state */ uartEdmaState->isRxBusy = false; retVal = kStatus_UART_Timeout; } } return retVal; }
/*FUNCTION********************************************************************** * * Function Name : QSPI_DRV_RxEdmaCallback * Description : EDMA callback function for QSPI rx, this will be called while * QSPI finished the reading. * *END**************************************************************************/ void QSPI_DRV_RxEdmaCallback(void *param, edma_chn_status_t status) { qspi_state_t *state = (qspi_state_t *)param; EDMA_DRV_StopChannel(&state->rxEdmaChn); state->isRxBusy = false; }
void stop_edma_loop(void *parameter, edma_chn_status_t status) { /* Stop eDMA channel transfers. */ EDMA_DRV_StopChannel((edma_chn_state_t *)parameter); }
void disable_edma_loop(edma_loop_setup_t *loopSetup) { EDMA_DRV_StopChannel(loopSetup->dmaCh); }