![]() |
|
|||
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_DMA_H_ 0009 #define _FSL_FLEXIO_I2S_DMA_H_ 0010 0011 #include "fsl_flexio_i2s.h" 0012 #include "fsl_dma.h" 0013 0014 /*! 0015 * @addtogroup flexio_dma_i2s 0016 * @{ 0017 */ 0018 0019 /******************************************************************************* 0020 * Definitions 0021 ******************************************************************************/ 0022 0023 /*! @name Driver version */ 0024 /*@{*/ 0025 /*! @brief FlexIO I2S DMA driver version 2.1.7. */ 0026 #define FSL_FLEXIO_I2S_DMA_DRIVER_VERSION (MAKE_VERSION(2, 1, 7)) 0027 /*@}*/ 0028 0029 typedef struct _flexio_i2s_dma_handle flexio_i2s_dma_handle_t; 0030 0031 /*! @brief FlexIO I2S DMA transfer callback function for finish and error */ 0032 typedef void (*flexio_i2s_dma_callback_t)(FLEXIO_I2S_Type *base, 0033 flexio_i2s_dma_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_dma_handle 0039 { 0040 dma_handle_t *dmaHandle; /*!< DMA handler for FlexIO I2S send */ 0041 uint8_t bytesPerFrame; /*!< Bytes in a frame */ 0042 uint32_t state; /*!< Internal state for FlexIO I2S DMA transfer */ 0043 flexio_i2s_dma_callback_t callback; /*!< Callback for users while transfer finish or error occurred */ 0044 void *userData; /*!< User callback parameter */ 0045 flexio_i2s_transfer_t queue[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */ 0046 size_t transferSize[FLEXIO_I2S_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */ 0047 volatile uint8_t queueUser; /*!< Index for user to queue transfer. */ 0048 volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ 0049 }; 0050 0051 /******************************************************************************* 0052 * APIs 0053 ******************************************************************************/ 0054 #if defined(__cplusplus) 0055 extern "C" { 0056 #endif 0057 0058 /*! 0059 * @name DMA Transactional 0060 * @{ 0061 */ 0062 0063 /*! 0064 * @brief Initializes the FlexIO I2S DMA handle. 0065 * 0066 * This function initializes the FlexIO I2S master DMA handle which can be used for other FlexIO I2S master 0067 * transactional APIs. 0068 * Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle. 0069 * 0070 * @param base FlexIO I2S peripheral base address. 0071 * @param handle FlexIO I2S DMA handle pointer. 0072 * @param callback FlexIO I2S DMA callback function called while finished a block. 0073 * @param userData User parameter for callback. 0074 * @param dmaHandle DMA handle for FlexIO I2S. This handle is a static value allocated by users. 0075 */ 0076 void FLEXIO_I2S_TransferTxCreateHandleDMA(FLEXIO_I2S_Type *base, 0077 flexio_i2s_dma_handle_t *handle, 0078 flexio_i2s_dma_callback_t callback, 0079 void *userData, 0080 dma_handle_t *dmaHandle); 0081 0082 /*! 0083 * @brief Initializes the FlexIO I2S Rx DMA handle. 0084 * 0085 * This function initializes the FlexIO I2S slave DMA handle which can be used for other FlexIO I2S master transactional 0086 * APIs. 0087 * Usually, for a specified FlexIO I2S instance, call this API once to get the initialized handle. 0088 * 0089 * @param base FlexIO I2S peripheral base address. 0090 * @param handle FlexIO I2S DMA handle pointer. 0091 * @param callback FlexIO I2S DMA callback function called while finished a block. 0092 * @param userData User parameter for callback. 0093 * @param dmaHandle DMA handle for FlexIO I2S. This handle is a static value allocated by users. 0094 */ 0095 void FLEXIO_I2S_TransferRxCreateHandleDMA(FLEXIO_I2S_Type *base, 0096 flexio_i2s_dma_handle_t *handle, 0097 flexio_i2s_dma_callback_t callback, 0098 void *userData, 0099 dma_handle_t *dmaHandle); 0100 0101 /*! 0102 * @brief Configures the FlexIO I2S Tx audio format. 0103 * 0104 * Audio format can be changed at run-time of FlexIO I2S. This function configures the sample rate and audio data 0105 * format to be transferred. This function also sets the DMA parameter according to the format. 0106 * 0107 * @param base FlexIO I2S peripheral base address. 0108 * @param handle FlexIO I2S DMA handle pointer 0109 * @param format Pointer to FlexIO I2S audio data format structure. 0110 * @param srcClock_Hz FlexIO I2S clock source frequency in Hz. It should be 0 while in slave mode. 0111 */ 0112 void FLEXIO_I2S_TransferSetFormatDMA(FLEXIO_I2S_Type *base, 0113 flexio_i2s_dma_handle_t *handle, 0114 flexio_i2s_format_t *format, 0115 uint32_t srcClock_Hz); 0116 0117 /*! 0118 * @brief Performs a non-blocking FlexIO I2S transfer using DMA. 0119 * 0120 * @note This interface returns immediately after transfer initiates. Call 0121 * FLEXIO_I2S_GetTransferStatus to poll the transfer status and check whether FLEXIO I2S transfer finished. 0122 * 0123 * @param base FlexIO I2S peripheral base address. 0124 * @param handle FlexIO I2S DMA handle pointer. 0125 * @param xfer Pointer to DMA transfer structure. 0126 * @retval kStatus_Success Start a FlexIO I2S DMA send successfully. 0127 * @retval kStatus_InvalidArgument The input arguments is invalid. 0128 * @retval kStatus_TxBusy FlexIO I2S is busy sending data. 0129 */ 0130 status_t FLEXIO_I2S_TransferSendDMA(FLEXIO_I2S_Type *base, 0131 flexio_i2s_dma_handle_t *handle, 0132 flexio_i2s_transfer_t *xfer); 0133 0134 /*! 0135 * @brief Performs a non-blocking FlexIO I2S receive using DMA. 0136 * 0137 * @note This interface returns immediately after transfer initiates. Call 0138 * FLEXIO_I2S_GetReceiveRemainingBytes to poll the transfer status to check whether the FlexIO I2S transfer is finished. 0139 * 0140 * @param base FlexIO I2S peripheral base address. 0141 * @param handle FlexIO I2S DMA handle pointer. 0142 * @param xfer Pointer to DMA transfer structure. 0143 * @retval kStatus_Success Start a FlexIO I2S DMA receive successfully. 0144 * @retval kStatus_InvalidArgument The input arguments is invalid. 0145 * @retval kStatus_RxBusy FlexIO I2S is busy receiving data. 0146 */ 0147 status_t FLEXIO_I2S_TransferReceiveDMA(FLEXIO_I2S_Type *base, 0148 flexio_i2s_dma_handle_t *handle, 0149 flexio_i2s_transfer_t *xfer); 0150 0151 /*! 0152 * @brief Aborts a FlexIO I2S transfer using DMA. 0153 * 0154 * @param base FlexIO I2S peripheral base address. 0155 * @param handle FlexIO I2S DMA handle pointer. 0156 */ 0157 void FLEXIO_I2S_TransferAbortSendDMA(FLEXIO_I2S_Type *base, flexio_i2s_dma_handle_t *handle); 0158 0159 /*! 0160 * @brief Aborts a FlexIO I2S receive using DMA. 0161 * 0162 * @param base FlexIO I2S peripheral base address. 0163 * @param handle FlexIO I2S DMA handle pointer. 0164 */ 0165 void FLEXIO_I2S_TransferAbortReceiveDMA(FLEXIO_I2S_Type *base, flexio_i2s_dma_handle_t *handle); 0166 0167 /*! 0168 * @brief Gets the remaining bytes to be sent. 0169 * 0170 * @param base FlexIO I2S peripheral base address. 0171 * @param handle FlexIO I2S DMA handle pointer. 0172 * @param count Bytes sent. 0173 * @retval kStatus_Success Succeed get the transfer count. 0174 * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. 0175 */ 0176 status_t FLEXIO_I2S_TransferGetSendCountDMA(FLEXIO_I2S_Type *base, flexio_i2s_dma_handle_t *handle, size_t *count); 0177 0178 /*! 0179 * @brief Gets the remaining bytes to be received. 0180 * 0181 * @param base FlexIO I2S peripheral base address. 0182 * @param handle FlexIO I2S DMA handle pointer. 0183 * @param count Bytes received. 0184 * @retval kStatus_Success Succeed get the transfer count. 0185 * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. 0186 */ 0187 status_t FLEXIO_I2S_TransferGetReceiveCountDMA(FLEXIO_I2S_Type *base, flexio_i2s_dma_handle_t *handle, size_t *count); 0188 0189 /*! @} */ 0190 0191 #if defined(__cplusplus) 0192 } 0193 #endif 0194 0195 /*! 0196 * @} 0197 */ 0198 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |