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_K64F/TOOLCHAIN_IAR/fsl_sai.h@172:65be27845400, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 20:53:29 2019 +0000
- Revision:
- 172:65be27845400
- Parent:
- 171:3a7713b1edbc
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AnnaBridge | 145:64910690c574 | 1 | /* |
AnnaBridge | 145:64910690c574 | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
AnnaBridge | 145:64910690c574 | 3 | * All rights reserved. |
AnnaBridge | 145:64910690c574 | 4 | * |
AnnaBridge | 145:64910690c574 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
AnnaBridge | 145:64910690c574 | 6 | * are permitted provided that the following conditions are met: |
AnnaBridge | 145:64910690c574 | 7 | * |
AnnaBridge | 145:64910690c574 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
AnnaBridge | 145:64910690c574 | 9 | * of conditions and the following disclaimer. |
AnnaBridge | 145:64910690c574 | 10 | * |
AnnaBridge | 145:64910690c574 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
AnnaBridge | 145:64910690c574 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
AnnaBridge | 145:64910690c574 | 13 | * other materials provided with the distribution. |
AnnaBridge | 145:64910690c574 | 14 | * |
AnnaBridge | 145:64910690c574 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
AnnaBridge | 145:64910690c574 | 16 | * contributors may be used to endorse or promote products derived from this |
AnnaBridge | 145:64910690c574 | 17 | * software without specific prior written permission. |
AnnaBridge | 145:64910690c574 | 18 | * |
AnnaBridge | 145:64910690c574 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
AnnaBridge | 145:64910690c574 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
AnnaBridge | 145:64910690c574 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
AnnaBridge | 145:64910690c574 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
AnnaBridge | 145:64910690c574 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
AnnaBridge | 145:64910690c574 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
AnnaBridge | 145:64910690c574 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
AnnaBridge | 145:64910690c574 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
AnnaBridge | 145:64910690c574 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
AnnaBridge | 145:64910690c574 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
AnnaBridge | 145:64910690c574 | 29 | */ |
AnnaBridge | 145:64910690c574 | 30 | |
AnnaBridge | 145:64910690c574 | 31 | #ifndef _FSL_SAI_H_ |
AnnaBridge | 145:64910690c574 | 32 | #define _FSL_SAI_H_ |
AnnaBridge | 145:64910690c574 | 33 | |
AnnaBridge | 145:64910690c574 | 34 | #include "fsl_common.h" |
AnnaBridge | 145:64910690c574 | 35 | |
AnnaBridge | 145:64910690c574 | 36 | /*! |
AnnaBridge | 145:64910690c574 | 37 | * @addtogroup sai |
AnnaBridge | 145:64910690c574 | 38 | * @{ |
AnnaBridge | 145:64910690c574 | 39 | */ |
AnnaBridge | 145:64910690c574 | 40 | |
AnnaBridge | 145:64910690c574 | 41 | |
AnnaBridge | 145:64910690c574 | 42 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 43 | * Definitions |
AnnaBridge | 145:64910690c574 | 44 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 45 | |
AnnaBridge | 145:64910690c574 | 46 | /*! @name Driver version */ |
AnnaBridge | 145:64910690c574 | 47 | /*@{*/ |
AnnaBridge | 145:64910690c574 | 48 | #define FSL_SAI_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) /*!< Version 2.1.1 */ |
AnnaBridge | 145:64910690c574 | 49 | /*@}*/ |
AnnaBridge | 145:64910690c574 | 50 | |
AnnaBridge | 145:64910690c574 | 51 | /*! @brief SAI return status*/ |
AnnaBridge | 145:64910690c574 | 52 | enum _sai_status_t |
AnnaBridge | 145:64910690c574 | 53 | { |
AnnaBridge | 145:64910690c574 | 54 | kStatus_SAI_TxBusy = MAKE_STATUS(kStatusGroup_SAI, 0), /*!< SAI Tx is busy. */ |
AnnaBridge | 145:64910690c574 | 55 | kStatus_SAI_RxBusy = MAKE_STATUS(kStatusGroup_SAI, 1), /*!< SAI Rx is busy. */ |
AnnaBridge | 145:64910690c574 | 56 | kStatus_SAI_TxError = MAKE_STATUS(kStatusGroup_SAI, 2), /*!< SAI Tx FIFO error. */ |
AnnaBridge | 145:64910690c574 | 57 | kStatus_SAI_RxError = MAKE_STATUS(kStatusGroup_SAI, 3), /*!< SAI Rx FIFO error. */ |
AnnaBridge | 145:64910690c574 | 58 | kStatus_SAI_QueueFull = MAKE_STATUS(kStatusGroup_SAI, 4), /*!< SAI transfer queue is full. */ |
AnnaBridge | 145:64910690c574 | 59 | kStatus_SAI_TxIdle = MAKE_STATUS(kStatusGroup_SAI, 5), /*!< SAI Tx is idle */ |
AnnaBridge | 145:64910690c574 | 60 | kStatus_SAI_RxIdle = MAKE_STATUS(kStatusGroup_SAI, 6) /*!< SAI Rx is idle */ |
AnnaBridge | 145:64910690c574 | 61 | }; |
AnnaBridge | 145:64910690c574 | 62 | |
AnnaBridge | 145:64910690c574 | 63 | /*! @brief Define the SAI bus type */ |
AnnaBridge | 145:64910690c574 | 64 | typedef enum _sai_protocol |
AnnaBridge | 145:64910690c574 | 65 | { |
AnnaBridge | 145:64910690c574 | 66 | kSAI_BusLeftJustified = 0x0U, /*!< Uses left justified format.*/ |
AnnaBridge | 145:64910690c574 | 67 | kSAI_BusRightJustified, /*!< Uses right justified format. */ |
AnnaBridge | 145:64910690c574 | 68 | kSAI_BusI2S, /*!< Uses I2S format. */ |
AnnaBridge | 145:64910690c574 | 69 | kSAI_BusPCMA, /*!< Uses I2S PCM A format.*/ |
AnnaBridge | 145:64910690c574 | 70 | kSAI_BusPCMB /*!< Uses I2S PCM B format. */ |
AnnaBridge | 145:64910690c574 | 71 | } sai_protocol_t; |
AnnaBridge | 145:64910690c574 | 72 | |
AnnaBridge | 145:64910690c574 | 73 | /*! @brief Master or slave mode */ |
AnnaBridge | 145:64910690c574 | 74 | typedef enum _sai_master_slave |
AnnaBridge | 145:64910690c574 | 75 | { |
AnnaBridge | 145:64910690c574 | 76 | kSAI_Master = 0x0U, /*!< Master mode */ |
AnnaBridge | 145:64910690c574 | 77 | kSAI_Slave = 0x1U /*!< Slave mode */ |
AnnaBridge | 145:64910690c574 | 78 | } sai_master_slave_t; |
AnnaBridge | 145:64910690c574 | 79 | |
AnnaBridge | 145:64910690c574 | 80 | /*! @brief Mono or stereo audio format */ |
AnnaBridge | 145:64910690c574 | 81 | typedef enum _sai_mono_stereo |
AnnaBridge | 145:64910690c574 | 82 | { |
AnnaBridge | 145:64910690c574 | 83 | kSAI_Stereo = 0x0U, /*!< Stereo sound. */ |
AnnaBridge | 145:64910690c574 | 84 | kSAI_MonoLeft, /*!< Only left channel have sound. */ |
AnnaBridge | 145:64910690c574 | 85 | kSAI_MonoRight /*!< Only Right channel have sound. */ |
AnnaBridge | 145:64910690c574 | 86 | } sai_mono_stereo_t; |
AnnaBridge | 145:64910690c574 | 87 | |
AnnaBridge | 145:64910690c574 | 88 | /*! @brief Synchronous or asynchronous mode */ |
AnnaBridge | 145:64910690c574 | 89 | typedef enum _sai_sync_mode |
AnnaBridge | 145:64910690c574 | 90 | { |
AnnaBridge | 145:64910690c574 | 91 | kSAI_ModeAsync = 0x0U, /*!< Asynchronous mode */ |
AnnaBridge | 145:64910690c574 | 92 | kSAI_ModeSync, /*!< Synchronous mode (with receiver or transmit) */ |
AnnaBridge | 145:64910690c574 | 93 | kSAI_ModeSyncWithOtherTx, /*!< Synchronous with another SAI transmit */ |
AnnaBridge | 145:64910690c574 | 94 | kSAI_ModeSyncWithOtherRx /*!< Synchronous with another SAI receiver */ |
AnnaBridge | 145:64910690c574 | 95 | } sai_sync_mode_t; |
AnnaBridge | 145:64910690c574 | 96 | |
AnnaBridge | 145:64910690c574 | 97 | /*! @brief Mater clock source */ |
AnnaBridge | 145:64910690c574 | 98 | typedef enum _sai_mclk_source |
AnnaBridge | 145:64910690c574 | 99 | { |
AnnaBridge | 145:64910690c574 | 100 | kSAI_MclkSourceSysclk = 0x0U, /*!< Master clock from the system clock */ |
AnnaBridge | 145:64910690c574 | 101 | kSAI_MclkSourceSelect1, /*!< Master clock from source 1 */ |
AnnaBridge | 145:64910690c574 | 102 | kSAI_MclkSourceSelect2, /*!< Master clock from source 2 */ |
AnnaBridge | 145:64910690c574 | 103 | kSAI_MclkSourceSelect3 /*!< Master clock from source 3 */ |
AnnaBridge | 145:64910690c574 | 104 | } sai_mclk_source_t; |
AnnaBridge | 145:64910690c574 | 105 | |
AnnaBridge | 145:64910690c574 | 106 | /*! @brief Bit clock source */ |
AnnaBridge | 145:64910690c574 | 107 | typedef enum _sai_bclk_source |
AnnaBridge | 145:64910690c574 | 108 | { |
AnnaBridge | 145:64910690c574 | 109 | kSAI_BclkSourceBusclk = 0x0U, /*!< Bit clock using bus clock */ |
AnnaBridge | 145:64910690c574 | 110 | kSAI_BclkSourceMclkDiv, /*!< Bit clock using master clock divider */ |
AnnaBridge | 145:64910690c574 | 111 | kSAI_BclkSourceOtherSai0, /*!< Bit clock from other SAI device */ |
AnnaBridge | 145:64910690c574 | 112 | kSAI_BclkSourceOtherSai1 /*!< Bit clock from other SAI device */ |
AnnaBridge | 145:64910690c574 | 113 | } sai_bclk_source_t; |
AnnaBridge | 145:64910690c574 | 114 | |
AnnaBridge | 145:64910690c574 | 115 | /*! @brief The SAI interrupt enable flag */ |
AnnaBridge | 145:64910690c574 | 116 | enum _sai_interrupt_enable_t |
AnnaBridge | 145:64910690c574 | 117 | { |
AnnaBridge | 145:64910690c574 | 118 | kSAI_WordStartInterruptEnable = |
AnnaBridge | 145:64910690c574 | 119 | I2S_TCSR_WSIE_MASK, /*!< Word start flag, means the first word in a frame detected */ |
AnnaBridge | 145:64910690c574 | 120 | kSAI_SyncErrorInterruptEnable = I2S_TCSR_SEIE_MASK, /*!< Sync error flag, means the sync error is detected */ |
AnnaBridge | 145:64910690c574 | 121 | kSAI_FIFOWarningInterruptEnable = I2S_TCSR_FWIE_MASK, /*!< FIFO warning flag, means the FIFO is empty */ |
AnnaBridge | 145:64910690c574 | 122 | kSAI_FIFOErrorInterruptEnable = I2S_TCSR_FEIE_MASK, /*!< FIFO error flag */ |
AnnaBridge | 145:64910690c574 | 123 | #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1) |
AnnaBridge | 145:64910690c574 | 124 | kSAI_FIFORequestInterruptEnable = I2S_TCSR_FRIE_MASK, /*!< FIFO request, means reached watermark */ |
AnnaBridge | 145:64910690c574 | 125 | #endif /* FSL_FEATURE_SAI_FIFO_COUNT */ |
AnnaBridge | 145:64910690c574 | 126 | }; |
AnnaBridge | 145:64910690c574 | 127 | |
AnnaBridge | 145:64910690c574 | 128 | /*! @brief The DMA request sources */ |
AnnaBridge | 145:64910690c574 | 129 | enum _sai_dma_enable_t |
AnnaBridge | 145:64910690c574 | 130 | { |
AnnaBridge | 145:64910690c574 | 131 | kSAI_FIFOWarningDMAEnable = I2S_TCSR_FWDE_MASK, /*!< FIFO warning caused by the DMA request */ |
AnnaBridge | 145:64910690c574 | 132 | #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1) |
AnnaBridge | 145:64910690c574 | 133 | kSAI_FIFORequestDMAEnable = I2S_TCSR_FRDE_MASK, /*!< FIFO request caused by the DMA request */ |
AnnaBridge | 145:64910690c574 | 134 | #endif /* FSL_FEATURE_SAI_FIFO_COUNT */ |
AnnaBridge | 145:64910690c574 | 135 | }; |
AnnaBridge | 145:64910690c574 | 136 | |
AnnaBridge | 145:64910690c574 | 137 | /*! @brief The SAI status flag */ |
AnnaBridge | 145:64910690c574 | 138 | enum _sai_flags |
AnnaBridge | 145:64910690c574 | 139 | { |
AnnaBridge | 145:64910690c574 | 140 | kSAI_WordStartFlag = I2S_TCSR_WSF_MASK, /*!< Word start flag, means the first word in a frame detected */ |
AnnaBridge | 145:64910690c574 | 141 | kSAI_SyncErrorFlag = I2S_TCSR_SEF_MASK, /*!< Sync error flag, means the sync error is detected */ |
AnnaBridge | 145:64910690c574 | 142 | kSAI_FIFOErrorFlag = I2S_TCSR_FEF_MASK, /*!< FIFO error flag */ |
AnnaBridge | 145:64910690c574 | 143 | #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1) |
AnnaBridge | 145:64910690c574 | 144 | kSAI_FIFORequestFlag = I2S_TCSR_FRF_MASK, /*!< FIFO request flag. */ |
AnnaBridge | 145:64910690c574 | 145 | #endif /* FSL_FEATURE_SAI_FIFO_COUNT */ |
AnnaBridge | 145:64910690c574 | 146 | kSAI_FIFOWarningFlag = I2S_TCSR_FWF_MASK, /*!< FIFO warning flag */ |
AnnaBridge | 145:64910690c574 | 147 | }; |
AnnaBridge | 145:64910690c574 | 148 | |
AnnaBridge | 145:64910690c574 | 149 | /*! @brief The reset type */ |
AnnaBridge | 145:64910690c574 | 150 | typedef enum _sai_reset_type |
AnnaBridge | 145:64910690c574 | 151 | { |
AnnaBridge | 145:64910690c574 | 152 | kSAI_ResetTypeSoftware = I2S_TCSR_SR_MASK, /*!< Software reset, reset the logic state */ |
AnnaBridge | 145:64910690c574 | 153 | kSAI_ResetTypeFIFO = I2S_TCSR_FR_MASK, /*!< FIFO reset, reset the FIFO read and write pointer */ |
AnnaBridge | 145:64910690c574 | 154 | kSAI_ResetAll = I2S_TCSR_SR_MASK | I2S_TCSR_FR_MASK /*!< All reset. */ |
AnnaBridge | 145:64910690c574 | 155 | } sai_reset_type_t; |
AnnaBridge | 145:64910690c574 | 156 | |
AnnaBridge | 145:64910690c574 | 157 | #if defined(FSL_FEATURE_SAI_HAS_FIFO_PACKING) && FSL_FEATURE_SAI_HAS_FIFO_PACKING |
AnnaBridge | 145:64910690c574 | 158 | /*! |
AnnaBridge | 145:64910690c574 | 159 | * @brief The SAI packing mode |
AnnaBridge | 145:64910690c574 | 160 | * The mode includes 8 bit and 16 bit packing. |
AnnaBridge | 145:64910690c574 | 161 | */ |
AnnaBridge | 145:64910690c574 | 162 | typedef enum _sai_fifo_packing |
AnnaBridge | 145:64910690c574 | 163 | { |
AnnaBridge | 145:64910690c574 | 164 | kSAI_FifoPackingDisabled = 0x0U, /*!< Packing disabled */ |
AnnaBridge | 145:64910690c574 | 165 | kSAI_FifoPacking8bit = 0x2U, /*!< 8 bit packing enabled */ |
AnnaBridge | 145:64910690c574 | 166 | kSAI_FifoPacking16bit = 0x3U /*!< 16bit packing enabled */ |
AnnaBridge | 145:64910690c574 | 167 | } sai_fifo_packing_t; |
AnnaBridge | 145:64910690c574 | 168 | #endif /* FSL_FEATURE_SAI_HAS_FIFO_PACKING */ |
AnnaBridge | 145:64910690c574 | 169 | |
AnnaBridge | 145:64910690c574 | 170 | /*! @brief SAI user configuration structure */ |
AnnaBridge | 145:64910690c574 | 171 | typedef struct _sai_config |
AnnaBridge | 145:64910690c574 | 172 | { |
AnnaBridge | 145:64910690c574 | 173 | sai_protocol_t protocol; /*!< Audio bus protocol in SAI */ |
AnnaBridge | 145:64910690c574 | 174 | sai_sync_mode_t syncMode; /*!< SAI sync mode, control Tx/Rx clock sync */ |
AnnaBridge | 145:64910690c574 | 175 | #if defined(FSL_FEATURE_SAI_HAS_MCR) && (FSL_FEATURE_SAI_HAS_MCR) |
AnnaBridge | 145:64910690c574 | 176 | bool mclkOutputEnable; /*!< Master clock output enable, true means master clock divider enabled */ |
AnnaBridge | 145:64910690c574 | 177 | #endif /* FSL_FEATURE_SAI_HAS_MCR */ |
AnnaBridge | 145:64910690c574 | 178 | sai_mclk_source_t mclkSource; /*!< Master Clock source */ |
AnnaBridge | 145:64910690c574 | 179 | sai_bclk_source_t bclkSource; /*!< Bit Clock source */ |
AnnaBridge | 145:64910690c574 | 180 | sai_master_slave_t masterSlave; /*!< Master or slave */ |
AnnaBridge | 145:64910690c574 | 181 | } sai_config_t; |
AnnaBridge | 145:64910690c574 | 182 | |
AnnaBridge | 145:64910690c574 | 183 | /*!@brief SAI transfer queue size, user can refine it according to use case. */ |
AnnaBridge | 145:64910690c574 | 184 | #define SAI_XFER_QUEUE_SIZE (4) |
AnnaBridge | 145:64910690c574 | 185 | |
AnnaBridge | 145:64910690c574 | 186 | /*! @brief Audio sample rate */ |
AnnaBridge | 145:64910690c574 | 187 | typedef enum _sai_sample_rate |
AnnaBridge | 145:64910690c574 | 188 | { |
AnnaBridge | 145:64910690c574 | 189 | kSAI_SampleRate8KHz = 8000U, /*!< Sample rate 8000 Hz */ |
AnnaBridge | 145:64910690c574 | 190 | kSAI_SampleRate11025Hz = 11025U, /*!< Sample rate 11025 Hz */ |
AnnaBridge | 145:64910690c574 | 191 | kSAI_SampleRate12KHz = 12000U, /*!< Sample rate 12000 Hz */ |
AnnaBridge | 145:64910690c574 | 192 | kSAI_SampleRate16KHz = 16000U, /*!< Sample rate 16000 Hz */ |
AnnaBridge | 145:64910690c574 | 193 | kSAI_SampleRate22050Hz = 22050U, /*!< Sample rate 22050 Hz */ |
AnnaBridge | 145:64910690c574 | 194 | kSAI_SampleRate24KHz = 24000U, /*!< Sample rate 24000 Hz */ |
AnnaBridge | 145:64910690c574 | 195 | kSAI_SampleRate32KHz = 32000U, /*!< Sample rate 32000 Hz */ |
AnnaBridge | 145:64910690c574 | 196 | kSAI_SampleRate44100Hz = 44100U, /*!< Sample rate 44100 Hz */ |
AnnaBridge | 145:64910690c574 | 197 | kSAI_SampleRate48KHz = 48000U, /*!< Sample rate 48000 Hz */ |
AnnaBridge | 145:64910690c574 | 198 | kSAI_SampleRate96KHz = 96000U /*!< Sample rate 96000 Hz */ |
AnnaBridge | 145:64910690c574 | 199 | } sai_sample_rate_t; |
AnnaBridge | 145:64910690c574 | 200 | |
AnnaBridge | 145:64910690c574 | 201 | /*! @brief Audio word width */ |
AnnaBridge | 145:64910690c574 | 202 | typedef enum _sai_word_width |
AnnaBridge | 145:64910690c574 | 203 | { |
AnnaBridge | 145:64910690c574 | 204 | kSAI_WordWidth8bits = 8U, /*!< Audio data width 8 bits */ |
AnnaBridge | 145:64910690c574 | 205 | kSAI_WordWidth16bits = 16U, /*!< Audio data width 16 bits */ |
AnnaBridge | 145:64910690c574 | 206 | kSAI_WordWidth24bits = 24U, /*!< Audio data width 24 bits */ |
AnnaBridge | 145:64910690c574 | 207 | kSAI_WordWidth32bits = 32U /*!< Audio data width 32 bits */ |
AnnaBridge | 145:64910690c574 | 208 | } sai_word_width_t; |
AnnaBridge | 145:64910690c574 | 209 | |
AnnaBridge | 145:64910690c574 | 210 | /*! @brief sai transfer format */ |
AnnaBridge | 145:64910690c574 | 211 | typedef struct _sai_transfer_format |
AnnaBridge | 145:64910690c574 | 212 | { |
AnnaBridge | 145:64910690c574 | 213 | uint32_t sampleRate_Hz; /*!< Sample rate of audio data */ |
AnnaBridge | 145:64910690c574 | 214 | uint32_t bitWidth; /*!< Data length of audio data, usually 8/16/24/32 bits */ |
AnnaBridge | 145:64910690c574 | 215 | sai_mono_stereo_t stereo; /*!< Mono or stereo */ |
AnnaBridge | 145:64910690c574 | 216 | uint32_t masterClockHz; /*!< Master clock frequency in Hz */ |
AnnaBridge | 145:64910690c574 | 217 | #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1) |
AnnaBridge | 145:64910690c574 | 218 | uint8_t watermark; /*!< Watermark value */ |
AnnaBridge | 145:64910690c574 | 219 | #endif /* FSL_FEATURE_SAI_FIFO_COUNT */ |
AnnaBridge | 145:64910690c574 | 220 | uint8_t channel; /*!< Data channel used in transfer.*/ |
AnnaBridge | 145:64910690c574 | 221 | sai_protocol_t protocol; /*!< Which audio protocol used */ |
AnnaBridge | 145:64910690c574 | 222 | } sai_transfer_format_t; |
AnnaBridge | 145:64910690c574 | 223 | |
AnnaBridge | 145:64910690c574 | 224 | /*! @brief SAI transfer structure */ |
AnnaBridge | 145:64910690c574 | 225 | typedef struct _sai_transfer |
AnnaBridge | 145:64910690c574 | 226 | { |
AnnaBridge | 145:64910690c574 | 227 | uint8_t *data; /*!< Data start address to transfer. */ |
AnnaBridge | 145:64910690c574 | 228 | size_t dataSize; /*!< Transfer size. */ |
AnnaBridge | 145:64910690c574 | 229 | } sai_transfer_t; |
AnnaBridge | 145:64910690c574 | 230 | |
AnnaBridge | 145:64910690c574 | 231 | typedef struct _sai_handle sai_handle_t; |
AnnaBridge | 145:64910690c574 | 232 | |
AnnaBridge | 145:64910690c574 | 233 | /*! @brief SAI transfer callback prototype */ |
AnnaBridge | 145:64910690c574 | 234 | typedef void (*sai_transfer_callback_t)(I2S_Type *base, sai_handle_t *handle, status_t status, void *userData); |
AnnaBridge | 145:64910690c574 | 235 | |
AnnaBridge | 145:64910690c574 | 236 | /*! @brief SAI handle structure */ |
AnnaBridge | 145:64910690c574 | 237 | struct _sai_handle |
AnnaBridge | 145:64910690c574 | 238 | { |
AnnaBridge | 145:64910690c574 | 239 | uint32_t state; /*!< Transfer status */ |
AnnaBridge | 145:64910690c574 | 240 | sai_transfer_callback_t callback; /*!< Callback function called at transfer event*/ |
AnnaBridge | 145:64910690c574 | 241 | void *userData; /*!< Callback parameter passed to callback function*/ |
AnnaBridge | 145:64910690c574 | 242 | uint8_t bitWidth; /*!< Bit width for transfer, 8/16/24/32 bits */ |
AnnaBridge | 145:64910690c574 | 243 | uint8_t channel; /*!< Transfer channel */ |
AnnaBridge | 145:64910690c574 | 244 | sai_transfer_t saiQueue[SAI_XFER_QUEUE_SIZE]; /*!< Transfer queue storing queued transfer */ |
AnnaBridge | 145:64910690c574 | 245 | size_t transferSize[SAI_XFER_QUEUE_SIZE]; /*!< Data bytes need to transfer */ |
AnnaBridge | 145:64910690c574 | 246 | volatile uint8_t queueUser; /*!< Index for user to queue transfer */ |
AnnaBridge | 145:64910690c574 | 247 | volatile uint8_t queueDriver; /*!< Index for driver to get the transfer data and size */ |
AnnaBridge | 145:64910690c574 | 248 | #if defined(FSL_FEATURE_SAI_FIFO_COUNT) && (FSL_FEATURE_SAI_FIFO_COUNT > 1) |
AnnaBridge | 145:64910690c574 | 249 | uint8_t watermark; /*!< Watermark value */ |
AnnaBridge | 145:64910690c574 | 250 | #endif |
AnnaBridge | 145:64910690c574 | 251 | }; |
AnnaBridge | 145:64910690c574 | 252 | |
AnnaBridge | 145:64910690c574 | 253 | /******************************************************************************* |
AnnaBridge | 145:64910690c574 | 254 | * API |
AnnaBridge | 145:64910690c574 | 255 | ******************************************************************************/ |
AnnaBridge | 145:64910690c574 | 256 | |
AnnaBridge | 145:64910690c574 | 257 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 258 | extern "C" { |
AnnaBridge | 145:64910690c574 | 259 | #endif /*_cplusplus*/ |
AnnaBridge | 145:64910690c574 | 260 | |
AnnaBridge | 145:64910690c574 | 261 | /*! |
AnnaBridge | 145:64910690c574 | 262 | * @name Initialization and deinitialization |
AnnaBridge | 145:64910690c574 | 263 | * @{ |
AnnaBridge | 145:64910690c574 | 264 | */ |
AnnaBridge | 145:64910690c574 | 265 | |
AnnaBridge | 145:64910690c574 | 266 | /*! |
AnnaBridge | 145:64910690c574 | 267 | * @brief Initializes the SAI Tx peripheral. |
AnnaBridge | 145:64910690c574 | 268 | * |
AnnaBridge | 145:64910690c574 | 269 | * Ungates the SAI clock, resets the module, and configures SAI Tx with a configuration structure. |
AnnaBridge | 145:64910690c574 | 270 | * The configuration structure can be custom filled or set with default values by |
AnnaBridge | 145:64910690c574 | 271 | * SAI_TxGetDefaultConfig(). |
AnnaBridge | 145:64910690c574 | 272 | * |
AnnaBridge | 145:64910690c574 | 273 | * @note This API should be called at the beginning of the application to use |
AnnaBridge | 145:64910690c574 | 274 | * the SAI driver. Otherwise, accessing the SAIM module can cause a hard fault |
AnnaBridge | 145:64910690c574 | 275 | * because the clock is not enabled. |
AnnaBridge | 145:64910690c574 | 276 | * |
AnnaBridge | 145:64910690c574 | 277 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 278 | * @param config SAI configuration structure. |
AnnaBridge | 145:64910690c574 | 279 | */ |
AnnaBridge | 145:64910690c574 | 280 | void SAI_TxInit(I2S_Type *base, const sai_config_t *config); |
AnnaBridge | 145:64910690c574 | 281 | |
AnnaBridge | 145:64910690c574 | 282 | /*! |
AnnaBridge | 145:64910690c574 | 283 | * @brief Initializes the the SAI Rx peripheral. |
AnnaBridge | 145:64910690c574 | 284 | * |
AnnaBridge | 145:64910690c574 | 285 | * Ungates the SAI clock, resets the module, and configures the SAI Rx with a configuration structure. |
AnnaBridge | 145:64910690c574 | 286 | * The configuration structure can be custom filled or set with default values by |
AnnaBridge | 145:64910690c574 | 287 | * SAI_RxGetDefaultConfig(). |
AnnaBridge | 145:64910690c574 | 288 | * |
AnnaBridge | 145:64910690c574 | 289 | * @note This API should be called at the beginning of the application to use |
AnnaBridge | 145:64910690c574 | 290 | * the SAI driver. Otherwise, accessing the SAI module can cause a hard fault |
AnnaBridge | 145:64910690c574 | 291 | * because the clock is not enabled. |
AnnaBridge | 145:64910690c574 | 292 | * |
AnnaBridge | 145:64910690c574 | 293 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 294 | * @param config SAI configuration structure. |
AnnaBridge | 145:64910690c574 | 295 | */ |
AnnaBridge | 145:64910690c574 | 296 | void SAI_RxInit(I2S_Type *base, const sai_config_t *config); |
AnnaBridge | 145:64910690c574 | 297 | |
AnnaBridge | 145:64910690c574 | 298 | /*! |
AnnaBridge | 145:64910690c574 | 299 | * @brief Sets the SAI Tx configuration structure to default values. |
AnnaBridge | 145:64910690c574 | 300 | * |
AnnaBridge | 145:64910690c574 | 301 | * This API initializes the configuration structure for use in SAI_TxConfig(). |
AnnaBridge | 145:64910690c574 | 302 | * The initialized structure can remain unchanged in SAI_TxConfig(), or it can be modified |
AnnaBridge | 145:64910690c574 | 303 | * before calling SAI_TxConfig(). |
AnnaBridge | 145:64910690c574 | 304 | * This is an example. |
AnnaBridge | 145:64910690c574 | 305 | @code |
AnnaBridge | 145:64910690c574 | 306 | sai_config_t config; |
AnnaBridge | 145:64910690c574 | 307 | SAI_TxGetDefaultConfig(&config); |
AnnaBridge | 145:64910690c574 | 308 | @endcode |
AnnaBridge | 145:64910690c574 | 309 | * |
AnnaBridge | 145:64910690c574 | 310 | * @param config pointer to master configuration structure |
AnnaBridge | 145:64910690c574 | 311 | */ |
AnnaBridge | 145:64910690c574 | 312 | void SAI_TxGetDefaultConfig(sai_config_t *config); |
AnnaBridge | 145:64910690c574 | 313 | |
AnnaBridge | 145:64910690c574 | 314 | /*! |
AnnaBridge | 145:64910690c574 | 315 | * @brief Sets the SAI Rx configuration structure to default values. |
AnnaBridge | 145:64910690c574 | 316 | * |
AnnaBridge | 145:64910690c574 | 317 | * This API initializes the configuration structure for use in SAI_RxConfig(). |
AnnaBridge | 145:64910690c574 | 318 | * The initialized structure can remain unchanged in SAI_RxConfig() or it can be modified |
AnnaBridge | 145:64910690c574 | 319 | * before calling SAI_RxConfig(). |
AnnaBridge | 145:64910690c574 | 320 | * This is an example. |
AnnaBridge | 145:64910690c574 | 321 | @code |
AnnaBridge | 145:64910690c574 | 322 | sai_config_t config; |
AnnaBridge | 145:64910690c574 | 323 | SAI_RxGetDefaultConfig(&config); |
AnnaBridge | 145:64910690c574 | 324 | @endcode |
AnnaBridge | 145:64910690c574 | 325 | * |
AnnaBridge | 145:64910690c574 | 326 | * @param config pointer to master configuration structure |
AnnaBridge | 145:64910690c574 | 327 | */ |
AnnaBridge | 145:64910690c574 | 328 | void SAI_RxGetDefaultConfig(sai_config_t *config); |
AnnaBridge | 145:64910690c574 | 329 | |
AnnaBridge | 145:64910690c574 | 330 | /*! |
AnnaBridge | 145:64910690c574 | 331 | * @brief De-initializes the SAI peripheral. |
AnnaBridge | 145:64910690c574 | 332 | * |
AnnaBridge | 145:64910690c574 | 333 | * This API gates the SAI clock. The SAI module can't operate unless SAI_TxInit |
AnnaBridge | 145:64910690c574 | 334 | * or SAI_RxInit is called to enable the clock. |
AnnaBridge | 145:64910690c574 | 335 | * |
AnnaBridge | 145:64910690c574 | 336 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 337 | */ |
AnnaBridge | 145:64910690c574 | 338 | void SAI_Deinit(I2S_Type *base); |
AnnaBridge | 145:64910690c574 | 339 | |
AnnaBridge | 145:64910690c574 | 340 | /*! |
AnnaBridge | 145:64910690c574 | 341 | * @brief Resets the SAI Tx. |
AnnaBridge | 145:64910690c574 | 342 | * |
AnnaBridge | 145:64910690c574 | 343 | * This function enables the software reset and FIFO reset of SAI Tx. After reset, clear the reset bit. |
AnnaBridge | 145:64910690c574 | 344 | * |
AnnaBridge | 145:64910690c574 | 345 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 346 | */ |
AnnaBridge | 145:64910690c574 | 347 | void SAI_TxReset(I2S_Type *base); |
AnnaBridge | 145:64910690c574 | 348 | |
AnnaBridge | 145:64910690c574 | 349 | /*! |
AnnaBridge | 145:64910690c574 | 350 | * @brief Resets the SAI Rx. |
AnnaBridge | 145:64910690c574 | 351 | * |
AnnaBridge | 145:64910690c574 | 352 | * This function enables the software reset and FIFO reset of SAI Rx. After reset, clear the reset bit. |
AnnaBridge | 145:64910690c574 | 353 | * |
AnnaBridge | 145:64910690c574 | 354 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 355 | */ |
AnnaBridge | 145:64910690c574 | 356 | void SAI_RxReset(I2S_Type *base); |
AnnaBridge | 145:64910690c574 | 357 | |
AnnaBridge | 145:64910690c574 | 358 | /*! |
AnnaBridge | 145:64910690c574 | 359 | * @brief Enables/disables the SAI Tx. |
AnnaBridge | 145:64910690c574 | 360 | * |
AnnaBridge | 145:64910690c574 | 361 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 362 | * @param enable True means enable SAI Tx, false means disable. |
AnnaBridge | 145:64910690c574 | 363 | */ |
AnnaBridge | 145:64910690c574 | 364 | void SAI_TxEnable(I2S_Type *base, bool enable); |
AnnaBridge | 145:64910690c574 | 365 | |
AnnaBridge | 145:64910690c574 | 366 | /*! |
AnnaBridge | 145:64910690c574 | 367 | * @brief Enables/disables the SAI Rx. |
AnnaBridge | 145:64910690c574 | 368 | * |
AnnaBridge | 145:64910690c574 | 369 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 370 | * @param enable True means enable SAI Rx, false means disable. |
AnnaBridge | 145:64910690c574 | 371 | */ |
AnnaBridge | 145:64910690c574 | 372 | void SAI_RxEnable(I2S_Type *base, bool enable); |
AnnaBridge | 145:64910690c574 | 373 | |
AnnaBridge | 145:64910690c574 | 374 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 375 | |
AnnaBridge | 145:64910690c574 | 376 | /*! |
AnnaBridge | 145:64910690c574 | 377 | * @name Status |
AnnaBridge | 145:64910690c574 | 378 | * @{ |
AnnaBridge | 145:64910690c574 | 379 | */ |
AnnaBridge | 145:64910690c574 | 380 | |
AnnaBridge | 145:64910690c574 | 381 | /*! |
AnnaBridge | 145:64910690c574 | 382 | * @brief Gets the SAI Tx status flag state. |
AnnaBridge | 145:64910690c574 | 383 | * |
AnnaBridge | 145:64910690c574 | 384 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 385 | * @return SAI Tx status flag value. Use the Status Mask to get the status value needed. |
AnnaBridge | 145:64910690c574 | 386 | */ |
AnnaBridge | 145:64910690c574 | 387 | static inline uint32_t SAI_TxGetStatusFlag(I2S_Type *base) |
AnnaBridge | 145:64910690c574 | 388 | { |
AnnaBridge | 145:64910690c574 | 389 | return base->TCSR; |
AnnaBridge | 145:64910690c574 | 390 | } |
AnnaBridge | 145:64910690c574 | 391 | |
AnnaBridge | 145:64910690c574 | 392 | /*! |
AnnaBridge | 145:64910690c574 | 393 | * @brief Clears the SAI Tx status flag state. |
AnnaBridge | 145:64910690c574 | 394 | * |
AnnaBridge | 145:64910690c574 | 395 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 396 | * @param mask State mask. It can be a combination of the following source if defined: |
AnnaBridge | 145:64910690c574 | 397 | * @arg kSAI_WordStartFlag |
AnnaBridge | 145:64910690c574 | 398 | * @arg kSAI_SyncErrorFlag |
AnnaBridge | 145:64910690c574 | 399 | * @arg kSAI_FIFOErrorFlag |
AnnaBridge | 145:64910690c574 | 400 | */ |
AnnaBridge | 145:64910690c574 | 401 | static inline void SAI_TxClearStatusFlags(I2S_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 402 | { |
AnnaBridge | 145:64910690c574 | 403 | base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | mask); |
AnnaBridge | 145:64910690c574 | 404 | } |
AnnaBridge | 145:64910690c574 | 405 | |
AnnaBridge | 145:64910690c574 | 406 | /*! |
AnnaBridge | 145:64910690c574 | 407 | * @brief Gets the SAI Tx status flag state. |
AnnaBridge | 145:64910690c574 | 408 | * |
AnnaBridge | 145:64910690c574 | 409 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 410 | * @return SAI Rx status flag value. Use the Status Mask to get the status value needed. |
AnnaBridge | 145:64910690c574 | 411 | */ |
AnnaBridge | 145:64910690c574 | 412 | static inline uint32_t SAI_RxGetStatusFlag(I2S_Type *base) |
AnnaBridge | 145:64910690c574 | 413 | { |
AnnaBridge | 145:64910690c574 | 414 | return base->RCSR; |
AnnaBridge | 145:64910690c574 | 415 | } |
AnnaBridge | 145:64910690c574 | 416 | |
AnnaBridge | 145:64910690c574 | 417 | /*! |
AnnaBridge | 145:64910690c574 | 418 | * @brief Clears the SAI Rx status flag state. |
AnnaBridge | 145:64910690c574 | 419 | * |
AnnaBridge | 145:64910690c574 | 420 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 421 | * @param mask State mask. It can be a combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 422 | * @arg kSAI_WordStartFlag |
AnnaBridge | 145:64910690c574 | 423 | * @arg kSAI_SyncErrorFlag |
AnnaBridge | 145:64910690c574 | 424 | * @arg kSAI_FIFOErrorFlag |
AnnaBridge | 145:64910690c574 | 425 | */ |
AnnaBridge | 145:64910690c574 | 426 | static inline void SAI_RxClearStatusFlags(I2S_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 427 | { |
AnnaBridge | 145:64910690c574 | 428 | base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | mask); |
AnnaBridge | 145:64910690c574 | 429 | } |
AnnaBridge | 145:64910690c574 | 430 | |
AnnaBridge | 145:64910690c574 | 431 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 432 | |
AnnaBridge | 145:64910690c574 | 433 | /*! |
AnnaBridge | 145:64910690c574 | 434 | * @name Interrupts |
AnnaBridge | 145:64910690c574 | 435 | * @{ |
AnnaBridge | 145:64910690c574 | 436 | */ |
AnnaBridge | 145:64910690c574 | 437 | |
AnnaBridge | 145:64910690c574 | 438 | /*! |
AnnaBridge | 145:64910690c574 | 439 | * @brief Enables the SAI Tx interrupt requests. |
AnnaBridge | 145:64910690c574 | 440 | * |
AnnaBridge | 145:64910690c574 | 441 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 442 | * @param mask interrupt source |
AnnaBridge | 145:64910690c574 | 443 | * The parameter can be a combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 444 | * @arg kSAI_WordStartInterruptEnable |
AnnaBridge | 145:64910690c574 | 445 | * @arg kSAI_SyncErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 446 | * @arg kSAI_FIFOWarningInterruptEnable |
AnnaBridge | 145:64910690c574 | 447 | * @arg kSAI_FIFORequestInterruptEnable |
AnnaBridge | 145:64910690c574 | 448 | * @arg kSAI_FIFOErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 449 | */ |
AnnaBridge | 145:64910690c574 | 450 | static inline void SAI_TxEnableInterrupts(I2S_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 451 | { |
AnnaBridge | 145:64910690c574 | 452 | base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | mask); |
AnnaBridge | 145:64910690c574 | 453 | } |
AnnaBridge | 145:64910690c574 | 454 | |
AnnaBridge | 145:64910690c574 | 455 | /*! |
AnnaBridge | 145:64910690c574 | 456 | * @brief Enables the SAI Rx interrupt requests. |
AnnaBridge | 145:64910690c574 | 457 | * |
AnnaBridge | 145:64910690c574 | 458 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 459 | * @param mask interrupt source |
AnnaBridge | 145:64910690c574 | 460 | * The parameter can be a combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 461 | * @arg kSAI_WordStartInterruptEnable |
AnnaBridge | 145:64910690c574 | 462 | * @arg kSAI_SyncErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 463 | * @arg kSAI_FIFOWarningInterruptEnable |
AnnaBridge | 145:64910690c574 | 464 | * @arg kSAI_FIFORequestInterruptEnable |
AnnaBridge | 145:64910690c574 | 465 | * @arg kSAI_FIFOErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 466 | */ |
AnnaBridge | 145:64910690c574 | 467 | static inline void SAI_RxEnableInterrupts(I2S_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 468 | { |
AnnaBridge | 145:64910690c574 | 469 | base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | mask); |
AnnaBridge | 145:64910690c574 | 470 | } |
AnnaBridge | 145:64910690c574 | 471 | |
AnnaBridge | 145:64910690c574 | 472 | /*! |
AnnaBridge | 145:64910690c574 | 473 | * @brief Disables the SAI Tx interrupt requests. |
AnnaBridge | 145:64910690c574 | 474 | * |
AnnaBridge | 145:64910690c574 | 475 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 476 | * @param mask interrupt source |
AnnaBridge | 145:64910690c574 | 477 | * The parameter can be a combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 478 | * @arg kSAI_WordStartInterruptEnable |
AnnaBridge | 145:64910690c574 | 479 | * @arg kSAI_SyncErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 480 | * @arg kSAI_FIFOWarningInterruptEnable |
AnnaBridge | 145:64910690c574 | 481 | * @arg kSAI_FIFORequestInterruptEnable |
AnnaBridge | 145:64910690c574 | 482 | * @arg kSAI_FIFOErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 483 | */ |
AnnaBridge | 145:64910690c574 | 484 | static inline void SAI_TxDisableInterrupts(I2S_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 485 | { |
AnnaBridge | 145:64910690c574 | 486 | base->TCSR = ((base->TCSR & 0xFFE3FFFFU) & (~mask)); |
AnnaBridge | 145:64910690c574 | 487 | } |
AnnaBridge | 145:64910690c574 | 488 | |
AnnaBridge | 145:64910690c574 | 489 | /*! |
AnnaBridge | 145:64910690c574 | 490 | * @brief Disables the SAI Rx interrupt requests. |
AnnaBridge | 145:64910690c574 | 491 | * |
AnnaBridge | 145:64910690c574 | 492 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 493 | * @param mask interrupt source |
AnnaBridge | 145:64910690c574 | 494 | * The parameter can be a combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 495 | * @arg kSAI_WordStartInterruptEnable |
AnnaBridge | 145:64910690c574 | 496 | * @arg kSAI_SyncErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 497 | * @arg kSAI_FIFOWarningInterruptEnable |
AnnaBridge | 145:64910690c574 | 498 | * @arg kSAI_FIFORequestInterruptEnable |
AnnaBridge | 145:64910690c574 | 499 | * @arg kSAI_FIFOErrorInterruptEnable |
AnnaBridge | 145:64910690c574 | 500 | */ |
AnnaBridge | 145:64910690c574 | 501 | static inline void SAI_RxDisableInterrupts(I2S_Type *base, uint32_t mask) |
AnnaBridge | 145:64910690c574 | 502 | { |
AnnaBridge | 145:64910690c574 | 503 | base->RCSR = ((base->RCSR & 0xFFE3FFFFU) & (~mask)); |
AnnaBridge | 145:64910690c574 | 504 | } |
AnnaBridge | 145:64910690c574 | 505 | |
AnnaBridge | 145:64910690c574 | 506 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 507 | |
AnnaBridge | 145:64910690c574 | 508 | /*! |
AnnaBridge | 145:64910690c574 | 509 | * @name DMA Control |
AnnaBridge | 145:64910690c574 | 510 | * @{ |
AnnaBridge | 145:64910690c574 | 511 | */ |
AnnaBridge | 145:64910690c574 | 512 | |
AnnaBridge | 145:64910690c574 | 513 | /*! |
AnnaBridge | 145:64910690c574 | 514 | * @brief Enables/disables the SAI Tx DMA requests. |
AnnaBridge | 145:64910690c574 | 515 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 516 | * @param mask DMA source |
AnnaBridge | 145:64910690c574 | 517 | * The parameter can be combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 518 | * @arg kSAI_FIFOWarningDMAEnable |
AnnaBridge | 145:64910690c574 | 519 | * @arg kSAI_FIFORequestDMAEnable |
AnnaBridge | 145:64910690c574 | 520 | * @param enable True means enable DMA, false means disable DMA. |
AnnaBridge | 145:64910690c574 | 521 | */ |
AnnaBridge | 145:64910690c574 | 522 | static inline void SAI_TxEnableDMA(I2S_Type *base, uint32_t mask, bool enable) |
AnnaBridge | 145:64910690c574 | 523 | { |
AnnaBridge | 145:64910690c574 | 524 | if (enable) |
AnnaBridge | 145:64910690c574 | 525 | { |
AnnaBridge | 145:64910690c574 | 526 | base->TCSR = ((base->TCSR & 0xFFE3FFFFU) | mask); |
AnnaBridge | 145:64910690c574 | 527 | } |
AnnaBridge | 145:64910690c574 | 528 | else |
AnnaBridge | 145:64910690c574 | 529 | { |
AnnaBridge | 145:64910690c574 | 530 | base->TCSR = ((base->TCSR & 0xFFE3FFFFU) & (~mask)); |
AnnaBridge | 145:64910690c574 | 531 | } |
AnnaBridge | 145:64910690c574 | 532 | } |
AnnaBridge | 145:64910690c574 | 533 | |
AnnaBridge | 145:64910690c574 | 534 | /*! |
AnnaBridge | 145:64910690c574 | 535 | * @brief Enables/disables the SAI Rx DMA requests. |
AnnaBridge | 145:64910690c574 | 536 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 537 | * @param mask DMA source |
AnnaBridge | 145:64910690c574 | 538 | * The parameter can be a combination of the following sources if defined. |
AnnaBridge | 145:64910690c574 | 539 | * @arg kSAI_FIFOWarningDMAEnable |
AnnaBridge | 145:64910690c574 | 540 | * @arg kSAI_FIFORequestDMAEnable |
AnnaBridge | 145:64910690c574 | 541 | * @param enable True means enable DMA, false means disable DMA. |
AnnaBridge | 145:64910690c574 | 542 | */ |
AnnaBridge | 145:64910690c574 | 543 | static inline void SAI_RxEnableDMA(I2S_Type *base, uint32_t mask, bool enable) |
AnnaBridge | 145:64910690c574 | 544 | { |
AnnaBridge | 145:64910690c574 | 545 | if (enable) |
AnnaBridge | 145:64910690c574 | 546 | { |
AnnaBridge | 145:64910690c574 | 547 | base->RCSR = ((base->RCSR & 0xFFE3FFFFU) | mask); |
AnnaBridge | 145:64910690c574 | 548 | } |
AnnaBridge | 145:64910690c574 | 549 | else |
AnnaBridge | 145:64910690c574 | 550 | { |
AnnaBridge | 145:64910690c574 | 551 | base->RCSR = ((base->RCSR & 0xFFE3FFFFU) & (~mask)); |
AnnaBridge | 145:64910690c574 | 552 | } |
AnnaBridge | 145:64910690c574 | 553 | } |
AnnaBridge | 145:64910690c574 | 554 | |
AnnaBridge | 145:64910690c574 | 555 | /*! |
AnnaBridge | 145:64910690c574 | 556 | * @brief Gets the SAI Tx data register address. |
AnnaBridge | 145:64910690c574 | 557 | * |
AnnaBridge | 145:64910690c574 | 558 | * This API is used to provide a transfer address for the SAI DMA transfer configuration. |
AnnaBridge | 145:64910690c574 | 559 | * |
AnnaBridge | 145:64910690c574 | 560 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 561 | * @param channel Which data channel used. |
AnnaBridge | 145:64910690c574 | 562 | * @return data register address. |
AnnaBridge | 145:64910690c574 | 563 | */ |
AnnaBridge | 145:64910690c574 | 564 | static inline uint32_t SAI_TxGetDataRegisterAddress(I2S_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 565 | { |
AnnaBridge | 145:64910690c574 | 566 | return (uint32_t)(&(base->TDR)[channel]); |
AnnaBridge | 145:64910690c574 | 567 | } |
AnnaBridge | 145:64910690c574 | 568 | |
AnnaBridge | 145:64910690c574 | 569 | /*! |
AnnaBridge | 145:64910690c574 | 570 | * @brief Gets the SAI Rx data register address. |
AnnaBridge | 145:64910690c574 | 571 | * |
AnnaBridge | 145:64910690c574 | 572 | * This API is used to provide a transfer address for the SAI DMA transfer configuration. |
AnnaBridge | 145:64910690c574 | 573 | * |
AnnaBridge | 145:64910690c574 | 574 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 575 | * @param channel Which data channel used. |
AnnaBridge | 145:64910690c574 | 576 | * @return data register address. |
AnnaBridge | 145:64910690c574 | 577 | */ |
AnnaBridge | 145:64910690c574 | 578 | static inline uint32_t SAI_RxGetDataRegisterAddress(I2S_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 579 | { |
AnnaBridge | 145:64910690c574 | 580 | return (uint32_t)(&(base->RDR)[channel]); |
AnnaBridge | 145:64910690c574 | 581 | } |
AnnaBridge | 145:64910690c574 | 582 | |
AnnaBridge | 145:64910690c574 | 583 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 584 | |
AnnaBridge | 145:64910690c574 | 585 | /*! |
AnnaBridge | 145:64910690c574 | 586 | * @name Bus Operations |
AnnaBridge | 145:64910690c574 | 587 | * @{ |
AnnaBridge | 145:64910690c574 | 588 | */ |
AnnaBridge | 145:64910690c574 | 589 | |
AnnaBridge | 145:64910690c574 | 590 | /*! |
AnnaBridge | 145:64910690c574 | 591 | * @brief Configures the SAI Tx audio format. |
AnnaBridge | 145:64910690c574 | 592 | * |
AnnaBridge | 145:64910690c574 | 593 | * The audio format can be changed at run-time. This function configures the sample rate and audio data |
AnnaBridge | 145:64910690c574 | 594 | * format to be transferred. |
AnnaBridge | 145:64910690c574 | 595 | * |
AnnaBridge | 145:64910690c574 | 596 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 597 | * @param format Pointer to the SAI audio data format structure. |
AnnaBridge | 145:64910690c574 | 598 | * @param mclkSourceClockHz SAI master clock source frequency in Hz. |
AnnaBridge | 145:64910690c574 | 599 | * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If the bit clock source is a master |
AnnaBridge | 145:64910690c574 | 600 | * clock, this value should equal the masterClockHz. |
AnnaBridge | 145:64910690c574 | 601 | */ |
AnnaBridge | 145:64910690c574 | 602 | void SAI_TxSetFormat(I2S_Type *base, |
AnnaBridge | 145:64910690c574 | 603 | sai_transfer_format_t *format, |
AnnaBridge | 145:64910690c574 | 604 | uint32_t mclkSourceClockHz, |
AnnaBridge | 145:64910690c574 | 605 | uint32_t bclkSourceClockHz); |
AnnaBridge | 145:64910690c574 | 606 | |
AnnaBridge | 145:64910690c574 | 607 | /*! |
AnnaBridge | 145:64910690c574 | 608 | * @brief Configures the SAI Rx audio format. |
AnnaBridge | 145:64910690c574 | 609 | * |
AnnaBridge | 145:64910690c574 | 610 | * The audio format can be changed at run-time. This function configures the sample rate and audio data |
AnnaBridge | 145:64910690c574 | 611 | * format to be transferred. |
AnnaBridge | 145:64910690c574 | 612 | * |
AnnaBridge | 145:64910690c574 | 613 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 614 | * @param format Pointer to the SAI audio data format structure. |
AnnaBridge | 145:64910690c574 | 615 | * @param mclkSourceClockHz SAI master clock source frequency in Hz. |
AnnaBridge | 145:64910690c574 | 616 | * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If the bit clock source is a master |
AnnaBridge | 145:64910690c574 | 617 | * clock, this value should equal the masterClockHz. |
AnnaBridge | 145:64910690c574 | 618 | */ |
AnnaBridge | 145:64910690c574 | 619 | void SAI_RxSetFormat(I2S_Type *base, |
AnnaBridge | 145:64910690c574 | 620 | sai_transfer_format_t *format, |
AnnaBridge | 145:64910690c574 | 621 | uint32_t mclkSourceClockHz, |
AnnaBridge | 145:64910690c574 | 622 | uint32_t bclkSourceClockHz); |
AnnaBridge | 145:64910690c574 | 623 | |
AnnaBridge | 145:64910690c574 | 624 | /*! |
AnnaBridge | 145:64910690c574 | 625 | * @brief Sends data using a blocking method. |
AnnaBridge | 145:64910690c574 | 626 | * |
AnnaBridge | 145:64910690c574 | 627 | * @note This function blocks by polling until data is ready to be sent. |
AnnaBridge | 145:64910690c574 | 628 | * |
AnnaBridge | 145:64910690c574 | 629 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 630 | * @param channel Data channel used. |
AnnaBridge | 145:64910690c574 | 631 | * @param bitWidth How many bits in an audio word; usually 8/16/24/32 bits. |
AnnaBridge | 145:64910690c574 | 632 | * @param buffer Pointer to the data to be written. |
AnnaBridge | 145:64910690c574 | 633 | * @param size Bytes to be written. |
AnnaBridge | 145:64910690c574 | 634 | */ |
AnnaBridge | 145:64910690c574 | 635 | void SAI_WriteBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size); |
AnnaBridge | 145:64910690c574 | 636 | |
AnnaBridge | 145:64910690c574 | 637 | /*! |
AnnaBridge | 145:64910690c574 | 638 | * @brief Writes data into SAI FIFO. |
AnnaBridge | 145:64910690c574 | 639 | * |
AnnaBridge | 145:64910690c574 | 640 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 641 | * @param channel Data channel used. |
AnnaBridge | 145:64910690c574 | 642 | * @param data Data needs to be written. |
AnnaBridge | 145:64910690c574 | 643 | */ |
AnnaBridge | 145:64910690c574 | 644 | static inline void SAI_WriteData(I2S_Type *base, uint32_t channel, uint32_t data) |
AnnaBridge | 145:64910690c574 | 645 | { |
AnnaBridge | 145:64910690c574 | 646 | base->TDR[channel] = data; |
AnnaBridge | 145:64910690c574 | 647 | } |
AnnaBridge | 145:64910690c574 | 648 | |
AnnaBridge | 145:64910690c574 | 649 | /*! |
AnnaBridge | 145:64910690c574 | 650 | * @brief Receives data using a blocking method. |
AnnaBridge | 145:64910690c574 | 651 | * |
AnnaBridge | 145:64910690c574 | 652 | * @note This function blocks by polling until data is ready to be sent. |
AnnaBridge | 145:64910690c574 | 653 | * |
AnnaBridge | 145:64910690c574 | 654 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 655 | * @param channel Data channel used. |
AnnaBridge | 145:64910690c574 | 656 | * @param bitWidth How many bits in an audio word; usually 8/16/24/32 bits. |
AnnaBridge | 145:64910690c574 | 657 | * @param buffer Pointer to the data to be read. |
AnnaBridge | 145:64910690c574 | 658 | * @param size Bytes to be read. |
AnnaBridge | 145:64910690c574 | 659 | */ |
AnnaBridge | 145:64910690c574 | 660 | void SAI_ReadBlocking(I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size); |
AnnaBridge | 145:64910690c574 | 661 | |
AnnaBridge | 145:64910690c574 | 662 | /*! |
AnnaBridge | 145:64910690c574 | 663 | * @brief Reads data from the SAI FIFO. |
AnnaBridge | 145:64910690c574 | 664 | * |
AnnaBridge | 145:64910690c574 | 665 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 666 | * @param channel Data channel used. |
AnnaBridge | 145:64910690c574 | 667 | * @return Data in SAI FIFO. |
AnnaBridge | 145:64910690c574 | 668 | */ |
AnnaBridge | 145:64910690c574 | 669 | static inline uint32_t SAI_ReadData(I2S_Type *base, uint32_t channel) |
AnnaBridge | 145:64910690c574 | 670 | { |
AnnaBridge | 145:64910690c574 | 671 | return base->RDR[channel]; |
AnnaBridge | 145:64910690c574 | 672 | } |
AnnaBridge | 145:64910690c574 | 673 | |
AnnaBridge | 145:64910690c574 | 674 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 675 | |
AnnaBridge | 145:64910690c574 | 676 | /*! |
AnnaBridge | 145:64910690c574 | 677 | * @name Transactional |
AnnaBridge | 145:64910690c574 | 678 | * @{ |
AnnaBridge | 145:64910690c574 | 679 | */ |
AnnaBridge | 145:64910690c574 | 680 | |
AnnaBridge | 145:64910690c574 | 681 | /*! |
AnnaBridge | 145:64910690c574 | 682 | * @brief Initializes the SAI Tx handle. |
AnnaBridge | 145:64910690c574 | 683 | * |
AnnaBridge | 145:64910690c574 | 684 | * This function initializes the Tx handle for the SAI Tx transactional APIs. Call |
AnnaBridge | 145:64910690c574 | 685 | * this function once to get the handle initialized. |
AnnaBridge | 145:64910690c574 | 686 | * |
AnnaBridge | 145:64910690c574 | 687 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 688 | * @param handle SAI handle pointer. |
AnnaBridge | 145:64910690c574 | 689 | * @param callback Pointer to the user callback function. |
AnnaBridge | 145:64910690c574 | 690 | * @param userData User parameter passed to the callback function |
AnnaBridge | 145:64910690c574 | 691 | */ |
AnnaBridge | 145:64910690c574 | 692 | void SAI_TransferTxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData); |
AnnaBridge | 145:64910690c574 | 693 | |
AnnaBridge | 145:64910690c574 | 694 | /*! |
AnnaBridge | 145:64910690c574 | 695 | * @brief Initializes the SAI Rx handle. |
AnnaBridge | 145:64910690c574 | 696 | * |
AnnaBridge | 145:64910690c574 | 697 | * This function initializes the Rx handle for the SAI Rx transactional APIs. Call |
AnnaBridge | 145:64910690c574 | 698 | * this function once to get the handle initialized. |
AnnaBridge | 145:64910690c574 | 699 | * |
AnnaBridge | 145:64910690c574 | 700 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 701 | * @param handle SAI handle pointer. |
AnnaBridge | 145:64910690c574 | 702 | * @param callback Pointer to the user callback function. |
AnnaBridge | 145:64910690c574 | 703 | * @param userData User parameter passed to the callback function. |
AnnaBridge | 145:64910690c574 | 704 | */ |
AnnaBridge | 145:64910690c574 | 705 | void SAI_TransferRxCreateHandle(I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData); |
AnnaBridge | 145:64910690c574 | 706 | |
AnnaBridge | 145:64910690c574 | 707 | /*! |
AnnaBridge | 145:64910690c574 | 708 | * @brief Configures the SAI Tx audio format. |
AnnaBridge | 145:64910690c574 | 709 | * |
AnnaBridge | 145:64910690c574 | 710 | * The audio format can be changed at run-time. This function configures the sample rate and audio data |
AnnaBridge | 145:64910690c574 | 711 | * format to be transferred. |
AnnaBridge | 145:64910690c574 | 712 | * |
AnnaBridge | 145:64910690c574 | 713 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 714 | * @param handle SAI handle pointer. |
AnnaBridge | 145:64910690c574 | 715 | * @param format Pointer to the SAI audio data format structure. |
AnnaBridge | 145:64910690c574 | 716 | * @param mclkSourceClockHz SAI master clock source frequency in Hz. |
AnnaBridge | 145:64910690c574 | 717 | * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If a bit clock source is a master |
AnnaBridge | 145:64910690c574 | 718 | * clock, this value should equal the masterClockHz in format. |
AnnaBridge | 145:64910690c574 | 719 | * @return Status of this function. Return value is the status_t. |
AnnaBridge | 145:64910690c574 | 720 | */ |
AnnaBridge | 145:64910690c574 | 721 | status_t SAI_TransferTxSetFormat(I2S_Type *base, |
AnnaBridge | 145:64910690c574 | 722 | sai_handle_t *handle, |
AnnaBridge | 145:64910690c574 | 723 | sai_transfer_format_t *format, |
AnnaBridge | 145:64910690c574 | 724 | uint32_t mclkSourceClockHz, |
AnnaBridge | 145:64910690c574 | 725 | uint32_t bclkSourceClockHz); |
AnnaBridge | 145:64910690c574 | 726 | |
AnnaBridge | 145:64910690c574 | 727 | /*! |
AnnaBridge | 145:64910690c574 | 728 | * @brief Configures the SAI Rx audio format. |
AnnaBridge | 145:64910690c574 | 729 | * |
AnnaBridge | 145:64910690c574 | 730 | * The audio format can be changed at run-time. This function configures the sample rate and audio data |
AnnaBridge | 145:64910690c574 | 731 | * format to be transferred. |
AnnaBridge | 145:64910690c574 | 732 | * |
AnnaBridge | 145:64910690c574 | 733 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 734 | * @param handle SAI handle pointer. |
AnnaBridge | 145:64910690c574 | 735 | * @param format Pointer to the SAI audio data format structure. |
AnnaBridge | 145:64910690c574 | 736 | * @param mclkSourceClockHz SAI master clock source frequency in Hz. |
AnnaBridge | 145:64910690c574 | 737 | * @param bclkSourceClockHz SAI bit clock source frequency in Hz. If a bit clock source is a master |
AnnaBridge | 145:64910690c574 | 738 | * clock, this value should equal the masterClockHz in format. |
AnnaBridge | 145:64910690c574 | 739 | * @return Status of this function. Return value is one of status_t. |
AnnaBridge | 145:64910690c574 | 740 | */ |
AnnaBridge | 145:64910690c574 | 741 | status_t SAI_TransferRxSetFormat(I2S_Type *base, |
AnnaBridge | 145:64910690c574 | 742 | sai_handle_t *handle, |
AnnaBridge | 145:64910690c574 | 743 | sai_transfer_format_t *format, |
AnnaBridge | 145:64910690c574 | 744 | uint32_t mclkSourceClockHz, |
AnnaBridge | 145:64910690c574 | 745 | uint32_t bclkSourceClockHz); |
AnnaBridge | 145:64910690c574 | 746 | |
AnnaBridge | 145:64910690c574 | 747 | /*! |
AnnaBridge | 145:64910690c574 | 748 | * @brief Performs an interrupt non-blocking send transfer on SAI. |
AnnaBridge | 145:64910690c574 | 749 | * |
AnnaBridge | 145:64910690c574 | 750 | * @note This API returns immediately after the transfer initiates. |
AnnaBridge | 145:64910690c574 | 751 | * Call the SAI_TxGetTransferStatusIRQ to poll the transfer status and check whether |
AnnaBridge | 145:64910690c574 | 752 | * the transfer is finished. If the return status is not kStatus_SAI_Busy, the transfer |
AnnaBridge | 145:64910690c574 | 753 | * is finished. |
AnnaBridge | 145:64910690c574 | 754 | * |
AnnaBridge | 145:64910690c574 | 755 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 756 | * @param handle Pointer to the sai_handle_t structure which stores the transfer state. |
AnnaBridge | 145:64910690c574 | 757 | * @param xfer Pointer to the sai_transfer_t structure. |
AnnaBridge | 145:64910690c574 | 758 | * @retval kStatus_Success Successfully started the data receive. |
AnnaBridge | 145:64910690c574 | 759 | * @retval kStatus_SAI_TxBusy Previous receive still not finished. |
AnnaBridge | 145:64910690c574 | 760 | * @retval kStatus_InvalidArgument The input parameter is invalid. |
AnnaBridge | 145:64910690c574 | 761 | */ |
AnnaBridge | 145:64910690c574 | 762 | status_t SAI_TransferSendNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer); |
AnnaBridge | 145:64910690c574 | 763 | |
AnnaBridge | 145:64910690c574 | 764 | /*! |
AnnaBridge | 145:64910690c574 | 765 | * @brief Performs an interrupt non-blocking receive transfer on SAI. |
AnnaBridge | 145:64910690c574 | 766 | * |
AnnaBridge | 145:64910690c574 | 767 | * @note This API returns immediately after the transfer initiates. |
AnnaBridge | 145:64910690c574 | 768 | * Call the SAI_RxGetTransferStatusIRQ to poll the transfer status and check whether |
AnnaBridge | 145:64910690c574 | 769 | * the transfer is finished. If the return status is not kStatus_SAI_Busy, the transfer |
AnnaBridge | 145:64910690c574 | 770 | * is finished. |
AnnaBridge | 145:64910690c574 | 771 | * |
AnnaBridge | 145:64910690c574 | 772 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 773 | * @param handle Pointer to the sai_handle_t structure which stores the transfer state. |
AnnaBridge | 145:64910690c574 | 774 | * @param xfer Pointer to the sai_transfer_t structure. |
AnnaBridge | 145:64910690c574 | 775 | * @retval kStatus_Success Successfully started the data receive. |
AnnaBridge | 145:64910690c574 | 776 | * @retval kStatus_SAI_RxBusy Previous receive still not finished. |
AnnaBridge | 145:64910690c574 | 777 | * @retval kStatus_InvalidArgument The input parameter is invalid. |
AnnaBridge | 145:64910690c574 | 778 | */ |
AnnaBridge | 145:64910690c574 | 779 | status_t SAI_TransferReceiveNonBlocking(I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer); |
AnnaBridge | 145:64910690c574 | 780 | |
AnnaBridge | 145:64910690c574 | 781 | /*! |
AnnaBridge | 145:64910690c574 | 782 | * @brief Gets a set byte count. |
AnnaBridge | 145:64910690c574 | 783 | * |
AnnaBridge | 145:64910690c574 | 784 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 785 | * @param handle Pointer to the sai_handle_t structure which stores the transfer state. |
AnnaBridge | 145:64910690c574 | 786 | * @param count Bytes count sent. |
AnnaBridge | 145:64910690c574 | 787 | * @retval kStatus_Success Succeed get the transfer count. |
AnnaBridge | 145:64910690c574 | 788 | * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. |
AnnaBridge | 145:64910690c574 | 789 | */ |
AnnaBridge | 145:64910690c574 | 790 | status_t SAI_TransferGetSendCount(I2S_Type *base, sai_handle_t *handle, size_t *count); |
AnnaBridge | 145:64910690c574 | 791 | |
AnnaBridge | 145:64910690c574 | 792 | /*! |
AnnaBridge | 145:64910690c574 | 793 | * @brief Gets a received byte count. |
AnnaBridge | 145:64910690c574 | 794 | * |
AnnaBridge | 145:64910690c574 | 795 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 796 | * @param handle Pointer to the sai_handle_t structure which stores the transfer state. |
AnnaBridge | 145:64910690c574 | 797 | * @param count Bytes count received. |
AnnaBridge | 145:64910690c574 | 798 | * @retval kStatus_Success Succeed get the transfer count. |
AnnaBridge | 145:64910690c574 | 799 | * @retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress. |
AnnaBridge | 145:64910690c574 | 800 | */ |
AnnaBridge | 145:64910690c574 | 801 | status_t SAI_TransferGetReceiveCount(I2S_Type *base, sai_handle_t *handle, size_t *count); |
AnnaBridge | 145:64910690c574 | 802 | |
AnnaBridge | 145:64910690c574 | 803 | /*! |
AnnaBridge | 145:64910690c574 | 804 | * @brief Aborts the current send. |
AnnaBridge | 145:64910690c574 | 805 | * |
AnnaBridge | 145:64910690c574 | 806 | * @note This API can be called any time when an interrupt non-blocking transfer initiates |
AnnaBridge | 145:64910690c574 | 807 | * to abort the transfer early. |
AnnaBridge | 145:64910690c574 | 808 | * |
AnnaBridge | 145:64910690c574 | 809 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 810 | * @param handle Pointer to the sai_handle_t structure which stores the transfer state. |
AnnaBridge | 145:64910690c574 | 811 | */ |
AnnaBridge | 145:64910690c574 | 812 | void SAI_TransferAbortSend(I2S_Type *base, sai_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 813 | |
AnnaBridge | 145:64910690c574 | 814 | /*! |
AnnaBridge | 145:64910690c574 | 815 | * @brief Aborts the the current IRQ receive. |
AnnaBridge | 145:64910690c574 | 816 | * |
AnnaBridge | 145:64910690c574 | 817 | * @note This API can be called when an interrupt non-blocking transfer initiates |
AnnaBridge | 145:64910690c574 | 818 | * to abort the transfer early. |
AnnaBridge | 145:64910690c574 | 819 | * |
AnnaBridge | 145:64910690c574 | 820 | * @param base SAI base pointer |
AnnaBridge | 145:64910690c574 | 821 | * @param handle Pointer to the sai_handle_t structure which stores the transfer state. |
AnnaBridge | 145:64910690c574 | 822 | */ |
AnnaBridge | 145:64910690c574 | 823 | void SAI_TransferAbortReceive(I2S_Type *base, sai_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 824 | |
AnnaBridge | 145:64910690c574 | 825 | /*! |
AnnaBridge | 145:64910690c574 | 826 | * @brief Tx interrupt handler. |
AnnaBridge | 145:64910690c574 | 827 | * |
AnnaBridge | 145:64910690c574 | 828 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 829 | * @param handle Pointer to the sai_handle_t structure. |
AnnaBridge | 145:64910690c574 | 830 | */ |
AnnaBridge | 145:64910690c574 | 831 | void SAI_TransferTxHandleIRQ(I2S_Type *base, sai_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 832 | |
AnnaBridge | 145:64910690c574 | 833 | /*! |
AnnaBridge | 145:64910690c574 | 834 | * @brief Tx interrupt handler. |
AnnaBridge | 145:64910690c574 | 835 | * |
AnnaBridge | 145:64910690c574 | 836 | * @param base SAI base pointer. |
AnnaBridge | 145:64910690c574 | 837 | * @param handle Pointer to the sai_handle_t structure. |
AnnaBridge | 145:64910690c574 | 838 | */ |
AnnaBridge | 145:64910690c574 | 839 | void SAI_TransferRxHandleIRQ(I2S_Type *base, sai_handle_t *handle); |
AnnaBridge | 145:64910690c574 | 840 | |
AnnaBridge | 145:64910690c574 | 841 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 842 | |
AnnaBridge | 145:64910690c574 | 843 | #if defined(__cplusplus) |
AnnaBridge | 145:64910690c574 | 844 | } |
AnnaBridge | 145:64910690c574 | 845 | #endif /*_cplusplus*/ |
AnnaBridge | 145:64910690c574 | 846 | |
AnnaBridge | 145:64910690c574 | 847 | /*! @} */ |
AnnaBridge | 145:64910690c574 | 848 | |
AnnaBridge | 145:64910690c574 | 849 | #endif /* _FSL_SAI_H_ */ |