added prescaler for 16 bit pwm in LPC1347 target

Fork of mbed-dev by mbed official

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?

UserRevisionLine numberNew 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_EDMA_H_
<> 144:ef7eb2e8f9f7 31 #define _FSL_SAI_EDMA_H_
<> 144:ef7eb2e8f9f7 32
<> 144:ef7eb2e8f9f7 33 #include "fsl_sai.h"
<> 144:ef7eb2e8f9f7 34 #include "fsl_edma.h"
<> 144:ef7eb2e8f9f7 35
<> 144:ef7eb2e8f9f7 36 /*!
<> 144:ef7eb2e8f9f7 37 * @addtogroup sai_edma
<> 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_edma_handle sai_edma_handle_t;
<> 144:ef7eb2e8f9f7 48
<> 144:ef7eb2e8f9f7 49 /*! @brief SAI eDMA transfer callback function for finish and error */
<> 144:ef7eb2e8f9f7 50 typedef void (*sai_edma_callback_t)(I2S_Type *base, sai_edma_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_edma_handle
<> 144:ef7eb2e8f9f7 54 {
<> 144:ef7eb2e8f9f7 55 edma_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 */
<> 144:ef7eb2e8f9f7 58 uint8_t count; /*!< The transfer data count in a DMA request */
<> 144:ef7eb2e8f9f7 59 uint32_t state; /*!< Internal state for SAI eDMA transfer */
<> 144:ef7eb2e8f9f7 60 sai_edma_callback_t callback; /*!< Callback for users while transfer finish or error occurs */
<> 144:ef7eb2e8f9f7 61 void *userData; /*!< User callback parameter */
<> 144:ef7eb2e8f9f7 62 edma_tcd_t tcd[SAI_XFER_QUEUE_SIZE + 1U]; /*!< TCD pool for eDMA transfer. */
<> 144:ef7eb2e8f9f7 63 sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer. */
<> 144:ef7eb2e8f9f7 64 size_t transferSize[SAI_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */
<> 144:ef7eb2e8f9f7 65 volatile uint8_t queueUser; /*!< Index for user to queue transfer. */
<> 144:ef7eb2e8f9f7 66 volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */
<> 144:ef7eb2e8f9f7 67 };
<> 144:ef7eb2e8f9f7 68
<> 144:ef7eb2e8f9f7 69 /*******************************************************************************
<> 144:ef7eb2e8f9f7 70 * APIs
<> 144:ef7eb2e8f9f7 71 ******************************************************************************/
<> 144:ef7eb2e8f9f7 72 #if defined(__cplusplus)
<> 144:ef7eb2e8f9f7 73 extern "C" {
<> 144:ef7eb2e8f9f7 74 #endif
<> 144:ef7eb2e8f9f7 75
<> 144:ef7eb2e8f9f7 76 /*!
<> 144:ef7eb2e8f9f7 77 * @name eDMA Transactional
<> 144:ef7eb2e8f9f7 78 * @{
<> 144:ef7eb2e8f9f7 79 */
<> 144:ef7eb2e8f9f7 80
<> 144:ef7eb2e8f9f7 81 /*!
<> 144:ef7eb2e8f9f7 82 * @brief Initializes the SAI eDMA handle.
<> 144:ef7eb2e8f9f7 83 *
<> 144:ef7eb2e8f9f7 84 * This function initializes the SAI master DMA handle, which can be used for other SAI master transactional APIs.
<> 144:ef7eb2e8f9f7 85 * Usually, for a specified SAI instance, call this API once to get the initialized handle.
<> 144:ef7eb2e8f9f7 86 *
<> 144:ef7eb2e8f9f7 87 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 88 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 89 * @param base SAI peripheral base address.
<> 144:ef7eb2e8f9f7 90 * @param callback Pointer to user callback function.
<> 144:ef7eb2e8f9f7 91 * @param userData User parameter passed to the callback function.
<> 144:ef7eb2e8f9f7 92 * @param dmaHandle eDMA handle pointer, this handle shall be static allocated by users.
<> 144:ef7eb2e8f9f7 93 */
<> 144:ef7eb2e8f9f7 94 void SAI_TransferTxCreateHandleEDMA(
<> 144:ef7eb2e8f9f7 95 I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *dmaHandle);
<> 144:ef7eb2e8f9f7 96
<> 144:ef7eb2e8f9f7 97 /*!
<> 144:ef7eb2e8f9f7 98 * @brief Initializes the SAI Rx eDMA handle.
<> 144:ef7eb2e8f9f7 99 *
<> 144:ef7eb2e8f9f7 100 * This function initializes the SAI slave DMA handle, which can be used for other SAI master transactional APIs.
<> 144:ef7eb2e8f9f7 101 * Usually, for a specified SAI instance, call this API once to get the initialized handle.
<> 144:ef7eb2e8f9f7 102 *
<> 144:ef7eb2e8f9f7 103 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 104 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 105 * @param base SAI peripheral base address.
<> 144:ef7eb2e8f9f7 106 * @param callback Pointer to user callback function.
<> 144:ef7eb2e8f9f7 107 * @param userData User parameter passed to the callback function.
<> 144:ef7eb2e8f9f7 108 * @param dmaHandle eDMA handle pointer, this handle shall be static allocated by users.
<> 144:ef7eb2e8f9f7 109 */
<> 144:ef7eb2e8f9f7 110 void SAI_TransferRxCreateHandleEDMA(
<> 144:ef7eb2e8f9f7 111 I2S_Type *base, sai_edma_handle_t *handle, sai_edma_callback_t callback, void *userData, edma_handle_t *dmaHandle);
<> 144:ef7eb2e8f9f7 112
<> 144:ef7eb2e8f9f7 113 /*!
<> 144:ef7eb2e8f9f7 114 * @brief Configures the SAI Tx audio format.
<> 144:ef7eb2e8f9f7 115 *
<> 144:ef7eb2e8f9f7 116 * The audio format can be changed at run-time. This function configures the sample rate and audio data
<> 144:ef7eb2e8f9f7 117 * format to be transferred. This function also sets the eDMA parameter according to formatting requirements.
<> 144:ef7eb2e8f9f7 118 *
<> 144:ef7eb2e8f9f7 119 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 120 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 121 * @param format Pointer to SAI audio data format structure.
<> 144:ef7eb2e8f9f7 122 * @param mclkSourceClockHz SAI master clock source frequency in Hz.
<> 144:ef7eb2e8f9f7 123 * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If bit clock source is master
<> 144:ef7eb2e8f9f7 124 * clock, this value should equals to masterClockHz in format.
<> 144:ef7eb2e8f9f7 125 * @retval kStatus_Success Audio format set successfully.
<> 144:ef7eb2e8f9f7 126 * @retval kStatus_InvalidArgument The input argument is invalid.
<> 144:ef7eb2e8f9f7 127 */
<> 144:ef7eb2e8f9f7 128 void SAI_TransferTxSetFormatEDMA(I2S_Type *base,
<> 144:ef7eb2e8f9f7 129 sai_edma_handle_t *handle,
<> 144:ef7eb2e8f9f7 130 sai_transfer_format_t *format,
<> 144:ef7eb2e8f9f7 131 uint32_t mclkSourceClockHz,
<> 144:ef7eb2e8f9f7 132 uint32_t bclkSourceClockHz);
<> 144:ef7eb2e8f9f7 133
<> 144:ef7eb2e8f9f7 134 /*!
<> 144:ef7eb2e8f9f7 135 * @brief Configures the SAI Rx audio format.
<> 144:ef7eb2e8f9f7 136 *
<> 144:ef7eb2e8f9f7 137 * The audio format can be changed at run-time. This function configures the sample rate and audio data
<> 144:ef7eb2e8f9f7 138 * format to be transferred. This function also sets the eDMA parameter according to formatting requirements.
<> 144:ef7eb2e8f9f7 139 *
<> 144:ef7eb2e8f9f7 140 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 141 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 142 * @param format Pointer to SAI audio data format structure.
<> 144:ef7eb2e8f9f7 143 * @param mclkSourceClockHz SAI master clock source frequency in Hz.
<> 144:ef7eb2e8f9f7 144 * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If a bit clock source is the master
<> 144:ef7eb2e8f9f7 145 * clock, this value should equal to masterClockHz in format.
<> 144:ef7eb2e8f9f7 146 * @retval kStatus_Success Audio format set successfully.
<> 144:ef7eb2e8f9f7 147 * @retval kStatus_InvalidArgument The input argument is invalid.
<> 144:ef7eb2e8f9f7 148 */
<> 144:ef7eb2e8f9f7 149 void SAI_TransferRxSetFormatEDMA(I2S_Type *base,
<> 144:ef7eb2e8f9f7 150 sai_edma_handle_t *handle,
<> 144:ef7eb2e8f9f7 151 sai_transfer_format_t *format,
<> 144:ef7eb2e8f9f7 152 uint32_t mclkSourceClockHz,
<> 144:ef7eb2e8f9f7 153 uint32_t bclkSourceClockHz);
<> 144:ef7eb2e8f9f7 154
<> 144:ef7eb2e8f9f7 155 /*!
<> 144:ef7eb2e8f9f7 156 * @brief Performs a non-blocking SAI transfer using DMA.
<> 144:ef7eb2e8f9f7 157 *
<> 144:ef7eb2e8f9f7 158 * @note This interface returns immediately after the transfer initiates. Call
<> 144:ef7eb2e8f9f7 159 * SAI_GetTransferStatus to poll the transfer status and check whether the SAI transfer is finished.
<> 144:ef7eb2e8f9f7 160 *
<> 144:ef7eb2e8f9f7 161 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 162 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 163 * @param xfer Pointer to the DMA transfer structure.
<> 144:ef7eb2e8f9f7 164 * @retval kStatus_Success Start a SAI eDMA send successfully.
<> 144:ef7eb2e8f9f7 165 * @retval kStatus_InvalidArgument The input argument is invalid.
<> 144:ef7eb2e8f9f7 166 * @retval kStatus_TxBusy SAI is busy sending data.
<> 144:ef7eb2e8f9f7 167 */
<> 144:ef7eb2e8f9f7 168 status_t SAI_TransferSendEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_t *xfer);
<> 144:ef7eb2e8f9f7 169
<> 144:ef7eb2e8f9f7 170 /*!
<> 144:ef7eb2e8f9f7 171 * @brief Performs a non-blocking SAI receive using eDMA.
<> 144:ef7eb2e8f9f7 172 *
<> 144:ef7eb2e8f9f7 173 * @note This interface returns immediately after the transfer initiates. Call
<> 144:ef7eb2e8f9f7 174 * the SAI_GetReceiveRemainingBytes to poll the transfer status and check whether the SAI transfer is finished.
<> 144:ef7eb2e8f9f7 175 *
<> 144:ef7eb2e8f9f7 176 * @param base SAI base pointer
<> 144:ef7eb2e8f9f7 177 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 178 * @param xfer Pointer to DMA transfer structure.
<> 144:ef7eb2e8f9f7 179 * @retval kStatus_Success Start a SAI eDMA receive successfully.
<> 144:ef7eb2e8f9f7 180 * @retval kStatus_InvalidArgument The input argument is invalid.
<> 144:ef7eb2e8f9f7 181 * @retval kStatus_RxBusy SAI is busy receiving data.
<> 144:ef7eb2e8f9f7 182 */
<> 144:ef7eb2e8f9f7 183 status_t SAI_TransferReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle, sai_transfer_t *xfer);
<> 144:ef7eb2e8f9f7 184
<> 144:ef7eb2e8f9f7 185 /*!
<> 144:ef7eb2e8f9f7 186 * @brief Aborts a SAI transfer using eDMA.
<> 144:ef7eb2e8f9f7 187 *
<> 144:ef7eb2e8f9f7 188 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 189 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 190 */
<> 144:ef7eb2e8f9f7 191 void SAI_TransferAbortSendEDMA(I2S_Type *base, sai_edma_handle_t *handle);
<> 144:ef7eb2e8f9f7 192
<> 144:ef7eb2e8f9f7 193 /*!
<> 144:ef7eb2e8f9f7 194 * @brief Aborts a SAI receive using eDMA.
<> 144:ef7eb2e8f9f7 195 *
<> 144:ef7eb2e8f9f7 196 * @param base SAI base pointer
<> 144:ef7eb2e8f9f7 197 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 198 */
<> 144:ef7eb2e8f9f7 199 void SAI_TransferAbortReceiveEDMA(I2S_Type *base, sai_edma_handle_t *handle);
<> 144:ef7eb2e8f9f7 200
<> 144:ef7eb2e8f9f7 201 /*!
<> 144:ef7eb2e8f9f7 202 * @brief Gets byte count sent by SAI.
<> 144:ef7eb2e8f9f7 203 *
<> 144:ef7eb2e8f9f7 204 * @param base SAI base pointer.
<> 144:ef7eb2e8f9f7 205 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 206 * @param count Bytes count sent by SAI.
<> 144:ef7eb2e8f9f7 207 * @retval kStatus_Success Succeed get the transfer count.
<> 144:ef7eb2e8f9f7 208 * @retval kStatus_NoTransferInProgress There is no non-blocking transaction in progress.
<> 144:ef7eb2e8f9f7 209 */
<> 144:ef7eb2e8f9f7 210 status_t SAI_TransferGetSendCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count);
<> 144:ef7eb2e8f9f7 211
<> 144:ef7eb2e8f9f7 212 /*!
<> 144:ef7eb2e8f9f7 213 * @brief Gets byte count received by SAI.
<> 144:ef7eb2e8f9f7 214 *
<> 144:ef7eb2e8f9f7 215 * @param base SAI base pointer
<> 144:ef7eb2e8f9f7 216 * @param handle SAI eDMA handle pointer.
<> 144:ef7eb2e8f9f7 217 * @param count Bytes count received by SAI.
<> 144:ef7eb2e8f9f7 218 * @retval kStatus_Success Succeed get the transfer count.
<> 144:ef7eb2e8f9f7 219 * @retval kStatus_NoTransferInProgress There is no non-blocking transaction in progress.
<> 144:ef7eb2e8f9f7 220 */
<> 144:ef7eb2e8f9f7 221 status_t SAI_TransferGetReceiveCountEDMA(I2S_Type *base, sai_edma_handle_t *handle, size_t *count);
<> 144:ef7eb2e8f9f7 222
<> 144:ef7eb2e8f9f7 223 /*! @} */
<> 144:ef7eb2e8f9f7 224
<> 144:ef7eb2e8f9f7 225 #if defined(__cplusplus)
<> 144:ef7eb2e8f9f7 226 }
<> 144:ef7eb2e8f9f7 227 #endif
<> 144:ef7eb2e8f9f7 228
<> 144:ef7eb2e8f9f7 229 /*!
<> 144:ef7eb2e8f9f7 230 * @}
<> 144:ef7eb2e8f9f7 231 */
<> 144:ef7eb2e8f9f7 232 #endif