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