![]() |
|
|||
File indexing completed on 2025-05-11 08:22:58
0001 /* 0002 * Copyright 2019-2020 NXP 0003 * All rights reserved. 0004 * 0005 * SPDX-License-Identifier: BSD-3-Clause 0006 */ 0007 #ifndef _FSL_ASRC_P2P_EDMA_H_ 0008 #define _FSL_ASRC_P2P_EDMA_H_ 0009 0010 #include "fsl_edma.h" 0011 #include "fsl_asrc.h" 0012 0013 /*! 0014 * @addtogroup asrc_edma_driver 0015 * @{ 0016 */ 0017 0018 /******************************************************************************* 0019 * Definitions 0020 ******************************************************************************/ 0021 0022 /*! @name Driver version */ 0023 /*@{*/ 0024 #define FSL_ASRC_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) /*!< Version 2.1.0 */ 0025 /*@}*/ 0026 /*!< @brief ASRC IN edma QUEUE size */ 0027 #define ASRC_XFER_IN_QUEUE_SIZE 4U 0028 #define ASRC_XFER_OUT_QUEUE_SIZE (ASRC_XFER_QUEUE_SIZE * 2U) 0029 0030 typedef struct _asrc_edma_handle asrc_edma_handle_t; 0031 0032 /*! @brief ASRC eDMA transfer callback function for finish and error */ 0033 typedef void (*asrc_edma_callback_t)(ASRC_Type *base, asrc_edma_handle_t *handle, status_t status, void *userData); 0034 0035 /*! @brief ASRC trigger peripheral function pointer */ 0036 typedef void (*asrc_start_peripheral_t)(bool start); 0037 /*! @brief destination peripheral configuration */ 0038 typedef struct _asrc_p2p_edma_config 0039 { 0040 uint8_t watermark; /*!< peripheral watermark */ 0041 uint8_t channel; /*!< peripheral channel number */ 0042 asrc_start_peripheral_t startPeripheral; /*!< trigger peripheral start */ 0043 } asrc_p2p_edma_config_t; 0044 0045 /*!@ brief asrc in edma handler */ 0046 typedef struct _asrc_in_edma_handle 0047 { 0048 edma_handle_t *inDmaHandle; /*!< DMA handler for ASRC in */ 0049 0050 uint8_t tcd[(ASRC_XFER_IN_QUEUE_SIZE + 1U) * sizeof(edma_tcd_t)]; /*!< TCD pool for eDMA send. */ 0051 0052 uint32_t sampleWidth; /*!< input data width */ 0053 uint32_t fifoThreshold; /*!< ASRC input fifo threshold */ 0054 uint32_t *asrcQueue[ASRC_XFER_IN_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */ 0055 size_t transferSize[ASRC_XFER_IN_QUEUE_SIZE]; /*!< Data bytes need to transfer */ 0056 volatile uint8_t queueUser; /*!< Index for user to queue transfer. */ 0057 volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ 0058 uint32_t state; /*!< Internal state for ASRC eDMA transfer */ 0059 0060 const asrc_p2p_edma_config_t *peripheralConfig; /*!< peripheral configuration pointer */ 0061 } asrc_in_edma_handle_t; 0062 0063 /*!@ brief asrc out edma handler */ 0064 typedef struct _asrc_out_edma_handle 0065 { 0066 edma_handle_t *outDmaHandle; /*!< DMA handler for ASRC out */ 0067 0068 uint8_t tcd[(ASRC_XFER_OUT_QUEUE_SIZE + 1U) * sizeof(edma_tcd_t)]; /*!< TCD pool for eDMA send. */ 0069 0070 uint32_t sampleWidth; /*!< output data width */ 0071 uint32_t fifoThreshold; /*!< ASRC output fifo threshold */ 0072 uint32_t *asrcQueue[ASRC_XFER_OUT_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */ 0073 size_t transferSize[ASRC_XFER_OUT_QUEUE_SIZE]; /*!< Data bytes need to transfer */ 0074 volatile uint8_t queueUser; /*!< Index for user to queue transfer. */ 0075 volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ 0076 uint32_t state; /*!< Internal state for ASRC eDMA transfer */ 0077 const asrc_p2p_edma_config_t *peripheralConfig; /*!< peripheral configuration pointer */ 0078 } asrc_out_edma_handle_t; 0079 0080 /*! @brief ASRC DMA transfer handle.*/ 0081 struct _asrc_edma_handle 0082 { 0083 asrc_in_edma_handle_t in; /*!< asrc in handler */ 0084 asrc_out_edma_handle_t out; /*!< asrc out handler */ 0085 asrc_channel_pair_t channelPair; /*!< channel pair */ 0086 void *userData; /*!< User callback parameter */ 0087 asrc_edma_callback_t callback; /*!< Callback for users while transfer finish or error occurs */ 0088 }; 0089 0090 /******************************************************************************* 0091 * APIs 0092 ******************************************************************************/ 0093 #if defined(__cplusplus) 0094 extern "C" { 0095 #endif 0096 0097 /*! 0098 * @name eDMA Transactional 0099 * @{ 0100 */ 0101 0102 /*! 0103 * @brief Initializes the ASRC IN eDMA handle. 0104 * 0105 * This function initializes the ASRC DMA handle, which can be used for other ASRC transactional APIs. 0106 * Usually, for a specified ASRC channel pair, call this API once to get the initialized handle. 0107 * 0108 * @param base ASRC base pointer. 0109 * @param channelPair ASRC channel pair 0110 * @param handle ASRC eDMA handle pointer. 0111 * @param callback Pointer to user callback function. 0112 * @param inDmaHandle DMA handler for ASRC in. 0113 * @param periphConfig peripheral configuration. 0114 * @param userData User parameter passed to the callback function. 0115 */ 0116 void ASRC_TransferInCreateHandleEDMA(ASRC_Type *base, 0117 asrc_edma_handle_t *handle, 0118 asrc_channel_pair_t channelPair, 0119 asrc_edma_callback_t callback, 0120 edma_handle_t *inDmaHandle, 0121 const asrc_p2p_edma_config_t *periphConfig, 0122 void *userData); 0123 0124 /*! 0125 * @brief Initializes the ASRC OUT eDMA handle. 0126 * 0127 * This function initializes the ASRC DMA handle, which can be used for other ASRC transactional APIs. 0128 * Usually, for a specified ASRC channel pair, call this API once to get the initialized handle. 0129 * 0130 * @param base ASRC base pointer. 0131 * @param channelPair ASRC channel pair 0132 * @param handle ASRC eDMA handle pointer. 0133 * @param callback Pointer to user callback function. 0134 * @param outDmaHandle DMA handler for ASRC out. 0135 * @param periphConfig peripheral configuration. 0136 * @param userData User parameter passed to the callback function. 0137 */ 0138 void ASRC_TransferOutCreateHandleEDMA(ASRC_Type *base, 0139 asrc_edma_handle_t *handle, 0140 asrc_channel_pair_t channelPair, 0141 asrc_edma_callback_t callback, 0142 edma_handle_t *outDmaHandle, 0143 const asrc_p2p_edma_config_t *periphConfig, 0144 void *userData); 0145 0146 /*! 0147 * @brief Configures the ASRC P2P channel pair. 0148 * 0149 * 0150 * @param base ASRC base pointer. 0151 * @param handle ASRC eDMA handle pointer. 0152 * @param asrcConfig asrc configurations. 0153 * @param inSampleRate ASRC input sample rate. 0154 * @param outSampleRate ASRC output sample rate. 0155 */ 0156 status_t ASRC_TransferSetChannelPairConfigEDMA(ASRC_Type *base, 0157 asrc_edma_handle_t *handle, 0158 asrc_channel_pair_config_t *asrcConfig, 0159 uint32_t inSampleRate, 0160 uint32_t outSampleRate); 0161 0162 /*! 0163 * @brief Get output sample buffer size can be transferred by edma. 0164 * 0165 * @note This API is depends on the ASRC output configuration, should be called after the 0166 * ASRC_TransferSetChannelPairConfigEDMA. 0167 * 0168 * @param base asrc base pointer. 0169 * @param handle ASRC channel pair edma handle. 0170 * @param inSampleRate input sample rate. 0171 * @param outSampleRate output sample rate. 0172 * @param inSamplesize input sampleS size. 0173 * @retval output buffer size in byte. 0174 */ 0175 uint32_t ASRC_GetOutSamplesSizeEDMA( 0176 ASRC_Type *base, asrc_edma_handle_t *handle, uint32_t inSampleRate, uint32_t outSampleRate, uint32_t inSamplesize); 0177 0178 /*! 0179 * @brief Performs a non-blocking ASRC m2m convert using EDMA. 0180 * 0181 * @note This interface returns immediately after the transfer initiates. 0182 0183 * @param base ASRC base pointer. 0184 * @param handle ASRC eDMA handle pointer. 0185 * @param xfer Pointer to the DMA transfer structure. 0186 * @retval kStatus_Success Start a ASRC eDMA send successfully. 0187 * @retval kStatus_InvalidArgument The input argument is invalid. 0188 * @retval kStatus_ASRCQueueFull ASRC EDMA driver queue is full. 0189 */ 0190 status_t ASRC_TransferEDMA(ASRC_Type *base, asrc_edma_handle_t *handle, asrc_transfer_t *xfer); 0191 0192 /*! 0193 * @brief Aborts a ASRC IN transfer using eDMA. 0194 * 0195 * This function only aborts the current transfer slots, the other transfer slots' information still kept 0196 * in the handler. If users want to terminate all transfer slots, just call ASRC_TransferTerminalP2PEDMA. 0197 * 0198 * @param base ASRC base pointer. 0199 * @param handle ASRC eDMA handle pointer. 0200 */ 0201 void ASRC_TransferInAbortEDMA(ASRC_Type *base, asrc_edma_handle_t *handle); 0202 0203 /*! 0204 * @brief Aborts a ASRC OUT transfer using eDMA. 0205 * 0206 * This function only aborts the current transfer slots, the other transfer slots' information still kept 0207 * in the handler. If users want to terminate all transfer slots, just call ASRC_TransferTerminalP2PEDMA. 0208 * 0209 * @param base ASRC base pointer. 0210 * @param handle ASRC eDMA handle pointer. 0211 */ 0212 void ASRC_TransferOutAbortEDMA(ASRC_Type *base, asrc_edma_handle_t *handle); 0213 0214 /*! 0215 * @brief Terminate In ASRC Convert. 0216 * 0217 * This function will clear all transfer slots buffered in the asrc queue. If users only want to abort the 0218 * current transfer slot, please call ASRC_TransferAbortPP2PEDMA. 0219 * 0220 * @param base ASRC base pointer. 0221 * @param handle ASRC eDMA handle pointer. 0222 */ 0223 void ASRC_TransferInTerminalEDMA(ASRC_Type *base, asrc_edma_handle_t *handle); 0224 0225 /*! 0226 * @brief Terminate Out ASRC Convert. 0227 * 0228 * This function will clear all transfer slots buffered in the asrc queue. If users only want to abort the 0229 * current transfer slot, please call ASRC_TransferAbortPP2PEDMA. 0230 * 0231 * @param base ASRC base pointer. 0232 * @param handle ASRC eDMA handle pointer. 0233 */ 0234 void ASRC_TransferOutTerminalEDMA(ASRC_Type *base, asrc_edma_handle_t *handle); 0235 0236 /*! @} */ 0237 0238 #if defined(__cplusplus) 0239 } 0240 #endif 0241 0242 /*! 0243 * @} 0244 */ 0245 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |