Hal Drivers for L4
Dependents: BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo
Fork of STM32L4xx_HAL_Driver by
Inc/stm32l4xx_hal_sai.h@0:80ee8f3b695e, 2015-11-02 (annotated)
- Committer:
- EricLew
- Date:
- Mon Nov 02 19:37:23 2015 +0000
- Revision:
- 0:80ee8f3b695e
Errors are with definitions of LCD and QSPI functions. I believe all .h and .c files are uploaded, but there may need to be certain functions called.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
EricLew | 0:80ee8f3b695e | 1 | /** |
EricLew | 0:80ee8f3b695e | 2 | ****************************************************************************** |
EricLew | 0:80ee8f3b695e | 3 | * @file stm32l4xx_hal_sai.h |
EricLew | 0:80ee8f3b695e | 4 | * @author MCD Application Team |
EricLew | 0:80ee8f3b695e | 5 | * @version V1.1.0 |
EricLew | 0:80ee8f3b695e | 6 | * @date 16-September-2015 |
EricLew | 0:80ee8f3b695e | 7 | * @brief Header file of SAI HAL module. |
EricLew | 0:80ee8f3b695e | 8 | ****************************************************************************** |
EricLew | 0:80ee8f3b695e | 9 | * @attention |
EricLew | 0:80ee8f3b695e | 10 | * |
EricLew | 0:80ee8f3b695e | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
EricLew | 0:80ee8f3b695e | 12 | * |
EricLew | 0:80ee8f3b695e | 13 | * Redistribution and use in source and binary forms, with or without modification, |
EricLew | 0:80ee8f3b695e | 14 | * are permitted provided that the following conditions are met: |
EricLew | 0:80ee8f3b695e | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
EricLew | 0:80ee8f3b695e | 16 | * this list of conditions and the following disclaimer. |
EricLew | 0:80ee8f3b695e | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
EricLew | 0:80ee8f3b695e | 18 | * this list of conditions and the following disclaimer in the documentation |
EricLew | 0:80ee8f3b695e | 19 | * and/or other materials provided with the distribution. |
EricLew | 0:80ee8f3b695e | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
EricLew | 0:80ee8f3b695e | 21 | * may be used to endorse or promote products derived from this software |
EricLew | 0:80ee8f3b695e | 22 | * without specific prior written permission. |
EricLew | 0:80ee8f3b695e | 23 | * |
EricLew | 0:80ee8f3b695e | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
EricLew | 0:80ee8f3b695e | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
EricLew | 0:80ee8f3b695e | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
EricLew | 0:80ee8f3b695e | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
EricLew | 0:80ee8f3b695e | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
EricLew | 0:80ee8f3b695e | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
EricLew | 0:80ee8f3b695e | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
EricLew | 0:80ee8f3b695e | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
EricLew | 0:80ee8f3b695e | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
EricLew | 0:80ee8f3b695e | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
EricLew | 0:80ee8f3b695e | 34 | * |
EricLew | 0:80ee8f3b695e | 35 | ****************************************************************************** |
EricLew | 0:80ee8f3b695e | 36 | */ |
EricLew | 0:80ee8f3b695e | 37 | |
EricLew | 0:80ee8f3b695e | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 39 | #ifndef __STM32L4xx_HAL_SAI_H |
EricLew | 0:80ee8f3b695e | 40 | #define __STM32L4xx_HAL_SAI_H |
EricLew | 0:80ee8f3b695e | 41 | |
EricLew | 0:80ee8f3b695e | 42 | #ifdef __cplusplus |
EricLew | 0:80ee8f3b695e | 43 | extern "C" { |
EricLew | 0:80ee8f3b695e | 44 | #endif |
EricLew | 0:80ee8f3b695e | 45 | |
EricLew | 0:80ee8f3b695e | 46 | /* Includes ------------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 47 | #include "stm32l4xx_hal_def.h" |
EricLew | 0:80ee8f3b695e | 48 | |
EricLew | 0:80ee8f3b695e | 49 | /** @addtogroup STM32L4xx_HAL_Driver |
EricLew | 0:80ee8f3b695e | 50 | * @{ |
EricLew | 0:80ee8f3b695e | 51 | */ |
EricLew | 0:80ee8f3b695e | 52 | |
EricLew | 0:80ee8f3b695e | 53 | /** @addtogroup SAI |
EricLew | 0:80ee8f3b695e | 54 | * @{ |
EricLew | 0:80ee8f3b695e | 55 | */ |
EricLew | 0:80ee8f3b695e | 56 | |
EricLew | 0:80ee8f3b695e | 57 | /* Exported types ------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 58 | /** @defgroup SAI_Exported_Types SAI Exported Types |
EricLew | 0:80ee8f3b695e | 59 | * @{ |
EricLew | 0:80ee8f3b695e | 60 | */ |
EricLew | 0:80ee8f3b695e | 61 | |
EricLew | 0:80ee8f3b695e | 62 | /** |
EricLew | 0:80ee8f3b695e | 63 | * @brief HAL State structures definition |
EricLew | 0:80ee8f3b695e | 64 | */ |
EricLew | 0:80ee8f3b695e | 65 | typedef enum |
EricLew | 0:80ee8f3b695e | 66 | { |
EricLew | 0:80ee8f3b695e | 67 | HAL_SAI_STATE_RESET = 0x00, /*!< SAI not yet initialized or disabled */ |
EricLew | 0:80ee8f3b695e | 68 | HAL_SAI_STATE_READY = 0x01, /*!< SAI initialized and ready for use */ |
EricLew | 0:80ee8f3b695e | 69 | HAL_SAI_STATE_BUSY = 0x02, /*!< SAI internal process is ongoing */ |
EricLew | 0:80ee8f3b695e | 70 | HAL_SAI_STATE_BUSY_TX = 0x12, /*!< Data transmission process is ongoing */ |
EricLew | 0:80ee8f3b695e | 71 | HAL_SAI_STATE_BUSY_RX = 0x22 /*!< Data reception process is ongoing */ |
EricLew | 0:80ee8f3b695e | 72 | }HAL_SAI_StateTypeDef; |
EricLew | 0:80ee8f3b695e | 73 | |
EricLew | 0:80ee8f3b695e | 74 | /** |
EricLew | 0:80ee8f3b695e | 75 | * @brief SAI Callback prototype |
EricLew | 0:80ee8f3b695e | 76 | */ |
EricLew | 0:80ee8f3b695e | 77 | typedef void (*SAIcallback)(void); |
EricLew | 0:80ee8f3b695e | 78 | |
EricLew | 0:80ee8f3b695e | 79 | /** @defgroup SAI_Block_SyncExt SAI External synchronisation |
EricLew | 0:80ee8f3b695e | 80 | * @{ |
EricLew | 0:80ee8f3b695e | 81 | */ |
EricLew | 0:80ee8f3b695e | 82 | #define SAI_SYNCEXT_DISABLE 0 |
EricLew | 0:80ee8f3b695e | 83 | #define SAI_SYNCEXT_IN_ENABLE 1 |
EricLew | 0:80ee8f3b695e | 84 | #define SAI_SYNCEXT_OUTBLOCKA_ENABLE 2 |
EricLew | 0:80ee8f3b695e | 85 | #define SAI_SYNCEXT_OUTBLOCKB_ENABLE 3 |
EricLew | 0:80ee8f3b695e | 86 | |
EricLew | 0:80ee8f3b695e | 87 | /** |
EricLew | 0:80ee8f3b695e | 88 | * @} |
EricLew | 0:80ee8f3b695e | 89 | */ |
EricLew | 0:80ee8f3b695e | 90 | |
EricLew | 0:80ee8f3b695e | 91 | /** @defgroup SAI_Protocol SAI Supported protocol |
EricLew | 0:80ee8f3b695e | 92 | * @{ |
EricLew | 0:80ee8f3b695e | 93 | */ |
EricLew | 0:80ee8f3b695e | 94 | #define SAI_I2S_STANDARD 0 |
EricLew | 0:80ee8f3b695e | 95 | #define SAI_I2S_MSBJUSTIFIED 1 |
EricLew | 0:80ee8f3b695e | 96 | #define SAI_I2S_LSBJUSTIFIED 2 |
EricLew | 0:80ee8f3b695e | 97 | #define SAI_PCM_LONG 3 |
EricLew | 0:80ee8f3b695e | 98 | #define SAI_PCM_SHORT 4 |
EricLew | 0:80ee8f3b695e | 99 | |
EricLew | 0:80ee8f3b695e | 100 | /** |
EricLew | 0:80ee8f3b695e | 101 | * @} |
EricLew | 0:80ee8f3b695e | 102 | */ |
EricLew | 0:80ee8f3b695e | 103 | |
EricLew | 0:80ee8f3b695e | 104 | /** @defgroup SAI_Protocol_DataSize SAI protocol data size |
EricLew | 0:80ee8f3b695e | 105 | * @{ |
EricLew | 0:80ee8f3b695e | 106 | */ |
EricLew | 0:80ee8f3b695e | 107 | #define SAI_PROTOCOL_DATASIZE_16BIT 0 |
EricLew | 0:80ee8f3b695e | 108 | #define SAI_PROTOCOL_DATASIZE_16BITEXTENDED 1 |
EricLew | 0:80ee8f3b695e | 109 | #define SAI_PROTOCOL_DATASIZE_24BIT 2 |
EricLew | 0:80ee8f3b695e | 110 | #define SAI_PROTOCOL_DATASIZE_32BIT 3 |
EricLew | 0:80ee8f3b695e | 111 | |
EricLew | 0:80ee8f3b695e | 112 | /** |
EricLew | 0:80ee8f3b695e | 113 | * @} |
EricLew | 0:80ee8f3b695e | 114 | */ |
EricLew | 0:80ee8f3b695e | 115 | |
EricLew | 0:80ee8f3b695e | 116 | /** @defgroup SAI_Init_Structure_definition SAI Init Structure definition |
EricLew | 0:80ee8f3b695e | 117 | * @brief SAI Init Structure definition |
EricLew | 0:80ee8f3b695e | 118 | * @{ |
EricLew | 0:80ee8f3b695e | 119 | */ |
EricLew | 0:80ee8f3b695e | 120 | typedef struct |
EricLew | 0:80ee8f3b695e | 121 | { |
EricLew | 0:80ee8f3b695e | 122 | uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode. |
EricLew | 0:80ee8f3b695e | 123 | This parameter can be a value of @ref SAI_Block_Mode */ |
EricLew | 0:80ee8f3b695e | 124 | |
EricLew | 0:80ee8f3b695e | 125 | uint32_t Synchro; /*!< Specifies SAI Block synchronization |
EricLew | 0:80ee8f3b695e | 126 | This parameter can be a value of @ref SAI_Block_Synchronization */ |
EricLew | 0:80ee8f3b695e | 127 | |
EricLew | 0:80ee8f3b695e | 128 | uint32_t SynchroExt; /*!< Specifies SAI Block synchronization, this setup is common |
EricLew | 0:80ee8f3b695e | 129 | for BLOCKA and BLOB |
EricLew | 0:80ee8f3b695e | 130 | This parameter can be a value of @ref SAI_Block_SyncExt */ |
EricLew | 0:80ee8f3b695e | 131 | |
EricLew | 0:80ee8f3b695e | 132 | uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven. |
EricLew | 0:80ee8f3b695e | 133 | This parameter can be a value of @ref SAI_Block_Output_Drive |
EricLew | 0:80ee8f3b695e | 134 | @note this value has to be set before enabling the audio block |
EricLew | 0:80ee8f3b695e | 135 | but after the audio block configuration. */ |
EricLew | 0:80ee8f3b695e | 136 | |
EricLew | 0:80ee8f3b695e | 137 | uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not. |
EricLew | 0:80ee8f3b695e | 138 | This parameter can be a value of @ref SAI_Block_NoDivider |
EricLew | 0:80ee8f3b695e | 139 | @note: If bit NODIV in the SAI_xCR1 register is cleared, the frame length |
EricLew | 0:80ee8f3b695e | 140 | should be aligned to a number equal to a power of 2, from 8 to 256. |
EricLew | 0:80ee8f3b695e | 141 | If bit NODIV in the SAI_xCR1 register is set, the frame length can |
EricLew | 0:80ee8f3b695e | 142 | take any of the values without constraint since the input clock of |
EricLew | 0:80ee8f3b695e | 143 | the audio block should be equal to the bit clock. |
EricLew | 0:80ee8f3b695e | 144 | There is no MCLK_x clock which can be output. */ |
EricLew | 0:80ee8f3b695e | 145 | |
EricLew | 0:80ee8f3b695e | 146 | uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold. |
EricLew | 0:80ee8f3b695e | 147 | This parameter can be a value of @ref SAI_Block_Fifo_Threshold */ |
EricLew | 0:80ee8f3b695e | 148 | |
EricLew | 0:80ee8f3b695e | 149 | uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling. |
EricLew | 0:80ee8f3b695e | 150 | This parameter can be a value of @ref SAI_Audio_Frequency */ |
EricLew | 0:80ee8f3b695e | 151 | |
EricLew | 0:80ee8f3b695e | 152 | uint32_t Mckdiv; /*!< Specifies the master clock divider, the parameter will be used if for |
EricLew | 0:80ee8f3b695e | 153 | AudioFrequency the user choice |
EricLew | 0:80ee8f3b695e | 154 | This parameter must be a number between Min_Data = 0 and Max_Data = 15 */ |
EricLew | 0:80ee8f3b695e | 155 | |
EricLew | 0:80ee8f3b695e | 156 | uint32_t MonoStereoMode; /*!< Specifies if the mono or stereo mode is selected. |
EricLew | 0:80ee8f3b695e | 157 | This parameter can be a value of @ref SAI_Mono_Stereo_Mode */ |
EricLew | 0:80ee8f3b695e | 158 | |
EricLew | 0:80ee8f3b695e | 159 | uint32_t CompandingMode; /*!< Specifies the companding mode type. |
EricLew | 0:80ee8f3b695e | 160 | This parameter can be a value of @ref SAI_Block_Companding_Mode */ |
EricLew | 0:80ee8f3b695e | 161 | |
EricLew | 0:80ee8f3b695e | 162 | uint32_t TriState; /*!< Specifies the companding mode type. |
EricLew | 0:80ee8f3b695e | 163 | This parameter can be a value of @ref SAI_TRIState_Management */ |
EricLew | 0:80ee8f3b695e | 164 | |
EricLew | 0:80ee8f3b695e | 165 | /* This part of the structure is automatically filled if your are using the high level initialisation |
EricLew | 0:80ee8f3b695e | 166 | function HAL_SAI_InitProtocol */ |
EricLew | 0:80ee8f3b695e | 167 | |
EricLew | 0:80ee8f3b695e | 168 | uint32_t Protocol; /*!< Specifies the SAI Block protocol. |
EricLew | 0:80ee8f3b695e | 169 | This parameter can be a value of @ref SAI_Block_Protocol */ |
EricLew | 0:80ee8f3b695e | 170 | |
EricLew | 0:80ee8f3b695e | 171 | uint32_t DataSize; /*!< Specifies the SAI Block data size. |
EricLew | 0:80ee8f3b695e | 172 | This parameter can be a value of @ref SAI_Block_Data_Size */ |
EricLew | 0:80ee8f3b695e | 173 | |
EricLew | 0:80ee8f3b695e | 174 | uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
EricLew | 0:80ee8f3b695e | 175 | This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */ |
EricLew | 0:80ee8f3b695e | 176 | |
EricLew | 0:80ee8f3b695e | 177 | uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity. |
EricLew | 0:80ee8f3b695e | 178 | This parameter can be a value of @ref SAI_Block_Clock_Strobing */ |
EricLew | 0:80ee8f3b695e | 179 | }SAI_InitTypeDef; |
EricLew | 0:80ee8f3b695e | 180 | /** |
EricLew | 0:80ee8f3b695e | 181 | * @} |
EricLew | 0:80ee8f3b695e | 182 | */ |
EricLew | 0:80ee8f3b695e | 183 | |
EricLew | 0:80ee8f3b695e | 184 | /** @defgroup SAI_Frame_Structure_definition SAI Frame Structure definition |
EricLew | 0:80ee8f3b695e | 185 | * @brief SAI Frame Init structure definition |
EricLew | 0:80ee8f3b695e | 186 | * @{ |
EricLew | 0:80ee8f3b695e | 187 | */ |
EricLew | 0:80ee8f3b695e | 188 | typedef struct |
EricLew | 0:80ee8f3b695e | 189 | { |
EricLew | 0:80ee8f3b695e | 190 | |
EricLew | 0:80ee8f3b695e | 191 | uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame. |
EricLew | 0:80ee8f3b695e | 192 | This parameter must be a number between Min_Data = 8 and Max_Data = 256. |
EricLew | 0:80ee8f3b695e | 193 | @note: If master clock MCLK_x pin is declared as an output, the frame length |
EricLew | 0:80ee8f3b695e | 194 | should be aligned to a number equal to power of 2 in order to keep |
EricLew | 0:80ee8f3b695e | 195 | in an audio frame, an integer number of MCLK pulses by bit Clock. */ |
EricLew | 0:80ee8f3b695e | 196 | |
EricLew | 0:80ee8f3b695e | 197 | uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length. |
EricLew | 0:80ee8f3b695e | 198 | This Parameter specifies the length in number of bit clock (SCK + 1) |
EricLew | 0:80ee8f3b695e | 199 | of the active level of FS signal in audio frame. |
EricLew | 0:80ee8f3b695e | 200 | This parameter must be a number between Min_Data = 1 and Max_Data = 128 */ |
EricLew | 0:80ee8f3b695e | 201 | |
EricLew | 0:80ee8f3b695e | 202 | uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition. |
EricLew | 0:80ee8f3b695e | 203 | This parameter can be a value of @ref SAI_Block_FS_Definition */ |
EricLew | 0:80ee8f3b695e | 204 | |
EricLew | 0:80ee8f3b695e | 205 | uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity. |
EricLew | 0:80ee8f3b695e | 206 | This parameter can be a value of @ref SAI_Block_FS_Polarity */ |
EricLew | 0:80ee8f3b695e | 207 | |
EricLew | 0:80ee8f3b695e | 208 | uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset. |
EricLew | 0:80ee8f3b695e | 209 | This parameter can be a value of @ref SAI_Block_FS_Offset */ |
EricLew | 0:80ee8f3b695e | 210 | |
EricLew | 0:80ee8f3b695e | 211 | }SAI_FrameInitTypeDef; |
EricLew | 0:80ee8f3b695e | 212 | /** |
EricLew | 0:80ee8f3b695e | 213 | * @} |
EricLew | 0:80ee8f3b695e | 214 | */ |
EricLew | 0:80ee8f3b695e | 215 | |
EricLew | 0:80ee8f3b695e | 216 | /** @defgroup SAI_Slot_Structure_definition SAI Slot Structure definition |
EricLew | 0:80ee8f3b695e | 217 | * @brief SAI Block Slot Init Structure definition |
EricLew | 0:80ee8f3b695e | 218 | * @{ |
EricLew | 0:80ee8f3b695e | 219 | */ |
EricLew | 0:80ee8f3b695e | 220 | |
EricLew | 0:80ee8f3b695e | 221 | typedef struct |
EricLew | 0:80ee8f3b695e | 222 | { |
EricLew | 0:80ee8f3b695e | 223 | uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot. |
EricLew | 0:80ee8f3b695e | 224 | This parameter must be a number between Min_Data = 0 and Max_Data = 24 */ |
EricLew | 0:80ee8f3b695e | 225 | |
EricLew | 0:80ee8f3b695e | 226 | uint32_t SlotSize; /*!< Specifies the Slot Size. |
EricLew | 0:80ee8f3b695e | 227 | This parameter can be a value of @ref SAI_Block_Slot_Size */ |
EricLew | 0:80ee8f3b695e | 228 | |
EricLew | 0:80ee8f3b695e | 229 | uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame. |
EricLew | 0:80ee8f3b695e | 230 | This parameter must be a number between Min_Data = 1 and Max_Data = 16 */ |
EricLew | 0:80ee8f3b695e | 231 | |
EricLew | 0:80ee8f3b695e | 232 | uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated. |
EricLew | 0:80ee8f3b695e | 233 | This parameter can be a value of @ref SAI_Block_Slot_Active */ |
EricLew | 0:80ee8f3b695e | 234 | }SAI_SlotInitTypeDef; |
EricLew | 0:80ee8f3b695e | 235 | /** |
EricLew | 0:80ee8f3b695e | 236 | * @} |
EricLew | 0:80ee8f3b695e | 237 | */ |
EricLew | 0:80ee8f3b695e | 238 | |
EricLew | 0:80ee8f3b695e | 239 | /** @defgroup SAI_Handle_Structure_definition SAI Handle Structure definition |
EricLew | 0:80ee8f3b695e | 240 | * @brief SAI handle Structure definition |
EricLew | 0:80ee8f3b695e | 241 | * @{ |
EricLew | 0:80ee8f3b695e | 242 | */ |
EricLew | 0:80ee8f3b695e | 243 | typedef struct __SAI_HandleTypeDef |
EricLew | 0:80ee8f3b695e | 244 | { |
EricLew | 0:80ee8f3b695e | 245 | SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */ |
EricLew | 0:80ee8f3b695e | 246 | |
EricLew | 0:80ee8f3b695e | 247 | SAI_InitTypeDef Init; /*!< SAI communication parameters */ |
EricLew | 0:80ee8f3b695e | 248 | |
EricLew | 0:80ee8f3b695e | 249 | SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters*/ |
EricLew | 0:80ee8f3b695e | 250 | |
EricLew | 0:80ee8f3b695e | 251 | SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */ |
EricLew | 0:80ee8f3b695e | 252 | |
EricLew | 0:80ee8f3b695e | 253 | uint8_t *pBuffPtr; /*!< Pointer to SAI transfer Buffer */ |
EricLew | 0:80ee8f3b695e | 254 | |
EricLew | 0:80ee8f3b695e | 255 | uint16_t XferSize; /*!< SAI transfer size */ |
EricLew | 0:80ee8f3b695e | 256 | |
EricLew | 0:80ee8f3b695e | 257 | uint16_t XferCount; /*!< SAI transfer counter */ |
EricLew | 0:80ee8f3b695e | 258 | |
EricLew | 0:80ee8f3b695e | 259 | DMA_HandleTypeDef *hdmatx; /*!< SAI DMA tx handle parameters */ |
EricLew | 0:80ee8f3b695e | 260 | |
EricLew | 0:80ee8f3b695e | 261 | DMA_HandleTypeDef *hdmarx; /*!< SAI DMA rx handle parameters */ |
EricLew | 0:80ee8f3b695e | 262 | |
EricLew | 0:80ee8f3b695e | 263 | SAIcallback mutecallback;/*!< SAI mute callback */ |
EricLew | 0:80ee8f3b695e | 264 | |
EricLew | 0:80ee8f3b695e | 265 | void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */ |
EricLew | 0:80ee8f3b695e | 266 | |
EricLew | 0:80ee8f3b695e | 267 | HAL_LockTypeDef Lock; /*!< SAI locking object */ |
EricLew | 0:80ee8f3b695e | 268 | |
EricLew | 0:80ee8f3b695e | 269 | HAL_SAI_StateTypeDef State; /*!< SAI communication state */ |
EricLew | 0:80ee8f3b695e | 270 | |
EricLew | 0:80ee8f3b695e | 271 | uint32_t ErrorCode; /*!< SAI Error code */ |
EricLew | 0:80ee8f3b695e | 272 | }SAI_HandleTypeDef; |
EricLew | 0:80ee8f3b695e | 273 | /** |
EricLew | 0:80ee8f3b695e | 274 | * @} |
EricLew | 0:80ee8f3b695e | 275 | */ |
EricLew | 0:80ee8f3b695e | 276 | |
EricLew | 0:80ee8f3b695e | 277 | /** |
EricLew | 0:80ee8f3b695e | 278 | * @} |
EricLew | 0:80ee8f3b695e | 279 | */ |
EricLew | 0:80ee8f3b695e | 280 | |
EricLew | 0:80ee8f3b695e | 281 | /* Exported constants --------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 282 | |
EricLew | 0:80ee8f3b695e | 283 | /** @defgroup SAI_Exported_Constants SAI Exported Constants |
EricLew | 0:80ee8f3b695e | 284 | * @{ |
EricLew | 0:80ee8f3b695e | 285 | */ |
EricLew | 0:80ee8f3b695e | 286 | |
EricLew | 0:80ee8f3b695e | 287 | /** @defgroup SAI_Error_Code SAI Error Code |
EricLew | 0:80ee8f3b695e | 288 | * @{ |
EricLew | 0:80ee8f3b695e | 289 | */ |
EricLew | 0:80ee8f3b695e | 290 | #define HAL_SAI_ERROR_NONE (uint32_t)0x00000000 /*!< No error */ |
EricLew | 0:80ee8f3b695e | 291 | #define HAL_SAI_ERROR_OVR (uint32_t)0x00000001 /*!< Overrun Error */ |
EricLew | 0:80ee8f3b695e | 292 | #define HAL_SAI_ERROR_UDR (uint32_t)0x00000002 /*!< Underrun error */ |
EricLew | 0:80ee8f3b695e | 293 | #define HAL_SAI_ERROR_AFSDET (uint32_t)0x00000004 /*!< Anticipated Frame synchronisation detection */ |
EricLew | 0:80ee8f3b695e | 294 | #define HAL_SAI_ERROR_LFSDET (uint32_t)0x00000008 /*!< Late Frame synchronisation detection */ |
EricLew | 0:80ee8f3b695e | 295 | #define HAL_SAI_ERROR_CNREADY (uint32_t)0x00000010 /*!< codec not ready */ |
EricLew | 0:80ee8f3b695e | 296 | #define HAL_SAI_ERROR_WCKCFG (uint32_t)0x00000020 /*!< Wrong clock configuration */ |
EricLew | 0:80ee8f3b695e | 297 | /** |
EricLew | 0:80ee8f3b695e | 298 | * @} |
EricLew | 0:80ee8f3b695e | 299 | */ |
EricLew | 0:80ee8f3b695e | 300 | |
EricLew | 0:80ee8f3b695e | 301 | /** @defgroup SAI_Audio_Frequency SAI Audio Frequency |
EricLew | 0:80ee8f3b695e | 302 | * @{ |
EricLew | 0:80ee8f3b695e | 303 | */ |
EricLew | 0:80ee8f3b695e | 304 | #define SAI_AUDIO_FREQUENCY_192K ((uint32_t)192000) |
EricLew | 0:80ee8f3b695e | 305 | #define SAI_AUDIO_FREQUENCY_96K ((uint32_t)96000) |
EricLew | 0:80ee8f3b695e | 306 | #define SAI_AUDIO_FREQUENCY_48K ((uint32_t)48000) |
EricLew | 0:80ee8f3b695e | 307 | #define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100) |
EricLew | 0:80ee8f3b695e | 308 | #define SAI_AUDIO_FREQUENCY_32K ((uint32_t)32000) |
EricLew | 0:80ee8f3b695e | 309 | #define SAI_AUDIO_FREQUENCY_22K ((uint32_t)22050) |
EricLew | 0:80ee8f3b695e | 310 | #define SAI_AUDIO_FREQUENCY_16K ((uint32_t)16000) |
EricLew | 0:80ee8f3b695e | 311 | #define SAI_AUDIO_FREQUENCY_11K ((uint32_t)11025) |
EricLew | 0:80ee8f3b695e | 312 | #define SAI_AUDIO_FREQUENCY_8K ((uint32_t)8000) |
EricLew | 0:80ee8f3b695e | 313 | #define SAI_AUDIO_FREQUENCY_MCKDIV ((uint32_t)0) |
EricLew | 0:80ee8f3b695e | 314 | |
EricLew | 0:80ee8f3b695e | 315 | /** |
EricLew | 0:80ee8f3b695e | 316 | * @} |
EricLew | 0:80ee8f3b695e | 317 | */ |
EricLew | 0:80ee8f3b695e | 318 | |
EricLew | 0:80ee8f3b695e | 319 | /** @defgroup SAI_Block_Mode SAI Block Mode |
EricLew | 0:80ee8f3b695e | 320 | * @{ |
EricLew | 0:80ee8f3b695e | 321 | */ |
EricLew | 0:80ee8f3b695e | 322 | #define SAI_MODEMASTER_TX ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 323 | #define SAI_MODEMASTER_RX (SAI_xCR1_MODE_0) |
EricLew | 0:80ee8f3b695e | 324 | #define SAI_MODESLAVE_TX (SAI_xCR1_MODE_1) |
EricLew | 0:80ee8f3b695e | 325 | #define SAI_MODESLAVE_RX (SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0) |
EricLew | 0:80ee8f3b695e | 326 | |
EricLew | 0:80ee8f3b695e | 327 | /** |
EricLew | 0:80ee8f3b695e | 328 | * @} |
EricLew | 0:80ee8f3b695e | 329 | */ |
EricLew | 0:80ee8f3b695e | 330 | |
EricLew | 0:80ee8f3b695e | 331 | /** @defgroup SAI_Block_Protocol SAI Block Protocol |
EricLew | 0:80ee8f3b695e | 332 | * @{ |
EricLew | 0:80ee8f3b695e | 333 | */ |
EricLew | 0:80ee8f3b695e | 334 | #define SAI_FREE_PROTOCOL ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 335 | #define SAI_SPDIF_PROTOCOL (SAI_xCR1_PRTCFG_0) |
EricLew | 0:80ee8f3b695e | 336 | #define SAI_AC97_PROTOCOL (SAI_xCR1_PRTCFG_1) |
EricLew | 0:80ee8f3b695e | 337 | |
EricLew | 0:80ee8f3b695e | 338 | /** |
EricLew | 0:80ee8f3b695e | 339 | * @} |
EricLew | 0:80ee8f3b695e | 340 | */ |
EricLew | 0:80ee8f3b695e | 341 | |
EricLew | 0:80ee8f3b695e | 342 | /** @defgroup SAI_Block_Data_Size SAI Block Data Size |
EricLew | 0:80ee8f3b695e | 343 | * @{ |
EricLew | 0:80ee8f3b695e | 344 | */ |
EricLew | 0:80ee8f3b695e | 345 | #define SAI_DATASIZE_8 (SAI_xCR1_DS_1) |
EricLew | 0:80ee8f3b695e | 346 | #define SAI_DATASIZE_10 (SAI_xCR1_DS_1 | SAI_xCR1_DS_0) |
EricLew | 0:80ee8f3b695e | 347 | #define SAI_DATASIZE_16 (SAI_xCR1_DS_2) |
EricLew | 0:80ee8f3b695e | 348 | #define SAI_DATASIZE_20 (SAI_xCR1_DS_2 | SAI_xCR1_DS_0) |
EricLew | 0:80ee8f3b695e | 349 | #define SAI_DATASIZE_24 (SAI_xCR1_DS_2 | SAI_xCR1_DS_1) |
EricLew | 0:80ee8f3b695e | 350 | #define SAI_DATASIZE_32 (SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0) |
EricLew | 0:80ee8f3b695e | 351 | |
EricLew | 0:80ee8f3b695e | 352 | /** |
EricLew | 0:80ee8f3b695e | 353 | * @} |
EricLew | 0:80ee8f3b695e | 354 | */ |
EricLew | 0:80ee8f3b695e | 355 | |
EricLew | 0:80ee8f3b695e | 356 | /** @defgroup SAI_Block_MSB_LSB_transmission SAI Block MSB LSB transmission |
EricLew | 0:80ee8f3b695e | 357 | * @{ |
EricLew | 0:80ee8f3b695e | 358 | */ |
EricLew | 0:80ee8f3b695e | 359 | #define SAI_FIRSTBIT_MSB ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 360 | #define SAI_FIRSTBIT_LSB ((uint32_t)SAI_xCR1_LSBFIRST) |
EricLew | 0:80ee8f3b695e | 361 | |
EricLew | 0:80ee8f3b695e | 362 | /** |
EricLew | 0:80ee8f3b695e | 363 | * @} |
EricLew | 0:80ee8f3b695e | 364 | */ |
EricLew | 0:80ee8f3b695e | 365 | |
EricLew | 0:80ee8f3b695e | 366 | /** @defgroup SAI_Block_Clock_Strobing SAI Block Clock Strobing |
EricLew | 0:80ee8f3b695e | 367 | * @{ |
EricLew | 0:80ee8f3b695e | 368 | */ |
EricLew | 0:80ee8f3b695e | 369 | #define SAI_CLOCKSTROBING_FALLINGEDGE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 370 | #define SAI_CLOCKSTROBING_RISINGEDGE ((uint32_t)SAI_xCR1_CKSTR) |
EricLew | 0:80ee8f3b695e | 371 | |
EricLew | 0:80ee8f3b695e | 372 | /** |
EricLew | 0:80ee8f3b695e | 373 | * @} |
EricLew | 0:80ee8f3b695e | 374 | */ |
EricLew | 0:80ee8f3b695e | 375 | |
EricLew | 0:80ee8f3b695e | 376 | /** @defgroup SAI_Block_Synchronization SAI Block Synchronization |
EricLew | 0:80ee8f3b695e | 377 | * @{ |
EricLew | 0:80ee8f3b695e | 378 | */ |
EricLew | 0:80ee8f3b695e | 379 | #define SAI_ASYNCHRONOUS ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 380 | #define SAI_SYNCHRONOUS ((uint32_t)SAI_xCR1_SYNCEN_0) |
EricLew | 0:80ee8f3b695e | 381 | #define SAI_SYNCHRONOUS_EXT ((uint32_t)SAI_xCR1_SYNCEN_1) |
EricLew | 0:80ee8f3b695e | 382 | |
EricLew | 0:80ee8f3b695e | 383 | /** |
EricLew | 0:80ee8f3b695e | 384 | * @} |
EricLew | 0:80ee8f3b695e | 385 | */ |
EricLew | 0:80ee8f3b695e | 386 | |
EricLew | 0:80ee8f3b695e | 387 | /** @defgroup SAI_Block_Output_Drive SAI Block Output Drive |
EricLew | 0:80ee8f3b695e | 388 | * @{ |
EricLew | 0:80ee8f3b695e | 389 | */ |
EricLew | 0:80ee8f3b695e | 390 | #define SAI_OUTPUTDRIVE_DISABLE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 391 | #define SAI_OUTPUTDRIVE_ENABLE ((uint32_t)SAI_xCR1_OUTDRIV) |
EricLew | 0:80ee8f3b695e | 392 | |
EricLew | 0:80ee8f3b695e | 393 | /** |
EricLew | 0:80ee8f3b695e | 394 | * @} |
EricLew | 0:80ee8f3b695e | 395 | */ |
EricLew | 0:80ee8f3b695e | 396 | |
EricLew | 0:80ee8f3b695e | 397 | /** @defgroup SAI_Block_NoDivider SAI Block NoDivider |
EricLew | 0:80ee8f3b695e | 398 | * @{ |
EricLew | 0:80ee8f3b695e | 399 | */ |
EricLew | 0:80ee8f3b695e | 400 | #define SAI_MASTERDIVIDER_ENABLE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 401 | #define SAI_MASTERDIVIDER_DISABLE ((uint32_t)SAI_xCR1_NODIV) |
EricLew | 0:80ee8f3b695e | 402 | |
EricLew | 0:80ee8f3b695e | 403 | /** |
EricLew | 0:80ee8f3b695e | 404 | * @} |
EricLew | 0:80ee8f3b695e | 405 | */ |
EricLew | 0:80ee8f3b695e | 406 | |
EricLew | 0:80ee8f3b695e | 407 | |
EricLew | 0:80ee8f3b695e | 408 | /** @defgroup SAI_Block_FS_Definition SAI Block FS Definition |
EricLew | 0:80ee8f3b695e | 409 | * @{ |
EricLew | 0:80ee8f3b695e | 410 | */ |
EricLew | 0:80ee8f3b695e | 411 | #define SAI_FS_STARTFRAME ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 412 | #define SAI_FS_CHANNEL_IDENTIFICATION ((uint32_t)SAI_xFRCR_FSDEF) |
EricLew | 0:80ee8f3b695e | 413 | |
EricLew | 0:80ee8f3b695e | 414 | /** |
EricLew | 0:80ee8f3b695e | 415 | * @} |
EricLew | 0:80ee8f3b695e | 416 | */ |
EricLew | 0:80ee8f3b695e | 417 | |
EricLew | 0:80ee8f3b695e | 418 | /** @defgroup SAI_Block_FS_Polarity SAI Block FS Polarity |
EricLew | 0:80ee8f3b695e | 419 | * @{ |
EricLew | 0:80ee8f3b695e | 420 | */ |
EricLew | 0:80ee8f3b695e | 421 | #define SAI_FS_ACTIVE_LOW ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 422 | #define SAI_FS_ACTIVE_HIGH ((uint32_t)SAI_xFRCR_FSPO) |
EricLew | 0:80ee8f3b695e | 423 | |
EricLew | 0:80ee8f3b695e | 424 | /** |
EricLew | 0:80ee8f3b695e | 425 | * @} |
EricLew | 0:80ee8f3b695e | 426 | */ |
EricLew | 0:80ee8f3b695e | 427 | |
EricLew | 0:80ee8f3b695e | 428 | /** @defgroup SAI_Block_FS_Offset SAI Block FS Offset |
EricLew | 0:80ee8f3b695e | 429 | * @{ |
EricLew | 0:80ee8f3b695e | 430 | */ |
EricLew | 0:80ee8f3b695e | 431 | #define SAI_FS_FIRSTBIT ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 432 | #define SAI_FS_BEFOREFIRSTBIT ((uint32_t)SAI_xFRCR_FSOFF) |
EricLew | 0:80ee8f3b695e | 433 | |
EricLew | 0:80ee8f3b695e | 434 | /** |
EricLew | 0:80ee8f3b695e | 435 | * @} |
EricLew | 0:80ee8f3b695e | 436 | */ |
EricLew | 0:80ee8f3b695e | 437 | |
EricLew | 0:80ee8f3b695e | 438 | |
EricLew | 0:80ee8f3b695e | 439 | /** @defgroup SAI_Block_Slot_Size SAI Block Slot Size |
EricLew | 0:80ee8f3b695e | 440 | * @{ |
EricLew | 0:80ee8f3b695e | 441 | */ |
EricLew | 0:80ee8f3b695e | 442 | #define SAI_SLOTSIZE_DATASIZE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 443 | #define SAI_SLOTSIZE_16B ((uint32_t)SAI_xSLOTR_SLOTSZ_0) |
EricLew | 0:80ee8f3b695e | 444 | #define SAI_SLOTSIZE_32B ((uint32_t)SAI_xSLOTR_SLOTSZ_1) |
EricLew | 0:80ee8f3b695e | 445 | /** |
EricLew | 0:80ee8f3b695e | 446 | * @} |
EricLew | 0:80ee8f3b695e | 447 | */ |
EricLew | 0:80ee8f3b695e | 448 | |
EricLew | 0:80ee8f3b695e | 449 | /** @defgroup SAI_Block_Slot_Active SAI Block Slot Active |
EricLew | 0:80ee8f3b695e | 450 | * @{ |
EricLew | 0:80ee8f3b695e | 451 | */ |
EricLew | 0:80ee8f3b695e | 452 | #define SAI_SLOT_NOTACTIVE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 453 | #define SAI_SLOTACTIVE_0 ((uint32_t)0x00010000) |
EricLew | 0:80ee8f3b695e | 454 | #define SAI_SLOTACTIVE_1 ((uint32_t)0x00020000) |
EricLew | 0:80ee8f3b695e | 455 | #define SAI_SLOTACTIVE_2 ((uint32_t)0x00040000) |
EricLew | 0:80ee8f3b695e | 456 | #define SAI_SLOTACTIVE_3 ((uint32_t)0x00080000) |
EricLew | 0:80ee8f3b695e | 457 | #define SAI_SLOTACTIVE_4 ((uint32_t)0x00100000) |
EricLew | 0:80ee8f3b695e | 458 | #define SAI_SLOTACTIVE_5 ((uint32_t)0x00200000) |
EricLew | 0:80ee8f3b695e | 459 | #define SAI_SLOTACTIVE_6 ((uint32_t)0x00400000) |
EricLew | 0:80ee8f3b695e | 460 | #define SAI_SLOTACTIVE_7 ((uint32_t)0x00800000) |
EricLew | 0:80ee8f3b695e | 461 | #define SAI_SLOTACTIVE_8 ((uint32_t)0x01000000) |
EricLew | 0:80ee8f3b695e | 462 | #define SAI_SLOTACTIVE_9 ((uint32_t)0x02000000) |
EricLew | 0:80ee8f3b695e | 463 | #define SAI_SLOTACTIVE_10 ((uint32_t)0x04000000) |
EricLew | 0:80ee8f3b695e | 464 | #define SAI_SLOTACTIVE_11 ((uint32_t)0x08000000) |
EricLew | 0:80ee8f3b695e | 465 | #define SAI_SLOTACTIVE_12 ((uint32_t)0x10000000) |
EricLew | 0:80ee8f3b695e | 466 | #define SAI_SLOTACTIVE_13 ((uint32_t)0x20000000) |
EricLew | 0:80ee8f3b695e | 467 | #define SAI_SLOTACTIVE_14 ((uint32_t)0x40000000) |
EricLew | 0:80ee8f3b695e | 468 | #define SAI_SLOTACTIVE_15 ((uint32_t)0x80000000) |
EricLew | 0:80ee8f3b695e | 469 | #define SAI_SLOTACTIVE_ALL ((uint32_t)0xFFFF0000) |
EricLew | 0:80ee8f3b695e | 470 | |
EricLew | 0:80ee8f3b695e | 471 | /** |
EricLew | 0:80ee8f3b695e | 472 | * @} |
EricLew | 0:80ee8f3b695e | 473 | */ |
EricLew | 0:80ee8f3b695e | 474 | |
EricLew | 0:80ee8f3b695e | 475 | /** @defgroup SAI_Mono_Stereo_Mode SAI Mono Stereo Mode |
EricLew | 0:80ee8f3b695e | 476 | * @{ |
EricLew | 0:80ee8f3b695e | 477 | */ |
EricLew | 0:80ee8f3b695e | 478 | #define SAI_STEREOMODE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 479 | #define SAI_MONOMODE ((uint32_t)SAI_xCR1_MONO) |
EricLew | 0:80ee8f3b695e | 480 | |
EricLew | 0:80ee8f3b695e | 481 | /** |
EricLew | 0:80ee8f3b695e | 482 | * @} |
EricLew | 0:80ee8f3b695e | 483 | */ |
EricLew | 0:80ee8f3b695e | 484 | |
EricLew | 0:80ee8f3b695e | 485 | /** @defgroup SAI_TRIState_Management SAI TRIState Management |
EricLew | 0:80ee8f3b695e | 486 | * @{ |
EricLew | 0:80ee8f3b695e | 487 | */ |
EricLew | 0:80ee8f3b695e | 488 | #define SAI_OUTPUT_NOTRELEASED ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 489 | #define SAI_OUTPUT_RELEASED ((uint32_t)SAI_xCR2_TRIS) |
EricLew | 0:80ee8f3b695e | 490 | |
EricLew | 0:80ee8f3b695e | 491 | /** |
EricLew | 0:80ee8f3b695e | 492 | * @} |
EricLew | 0:80ee8f3b695e | 493 | */ |
EricLew | 0:80ee8f3b695e | 494 | |
EricLew | 0:80ee8f3b695e | 495 | /** @defgroup SAI_Block_Fifo_Threshold SAI Block Fifo Threshold |
EricLew | 0:80ee8f3b695e | 496 | * @{ |
EricLew | 0:80ee8f3b695e | 497 | */ |
EricLew | 0:80ee8f3b695e | 498 | #define SAI_FIFOTHRESHOLD_EMPTY ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 499 | #define SAI_FIFOTHRESHOLD_1QF ((uint32_t)( SAI_xCR2_FTH_0)) |
EricLew | 0:80ee8f3b695e | 500 | #define SAI_FIFOTHRESHOLD_HF ((uint32_t)( SAI_xCR2_FTH_1)) |
EricLew | 0:80ee8f3b695e | 501 | #define SAI_FIFOTHRESHOLD_3QF ((uint32_t)( SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0)) |
EricLew | 0:80ee8f3b695e | 502 | #define SAI_FIFOTHRESHOLD_FULL ((uint32_t) SAI_xCR2_FTH_2) |
EricLew | 0:80ee8f3b695e | 503 | |
EricLew | 0:80ee8f3b695e | 504 | /** |
EricLew | 0:80ee8f3b695e | 505 | * @} |
EricLew | 0:80ee8f3b695e | 506 | */ |
EricLew | 0:80ee8f3b695e | 507 | |
EricLew | 0:80ee8f3b695e | 508 | /** @defgroup SAI_Block_Companding_Mode SAI Block Companding Mode |
EricLew | 0:80ee8f3b695e | 509 | * @{ |
EricLew | 0:80ee8f3b695e | 510 | */ |
EricLew | 0:80ee8f3b695e | 511 | #define SAI_NOCOMPANDING ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 512 | #define SAI_ULAW_1CPL_COMPANDING ((uint32_t)SAI_xCR2_COMP_1) |
EricLew | 0:80ee8f3b695e | 513 | #define SAI_ALAW_1CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0)) |
EricLew | 0:80ee8f3b695e | 514 | #define SAI_ULAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_CPL)) |
EricLew | 0:80ee8f3b695e | 515 | #define SAI_ALAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL)) |
EricLew | 0:80ee8f3b695e | 516 | |
EricLew | 0:80ee8f3b695e | 517 | /** |
EricLew | 0:80ee8f3b695e | 518 | * @} |
EricLew | 0:80ee8f3b695e | 519 | */ |
EricLew | 0:80ee8f3b695e | 520 | |
EricLew | 0:80ee8f3b695e | 521 | /** @defgroup SAI_Block_Mute_Value SAI Block Mute Value |
EricLew | 0:80ee8f3b695e | 522 | * @{ |
EricLew | 0:80ee8f3b695e | 523 | */ |
EricLew | 0:80ee8f3b695e | 524 | #define SAI_ZERO_VALUE ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 525 | #define SAI_LAST_SENT_VALUE ((uint32_t)SAI_xCR2_MUTEVAL) |
EricLew | 0:80ee8f3b695e | 526 | |
EricLew | 0:80ee8f3b695e | 527 | /** |
EricLew | 0:80ee8f3b695e | 528 | * @} |
EricLew | 0:80ee8f3b695e | 529 | */ |
EricLew | 0:80ee8f3b695e | 530 | |
EricLew | 0:80ee8f3b695e | 531 | |
EricLew | 0:80ee8f3b695e | 532 | /** @defgroup SAI_Block_Interrupts_Definition SAI Block Interrupts Definition |
EricLew | 0:80ee8f3b695e | 533 | * @{ |
EricLew | 0:80ee8f3b695e | 534 | */ |
EricLew | 0:80ee8f3b695e | 535 | #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE) |
EricLew | 0:80ee8f3b695e | 536 | #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE) |
EricLew | 0:80ee8f3b695e | 537 | #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE) |
EricLew | 0:80ee8f3b695e | 538 | #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE) |
EricLew | 0:80ee8f3b695e | 539 | #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE) |
EricLew | 0:80ee8f3b695e | 540 | #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE) |
EricLew | 0:80ee8f3b695e | 541 | #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE) |
EricLew | 0:80ee8f3b695e | 542 | |
EricLew | 0:80ee8f3b695e | 543 | /** |
EricLew | 0:80ee8f3b695e | 544 | * @} |
EricLew | 0:80ee8f3b695e | 545 | */ |
EricLew | 0:80ee8f3b695e | 546 | |
EricLew | 0:80ee8f3b695e | 547 | /** @defgroup SAI_Block_Flags_Definition SAI Block Flags Definition |
EricLew | 0:80ee8f3b695e | 548 | * @{ |
EricLew | 0:80ee8f3b695e | 549 | */ |
EricLew | 0:80ee8f3b695e | 550 | #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR) |
EricLew | 0:80ee8f3b695e | 551 | #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET) |
EricLew | 0:80ee8f3b695e | 552 | #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG) |
EricLew | 0:80ee8f3b695e | 553 | #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ) |
EricLew | 0:80ee8f3b695e | 554 | #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY) |
EricLew | 0:80ee8f3b695e | 555 | #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET) |
EricLew | 0:80ee8f3b695e | 556 | #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET) |
EricLew | 0:80ee8f3b695e | 557 | |
EricLew | 0:80ee8f3b695e | 558 | /** |
EricLew | 0:80ee8f3b695e | 559 | * @} |
EricLew | 0:80ee8f3b695e | 560 | */ |
EricLew | 0:80ee8f3b695e | 561 | |
EricLew | 0:80ee8f3b695e | 562 | /** @defgroup SAI_Block_Fifo_Status_Level SAI Block Fifo Status Level |
EricLew | 0:80ee8f3b695e | 563 | * @{ |
EricLew | 0:80ee8f3b695e | 564 | */ |
EricLew | 0:80ee8f3b695e | 565 | #define SAI_FIFOSTATUS_EMPTY ((uint32_t)0x00000000) |
EricLew | 0:80ee8f3b695e | 566 | #define SAI_FIFOSTATUS_LESS1QUARTERFULL ((uint32_t)0x00010000) |
EricLew | 0:80ee8f3b695e | 567 | #define SAI_FIFOSTATUS_1QUARTERFULL ((uint32_t)0x00020000) |
EricLew | 0:80ee8f3b695e | 568 | #define SAI_FIFOSTATUS_HALFFULL ((uint32_t)0x00030000) |
EricLew | 0:80ee8f3b695e | 569 | #define SAI_FIFOSTATUS_3QUARTERFULL ((uint32_t)0x00040000) |
EricLew | 0:80ee8f3b695e | 570 | #define SAI_FIFOSTATUS_FULL ((uint32_t)0x00050000) |
EricLew | 0:80ee8f3b695e | 571 | /** |
EricLew | 0:80ee8f3b695e | 572 | * @} |
EricLew | 0:80ee8f3b695e | 573 | */ |
EricLew | 0:80ee8f3b695e | 574 | |
EricLew | 0:80ee8f3b695e | 575 | /** |
EricLew | 0:80ee8f3b695e | 576 | * @} |
EricLew | 0:80ee8f3b695e | 577 | */ |
EricLew | 0:80ee8f3b695e | 578 | |
EricLew | 0:80ee8f3b695e | 579 | /* Exported macro ------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 580 | |
EricLew | 0:80ee8f3b695e | 581 | /** @defgroup SAI_Exported_Macros SAI Exported Macros |
EricLew | 0:80ee8f3b695e | 582 | * @brief macros to handle interrupts and specific configurations |
EricLew | 0:80ee8f3b695e | 583 | * @{ |
EricLew | 0:80ee8f3b695e | 584 | */ |
EricLew | 0:80ee8f3b695e | 585 | |
EricLew | 0:80ee8f3b695e | 586 | /** @brief Reset SAI handle state. |
EricLew | 0:80ee8f3b695e | 587 | * @param __HANDLE__: specifies the SAI Handle. |
EricLew | 0:80ee8f3b695e | 588 | * @retval None |
EricLew | 0:80ee8f3b695e | 589 | */ |
EricLew | 0:80ee8f3b695e | 590 | #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET) |
EricLew | 0:80ee8f3b695e | 591 | |
EricLew | 0:80ee8f3b695e | 592 | /** @brief Enable or disable the specified SAI interrupts. |
EricLew | 0:80ee8f3b695e | 593 | * @param __HANDLE__: specifies the SAI Handle. |
EricLew | 0:80ee8f3b695e | 594 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable. |
EricLew | 0:80ee8f3b695e | 595 | * This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 596 | * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable |
EricLew | 0:80ee8f3b695e | 597 | * @arg SAI_IT_MUTEDET: Mute detection interrupt enable |
EricLew | 0:80ee8f3b695e | 598 | * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable |
EricLew | 0:80ee8f3b695e | 599 | * @arg SAI_IT_FREQ: FIFO request interrupt enable |
EricLew | 0:80ee8f3b695e | 600 | * @arg SAI_IT_CNRDY: Codec not ready interrupt enable |
EricLew | 0:80ee8f3b695e | 601 | * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable |
EricLew | 0:80ee8f3b695e | 602 | * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable |
EricLew | 0:80ee8f3b695e | 603 | * @retval None |
EricLew | 0:80ee8f3b695e | 604 | */ |
EricLew | 0:80ee8f3b695e | 605 | |
EricLew | 0:80ee8f3b695e | 606 | #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__)) |
EricLew | 0:80ee8f3b695e | 607 | #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__))) |
EricLew | 0:80ee8f3b695e | 608 | |
EricLew | 0:80ee8f3b695e | 609 | /** @brief Check whether the specified SAI interrupt source is enabled or not. |
EricLew | 0:80ee8f3b695e | 610 | * @param __HANDLE__: specifies the SAI Handle. |
EricLew | 0:80ee8f3b695e | 611 | * @param __INTERRUPT__: specifies the SAI interrupt source to check. |
EricLew | 0:80ee8f3b695e | 612 | * This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 613 | * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable |
EricLew | 0:80ee8f3b695e | 614 | * @arg SAI_IT_MUTEDET: Mute detection interrupt enable |
EricLew | 0:80ee8f3b695e | 615 | * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable |
EricLew | 0:80ee8f3b695e | 616 | * @arg SAI_IT_FREQ: FIFO request interrupt enable |
EricLew | 0:80ee8f3b695e | 617 | * @arg SAI_IT_CNRDY: Codec not ready interrupt enable |
EricLew | 0:80ee8f3b695e | 618 | * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable |
EricLew | 0:80ee8f3b695e | 619 | * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable |
EricLew | 0:80ee8f3b695e | 620 | * @retval The new state of __INTERRUPT__ (TRUE or FALSE). |
EricLew | 0:80ee8f3b695e | 621 | */ |
EricLew | 0:80ee8f3b695e | 622 | #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
EricLew | 0:80ee8f3b695e | 623 | |
EricLew | 0:80ee8f3b695e | 624 | /** @brief Check whether the specified SAI flag is set or not. |
EricLew | 0:80ee8f3b695e | 625 | * @param __HANDLE__: specifies the SAI Handle. |
EricLew | 0:80ee8f3b695e | 626 | * @param __FLAG__: specifies the flag to check. |
EricLew | 0:80ee8f3b695e | 627 | * This parameter can be one of the following values: |
EricLew | 0:80ee8f3b695e | 628 | * @arg SAI_FLAG_OVRUDR: Overrun underrun flag. |
EricLew | 0:80ee8f3b695e | 629 | * @arg SAI_FLAG_MUTEDET: Mute detection flag. |
EricLew | 0:80ee8f3b695e | 630 | * @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag. |
EricLew | 0:80ee8f3b695e | 631 | * @arg SAI_FLAG_FREQ: FIFO request flag. |
EricLew | 0:80ee8f3b695e | 632 | * @arg SAI_FLAG_CNRDY: Codec not ready flag. |
EricLew | 0:80ee8f3b695e | 633 | * @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag. |
EricLew | 0:80ee8f3b695e | 634 | * @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag. |
EricLew | 0:80ee8f3b695e | 635 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
EricLew | 0:80ee8f3b695e | 636 | */ |
EricLew | 0:80ee8f3b695e | 637 | #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
EricLew | 0:80ee8f3b695e | 638 | |
EricLew | 0:80ee8f3b695e | 639 | /** @brief Clear the specified SAI pending flag. |
EricLew | 0:80ee8f3b695e | 640 | * @param __HANDLE__: specifies the SAI Handle. |
EricLew | 0:80ee8f3b695e | 641 | * @param __FLAG__: specifies the flag to check. |
EricLew | 0:80ee8f3b695e | 642 | * This parameter can be any combination of the following values: |
EricLew | 0:80ee8f3b695e | 643 | * @arg SAI_FLAG_OVRUDR: Clear Overrun underrun |
EricLew | 0:80ee8f3b695e | 644 | * @arg SAI_FLAG_MUTEDET: Clear Mute detection |
EricLew | 0:80ee8f3b695e | 645 | * @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration |
EricLew | 0:80ee8f3b695e | 646 | * @arg SAI_FLAG_FREQ: Clear FIFO request |
EricLew | 0:80ee8f3b695e | 647 | * @arg SAI_FLAG_CNRDY: Clear Codec not ready |
EricLew | 0:80ee8f3b695e | 648 | * @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection |
EricLew | 0:80ee8f3b695e | 649 | * @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection |
EricLew | 0:80ee8f3b695e | 650 | * |
EricLew | 0:80ee8f3b695e | 651 | * @retval None |
EricLew | 0:80ee8f3b695e | 652 | */ |
EricLew | 0:80ee8f3b695e | 653 | #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__)) |
EricLew | 0:80ee8f3b695e | 654 | |
EricLew | 0:80ee8f3b695e | 655 | #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN) |
EricLew | 0:80ee8f3b695e | 656 | #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN) |
EricLew | 0:80ee8f3b695e | 657 | |
EricLew | 0:80ee8f3b695e | 658 | /** |
EricLew | 0:80ee8f3b695e | 659 | * @} |
EricLew | 0:80ee8f3b695e | 660 | */ |
EricLew | 0:80ee8f3b695e | 661 | |
EricLew | 0:80ee8f3b695e | 662 | /* Exported functions --------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 663 | |
EricLew | 0:80ee8f3b695e | 664 | /** @addtogroup SAI_Exported_Functions |
EricLew | 0:80ee8f3b695e | 665 | * @{ |
EricLew | 0:80ee8f3b695e | 666 | */ |
EricLew | 0:80ee8f3b695e | 667 | |
EricLew | 0:80ee8f3b695e | 668 | /* Initialization/de-initialization functions **********************************/ |
EricLew | 0:80ee8f3b695e | 669 | /** @addtogroup SAI_Exported_Functions_Group1 |
EricLew | 0:80ee8f3b695e | 670 | * @{ |
EricLew | 0:80ee8f3b695e | 671 | */ |
EricLew | 0:80ee8f3b695e | 672 | HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 673 | HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot); |
EricLew | 0:80ee8f3b695e | 674 | HAL_StatusTypeDef HAL_SAI_DeInit (SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 675 | void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 676 | void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 677 | |
EricLew | 0:80ee8f3b695e | 678 | /** |
EricLew | 0:80ee8f3b695e | 679 | * @} |
EricLew | 0:80ee8f3b695e | 680 | */ |
EricLew | 0:80ee8f3b695e | 681 | |
EricLew | 0:80ee8f3b695e | 682 | /* I/O operation functions *****************************************************/ |
EricLew | 0:80ee8f3b695e | 683 | /** @addtogroup SAI_Exported_Functions_Group2 |
EricLew | 0:80ee8f3b695e | 684 | * @{ |
EricLew | 0:80ee8f3b695e | 685 | */ |
EricLew | 0:80ee8f3b695e | 686 | /* Blocking mode: Polling */ |
EricLew | 0:80ee8f3b695e | 687 | HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
EricLew | 0:80ee8f3b695e | 688 | HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
EricLew | 0:80ee8f3b695e | 689 | |
EricLew | 0:80ee8f3b695e | 690 | /* Non-Blocking mode: Interrupt */ |
EricLew | 0:80ee8f3b695e | 691 | HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
EricLew | 0:80ee8f3b695e | 692 | HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
EricLew | 0:80ee8f3b695e | 693 | |
EricLew | 0:80ee8f3b695e | 694 | /* Non-Blocking mode: DMA */ |
EricLew | 0:80ee8f3b695e | 695 | HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
EricLew | 0:80ee8f3b695e | 696 | HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
EricLew | 0:80ee8f3b695e | 697 | HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 698 | HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 699 | HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 700 | |
EricLew | 0:80ee8f3b695e | 701 | /* Abort function */ |
EricLew | 0:80ee8f3b695e | 702 | HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 703 | |
EricLew | 0:80ee8f3b695e | 704 | /* Mute management */ |
EricLew | 0:80ee8f3b695e | 705 | HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val); |
EricLew | 0:80ee8f3b695e | 706 | HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 707 | HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter); |
EricLew | 0:80ee8f3b695e | 708 | HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 709 | |
EricLew | 0:80ee8f3b695e | 710 | /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ |
EricLew | 0:80ee8f3b695e | 711 | void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 712 | void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 713 | void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 714 | void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 715 | void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 716 | void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 717 | /** |
EricLew | 0:80ee8f3b695e | 718 | * @} |
EricLew | 0:80ee8f3b695e | 719 | */ |
EricLew | 0:80ee8f3b695e | 720 | |
EricLew | 0:80ee8f3b695e | 721 | /** @addtogroup SAI_Exported_Functions_Group3 |
EricLew | 0:80ee8f3b695e | 722 | * @{ |
EricLew | 0:80ee8f3b695e | 723 | */ |
EricLew | 0:80ee8f3b695e | 724 | /* Peripheral State functions **************************************************/ |
EricLew | 0:80ee8f3b695e | 725 | HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 726 | uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai); |
EricLew | 0:80ee8f3b695e | 727 | /** |
EricLew | 0:80ee8f3b695e | 728 | * @} |
EricLew | 0:80ee8f3b695e | 729 | */ |
EricLew | 0:80ee8f3b695e | 730 | |
EricLew | 0:80ee8f3b695e | 731 | /** |
EricLew | 0:80ee8f3b695e | 732 | * @} |
EricLew | 0:80ee8f3b695e | 733 | */ |
EricLew | 0:80ee8f3b695e | 734 | |
EricLew | 0:80ee8f3b695e | 735 | /* Private types -------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 736 | /* Private variables ---------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 737 | |
EricLew | 0:80ee8f3b695e | 738 | /* Private constants ---------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 739 | /** @defgroup SAI_Private_Constants SAI Private Constants |
EricLew | 0:80ee8f3b695e | 740 | * @{ |
EricLew | 0:80ee8f3b695e | 741 | */ |
EricLew | 0:80ee8f3b695e | 742 | |
EricLew | 0:80ee8f3b695e | 743 | /** |
EricLew | 0:80ee8f3b695e | 744 | * @} |
EricLew | 0:80ee8f3b695e | 745 | */ |
EricLew | 0:80ee8f3b695e | 746 | |
EricLew | 0:80ee8f3b695e | 747 | /* Private macros ------------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 748 | /** @addtogroup SAI_Private_Macros |
EricLew | 0:80ee8f3b695e | 749 | * @{ |
EricLew | 0:80ee8f3b695e | 750 | */ |
EricLew | 0:80ee8f3b695e | 751 | #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \ |
EricLew | 0:80ee8f3b695e | 752 | ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \ |
EricLew | 0:80ee8f3b695e | 753 | ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \ |
EricLew | 0:80ee8f3b695e | 754 | ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \ |
EricLew | 0:80ee8f3b695e | 755 | ((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV)) |
EricLew | 0:80ee8f3b695e | 756 | |
EricLew | 0:80ee8f3b695e | 757 | #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \ |
EricLew | 0:80ee8f3b695e | 758 | ((MODE) == SAI_MODEMASTER_RX) || \ |
EricLew | 0:80ee8f3b695e | 759 | ((MODE) == SAI_MODESLAVE_TX) || \ |
EricLew | 0:80ee8f3b695e | 760 | ((MODE) == SAI_MODESLAVE_RX)) |
EricLew | 0:80ee8f3b695e | 761 | |
EricLew | 0:80ee8f3b695e | 762 | #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \ |
EricLew | 0:80ee8f3b695e | 763 | ((PROTOCOL) == SAI_AC97_PROTOCOL) || \ |
EricLew | 0:80ee8f3b695e | 764 | ((PROTOCOL) == SAI_SPDIF_PROTOCOL)) |
EricLew | 0:80ee8f3b695e | 765 | |
EricLew | 0:80ee8f3b695e | 766 | #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \ |
EricLew | 0:80ee8f3b695e | 767 | ((DATASIZE) == SAI_DATASIZE_10) || \ |
EricLew | 0:80ee8f3b695e | 768 | ((DATASIZE) == SAI_DATASIZE_16) || \ |
EricLew | 0:80ee8f3b695e | 769 | ((DATASIZE) == SAI_DATASIZE_20) || \ |
EricLew | 0:80ee8f3b695e | 770 | ((DATASIZE) == SAI_DATASIZE_24) || \ |
EricLew | 0:80ee8f3b695e | 771 | ((DATASIZE) == SAI_DATASIZE_32)) |
EricLew | 0:80ee8f3b695e | 772 | |
EricLew | 0:80ee8f3b695e | 773 | #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \ |
EricLew | 0:80ee8f3b695e | 774 | ((BIT) == SAI_FIRSTBIT_LSB)) |
EricLew | 0:80ee8f3b695e | 775 | |
EricLew | 0:80ee8f3b695e | 776 | #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \ |
EricLew | 0:80ee8f3b695e | 777 | ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE)) |
EricLew | 0:80ee8f3b695e | 778 | |
EricLew | 0:80ee8f3b695e | 779 | #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \ |
EricLew | 0:80ee8f3b695e | 780 | ((SYNCHRO) == SAI_SYNCHRONOUS) || \ |
EricLew | 0:80ee8f3b695e | 781 | ((SYNCHRO) == SAI_SYNCHRONOUS_EXT)) |
EricLew | 0:80ee8f3b695e | 782 | |
EricLew | 0:80ee8f3b695e | 783 | #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \ |
EricLew | 0:80ee8f3b695e | 784 | ((DRIVE) == SAI_OUTPUTDRIVE_ENABLE)) |
EricLew | 0:80ee8f3b695e | 785 | |
EricLew | 0:80ee8f3b695e | 786 | #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \ |
EricLew | 0:80ee8f3b695e | 787 | ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE)) |
EricLew | 0:80ee8f3b695e | 788 | |
EricLew | 0:80ee8f3b695e | 789 | #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63) |
EricLew | 0:80ee8f3b695e | 790 | |
EricLew | 0:80ee8f3b695e | 791 | #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \ |
EricLew | 0:80ee8f3b695e | 792 | ((VALUE) == SAI_LAST_SENT_VALUE)) |
EricLew | 0:80ee8f3b695e | 793 | |
EricLew | 0:80ee8f3b695e | 794 | #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \ |
EricLew | 0:80ee8f3b695e | 795 | ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \ |
EricLew | 0:80ee8f3b695e | 796 | ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \ |
EricLew | 0:80ee8f3b695e | 797 | ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \ |
EricLew | 0:80ee8f3b695e | 798 | ((MODE) == SAI_ALAW_2CPL_COMPANDING)) |
EricLew | 0:80ee8f3b695e | 799 | |
EricLew | 0:80ee8f3b695e | 800 | #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \ |
EricLew | 0:80ee8f3b695e | 801 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \ |
EricLew | 0:80ee8f3b695e | 802 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \ |
EricLew | 0:80ee8f3b695e | 803 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \ |
EricLew | 0:80ee8f3b695e | 804 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL)) |
EricLew | 0:80ee8f3b695e | 805 | |
EricLew | 0:80ee8f3b695e | 806 | #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\ |
EricLew | 0:80ee8f3b695e | 807 | ((STATE) == SAI_OUTPUT_RELEASED)) |
EricLew | 0:80ee8f3b695e | 808 | |
EricLew | 0:80ee8f3b695e | 809 | #define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\ |
EricLew | 0:80ee8f3b695e | 810 | ((STATE) == SAI_SYNCEXT_IN_ENABLE) ||\ |
EricLew | 0:80ee8f3b695e | 811 | ((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\ |
EricLew | 0:80ee8f3b695e | 812 | ((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE)) |
EricLew | 0:80ee8f3b695e | 813 | |
EricLew | 0:80ee8f3b695e | 814 | #define IS_SAI_MONOSTEREO_MODE(CHANNEL) (((CHANNEL) == SAI_STEREOMODE) ||\ |
EricLew | 0:80ee8f3b695e | 815 | ((CHANNEL) == SAI_MONOMODE)) |
EricLew | 0:80ee8f3b695e | 816 | |
EricLew | 0:80ee8f3b695e | 817 | #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((((ACTIVE) >> 16 ) > 0) && (((ACTIVE) >> 16 ) <= (SAI_SLOTACTIVE_ALL >> 16))) |
EricLew | 0:80ee8f3b695e | 818 | |
EricLew | 0:80ee8f3b695e | 819 | #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1 <= (NUMBER)) && ((NUMBER) <= 16)) |
EricLew | 0:80ee8f3b695e | 820 | |
EricLew | 0:80ee8f3b695e | 821 | #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \ |
EricLew | 0:80ee8f3b695e | 822 | ((SIZE) == SAI_SLOTSIZE_16B) || \ |
EricLew | 0:80ee8f3b695e | 823 | ((SIZE) == SAI_SLOTSIZE_32B)) |
EricLew | 0:80ee8f3b695e | 824 | |
EricLew | 0:80ee8f3b695e | 825 | #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24) |
EricLew | 0:80ee8f3b695e | 826 | |
EricLew | 0:80ee8f3b695e | 827 | #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \ |
EricLew | 0:80ee8f3b695e | 828 | ((OFFSET) == SAI_FS_BEFOREFIRSTBIT)) |
EricLew | 0:80ee8f3b695e | 829 | |
EricLew | 0:80ee8f3b695e | 830 | #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \ |
EricLew | 0:80ee8f3b695e | 831 | ((POLARITY) == SAI_FS_ACTIVE_HIGH)) |
EricLew | 0:80ee8f3b695e | 832 | |
EricLew | 0:80ee8f3b695e | 833 | #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \ |
EricLew | 0:80ee8f3b695e | 834 | ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION)) |
EricLew | 0:80ee8f3b695e | 835 | |
EricLew | 0:80ee8f3b695e | 836 | #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15) |
EricLew | 0:80ee8f3b695e | 837 | |
EricLew | 0:80ee8f3b695e | 838 | #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8 <= (LENGTH)) && ((LENGTH) <= 256)) |
EricLew | 0:80ee8f3b695e | 839 | |
EricLew | 0:80ee8f3b695e | 840 | #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1 <= (LENGTH)) && ((LENGTH) <= 128)) |
EricLew | 0:80ee8f3b695e | 841 | |
EricLew | 0:80ee8f3b695e | 842 | /** |
EricLew | 0:80ee8f3b695e | 843 | * @} |
EricLew | 0:80ee8f3b695e | 844 | */ |
EricLew | 0:80ee8f3b695e | 845 | |
EricLew | 0:80ee8f3b695e | 846 | /* Private functions ---------------------------------------------------------*/ |
EricLew | 0:80ee8f3b695e | 847 | /** @defgroup SAI_Private_Functions SAI Private Functions |
EricLew | 0:80ee8f3b695e | 848 | * @{ |
EricLew | 0:80ee8f3b695e | 849 | */ |
EricLew | 0:80ee8f3b695e | 850 | |
EricLew | 0:80ee8f3b695e | 851 | /** |
EricLew | 0:80ee8f3b695e | 852 | * @} |
EricLew | 0:80ee8f3b695e | 853 | */ |
EricLew | 0:80ee8f3b695e | 854 | |
EricLew | 0:80ee8f3b695e | 855 | /** |
EricLew | 0:80ee8f3b695e | 856 | * @} |
EricLew | 0:80ee8f3b695e | 857 | */ |
EricLew | 0:80ee8f3b695e | 858 | |
EricLew | 0:80ee8f3b695e | 859 | /** |
EricLew | 0:80ee8f3b695e | 860 | * @} |
EricLew | 0:80ee8f3b695e | 861 | */ |
EricLew | 0:80ee8f3b695e | 862 | #ifdef __cplusplus |
EricLew | 0:80ee8f3b695e | 863 | } |
EricLew | 0:80ee8f3b695e | 864 | #endif |
EricLew | 0:80ee8f3b695e | 865 | |
EricLew | 0:80ee8f3b695e | 866 | #endif /* __STM32L4xx_HAL_SAI_H */ |
EricLew | 0:80ee8f3b695e | 867 | |
EricLew | 0:80ee8f3b695e | 868 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
EricLew | 0:80ee8f3b695e | 869 |