001

Committer:
ganlikun
Date:
Sun Jun 12 14:02:44 2022 +0000
Revision:
0:13413ea9a877
00

Who changed what in which revision?

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