The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.
Dependents: hello SerialTestv11 SerialTestv12 Sierpinski ... more
mbed 2
This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.
TARGET_LPC546XX/TOOLCHAIN_IAR/fsl_i2s_dma.h@171:3a7713b1edbc, 2018-11-08 (annotated)
- Committer:
- AnnaBridge
- Date:
- Thu Nov 08 11:45:42 2018 +0000
- Revision:
- 171:3a7713b1edbc
mbed library. Release version 164
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 171:3a7713b1edbc | 1 | /* |
AnnaBridge | 171:3a7713b1edbc | 2 | * The Clear BSD License |
AnnaBridge | 171:3a7713b1edbc | 3 | * Copyright (c) 2016, Freescale Semiconductor, Inc. |
AnnaBridge | 171:3a7713b1edbc | 4 | * Copyright 2016-2017 NXP |
AnnaBridge | 171:3a7713b1edbc | 5 | * All rights reserved. |
AnnaBridge | 171:3a7713b1edbc | 6 | * |
AnnaBridge | 171:3a7713b1edbc | 7 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 171:3a7713b1edbc | 8 | * are permitted (subject to the limitations in the disclaimer below) provided |
AnnaBridge | 171:3a7713b1edbc | 9 | * that the following conditions are met: |
AnnaBridge | 171:3a7713b1edbc | 10 | * |
AnnaBridge | 171:3a7713b1edbc | 11 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 171:3a7713b1edbc | 12 | * of conditions and the following disclaimer. |
AnnaBridge | 171:3a7713b1edbc | 13 | * |
AnnaBridge | 171:3a7713b1edbc | 14 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 171:3a7713b1edbc | 15 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 171:3a7713b1edbc | 16 | * other materials provided with the distribution. |
AnnaBridge | 171:3a7713b1edbc | 17 | * |
AnnaBridge | 171:3a7713b1edbc | 18 | * o Neither the name of the copyright holder nor the names of its |
AnnaBridge | 171:3a7713b1edbc | 19 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 171:3a7713b1edbc | 20 | * software without specific prior written permission. |
AnnaBridge | 171:3a7713b1edbc | 21 | * |
AnnaBridge | 171:3a7713b1edbc | 22 | * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. |
AnnaBridge | 171:3a7713b1edbc | 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 171:3a7713b1edbc | 24 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 171:3a7713b1edbc | 25 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 171:3a7713b1edbc | 26 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 171:3a7713b1edbc | 27 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 171:3a7713b1edbc | 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 171:3a7713b1edbc | 29 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 171:3a7713b1edbc | 30 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 171:3a7713b1edbc | 31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 171:3a7713b1edbc | 32 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 171:3a7713b1edbc | 33 | */ |
AnnaBridge | 171:3a7713b1edbc | 34 | #ifndef _FSL_I2S_DMA_H_ |
AnnaBridge | 171:3a7713b1edbc | 35 | #define _FSL_I2S_DMA_H_ |
AnnaBridge | 171:3a7713b1edbc | 36 | |
AnnaBridge | 171:3a7713b1edbc | 37 | #include "fsl_device_registers.h" |
AnnaBridge | 171:3a7713b1edbc | 38 | #include "fsl_common.h" |
AnnaBridge | 171:3a7713b1edbc | 39 | #include "fsl_flexcomm.h" |
AnnaBridge | 171:3a7713b1edbc | 40 | |
AnnaBridge | 171:3a7713b1edbc | 41 | #include "fsl_dma.h" |
AnnaBridge | 171:3a7713b1edbc | 42 | #include "fsl_i2s.h" |
AnnaBridge | 171:3a7713b1edbc | 43 | |
AnnaBridge | 171:3a7713b1edbc | 44 | /******************************************************************************* |
AnnaBridge | 171:3a7713b1edbc | 45 | * Definitions |
AnnaBridge | 171:3a7713b1edbc | 46 | ******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 47 | |
AnnaBridge | 171:3a7713b1edbc | 48 | /*! |
AnnaBridge | 171:3a7713b1edbc | 49 | * @addtogroup i2s_dma_driver |
AnnaBridge | 171:3a7713b1edbc | 50 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 51 | */ |
AnnaBridge | 171:3a7713b1edbc | 52 | |
AnnaBridge | 171:3a7713b1edbc | 53 | /*! @brief Members not to be accessed / modified outside of the driver. */ |
AnnaBridge | 171:3a7713b1edbc | 54 | typedef struct _i2s_dma_handle i2s_dma_handle_t; |
AnnaBridge | 171:3a7713b1edbc | 55 | |
AnnaBridge | 171:3a7713b1edbc | 56 | /*! |
AnnaBridge | 171:3a7713b1edbc | 57 | * @brief Callback function invoked from DMA API on completion. |
AnnaBridge | 171:3a7713b1edbc | 58 | * |
AnnaBridge | 171:3a7713b1edbc | 59 | * @param base I2S base pointer. |
AnnaBridge | 171:3a7713b1edbc | 60 | * @param handle pointer to I2S transaction. |
AnnaBridge | 171:3a7713b1edbc | 61 | * @param completionStatus status of the transaction. |
AnnaBridge | 171:3a7713b1edbc | 62 | * @param userData optional pointer to user arguments data. |
AnnaBridge | 171:3a7713b1edbc | 63 | */ |
AnnaBridge | 171:3a7713b1edbc | 64 | typedef void (*i2s_dma_transfer_callback_t)(I2S_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 65 | i2s_dma_handle_t *handle, |
AnnaBridge | 171:3a7713b1edbc | 66 | status_t completionStatus, |
AnnaBridge | 171:3a7713b1edbc | 67 | void *userData); |
AnnaBridge | 171:3a7713b1edbc | 68 | |
AnnaBridge | 171:3a7713b1edbc | 69 | struct _i2s_dma_handle |
AnnaBridge | 171:3a7713b1edbc | 70 | { |
AnnaBridge | 171:3a7713b1edbc | 71 | uint32_t state; /*!< Internal state of I2S DMA transfer */ |
AnnaBridge | 171:3a7713b1edbc | 72 | i2s_dma_transfer_callback_t completionCallback; /*!< Callback function pointer */ |
AnnaBridge | 171:3a7713b1edbc | 73 | void *userData; /*!< Application data passed to callback */ |
AnnaBridge | 171:3a7713b1edbc | 74 | dma_handle_t *dmaHandle; /*!< DMA handle */ |
AnnaBridge | 171:3a7713b1edbc | 75 | volatile i2s_transfer_t i2sQueue[I2S_NUM_BUFFERS]; /*!< Transfer queue storing transfer buffers */ |
AnnaBridge | 171:3a7713b1edbc | 76 | volatile uint8_t queueUser; /*!< Queue index where user's next transfer will be stored */ |
AnnaBridge | 171:3a7713b1edbc | 77 | volatile uint8_t queueDriver; /*!< Queue index of buffer actually used by the driver */ |
AnnaBridge | 171:3a7713b1edbc | 78 | }; |
AnnaBridge | 171:3a7713b1edbc | 79 | |
AnnaBridge | 171:3a7713b1edbc | 80 | /******************************************************************************* |
AnnaBridge | 171:3a7713b1edbc | 81 | * API |
AnnaBridge | 171:3a7713b1edbc | 82 | ******************************************************************************/ |
AnnaBridge | 171:3a7713b1edbc | 83 | |
AnnaBridge | 171:3a7713b1edbc | 84 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 85 | extern "C" { |
AnnaBridge | 171:3a7713b1edbc | 86 | #endif |
AnnaBridge | 171:3a7713b1edbc | 87 | |
AnnaBridge | 171:3a7713b1edbc | 88 | /*! |
AnnaBridge | 171:3a7713b1edbc | 89 | * @name Initialization and deinitialization |
AnnaBridge | 171:3a7713b1edbc | 90 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 91 | */ |
AnnaBridge | 171:3a7713b1edbc | 92 | |
AnnaBridge | 171:3a7713b1edbc | 93 | /*! @} */ |
AnnaBridge | 171:3a7713b1edbc | 94 | |
AnnaBridge | 171:3a7713b1edbc | 95 | /*! |
AnnaBridge | 171:3a7713b1edbc | 96 | * @name DMA API |
AnnaBridge | 171:3a7713b1edbc | 97 | * @{ |
AnnaBridge | 171:3a7713b1edbc | 98 | */ |
AnnaBridge | 171:3a7713b1edbc | 99 | |
AnnaBridge | 171:3a7713b1edbc | 100 | /*! |
AnnaBridge | 171:3a7713b1edbc | 101 | * @brief Initializes handle for transfer of audio data. |
AnnaBridge | 171:3a7713b1edbc | 102 | * |
AnnaBridge | 171:3a7713b1edbc | 103 | * @param base I2S base pointer. |
AnnaBridge | 171:3a7713b1edbc | 104 | * @param handle pointer to handle structure. |
AnnaBridge | 171:3a7713b1edbc | 105 | * @param dmaHandle pointer to dma handle structure. |
AnnaBridge | 171:3a7713b1edbc | 106 | * @param callback function to be called back when transfer is done or fails. |
AnnaBridge | 171:3a7713b1edbc | 107 | * @param userData pointer to data passed to callback. |
AnnaBridge | 171:3a7713b1edbc | 108 | */ |
AnnaBridge | 171:3a7713b1edbc | 109 | void I2S_TxTransferCreateHandleDMA(I2S_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 110 | i2s_dma_handle_t *handle, |
AnnaBridge | 171:3a7713b1edbc | 111 | dma_handle_t *dmaHandle, |
AnnaBridge | 171:3a7713b1edbc | 112 | i2s_dma_transfer_callback_t callback, |
AnnaBridge | 171:3a7713b1edbc | 113 | void *userData); |
AnnaBridge | 171:3a7713b1edbc | 114 | |
AnnaBridge | 171:3a7713b1edbc | 115 | /*! |
AnnaBridge | 171:3a7713b1edbc | 116 | * @brief Begins or queue sending of the given data. |
AnnaBridge | 171:3a7713b1edbc | 117 | * |
AnnaBridge | 171:3a7713b1edbc | 118 | * @param base I2S base pointer. |
AnnaBridge | 171:3a7713b1edbc | 119 | * @param handle pointer to handle structure. |
AnnaBridge | 171:3a7713b1edbc | 120 | * @param transfer data buffer. |
AnnaBridge | 171:3a7713b1edbc | 121 | * |
AnnaBridge | 171:3a7713b1edbc | 122 | * @retval kStatus_Success |
AnnaBridge | 171:3a7713b1edbc | 123 | * @retval kStatus_I2S_Busy if all queue slots are occupied with unsent buffers. |
AnnaBridge | 171:3a7713b1edbc | 124 | */ |
AnnaBridge | 171:3a7713b1edbc | 125 | status_t I2S_TxTransferSendDMA(I2S_Type *base, i2s_dma_handle_t *handle, i2s_transfer_t transfer); |
AnnaBridge | 171:3a7713b1edbc | 126 | |
AnnaBridge | 171:3a7713b1edbc | 127 | /*! |
AnnaBridge | 171:3a7713b1edbc | 128 | * @brief Aborts transfer of data. |
AnnaBridge | 171:3a7713b1edbc | 129 | * |
AnnaBridge | 171:3a7713b1edbc | 130 | * @param base I2S base pointer. |
AnnaBridge | 171:3a7713b1edbc | 131 | * @param handle pointer to handle structure. |
AnnaBridge | 171:3a7713b1edbc | 132 | */ |
AnnaBridge | 171:3a7713b1edbc | 133 | void I2S_TransferAbortDMA(I2S_Type *base, i2s_dma_handle_t *handle); |
AnnaBridge | 171:3a7713b1edbc | 134 | |
AnnaBridge | 171:3a7713b1edbc | 135 | /*! |
AnnaBridge | 171:3a7713b1edbc | 136 | * @brief Initializes handle for reception of audio data. |
AnnaBridge | 171:3a7713b1edbc | 137 | * |
AnnaBridge | 171:3a7713b1edbc | 138 | * @param base I2S base pointer. |
AnnaBridge | 171:3a7713b1edbc | 139 | * @param handle pointer to handle structure. |
AnnaBridge | 171:3a7713b1edbc | 140 | * @param dmaHandle pointer to dma handle structure. |
AnnaBridge | 171:3a7713b1edbc | 141 | * @param callback function to be called back when transfer is done or fails. |
AnnaBridge | 171:3a7713b1edbc | 142 | * @param userData pointer to data passed to callback. |
AnnaBridge | 171:3a7713b1edbc | 143 | */ |
AnnaBridge | 171:3a7713b1edbc | 144 | void I2S_RxTransferCreateHandleDMA(I2S_Type *base, |
AnnaBridge | 171:3a7713b1edbc | 145 | i2s_dma_handle_t *handle, |
AnnaBridge | 171:3a7713b1edbc | 146 | dma_handle_t *dmaHandle, |
AnnaBridge | 171:3a7713b1edbc | 147 | i2s_dma_transfer_callback_t callback, |
AnnaBridge | 171:3a7713b1edbc | 148 | void *userData); |
AnnaBridge | 171:3a7713b1edbc | 149 | |
AnnaBridge | 171:3a7713b1edbc | 150 | /*! |
AnnaBridge | 171:3a7713b1edbc | 151 | * @brief Begins or queue reception of data into given buffer. |
AnnaBridge | 171:3a7713b1edbc | 152 | * |
AnnaBridge | 171:3a7713b1edbc | 153 | * @param base I2S base pointer. |
AnnaBridge | 171:3a7713b1edbc | 154 | * @param handle pointer to handle structure. |
AnnaBridge | 171:3a7713b1edbc | 155 | * @param transfer data buffer. |
AnnaBridge | 171:3a7713b1edbc | 156 | * |
AnnaBridge | 171:3a7713b1edbc | 157 | * @retval kStatus_Success |
AnnaBridge | 171:3a7713b1edbc | 158 | * @retval kStatus_I2S_Busy if all queue slots are occupied with buffers |
AnnaBridge | 171:3a7713b1edbc | 159 | * which are not full. |
AnnaBridge | 171:3a7713b1edbc | 160 | */ |
AnnaBridge | 171:3a7713b1edbc | 161 | status_t I2S_RxTransferReceiveDMA(I2S_Type *base, i2s_dma_handle_t *handle, i2s_transfer_t transfer); |
AnnaBridge | 171:3a7713b1edbc | 162 | |
AnnaBridge | 171:3a7713b1edbc | 163 | /*! |
AnnaBridge | 171:3a7713b1edbc | 164 | * @brief Invoked from DMA interrupt handler. |
AnnaBridge | 171:3a7713b1edbc | 165 | * |
AnnaBridge | 171:3a7713b1edbc | 166 | * @param handle pointer to DMA handle structure. |
AnnaBridge | 171:3a7713b1edbc | 167 | * @param userData argument for user callback. |
AnnaBridge | 171:3a7713b1edbc | 168 | * @param transferDone if transfer was done. |
AnnaBridge | 171:3a7713b1edbc | 169 | * @param tcds |
AnnaBridge | 171:3a7713b1edbc | 170 | */ |
AnnaBridge | 171:3a7713b1edbc | 171 | void I2S_DMACallback(dma_handle_t *handle, void *userData, bool transferDone, uint32_t tcds); |
AnnaBridge | 171:3a7713b1edbc | 172 | |
AnnaBridge | 171:3a7713b1edbc | 173 | /*! @} */ |
AnnaBridge | 171:3a7713b1edbc | 174 | |
AnnaBridge | 171:3a7713b1edbc | 175 | /*! @} */ |
AnnaBridge | 171:3a7713b1edbc | 176 | |
AnnaBridge | 171:3a7713b1edbc | 177 | #if defined(__cplusplus) |
AnnaBridge | 171:3a7713b1edbc | 178 | } |
AnnaBridge | 171:3a7713b1edbc | 179 | #endif |
AnnaBridge | 171:3a7713b1edbc | 180 | |
AnnaBridge | 171:3a7713b1edbc | 181 | #endif /* _FSL_I2S_DMA_H_ */ |