![]() |
|
|||
File indexing completed on 2025-05-11 08:23:00
0001 /* 0002 * Copyright (c) 2018, Freescale Semiconductor, Inc. 0003 * Copyright 2019 - 2020, NXP 0004 * All rights reserved. 0005 * 0006 * SPDX-License-Identifier: BSD-3-Clause 0007 */ 0008 0009 #ifndef _FSL_PDM_SDMA_H_ 0010 #define _FSL_PDM_SDMA_H_ 0011 0012 #include "fsl_pdm.h" 0013 #include "fsl_sdma.h" 0014 0015 /*! 0016 * @addtogroup pdm_sdma PDM SDMA Driver 0017 * @ingroup pdm 0018 * @{ 0019 */ 0020 0021 /******************************************************************************* 0022 * Definitions 0023 ******************************************************************************/ 0024 0025 /*! @name Driver version */ 0026 /*@{*/ 0027 #define FSL_PDM_SDMA_DRIVER_VERSION (MAKE_VERSION(2, 7, 0)) /*!< Version 2.7.0 */ 0028 /*@}*/ 0029 0030 typedef struct _pdm_sdma_handle pdm_sdma_handle_t; 0031 0032 /*! @brief PDM eDMA transfer callback function for finish and error */ 0033 typedef void (*pdm_sdma_callback_t)(PDM_Type *base, pdm_sdma_handle_t *handle, status_t status, void *userData); 0034 0035 /*! @brief PDM DMA transfer handle, users should not touch the content of the handle.*/ 0036 struct _pdm_sdma_handle 0037 { 0038 sdma_handle_t *dmaHandle; /*!< DMA handler for PDM send */ 0039 uint8_t nbytes; /*!< eDMA minor byte transfer count initially configured. */ 0040 uint8_t fifoWidth; /*!< fifo width */ 0041 uint8_t endChannel; /*!< The last enabled channel */ 0042 uint8_t channelNums; /*!< total channel numbers */ 0043 uint32_t count; /*!< The transfer data count in a DMA request */ 0044 uint32_t state; /*!< Internal state for PDM eDMA transfer */ 0045 uint32_t eventSource; /*!< PDM event source number */ 0046 pdm_sdma_callback_t callback; /*!< Callback for users while transfer finish or error occurs */ 0047 void *userData; /*!< User callback parameter */ 0048 sdma_buffer_descriptor_t bdPool[PDM_XFER_QUEUE_SIZE]; /*!< BD pool for SDMA transfer. */ 0049 pdm_transfer_t pdmQueue[PDM_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */ 0050 size_t transferSize[PDM_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */ 0051 volatile uint8_t queueUser; /*!< Index for user to queue transfer. */ 0052 volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ 0053 }; 0054 0055 /******************************************************************************* 0056 * APIs 0057 ******************************************************************************/ 0058 #if defined(__cplusplus) 0059 extern "C" { 0060 #endif 0061 0062 /*! 0063 * @name eDMA Transactional 0064 * @{ 0065 */ 0066 0067 /*! 0068 * @brief Initializes the PDM eDMA handle. 0069 * 0070 * This function initializes the PDM DMA handle, which can be used for other PDM master transactional APIs. 0071 * Usually, for a specified PDM instance, call this API once to get the initialized handle. 0072 * 0073 * @param base PDM base pointer. 0074 * @param handle PDM eDMA handle pointer. 0075 * @param callback Pointer to user callback function. 0076 * @param userData User parameter passed to the callback function. 0077 * @param dmaHandle eDMA handle pointer, this handle shall be static allocated by users. 0078 * @param eventSource PDM event source number. 0079 */ 0080 void PDM_TransferCreateHandleSDMA(PDM_Type *base, 0081 pdm_sdma_handle_t *handle, 0082 pdm_sdma_callback_t callback, 0083 void *userData, 0084 sdma_handle_t *dmaHandle, 0085 uint32_t eventSource); 0086 0087 /*! 0088 * @brief Performs a non-blocking PDM receive using eDMA. 0089 * 0090 * @note This interface returns immediately after the transfer initiates. Call 0091 * the PDM_GetReceiveRemainingBytes to poll the transfer status and check whether the PDM transfer is finished. 0092 * 0093 * @param base PDM base pointer 0094 * @param handle PDM eDMA handle pointer. 0095 * @param xfer Pointer to DMA transfer structure. 0096 * @retval kStatus_Success Start a PDM eDMA receive successfully. 0097 * @retval kStatus_InvalidArgument The input argument is invalid. 0098 * @retval kStatus_RxBusy PDM is busy receiving data. 0099 */ 0100 status_t PDM_TransferReceiveSDMA(PDM_Type *base, pdm_sdma_handle_t *handle, pdm_transfer_t *xfer); 0101 0102 /*! 0103 * @brief Aborts a PDM receive using eDMA. 0104 * 0105 * @param base PDM base pointer 0106 * @param handle PDM eDMA handle pointer. 0107 */ 0108 void PDM_TransferAbortReceiveSDMA(PDM_Type *base, pdm_sdma_handle_t *handle); 0109 0110 /*! 0111 * @brief PDM channel configurations. 0112 * 0113 * @param base PDM base pointer. 0114 * @param handle PDM eDMA handle pointer. 0115 * @param channel channel number. 0116 * @param config channel configurations. 0117 */ 0118 void PDM_SetChannelConfigSDMA(PDM_Type *base, 0119 pdm_sdma_handle_t *handle, 0120 uint32_t channel, 0121 const pdm_channel_config_t *config); 0122 0123 /*! 0124 * @brief Terminate all the PDM sdma receive transfer. 0125 * 0126 * @param base PDM base pointer. 0127 * @param handle PDM SDMA handle pointer. 0128 */ 0129 void PDM_TransferTerminateReceiveSDMA(PDM_Type *base, pdm_sdma_handle_t *handle); 0130 0131 /*! @} */ 0132 0133 #if defined(__cplusplus) 0134 } 0135 #endif 0136 0137 /*! 0138 * @} 0139 */ 0140 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |