added prescaler for 16 bit pwm in LPC1347 target
Fork of mbed-dev by
targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_KL43Z/drivers/fsl_sai_dma.h@144:ef7eb2e8f9f7, 2016-09-02 (annotated)
- Committer:
- <>
- Date:
- Fri Sep 02 15:07:44 2016 +0100
- Revision:
- 144:ef7eb2e8f9f7
This updates the lib to the mbed lib v125
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /* |
<> | 144:ef7eb2e8f9f7 | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
<> | 144:ef7eb2e8f9f7 | 3 | * All rights reserved. |
<> | 144:ef7eb2e8f9f7 | 4 | * |
<> | 144:ef7eb2e8f9f7 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 6 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 7 | * |
<> | 144:ef7eb2e8f9f7 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
<> | 144:ef7eb2e8f9f7 | 9 | * of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 10 | * |
<> | 144:ef7eb2e8f9f7 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
<> | 144:ef7eb2e8f9f7 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
<> | 144:ef7eb2e8f9f7 | 13 | * other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 14 | * |
<> | 144:ef7eb2e8f9f7 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
<> | 144:ef7eb2e8f9f7 | 16 | * contributors may be used to endorse or promote products derived from this |
<> | 144:ef7eb2e8f9f7 | 17 | * software without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 18 | * |
<> | 144:ef7eb2e8f9f7 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
<> | 144:ef7eb2e8f9f7 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
<> | 144:ef7eb2e8f9f7 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
<> | 144:ef7eb2e8f9f7 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
<> | 144:ef7eb2e8f9f7 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
<> | 144:ef7eb2e8f9f7 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
<> | 144:ef7eb2e8f9f7 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
<> | 144:ef7eb2e8f9f7 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
<> | 144:ef7eb2e8f9f7 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 29 | */ |
<> | 144:ef7eb2e8f9f7 | 30 | #ifndef _FSL_SAI_DMA_H_ |
<> | 144:ef7eb2e8f9f7 | 31 | #define _FSL_SAI_DMA_H_ |
<> | 144:ef7eb2e8f9f7 | 32 | |
<> | 144:ef7eb2e8f9f7 | 33 | #include "fsl_sai.h" |
<> | 144:ef7eb2e8f9f7 | 34 | #include "fsl_dma.h" |
<> | 144:ef7eb2e8f9f7 | 35 | |
<> | 144:ef7eb2e8f9f7 | 36 | /*! |
<> | 144:ef7eb2e8f9f7 | 37 | * @addtogroup sai_dma |
<> | 144:ef7eb2e8f9f7 | 38 | * @{ |
<> | 144:ef7eb2e8f9f7 | 39 | */ |
<> | 144:ef7eb2e8f9f7 | 40 | |
<> | 144:ef7eb2e8f9f7 | 41 | /*! @file */ |
<> | 144:ef7eb2e8f9f7 | 42 | |
<> | 144:ef7eb2e8f9f7 | 43 | /******************************************************************************* |
<> | 144:ef7eb2e8f9f7 | 44 | * Definitions |
<> | 144:ef7eb2e8f9f7 | 45 | ******************************************************************************/ |
<> | 144:ef7eb2e8f9f7 | 46 | |
<> | 144:ef7eb2e8f9f7 | 47 | typedef struct _sai_dma_handle sai_dma_handle_t; |
<> | 144:ef7eb2e8f9f7 | 48 | |
<> | 144:ef7eb2e8f9f7 | 49 | /*! @brief Define SAI DMA callback */ |
<> | 144:ef7eb2e8f9f7 | 50 | typedef void (*sai_dma_callback_t)(I2S_Type *base, sai_dma_handle_t *handle, status_t status, void *userData); |
<> | 144:ef7eb2e8f9f7 | 51 | |
<> | 144:ef7eb2e8f9f7 | 52 | /*! @brief SAI DMA transfer handle, users should not touch the content of the handle.*/ |
<> | 144:ef7eb2e8f9f7 | 53 | struct _sai_dma_handle |
<> | 144:ef7eb2e8f9f7 | 54 | { |
<> | 144:ef7eb2e8f9f7 | 55 | dma_handle_t *dmaHandle; /*!< DMA handler for SAI send */ |
<> | 144:ef7eb2e8f9f7 | 56 | uint8_t bytesPerFrame; /*!< Bytes in a frame */ |
<> | 144:ef7eb2e8f9f7 | 57 | uint8_t channel; /*!< Which Data channel SAI use */ |
<> | 144:ef7eb2e8f9f7 | 58 | uint32_t state; /*!< SAI DMA transfer internal state */ |
<> | 144:ef7eb2e8f9f7 | 59 | sai_dma_callback_t callback; /*!< Callback for users while transfer finish or error occured */ |
<> | 144:ef7eb2e8f9f7 | 60 | void *userData; /*!< User callback parameter */ |
<> | 144:ef7eb2e8f9f7 | 61 | sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */ |
<> | 144:ef7eb2e8f9f7 | 62 | size_t transferSize[SAI_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */ |
<> | 144:ef7eb2e8f9f7 | 63 | volatile uint8_t queueUser; /*!< Index for user to queue transfer. */ |
<> | 144:ef7eb2e8f9f7 | 64 | volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ |
<> | 144:ef7eb2e8f9f7 | 65 | }; |
<> | 144:ef7eb2e8f9f7 | 66 | |
<> | 144:ef7eb2e8f9f7 | 67 | /******************************************************************************* |
<> | 144:ef7eb2e8f9f7 | 68 | * APIs |
<> | 144:ef7eb2e8f9f7 | 69 | ******************************************************************************/ |
<> | 144:ef7eb2e8f9f7 | 70 | #if defined(__cplusplus) |
<> | 144:ef7eb2e8f9f7 | 71 | extern "C" { |
<> | 144:ef7eb2e8f9f7 | 72 | #endif |
<> | 144:ef7eb2e8f9f7 | 73 | |
<> | 144:ef7eb2e8f9f7 | 74 | /*! |
<> | 144:ef7eb2e8f9f7 | 75 | * @name DMA Transactional |
<> | 144:ef7eb2e8f9f7 | 76 | * @{ |
<> | 144:ef7eb2e8f9f7 | 77 | */ |
<> | 144:ef7eb2e8f9f7 | 78 | |
<> | 144:ef7eb2e8f9f7 | 79 | /*! |
<> | 144:ef7eb2e8f9f7 | 80 | * @brief Initializes the SAI master DMA handle. |
<> | 144:ef7eb2e8f9f7 | 81 | * |
<> | 144:ef7eb2e8f9f7 | 82 | * This function initializes the SAI master DMA handle, which can be used for other SAI master transactional APIs. |
<> | 144:ef7eb2e8f9f7 | 83 | * Usually, for a specified SAI instance, call this API once to get the initialized handle. |
<> | 144:ef7eb2e8f9f7 | 84 | * |
<> | 144:ef7eb2e8f9f7 | 85 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 86 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 87 | * @param base SAI peripheral base address. |
<> | 144:ef7eb2e8f9f7 | 88 | * @param callback Pointer to user callback function. |
<> | 144:ef7eb2e8f9f7 | 89 | * @param userData User parameter passed to the callback function. |
<> | 144:ef7eb2e8f9f7 | 90 | * @param dmaHandle DMA handle pointer, this handle shall be static allocated by users. |
<> | 144:ef7eb2e8f9f7 | 91 | */ |
<> | 144:ef7eb2e8f9f7 | 92 | void SAI_TransferTxCreateHandleDMA( |
<> | 144:ef7eb2e8f9f7 | 93 | I2S_Type *base, sai_dma_handle_t *handle, sai_dma_callback_t callback, void *userData, dma_handle_t *dmaHandle); |
<> | 144:ef7eb2e8f9f7 | 94 | |
<> | 144:ef7eb2e8f9f7 | 95 | /*! |
<> | 144:ef7eb2e8f9f7 | 96 | * @brief Initializes the SAI slave DMA handle. |
<> | 144:ef7eb2e8f9f7 | 97 | * |
<> | 144:ef7eb2e8f9f7 | 98 | * This function initializes the SAI slave DMA handle, which can be used for other SAI master transactional APIs. |
<> | 144:ef7eb2e8f9f7 | 99 | * Usually, for a specified SAI instance, call this API once to get the initialized handle. |
<> | 144:ef7eb2e8f9f7 | 100 | * |
<> | 144:ef7eb2e8f9f7 | 101 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 102 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 103 | * @param base SAI peripheral base address. |
<> | 144:ef7eb2e8f9f7 | 104 | * @param callback Pointer to user callback function. |
<> | 144:ef7eb2e8f9f7 | 105 | * @param userData User parameter passed to the callback function. |
<> | 144:ef7eb2e8f9f7 | 106 | * @param dmaHandle DMA handle pointer, this handle shall be static allocated by users. |
<> | 144:ef7eb2e8f9f7 | 107 | */ |
<> | 144:ef7eb2e8f9f7 | 108 | void SAI_TransferRxCreateHandleDMA( |
<> | 144:ef7eb2e8f9f7 | 109 | I2S_Type *base, sai_dma_handle_t *handle, sai_dma_callback_t callback, void *userData, dma_handle_t *dmaHandle); |
<> | 144:ef7eb2e8f9f7 | 110 | |
<> | 144:ef7eb2e8f9f7 | 111 | /*! |
<> | 144:ef7eb2e8f9f7 | 112 | * @brief Configures the SAI Tx audio format. |
<> | 144:ef7eb2e8f9f7 | 113 | * |
<> | 144:ef7eb2e8f9f7 | 114 | * The audio format can be changed at run-time. This function configures the sample rate and audio data |
<> | 144:ef7eb2e8f9f7 | 115 | * format to be transferred. This function also sets the eDMA parameter according to the format. |
<> | 144:ef7eb2e8f9f7 | 116 | * |
<> | 144:ef7eb2e8f9f7 | 117 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 118 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 119 | * @param format Pointer to SAI audio data format structure. |
<> | 144:ef7eb2e8f9f7 | 120 | * @param mclkSourceClockHz SAI master clock source frequency in Hz. |
<> | 144:ef7eb2e8f9f7 | 121 | * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If bit clock source is master. |
<> | 144:ef7eb2e8f9f7 | 122 | * clock, this value should equals to masterClockHz in format. |
<> | 144:ef7eb2e8f9f7 | 123 | * @retval kStatus_Success Audio format set successfully. |
<> | 144:ef7eb2e8f9f7 | 124 | * @retval kStatus_InvalidArgument The input arguments is invalid. |
<> | 144:ef7eb2e8f9f7 | 125 | */ |
<> | 144:ef7eb2e8f9f7 | 126 | void SAI_TransferTxSetFormatDMA(I2S_Type *base, |
<> | 144:ef7eb2e8f9f7 | 127 | sai_dma_handle_t *handle, |
<> | 144:ef7eb2e8f9f7 | 128 | sai_transfer_format_t *format, |
<> | 144:ef7eb2e8f9f7 | 129 | uint32_t mclkSourceClockHz, |
<> | 144:ef7eb2e8f9f7 | 130 | uint32_t bclkSourceClockHz); |
<> | 144:ef7eb2e8f9f7 | 131 | |
<> | 144:ef7eb2e8f9f7 | 132 | /*! |
<> | 144:ef7eb2e8f9f7 | 133 | * @brief Configures the SAI Rx audio format. |
<> | 144:ef7eb2e8f9f7 | 134 | * |
<> | 144:ef7eb2e8f9f7 | 135 | * The audio format can be changed at run-time. This function configures the sample rate and audio data |
<> | 144:ef7eb2e8f9f7 | 136 | * format to be transferred. This function also sets EDMA parameter according to format. |
<> | 144:ef7eb2e8f9f7 | 137 | * |
<> | 144:ef7eb2e8f9f7 | 138 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 139 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 140 | * @param format Pointer to SAI audio data format structure. |
<> | 144:ef7eb2e8f9f7 | 141 | * @param mclkSourceClockHz SAI master clock source frequency in Hz. |
<> | 144:ef7eb2e8f9f7 | 142 | * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If bit clock source is master. |
<> | 144:ef7eb2e8f9f7 | 143 | * clock, this value should equals to masterClockHz in format. |
<> | 144:ef7eb2e8f9f7 | 144 | * @retval kStatus_Success Audio format set successfully. |
<> | 144:ef7eb2e8f9f7 | 145 | * @retval kStatus_InvalidArgument The input arguments is invalid. |
<> | 144:ef7eb2e8f9f7 | 146 | */ |
<> | 144:ef7eb2e8f9f7 | 147 | void SAI_TransferRxSetFormatDMA(I2S_Type *base, |
<> | 144:ef7eb2e8f9f7 | 148 | sai_dma_handle_t *handle, |
<> | 144:ef7eb2e8f9f7 | 149 | sai_transfer_format_t *format, |
<> | 144:ef7eb2e8f9f7 | 150 | uint32_t mclkSourceClockHz, |
<> | 144:ef7eb2e8f9f7 | 151 | uint32_t bclkSourceClockHz); |
<> | 144:ef7eb2e8f9f7 | 152 | |
<> | 144:ef7eb2e8f9f7 | 153 | /*! |
<> | 144:ef7eb2e8f9f7 | 154 | * @brief Performs a non-blocking SAI transfer using DMA. |
<> | 144:ef7eb2e8f9f7 | 155 | * |
<> | 144:ef7eb2e8f9f7 | 156 | * @note This interface returns immediately after the transfer initiates. Call |
<> | 144:ef7eb2e8f9f7 | 157 | * the SAI_GetTransferStatus to poll the transfer status to check whether the SAI transfer finished. |
<> | 144:ef7eb2e8f9f7 | 158 | * |
<> | 144:ef7eb2e8f9f7 | 159 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 160 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 161 | * @param xfer Pointer to DMA transfer structure. |
<> | 144:ef7eb2e8f9f7 | 162 | * @retval kStatus_Success Successfully start the data receive. |
<> | 144:ef7eb2e8f9f7 | 163 | * @retval kStatus_SAI_TxBusy Previous receive still not finished. |
<> | 144:ef7eb2e8f9f7 | 164 | * @retval kStatus_InvalidArgument The input parameter is invalid. |
<> | 144:ef7eb2e8f9f7 | 165 | */ |
<> | 144:ef7eb2e8f9f7 | 166 | status_t SAI_TransferSendDMA(I2S_Type *base, sai_dma_handle_t *handle, sai_transfer_t *xfer); |
<> | 144:ef7eb2e8f9f7 | 167 | |
<> | 144:ef7eb2e8f9f7 | 168 | /*! |
<> | 144:ef7eb2e8f9f7 | 169 | * @brief Performs a non-blocking SAI transfer using DMA. |
<> | 144:ef7eb2e8f9f7 | 170 | * |
<> | 144:ef7eb2e8f9f7 | 171 | * @note This interface returns immediately after transfer initiates. Call |
<> | 144:ef7eb2e8f9f7 | 172 | * SAI_GetTransferStatus to poll the transfer status to check whether the SAI transfer is finished. |
<> | 144:ef7eb2e8f9f7 | 173 | * |
<> | 144:ef7eb2e8f9f7 | 174 | * @param base SAI base pointer |
<> | 144:ef7eb2e8f9f7 | 175 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 176 | * @param xfer Pointer to DMA transfer structure. |
<> | 144:ef7eb2e8f9f7 | 177 | * @retval kStatus_Success Successfully start the data receive. |
<> | 144:ef7eb2e8f9f7 | 178 | * @retval kStatus_SAI_RxBusy Previous receive still not finished. |
<> | 144:ef7eb2e8f9f7 | 179 | * @retval kStatus_InvalidArgument The input parameter is invalid. |
<> | 144:ef7eb2e8f9f7 | 180 | */ |
<> | 144:ef7eb2e8f9f7 | 181 | status_t SAI_TransferReceiveDMA(I2S_Type *base, sai_dma_handle_t *handle, sai_transfer_t *xfer); |
<> | 144:ef7eb2e8f9f7 | 182 | |
<> | 144:ef7eb2e8f9f7 | 183 | /*! |
<> | 144:ef7eb2e8f9f7 | 184 | * @brief Aborts a SAI transfer using DMA. |
<> | 144:ef7eb2e8f9f7 | 185 | * |
<> | 144:ef7eb2e8f9f7 | 186 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 187 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 188 | */ |
<> | 144:ef7eb2e8f9f7 | 189 | void SAI_TransferAbortSendDMA(I2S_Type *base, sai_dma_handle_t *handle); |
<> | 144:ef7eb2e8f9f7 | 190 | |
<> | 144:ef7eb2e8f9f7 | 191 | /*! |
<> | 144:ef7eb2e8f9f7 | 192 | * @brief Aborts a SAI transfer using DMA. |
<> | 144:ef7eb2e8f9f7 | 193 | * |
<> | 144:ef7eb2e8f9f7 | 194 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 195 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 196 | */ |
<> | 144:ef7eb2e8f9f7 | 197 | void SAI_TransferAbortReceiveDMA(I2S_Type *base, sai_dma_handle_t *handle); |
<> | 144:ef7eb2e8f9f7 | 198 | |
<> | 144:ef7eb2e8f9f7 | 199 | /*! |
<> | 144:ef7eb2e8f9f7 | 200 | * @brief Gets byte count sent by SAI. |
<> | 144:ef7eb2e8f9f7 | 201 | * |
<> | 144:ef7eb2e8f9f7 | 202 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 203 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 204 | * @param count Bytes count sent by SAI. |
<> | 144:ef7eb2e8f9f7 | 205 | * @retval kStatus_Success Succeed get the transfer count. |
<> | 144:ef7eb2e8f9f7 | 206 | * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. |
<> | 144:ef7eb2e8f9f7 | 207 | */ |
<> | 144:ef7eb2e8f9f7 | 208 | status_t SAI_TransferGetSendCountDMA(I2S_Type *base, sai_dma_handle_t *handle, size_t *count); |
<> | 144:ef7eb2e8f9f7 | 209 | |
<> | 144:ef7eb2e8f9f7 | 210 | /*! |
<> | 144:ef7eb2e8f9f7 | 211 | * @brief Gets byte count received by SAI. |
<> | 144:ef7eb2e8f9f7 | 212 | * |
<> | 144:ef7eb2e8f9f7 | 213 | * @param base SAI base pointer. |
<> | 144:ef7eb2e8f9f7 | 214 | * @param handle SAI DMA handle pointer. |
<> | 144:ef7eb2e8f9f7 | 215 | * @param count Bytes count received by SAI. |
<> | 144:ef7eb2e8f9f7 | 216 | * @retval kStatus_Success Succeed get the transfer count. |
<> | 144:ef7eb2e8f9f7 | 217 | * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. |
<> | 144:ef7eb2e8f9f7 | 218 | */ |
<> | 144:ef7eb2e8f9f7 | 219 | status_t SAI_TransferGetReceiveCountDMA(I2S_Type *base, sai_dma_handle_t *handle, size_t *count); |
<> | 144:ef7eb2e8f9f7 | 220 | |
<> | 144:ef7eb2e8f9f7 | 221 | /*! @} */ |
<> | 144:ef7eb2e8f9f7 | 222 | |
<> | 144:ef7eb2e8f9f7 | 223 | #if defined(__cplusplus) |
<> | 144:ef7eb2e8f9f7 | 224 | } |
<> | 144:ef7eb2e8f9f7 | 225 | #endif |
<> | 144:ef7eb2e8f9f7 | 226 | |
<> | 144:ef7eb2e8f9f7 | 227 | /*! |
<> | 144:ef7eb2e8f9f7 | 228 | * @} |
<> | 144:ef7eb2e8f9f7 | 229 | */ |
<> | 144:ef7eb2e8f9f7 | 230 | #endif |