![]() |
|
|||
File indexing completed on 2025-05-11 08:22:59
0001 /* 0002 * Copyright (c) 2015, Freescale Semiconductor, Inc. 0003 * Copyright 2016-2019 NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 #ifndef _FSL_FLEXIO_I2S_EDMA_H_ 0009 #define _FSL_FLEXIO_I2S_EDMA_H_ 0010 0011 #include "fsl_flexio_i2s.h" 0012 #include "fsl_edma.h" 0013 0014 /*! 0015 * @addtogroup flexio_edma_i2s 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief FlexIO I2S EDMA driver version 2.1.7. */ 0026 #define FSL_FLEXIO_I2S_EDMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 7)) 0027 /*@}*/ 0028 0029 typedef struct _flexio_i2s_edma_handle flexio_i2s_edma_handle_t; 0030 0031 /*! @brief FlexIO I2S eDMA transfer callback function for finish and error */ 0032 typedef void (*flexio_i2s_edma_callback_t)(FLEXIO_I2S_Type *base, 0033 flexio_i2s_edma_handle_t *handle, 0034 status_t status, 0035 void *userData); 0036 0037 /*! @brief FlexIO I2S DMA transfer handle, users should not touch the content of the handle.*/ 0038 struct _flexio_i2s_edma_handle 0039 { 0040 edma_handle_t *dmaHandle; /*!< DMA handler for FlexIO I2S send */ 0041 uint8_t bytesPerFrame; /*!< Bytes in a frame */ 0042 uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */ 0043 uint32_t state; /*!< Internal state for FlexIO I2S eDMA transfer */ 0044 flexio_i2s_edma_callback_t callback; /*!< Callback for users while transfer finish or error occurred */ 0045 void *userData; /*!< User callback parameter */ 0046 edma_tcd_t tcd[FLEXIO_I2S_XFER_QUEUE_SIZE + 1U]; /*!< TCD pool for eDMA transfer. */ 0047 flexio_i2s_transfer_t queue[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */ 0048 size_t transferSize[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */ 0049 volatile uint8_t queueUser; /*!< Index for user to queue transfer. */ 0050 volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ 0051 }; 0052 0053 /******************************************************************************* 0054 * APIs 0055 ******************************************************************************/ 0056 #if defined(__cplusplus) 0057 extern "C" { 0058 #endif 0059 0060 /*! 0061 * @name eDMA Transactional 0062 * @{ 0063 */ 0064 0065 /*! 0066 * @brief Initializes the FlexIO I2S eDMA handle. 0067 * 0068 * This function initializes the FlexIO I2S master DMA handle which can be used for other FlexIO I2S master 0069 * transactional APIs. 0070 * Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle. 0071 * 0072 * @param base FlexIO I2S peripheral base address. 0073 * @param handle FlexIO I2S eDMA handle pointer. 0074 * @param callback FlexIO I2S eDMA callback function called while finished a block. 0075 * @param userData User parameter for callback. 0076 * @param dmaHandle eDMA handle for FlexIO I2S. This handle is a static value allocated by users. 0077 */ 0078 void FLEXIO_I2S_TransferTxCreateHandleEDMA(FLEXIO_I2S_Type *base, 0079 flexio_i2s_edma_handle_t *handle, 0080 flexio_i2s_edma_callback_t callback, 0081 void *userData, 0082 edma_handle_t *dmaHandle); 0083 0084 /*! 0085 * @brief Initializes the FlexIO I2S Rx eDMA handle. 0086 * 0087 * This function initializes the FlexIO I2S slave DMA handle which can be used for other FlexIO I2S master transactional 0088 * APIs. 0089 * Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle. 0090 * 0091 * @param base FlexIO I2S peripheral base address. 0092 * @param handle FlexIO I2S eDMA handle pointer. 0093 * @param callback FlexIO I2S eDMA callback function called while finished a block. 0094 * @param userData User parameter for callback. 0095 * @param dmaHandle eDMA handle for FlexIO I2S. This handle is a static value allocated by users. 0096 */ 0097 void FLEXIO_I2S_TransferRxCreateHandleEDMA(FLEXIO_I2S_Type *base, 0098 flexio_i2s_edma_handle_t *handle, 0099 flexio_i2s_edma_callback_t callback, 0100 void *userData, 0101 edma_handle_t *dmaHandle); 0102 0103 /*! 0104 * @brief Configures the FlexIO I2S Tx audio format. 0105 * 0106 * Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data 0107 * format to be transferred. This function also sets the eDMA parameter according to format. 0108 * 0109 * @param base FlexIO I2S peripheral base address. 0110 * @param handle FlexIO I2S eDMA handle pointer 0111 * @param format Pointer to FlexIO I2S audio data format structure. 0112 * @param srcClock_Hz FlexIO I2S clock source frequency in Hz, it should be 0 while in slave mode. 0113 */ 0114 void FLEXIO_I2S_TransferSetFormatEDMA(FLEXIO_I2S_Type *base, 0115 flexio_i2s_edma_handle_t *handle, 0116 flexio_i2s_format_t *format, 0117 uint32_t srcClock_Hz); 0118 0119 /*! 0120 * @brief Performs a non-blocking FlexIO I2S transfer using DMA. 0121 * 0122 * @note This interface returned immediately after transfer initiates. Users should call 0123 * FLEXIO_I2S_GetTransferStatus to poll the transfer status and check whether the FlexIO I2S transfer is finished. 0124 * 0125 * @param base FlexIO I2S peripheral base address. 0126 * @param handle FlexIO I2S DMA handle pointer. 0127 * @param xfer Pointer to DMA transfer structure. 0128 * @retval kStatus_Success Start a FlexIO I2S eDMA send successfully. 0129 * @retval kStatus_InvalidArgument The input arguments is invalid. 0130 * @retval kStatus_TxBusy FlexIO I2S is busy sending data. 0131 */ 0132 status_t FLEXIO_I2S_TransferSendEDMA(FLEXIO_I2S_Type *base, 0133 flexio_i2s_edma_handle_t *handle, 0134 flexio_i2s_transfer_t *xfer); 0135 0136 /*! 0137 * @brief Performs a non-blocking FlexIO I2S receive using eDMA. 0138 * 0139 * @note This interface returned immediately after transfer initiates. Users should call 0140 * FLEXIO_I2S_GetReceiveRemainingBytes to poll the transfer status and check whether the FlexIO I2S transfer is 0141 * finished. 0142 * 0143 * @param base FlexIO I2S peripheral base address. 0144 * @param handle FlexIO I2S DMA handle pointer. 0145 * @param xfer Pointer to DMA transfer structure. 0146 * @retval kStatus_Success Start a FlexIO I2S eDMA receive successfully. 0147 * @retval kStatus_InvalidArgument The input arguments is invalid. 0148 * @retval kStatus_RxBusy FlexIO I2S is busy receiving data. 0149 */ 0150 status_t FLEXIO_I2S_TransferReceiveEDMA(FLEXIO_I2S_Type *base, 0151 flexio_i2s_edma_handle_t *handle, 0152 flexio_i2s_transfer_t *xfer); 0153 0154 /*! 0155 * @brief Aborts a FlexIO I2S transfer using eDMA. 0156 * 0157 * @param base FlexIO I2S peripheral base address. 0158 * @param handle FlexIO I2S DMA handle pointer. 0159 */ 0160 void FLEXIO_I2S_TransferAbortSendEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle); 0161 0162 /*! 0163 * @brief Aborts a FlexIO I2S receive using eDMA. 0164 * 0165 * @param base FlexIO I2S peripheral base address. 0166 * @param handle FlexIO I2S DMA handle pointer. 0167 */ 0168 void FLEXIO_I2S_TransferAbortReceiveEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle); 0169 0170 /*! 0171 * @brief Gets the remaining bytes to be sent. 0172 * 0173 * @param base FlexIO I2S peripheral base address. 0174 * @param handle FlexIO I2S DMA handle pointer. 0175 * @param count Bytes sent. 0176 * @retval kStatus_Success Succeed get the transfer count. 0177 * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. 0178 */ 0179 status_t FLEXIO_I2S_TransferGetSendCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle, size_t *count); 0180 0181 /*! 0182 * @brief Get the remaining bytes to be received. 0183 * 0184 * @param base FlexIO I2S peripheral base address. 0185 * @param handle FlexIO I2S DMA handle pointer. 0186 * @param count Bytes received. 0187 * @retval kStatus_Success Succeed get the transfer count. 0188 * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. 0189 */ 0190 status_t FLEXIO_I2S_TransferGetReceiveCountEDMA(FLEXIO_I2S_Type *base, flexio_i2s_edma_handle_t *handle, size_t *count); 0191 0192 /*! @} */ 0193 0194 #if defined(__cplusplus) 0195 } 0196 #endif 0197 0198 /*! 0199 * @} 0200 */ 0201 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |