STM32H735xx HAL User Manual
stm32h7xx_hal_sai.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_hal_sai.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of SAI HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32H7xx_HAL_SAI_H
00021 #define STM32H7xx_HAL_SAI_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32h7xx_hal_def.h"
00029 
00030 /** @addtogroup STM32H7xx_HAL_Driver
00031   * @{
00032   */
00033 
00034 /** @addtogroup SAI
00035   * @{
00036   */
00037 
00038 /* Exported types ------------------------------------------------------------*/
00039 /** @defgroup SAI_Exported_Types SAI Exported Types
00040   * @{
00041   */
00042 
00043 /**
00044   * @brief  HAL State structures definition
00045   */
00046 typedef enum
00047 {
00048   HAL_SAI_STATE_RESET   = 0x00U, /*!< SAI not yet initialized or disabled  */
00049   HAL_SAI_STATE_READY   = 0x01U, /*!< SAI initialized and ready for use    */
00050   HAL_SAI_STATE_BUSY    = 0x02U, /*!< SAI internal process is ongoing      */
00051   HAL_SAI_STATE_BUSY_TX = 0x12U, /*!< Data transmission process is ongoing */
00052   HAL_SAI_STATE_BUSY_RX = 0x22U, /*!< Data reception process is ongoing    */
00053 } HAL_SAI_StateTypeDef;
00054 
00055 /**
00056   * @brief  SAI Callback prototype
00057   */
00058 typedef void (*SAIcallback)(void);
00059 
00060 /** @defgroup SAI_PDM_Structure_definition SAI PDM Structure definition
00061   * @brief  SAI PDM Init structure definition
00062   * @{
00063   */
00064 typedef struct
00065 {
00066   FunctionalState  Activation;  /*!< Enable/disable PDM interface */
00067   uint32_t         MicPairsNbr; /*!< Specifies the number of microphone pairs used.
00068                                      This parameter must be a number between Min_Data = 1 and Max_Data = 3. */
00069   uint32_t         ClockEnable; /*!< Specifies which clock must be enabled.
00070                                      This parameter can be a values combination of @ref SAI_PDM_ClockEnable */
00071 } SAI_PdmInitTypeDef;
00072 /**
00073   * @}
00074   */
00075 
00076 /** @defgroup SAI_Init_Structure_definition SAI Init Structure definition
00077   * @brief  SAI Init Structure definition
00078   * @{
00079   */
00080 typedef struct
00081 {
00082   uint32_t AudioMode;           /*!< Specifies the SAI Block audio Mode.
00083                                      This parameter can be a value of @ref SAI_Block_Mode */
00084 
00085   uint32_t Synchro;             /*!< Specifies SAI Block synchronization
00086                                      This parameter can be a value of @ref SAI_Block_Synchronization */
00087 
00088   uint32_t SynchroExt;          /*!< Specifies SAI external output synchronization, this setup is common
00089                                      for BlockA and BlockB
00090                                      This parameter can be a value of @ref SAI_Block_SyncExt
00091                                      @note If both audio blocks of same SAI are used, this parameter has
00092                                            to be set to the same value for each audio block */
00093 
00094   uint32_t MckOutput;           /*!< Specifies whether master clock output will be generated or not.
00095                                      This parameter can be a value of @ref SAI_Block_MckOutput
00096                                      @note This feature is only available on STM32H7xx Rev.B and above */
00097 
00098   uint32_t OutputDrive;         /*!< Specifies when SAI Block outputs are driven.
00099                                      This parameter can be a value of @ref SAI_Block_Output_Drive
00100                                      @note This value has to be set before enabling the audio block
00101                                            but after the audio block configuration. */
00102 
00103   uint32_t NoDivider;           /*!< Specifies whether master clock will be divided or not.
00104                                      This parameter can be a value of @ref SAI_Block_NoDivider
00105                                      @note If bit NODIV in the SAI_xCR1 register is cleared, the frame length
00106                                            should be aligned to a number equal to a power of 2, from 8 to 256.
00107                                            If bit NODIV in the SAI_xCR1 register is set, the frame length can
00108                                            take any of the values from 8 to 256.
00109                                      @note The NODIV bit is the same as NOMCK bit in STM32H7xx rev.Y */
00110 
00111   uint32_t FIFOThreshold;       /*!< Specifies SAI Block FIFO threshold.
00112                                      This parameter can be a value of @ref SAI_Block_Fifo_Threshold */
00113 
00114   uint32_t AudioFrequency;      /*!< Specifies the audio frequency sampling.
00115                                      This parameter can be a value of @ref SAI_Audio_Frequency */
00116 
00117   uint32_t Mckdiv;              /*!< Specifies the master clock divider.
00118                                      This parameter must be a number between Min_Data = 0 and Max_Data = 63.
00119                                      @note This parameter is used only if AudioFrequency is set to
00120                                            SAI_AUDIO_FREQUENCY_MCKDIV otherwise it is internally computed. */
00121 
00122   uint32_t MckOverSampling;     /*!< Specifies the master clock oversampling.
00123                                      This parameter can be a value of @ref SAI_Block_Mck_OverSampling */
00124 
00125   uint32_t MonoStereoMode;      /*!< Specifies if the mono or stereo mode is selected.
00126                                      This parameter can be a value of @ref SAI_Mono_Stereo_Mode */
00127 
00128   uint32_t CompandingMode;      /*!< Specifies the companding mode type.
00129                                      This parameter can be a value of @ref SAI_Block_Companding_Mode */
00130 
00131   uint32_t TriState;            /*!< Specifies the companding mode type.
00132                                      This parameter can be a value of @ref SAI_TRIState_Management */
00133 
00134   SAI_PdmInitTypeDef PdmInit;   /*!< Specifies the PDM configuration. */
00135 
00136   /* This part of the structure is automatically filled if your are using the high level initialisation
00137      function HAL_SAI_InitProtocol */
00138 
00139   uint32_t Protocol;        /*!< Specifies the SAI Block protocol.
00140                                  This parameter can be a value of @ref SAI_Block_Protocol */
00141 
00142   uint32_t DataSize;        /*!< Specifies the SAI Block data size.
00143                                  This parameter can be a value of @ref SAI_Block_Data_Size */
00144 
00145   uint32_t FirstBit;        /*!< Specifies whether data transfers start from MSB or LSB bit.
00146                                  This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */
00147 
00148   uint32_t ClockStrobing;   /*!< Specifies the SAI Block clock strobing edge sensitivity.
00149                                  This parameter can be a value of @ref SAI_Block_Clock_Strobing */
00150 } SAI_InitTypeDef;
00151 /**
00152   * @}
00153   */
00154 
00155 /** @defgroup SAI_Frame_Structure_definition SAI Frame Structure definition
00156   * @brief  SAI Frame Init structure definition
00157   * @note   For SPDIF and AC97 protocol, these parameters are not used (set by hardware).
00158   * @{
00159   */
00160 typedef struct
00161 {
00162 
00163   uint32_t FrameLength;        /*!< Specifies the Frame length, the number of SCK clocks for each audio frame.
00164                                     This parameter must be a number between Min_Data = 8 and Max_Data = 256.
00165                                     @note If master clock MCLK_x pin is declared as an output, the frame length
00166                                           should be aligned to a number equal to power of 2 in order to keep
00167                                           in an audio frame, an integer number of MCLK pulses by bit Clock. */
00168 
00169   uint32_t ActiveFrameLength;  /*!< Specifies the Frame synchronization active level length.
00170                                     This Parameter specifies the length in number of bit clock (SCK + 1)
00171                                     of the active level of FS signal in audio frame.
00172                                     This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
00173 
00174   uint32_t FSDefinition;       /*!< Specifies the Frame synchronization definition.
00175                                     This parameter can be a value of @ref SAI_Block_FS_Definition */
00176 
00177   uint32_t FSPolarity;         /*!< Specifies the Frame synchronization Polarity.
00178                                     This parameter can be a value of @ref SAI_Block_FS_Polarity */
00179 
00180   uint32_t FSOffset;           /*!< Specifies the Frame synchronization Offset.
00181                                     This parameter can be a value of @ref SAI_Block_FS_Offset */
00182 
00183 } SAI_FrameInitTypeDef;
00184 /**
00185   * @}
00186   */
00187 
00188 /** @defgroup SAI_Slot_Structure_definition SAI Slot Structure definition
00189   * @brief   SAI Block Slot Init Structure definition
00190   * @note    For SPDIF protocol, these parameters are not used (set by hardware).
00191   * @note    For AC97 protocol, only SlotActive parameter is used (the others are set by hardware).
00192   * @{
00193   */
00194 typedef struct
00195 {
00196   uint32_t FirstBitOffset;  /*!< Specifies the position of first data transfer bit in the slot.
00197                                  This parameter must be a number between Min_Data = 0 and Max_Data = 24 */
00198 
00199   uint32_t SlotSize;        /*!< Specifies the Slot Size.
00200                                  This parameter can be a value of @ref SAI_Block_Slot_Size */
00201 
00202   uint32_t SlotNumber;      /*!< Specifies the number of slot in the audio frame.
00203                                  This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
00204 
00205   uint32_t SlotActive;      /*!< Specifies the slots in audio frame that will be activated.
00206                                  This parameter can be a value of @ref SAI_Block_Slot_Active */
00207 } SAI_SlotInitTypeDef;
00208 /**
00209   * @}
00210   */
00211 
00212 /** @defgroup SAI_Handle_Structure_definition SAI Handle Structure definition
00213   * @brief  SAI handle Structure definition
00214   * @{
00215   */
00216 typedef struct __SAI_HandleTypeDef
00217 {
00218   SAI_Block_TypeDef         *Instance;    /*!< SAI Blockx registers base address */
00219 
00220   SAI_InitTypeDef           Init;         /*!< SAI communication parameters */
00221 
00222   SAI_FrameInitTypeDef      FrameInit;    /*!< SAI Frame configuration parameters */
00223 
00224   SAI_SlotInitTypeDef       SlotInit;     /*!< SAI Slot configuration parameters */
00225 
00226   uint8_t                  *pBuffPtr;     /*!< Pointer to SAI transfer Buffer */
00227 
00228   uint16_t                  XferSize;     /*!< SAI transfer size */
00229 
00230   uint16_t                  XferCount;    /*!< SAI transfer counter */
00231 
00232   DMA_HandleTypeDef         *hdmatx;      /*!< SAI Tx DMA handle parameters */
00233 
00234   DMA_HandleTypeDef         *hdmarx;      /*!< SAI Rx DMA handle parameters */
00235 
00236   SAIcallback               mutecallback; /*!< SAI mute callback */
00237 
00238   void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */
00239 
00240   HAL_LockTypeDef           Lock;         /*!< SAI locking object */
00241 
00242   __IO HAL_SAI_StateTypeDef State;        /*!< SAI communication state */
00243 
00244   __IO uint32_t             ErrorCode;    /*!< SAI Error code */
00245 
00246 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
00247   void (*RxCpltCallback)(struct __SAI_HandleTypeDef *hsai);      /*!< SAI receive complete callback */
00248   void (*RxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai);  /*!< SAI receive half complete callback */
00249   void (*TxCpltCallback)(struct __SAI_HandleTypeDef *hsai);      /*!< SAI transmit complete callback */
00250   void (*TxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai);  /*!< SAI transmit half complete callback */
00251   void (*ErrorCallback)(struct __SAI_HandleTypeDef *hsai);       /*!< SAI error callback */
00252   void (*MspInitCallback)(struct __SAI_HandleTypeDef *hsai);     /*!< SAI MSP init callback */
00253   void (*MspDeInitCallback)(struct __SAI_HandleTypeDef *hsai);   /*!< SAI MSP de-init callback */
00254 #endif
00255 } SAI_HandleTypeDef;
00256 /**
00257   * @}
00258   */
00259 
00260 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
00261 /**
00262   * @brief  SAI callback ID enumeration definition
00263   */
00264 typedef enum
00265 {
00266   HAL_SAI_RX_COMPLETE_CB_ID       = 0x00U, /*!< SAI receive complete callback ID */
00267   HAL_SAI_RX_HALFCOMPLETE_CB_ID   = 0x01U, /*!< SAI receive half complete callback ID */
00268   HAL_SAI_TX_COMPLETE_CB_ID       = 0x02U, /*!< SAI transmit complete callback ID */
00269   HAL_SAI_TX_HALFCOMPLETE_CB_ID   = 0x03U, /*!< SAI transmit half complete callback ID */
00270   HAL_SAI_ERROR_CB_ID             = 0x04U, /*!< SAI error callback ID */
00271   HAL_SAI_MSPINIT_CB_ID           = 0x05U, /*!< SAI MSP init callback ID */
00272   HAL_SAI_MSPDEINIT_CB_ID         = 0x06U  /*!< SAI MSP de-init callback ID */
00273 } HAL_SAI_CallbackIDTypeDef;
00274 
00275 /**
00276   * @brief  SAI callback pointer definition
00277   */
00278 typedef void (*pSAI_CallbackTypeDef)(SAI_HandleTypeDef *hsai);
00279 #endif
00280 
00281 /**
00282   * @}
00283   */
00284 
00285 /* Exported constants --------------------------------------------------------*/
00286 /** @defgroup SAI_Exported_Constants SAI Exported Constants
00287   * @{
00288   */
00289 
00290 /** @defgroup SAI_Error_Code SAI Error Code
00291   * @{
00292   */
00293 #define HAL_SAI_ERROR_NONE          0x00000000U  /*!< No error */
00294 #define HAL_SAI_ERROR_OVR           0x00000001U  /*!< Overrun Error */
00295 #define HAL_SAI_ERROR_UDR           0x00000002U  /*!< Underrun error */
00296 #define HAL_SAI_ERROR_AFSDET        0x00000004U  /*!< Anticipated Frame synchronisation detection */
00297 #define HAL_SAI_ERROR_LFSDET        0x00000008U  /*!< Late Frame synchronisation detection */
00298 #define HAL_SAI_ERROR_CNREADY       0x00000010U  /*!< codec not ready */
00299 #define HAL_SAI_ERROR_WCKCFG        0x00000020U  /*!< Wrong clock configuration */
00300 #define HAL_SAI_ERROR_TIMEOUT       0x00000040U  /*!< Timeout error */
00301 #define HAL_SAI_ERROR_DMA           0x00000080U  /*!< DMA error */
00302 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
00303 #define HAL_SAI_ERROR_INVALID_CALLBACK   0x00000100U  /*!< Invalid callback error */
00304 #endif
00305 /**
00306   * @}
00307   */
00308 
00309 /** @defgroup SAI_Block_SyncExt SAI External synchronisation
00310   * @{
00311   */
00312 #define SAI_SYNCEXT_DISABLE           0U
00313 #define SAI_SYNCEXT_OUTBLOCKA_ENABLE  1U
00314 #define SAI_SYNCEXT_OUTBLOCKB_ENABLE  2U
00315 /**
00316   * @}
00317   */
00318 
00319 /** @defgroup SAI_Block_MckOutput SAI Block Master Clock Output
00320   * @{
00321   */
00322 #define SAI_MCK_OUTPUT_DISABLE      0x00000000U
00323 #define SAI_MCK_OUTPUT_ENABLE       SAI_xCR1_MCKEN
00324 /**
00325   * @}
00326   */
00327 
00328 /** @defgroup SAI_Protocol SAI Supported protocol
00329   * @{
00330   */
00331 #define SAI_I2S_STANDARD         0U
00332 #define SAI_I2S_MSBJUSTIFIED     1U
00333 #define SAI_I2S_LSBJUSTIFIED     2U
00334 #define SAI_PCM_LONG             3U
00335 #define SAI_PCM_SHORT            4U
00336 /**
00337   * @}
00338   */
00339 
00340 /** @defgroup SAI_Protocol_DataSize SAI protocol data size
00341   * @{
00342   */
00343 #define SAI_PROTOCOL_DATASIZE_16BIT         0U
00344 #define SAI_PROTOCOL_DATASIZE_16BITEXTENDED 1U
00345 #define SAI_PROTOCOL_DATASIZE_24BIT         2U
00346 #define SAI_PROTOCOL_DATASIZE_32BIT         3U
00347 /**
00348   * @}
00349   */
00350 
00351 /** @defgroup SAI_Audio_Frequency SAI Audio Frequency
00352   * @{
00353   */
00354 #define SAI_AUDIO_FREQUENCY_192K      192000U
00355 #define SAI_AUDIO_FREQUENCY_96K        96000U
00356 #define SAI_AUDIO_FREQUENCY_48K        48000U
00357 #define SAI_AUDIO_FREQUENCY_44K        44100U
00358 #define SAI_AUDIO_FREQUENCY_32K        32000U
00359 #define SAI_AUDIO_FREQUENCY_22K        22050U
00360 #define SAI_AUDIO_FREQUENCY_16K        16000U
00361 #define SAI_AUDIO_FREQUENCY_11K        11025U
00362 #define SAI_AUDIO_FREQUENCY_8K          8000U
00363 #define SAI_AUDIO_FREQUENCY_MCKDIV         0U
00364 /**
00365   * @}
00366   */
00367 
00368 /** @defgroup SAI_Block_Mck_OverSampling SAI Block Master Clock OverSampling
00369   * @{
00370   */
00371 #define SAI_MCK_OVERSAMPLING_DISABLE  0x00000000U
00372 #define SAI_MCK_OVERSAMPLING_ENABLE   SAI_xCR1_OSR
00373 /**
00374   * @}
00375   */
00376 
00377 /** @defgroup SAI_PDM_ClockEnable SAI PDM Clock Enable
00378   * @{
00379   */
00380 #define SAI_PDM_CLOCK1_ENABLE         SAI_PDMCR_CKEN1
00381 #define SAI_PDM_CLOCK2_ENABLE         SAI_PDMCR_CKEN2
00382 /**
00383   * @}
00384   */
00385 
00386 /** @defgroup SAI_Block_Mode SAI Block Mode
00387   * @{
00388   */
00389 #define SAI_MODEMASTER_TX             0x00000000U
00390 #define SAI_MODEMASTER_RX             SAI_xCR1_MODE_0
00391 #define SAI_MODESLAVE_TX              SAI_xCR1_MODE_1
00392 #define SAI_MODESLAVE_RX              (SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0)
00393 
00394 /**
00395   * @}
00396   */
00397 
00398 /** @defgroup SAI_Block_Protocol SAI Block Protocol
00399   * @{
00400   */
00401 #define SAI_FREE_PROTOCOL             0x00000000U
00402 #define SAI_SPDIF_PROTOCOL            SAI_xCR1_PRTCFG_0
00403 #define SAI_AC97_PROTOCOL             SAI_xCR1_PRTCFG_1
00404 /**
00405   * @}
00406   */
00407 
00408 /** @defgroup SAI_Block_Data_Size SAI Block Data Size
00409   * @{
00410   */
00411 #define SAI_DATASIZE_8                SAI_xCR1_DS_1
00412 #define SAI_DATASIZE_10               (SAI_xCR1_DS_1 | SAI_xCR1_DS_0)
00413 #define SAI_DATASIZE_16               SAI_xCR1_DS_2
00414 #define SAI_DATASIZE_20               (SAI_xCR1_DS_2 | SAI_xCR1_DS_0)
00415 #define SAI_DATASIZE_24               (SAI_xCR1_DS_2 | SAI_xCR1_DS_1)
00416 #define SAI_DATASIZE_32               (SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0)
00417 /**
00418   * @}
00419   */
00420 
00421 /** @defgroup SAI_Block_MSB_LSB_transmission SAI Block MSB LSB transmission
00422   * @{
00423   */
00424 #define SAI_FIRSTBIT_MSB              0x00000000U
00425 #define SAI_FIRSTBIT_LSB              SAI_xCR1_LSBFIRST
00426 /**
00427   * @}
00428   */
00429 
00430 /** @defgroup SAI_Block_Clock_Strobing SAI Block Clock Strobing
00431   * @{
00432   */
00433 #define SAI_CLOCKSTROBING_FALLINGEDGE  0U
00434 #define SAI_CLOCKSTROBING_RISINGEDGE   1U
00435 /**
00436   * @}
00437   */
00438 
00439 /** @defgroup SAI_Block_Synchronization SAI Block Synchronization
00440   * @{
00441   */
00442 #define SAI_ASYNCHRONOUS                  0U /*!< Asynchronous */
00443 #define SAI_SYNCHRONOUS                   1U /*!< Synchronous with other block of same SAI */
00444 #define SAI_SYNCHRONOUS_EXT_SAI1          2U /*!< Synchronous with other SAI, SAI1 */
00445 #if defined(SAI2)
00446 #define SAI_SYNCHRONOUS_EXT_SAI2          3U /*!< Synchronous with other SAI, SAI2 */
00447 #endif /* SAI2 */
00448 #if defined(SAI3)
00449 #define SAI_SYNCHRONOUS_EXT_SAI3          4U /*!< Synchronous with other SAI, SAI3 */
00450 #endif /* SAI3 */
00451 #if defined(SAI4)
00452 #define SAI_SYNCHRONOUS_EXT_SAI4          5U /*!< Synchronous with other SAI, SAI4 */
00453 #endif /* SAI4 */
00454 /**
00455   * @}
00456   */
00457 
00458 /** @defgroup SAI_Block_Output_Drive SAI Block Output Drive
00459   * @{
00460   */
00461 #define SAI_OUTPUTDRIVE_DISABLE     0x00000000U
00462 #define SAI_OUTPUTDRIVE_ENABLE      SAI_xCR1_OUTDRIV
00463 /**
00464   * @}
00465   */
00466 
00467 /** @defgroup SAI_Block_NoDivider SAI Block NoDivider
00468   * @{
00469   */
00470 #define SAI_MASTERDIVIDER_ENABLE    0x00000000U
00471 #define SAI_MASTERDIVIDER_DISABLE   SAI_xCR1_NODIV
00472 /**
00473   * @}
00474   */
00475 
00476 /** @defgroup SAI_Block_FS_Definition SAI Block FS Definition
00477   * @{
00478   */
00479 #define SAI_FS_STARTFRAME               0x00000000U
00480 #define SAI_FS_CHANNEL_IDENTIFICATION   SAI_xFRCR_FSDEF
00481 /**
00482   * @}
00483   */
00484 
00485 /** @defgroup SAI_Block_FS_Polarity SAI Block FS Polarity
00486   * @{
00487   */
00488 #define SAI_FS_ACTIVE_LOW           0x00000000U
00489 #define SAI_FS_ACTIVE_HIGH          SAI_xFRCR_FSPOL
00490 /**
00491   * @}
00492   */
00493 
00494 /** @defgroup SAI_Block_FS_Offset SAI Block FS Offset
00495   * @{
00496   */
00497 #define SAI_FS_FIRSTBIT             0x00000000U
00498 #define SAI_FS_BEFOREFIRSTBIT       SAI_xFRCR_FSOFF
00499 /**
00500   * @}
00501   */
00502 
00503 /** @defgroup SAI_Block_Slot_Size SAI Block Slot Size
00504   * @{
00505   */
00506 #define SAI_SLOTSIZE_DATASIZE       0x00000000U
00507 #define SAI_SLOTSIZE_16B            SAI_xSLOTR_SLOTSZ_0
00508 #define SAI_SLOTSIZE_32B            SAI_xSLOTR_SLOTSZ_1
00509 /**
00510   * @}
00511   */
00512 
00513 /** @defgroup SAI_Block_Slot_Active SAI Block Slot Active
00514   * @{
00515   */
00516 #define SAI_SLOT_NOTACTIVE          0x00000000U
00517 #define SAI_SLOTACTIVE_0            0x00000001U
00518 #define SAI_SLOTACTIVE_1            0x00000002U
00519 #define SAI_SLOTACTIVE_2            0x00000004U
00520 #define SAI_SLOTACTIVE_3            0x00000008U
00521 #define SAI_SLOTACTIVE_4            0x00000010U
00522 #define SAI_SLOTACTIVE_5            0x00000020U
00523 #define SAI_SLOTACTIVE_6            0x00000040U
00524 #define SAI_SLOTACTIVE_7            0x00000080U
00525 #define SAI_SLOTACTIVE_8            0x00000100U
00526 #define SAI_SLOTACTIVE_9            0x00000200U
00527 #define SAI_SLOTACTIVE_10           0x00000400U
00528 #define SAI_SLOTACTIVE_11           0x00000800U
00529 #define SAI_SLOTACTIVE_12           0x00001000U
00530 #define SAI_SLOTACTIVE_13           0x00002000U
00531 #define SAI_SLOTACTIVE_14           0x00004000U
00532 #define SAI_SLOTACTIVE_15           0x00008000U
00533 #define SAI_SLOTACTIVE_ALL          0x0000FFFFU
00534 /**
00535   * @}
00536   */
00537 
00538 /** @defgroup SAI_Mono_Stereo_Mode SAI Mono Stereo Mode
00539   * @{
00540   */
00541 #define SAI_STEREOMODE              0x00000000U
00542 #define SAI_MONOMODE                SAI_xCR1_MONO
00543 /**
00544   * @}
00545   */
00546 
00547 /** @defgroup SAI_TRIState_Management SAI TRIState Management
00548   * @{
00549   */
00550 #define SAI_OUTPUT_NOTRELEASED      0x00000000U
00551 #define SAI_OUTPUT_RELEASED         SAI_xCR2_TRIS
00552 /**
00553   * @}
00554   */
00555 
00556 /** @defgroup SAI_Block_Fifo_Threshold SAI Block Fifo Threshold
00557   * @{
00558   */
00559 #define SAI_FIFOTHRESHOLD_EMPTY     0x00000000U
00560 #define SAI_FIFOTHRESHOLD_1QF       SAI_xCR2_FTH_0
00561 #define SAI_FIFOTHRESHOLD_HF        SAI_xCR2_FTH_1
00562 #define SAI_FIFOTHRESHOLD_3QF       (SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0)
00563 #define SAI_FIFOTHRESHOLD_FULL      SAI_xCR2_FTH_2
00564 /**
00565   * @}
00566   */
00567 
00568 /** @defgroup SAI_Block_Companding_Mode SAI Block Companding Mode
00569   * @{
00570   */
00571 #define SAI_NOCOMPANDING            0x00000000U
00572 #define SAI_ULAW_1CPL_COMPANDING    SAI_xCR2_COMP_1
00573 #define SAI_ALAW_1CPL_COMPANDING    (SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0)
00574 #define SAI_ULAW_2CPL_COMPANDING    (SAI_xCR2_COMP_1 | SAI_xCR2_CPL)
00575 #define SAI_ALAW_2CPL_COMPANDING    (SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL)
00576 /**
00577   * @}
00578   */
00579 
00580 /** @defgroup SAI_Block_Mute_Value SAI Block Mute Value
00581   * @{
00582   */
00583 #define SAI_ZERO_VALUE              0x00000000U
00584 #define SAI_LAST_SENT_VALUE         SAI_xCR2_MUTEVAL
00585 /**
00586   * @}
00587   */
00588 
00589 /** @defgroup SAI_Block_Interrupts_Definition SAI Block Interrupts Definition
00590   * @{
00591   */
00592 #define SAI_IT_OVRUDR               SAI_xIMR_OVRUDRIE
00593 #define SAI_IT_MUTEDET              SAI_xIMR_MUTEDETIE
00594 #define SAI_IT_WCKCFG               SAI_xIMR_WCKCFGIE
00595 #define SAI_IT_FREQ                 SAI_xIMR_FREQIE
00596 #define SAI_IT_CNRDY                SAI_xIMR_CNRDYIE
00597 #define SAI_IT_AFSDET               SAI_xIMR_AFSDETIE
00598 #define SAI_IT_LFSDET               SAI_xIMR_LFSDETIE
00599 /**
00600   * @}
00601   */
00602 
00603 /** @defgroup SAI_Block_Flags_Definition  SAI Block Flags Definition
00604   * @{
00605   */
00606 #define SAI_FLAG_OVRUDR             SAI_xSR_OVRUDR
00607 #define SAI_FLAG_MUTEDET            SAI_xSR_MUTEDET
00608 #define SAI_FLAG_WCKCFG             SAI_xSR_WCKCFG
00609 #define SAI_FLAG_FREQ               SAI_xSR_FREQ
00610 #define SAI_FLAG_CNRDY              SAI_xSR_CNRDY
00611 #define SAI_FLAG_AFSDET             SAI_xSR_AFSDET
00612 #define SAI_FLAG_LFSDET             SAI_xSR_LFSDET
00613 /**
00614   * @}
00615   */
00616 
00617 /** @defgroup SAI_Block_Fifo_Status_Level   SAI Block Fifo Status Level
00618   * @{
00619   */
00620 #define SAI_FIFOSTATUS_EMPTY              0x00000000U
00621 #define SAI_FIFOSTATUS_LESS1QUARTERFULL   0x00010000U
00622 #define SAI_FIFOSTATUS_1QUARTERFULL       0x00020000U
00623 #define SAI_FIFOSTATUS_HALFFULL           0x00030000U
00624 #define SAI_FIFOSTATUS_3QUARTERFULL       0x00040000U
00625 #define SAI_FIFOSTATUS_FULL               0x00050000U
00626 /**
00627   * @}
00628   */
00629 
00630 /**
00631   * @}
00632   */
00633 
00634 /* Exported macro ------------------------------------------------------------*/
00635 /** @defgroup SAI_Exported_Macros SAI Exported Macros
00636   * @brief macros to handle interrupts and specific configurations
00637   * @{
00638   */
00639 
00640 /** @brief Reset SAI handle state.
00641   * @param  __HANDLE__ specifies the SAI Handle.
00642   * @retval None
00643   */
00644 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
00645 #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) do{                                            \
00646                                                      (__HANDLE__)->State = HAL_SAI_STATE_RESET; \
00647                                                      (__HANDLE__)->MspInitCallback = NULL;      \
00648                                                      (__HANDLE__)->MspDeInitCallback = NULL;    \
00649                                                    } while(0U)
00650 #else
00651 #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET)
00652 #endif
00653 
00654 /** @brief  Enable the specified SAI interrupts.
00655   * @param  __HANDLE__ specifies the SAI Handle.
00656   * @param  __INTERRUPT__ specifies the interrupt source to enable or disable.
00657   *         This parameter can be one of the following values:
00658   *            @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
00659   *            @arg SAI_IT_MUTEDET: Mute detection interrupt enable
00660   *            @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
00661   *            @arg SAI_IT_FREQ: FIFO request interrupt enable
00662   *            @arg SAI_IT_CNRDY: Codec not ready interrupt enable
00663   *            @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
00664   *            @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
00665   * @retval None
00666   */
00667 #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
00668 
00669 /** @brief  Disable the specified SAI interrupts.
00670   * @param  __HANDLE__ specifies the SAI Handle.
00671   * @param  __INTERRUPT__ specifies the interrupt source to enable or disable.
00672   *         This parameter can be one of the following values:
00673   *            @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
00674   *            @arg SAI_IT_MUTEDET: Mute detection interrupt enable
00675   *            @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
00676   *            @arg SAI_IT_FREQ: FIFO request interrupt enable
00677   *            @arg SAI_IT_CNRDY: Codec not ready interrupt enable
00678   *            @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
00679   *            @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
00680   * @retval None
00681   */
00682 #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__)))
00683 
00684 /** @brief  Check whether the specified SAI interrupt source is enabled or not.
00685   * @param  __HANDLE__ specifies the SAI Handle.
00686   * @param  __INTERRUPT__ specifies the SAI interrupt source to check.
00687   *         This parameter can be one of the following values:
00688   *            @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
00689   *            @arg SAI_IT_MUTEDET: Mute detection interrupt enable
00690   *            @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
00691   *            @arg SAI_IT_FREQ: FIFO request interrupt enable
00692   *            @arg SAI_IT_CNRDY: Codec not ready interrupt enable
00693   *            @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
00694   *            @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
00695   * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
00696   */
00697 #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
00698 
00699 /** @brief  Check whether the specified SAI flag is set or not.
00700   * @param  __HANDLE__ specifies the SAI Handle.
00701   * @param  __FLAG__ specifies the flag to check.
00702   *         This parameter can be one of the following values:
00703   *            @arg SAI_FLAG_OVRUDR: Overrun underrun flag.
00704   *            @arg SAI_FLAG_MUTEDET: Mute detection flag.
00705   *            @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag.
00706   *            @arg SAI_FLAG_FREQ: FIFO request flag.
00707   *            @arg SAI_FLAG_CNRDY: Codec not ready flag.
00708   *            @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag.
00709   *            @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag.
00710   * @retval The new state of __FLAG__ (TRUE or FALSE).
00711   */
00712 #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
00713 
00714 /** @brief  Clear the specified SAI pending flag.
00715   * @param  __HANDLE__ specifies the SAI Handle.
00716   * @param  __FLAG__ specifies the flag to check.
00717   *          This parameter can be any combination of the following values:
00718   *            @arg SAI_FLAG_OVRUDR: Clear Overrun underrun
00719   *            @arg SAI_FLAG_MUTEDET: Clear Mute detection
00720   *            @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration
00721   *            @arg SAI_FLAG_FREQ: Clear FIFO request
00722   *            @arg SAI_FLAG_CNRDY: Clear Codec not ready
00723   *            @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection
00724   *            @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection
00725   *
00726   * @retval None
00727   */
00728 #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__))
00729 
00730 /** @brief  Enable SAI.
00731   * @param  __HANDLE__ specifies the SAI Handle.
00732   * @retval None
00733   */
00734 #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |=  SAI_xCR1_SAIEN)
00735 
00736 /** @brief  Disable SAI.
00737   * @param  __HANDLE__ specifies the SAI Handle.
00738   * @retval None
00739   */
00740 #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &=  ~SAI_xCR1_SAIEN)
00741 
00742 /**
00743   * @}
00744   */
00745 
00746 /* Include SAI HAL Extension module */
00747 #include "stm32h7xx_hal_sai_ex.h"
00748 
00749 /* Exported functions --------------------------------------------------------*/
00750 /** @addtogroup SAI_Exported_Functions
00751   * @{
00752   */
00753 
00754 /* Initialization/de-initialization functions  ********************************/
00755 /** @addtogroup SAI_Exported_Functions_Group1
00756   * @{
00757   */
00758 HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot);
00759 HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai);
00760 HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai);
00761 void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai);
00762 void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai);
00763 
00764 #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
00765 /* SAI callbacks register/unregister functions ********************************/
00766 HAL_StatusTypeDef HAL_SAI_RegisterCallback(SAI_HandleTypeDef        *hsai,
00767                                            HAL_SAI_CallbackIDTypeDef CallbackID,
00768                                            pSAI_CallbackTypeDef      pCallback);
00769 HAL_StatusTypeDef HAL_SAI_UnRegisterCallback(SAI_HandleTypeDef        *hsai,
00770                                              HAL_SAI_CallbackIDTypeDef CallbackID);
00771 #endif
00772 /**
00773   * @}
00774   */
00775 
00776 /* I/O operation functions  ***************************************************/
00777 /** @addtogroup SAI_Exported_Functions_Group2
00778   * @{
00779   */
00780 /* Blocking mode: Polling */
00781 HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
00782 HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
00783 
00784 /* Non-Blocking mode: Interrupt */
00785 HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
00786 HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
00787 
00788 /* Non-Blocking mode: DMA */
00789 HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
00790 HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
00791 HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai);
00792 HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai);
00793 HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai);
00794 
00795 /* Abort function */
00796 HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai);
00797 
00798 /* Mute management */
00799 HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val);
00800 HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai);
00801 HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter);
00802 HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai);
00803 
00804 /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
00805 void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai);
00806 void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
00807 void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
00808 void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
00809 void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
00810 void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
00811 /**
00812   * @}
00813   */
00814 
00815 /** @addtogroup SAI_Exported_Functions_Group3
00816   * @{
00817   */
00818 /* Peripheral State functions  ************************************************/
00819 HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai);
00820 uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai);
00821 /**
00822   * @}
00823   */
00824 
00825 /**
00826   * @}
00827   */
00828 
00829 /* Private macros ------------------------------------------------------------*/
00830 /** @defgroup SAI_Private_Macros SAI Private Macros
00831   * @{
00832   */
00833 #define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\
00834                                      ((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\
00835                                      ((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE))
00836 
00837 #define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL)   (((PROTOCOL) == SAI_I2S_STANDARD)     ||\
00838                                                ((PROTOCOL) == SAI_I2S_MSBJUSTIFIED) ||\
00839                                                ((PROTOCOL) == SAI_I2S_LSBJUSTIFIED) ||\
00840                                                ((PROTOCOL) == SAI_PCM_LONG)         ||\
00841                                                ((PROTOCOL) == SAI_PCM_SHORT))
00842 
00843 #define IS_SAI_PROTOCOL_DATASIZE(DATASIZE)   (((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BIT)         ||\
00844                                               ((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BITEXTENDED) ||\
00845                                               ((DATASIZE) == SAI_PROTOCOL_DATASIZE_24BIT)         ||\
00846                                               ((DATASIZE) == SAI_PROTOCOL_DATASIZE_32BIT))
00847 
00848 #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \
00849                                        ((AUDIO) == SAI_AUDIO_FREQUENCY_48K)  || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \
00850                                        ((AUDIO) == SAI_AUDIO_FREQUENCY_32K)  || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \
00851                                        ((AUDIO) == SAI_AUDIO_FREQUENCY_16K)  || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \
00852                                        ((AUDIO) == SAI_AUDIO_FREQUENCY_8K)   || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV))
00853 
00854 #define IS_SAI_BLOCK_MCK_OVERSAMPLING(VALUE) (((VALUE) == SAI_MCK_OVERSAMPLING_DISABLE) || \
00855                                               ((VALUE) == SAI_MCK_OVERSAMPLING_ENABLE))
00856 
00857 #define IS_SAI_PDM_MIC_PAIRS_NUMBER(VALUE)   ((1U <= (VALUE)) && ((VALUE) <= 3U))
00858 
00859 #define IS_SAI_PDM_CLOCK_ENABLE(CLOCK) (((CLOCK) != 0U) && \
00860                                        (((CLOCK) & ~(SAI_PDM_CLOCK1_ENABLE | SAI_PDM_CLOCK2_ENABLE)) == 0U))
00861 
00862 #define IS_SAI_BLOCK_MODE(MODE)  (((MODE) == SAI_MODEMASTER_TX) || \
00863                                   ((MODE) == SAI_MODEMASTER_RX) || \
00864                                   ((MODE) == SAI_MODESLAVE_TX)  || \
00865                                   ((MODE) == SAI_MODESLAVE_RX))
00866 
00867 #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL)  || \
00868                                          ((PROTOCOL) == SAI_AC97_PROTOCOL)  || \
00869                                          ((PROTOCOL) == SAI_SPDIF_PROTOCOL))
00870 
00871 #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8)  || \
00872                                          ((DATASIZE) == SAI_DATASIZE_10) || \
00873                                          ((DATASIZE) == SAI_DATASIZE_16) || \
00874                                          ((DATASIZE) == SAI_DATASIZE_20) || \
00875                                          ((DATASIZE) == SAI_DATASIZE_24) || \
00876                                          ((DATASIZE) == SAI_DATASIZE_32))
00877 
00878 #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \
00879                                      ((BIT) == SAI_FIRSTBIT_LSB))
00880 
00881 #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \
00882                                             ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE))
00883 #if defined(SAI2) && defined(SAI3) && defined(SAI4)
00884 #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS)          || \
00885                                        ((SYNCHRO) == SAI_SYNCHRONOUS)           || \
00886                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1)  || \
00887                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2)  || \
00888                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI3)  || \
00889                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI4))
00890 #elif defined(SAI2)
00891 #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS)          || \
00892                                        ((SYNCHRO) == SAI_SYNCHRONOUS)           || \
00893                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1)  || \
00894                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2))
00895 #else
00896 #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS)          || \
00897                                        ((SYNCHRO) == SAI_SYNCHRONOUS)           || \
00898                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1)  || \
00899                                        ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI4))
00900 #endif
00901 
00902 #define IS_SAI_BLOCK_MCK_OUTPUT(VALUE) (((VALUE) == SAI_MCK_OUTPUT_ENABLE) || \
00903                                         ((VALUE) == SAI_MCK_OUTPUT_DISABLE))
00904 
00905 #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \
00906                                           ((DRIVE) == SAI_OUTPUTDRIVE_ENABLE))
00907 
00908 #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \
00909                                            ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE))
00910 
00911 #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63U)
00912 
00913 #define IS_SAI_BLOCK_MUTE_VALUE(VALUE)    (((VALUE) == SAI_ZERO_VALUE)     || \
00914                                            ((VALUE) == SAI_LAST_SENT_VALUE))
00915 
00916 #define IS_SAI_BLOCK_COMPANDING_MODE(MODE)    (((MODE) == SAI_NOCOMPANDING)         || \
00917                                                ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \
00918                                                ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \
00919                                                ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \
00920                                                ((MODE) == SAI_ALAW_2CPL_COMPANDING))
00921 
00922 #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY)   || \
00923                                                 ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF)     || \
00924                                                 ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF)      || \
00925                                                 ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF)     || \
00926                                                 ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL))
00927 
00928 #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\
00929                                                  ((STATE) == SAI_OUTPUT_RELEASED))
00930 
00931 #define IS_SAI_MONO_STEREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\
00932                                        ((MODE) == SAI_STEREOMODE))
00933 
00934 #define IS_SAI_SLOT_ACTIVE(ACTIVE)  ((ACTIVE) <= SAI_SLOTACTIVE_ALL)
00935 
00936 #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1U <= (NUMBER)) && ((NUMBER) <= 16U))
00937 
00938 #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \
00939                                       ((SIZE) == SAI_SLOTSIZE_16B)      || \
00940                                       ((SIZE) == SAI_SLOTSIZE_32B))
00941 
00942 #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24U)
00943 
00944 #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \
00945                                         ((OFFSET) == SAI_FS_BEFOREFIRSTBIT))
00946 
00947 #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \
00948                                             ((POLARITY) == SAI_FS_ACTIVE_HIGH))
00949 
00950 #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \
00951                                                 ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION))
00952 
00953 #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 63U)
00954 
00955 #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8U <= (LENGTH)) && ((LENGTH) <= 256U))
00956 
00957 #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1U <= (LENGTH)) && ((LENGTH) <= 128U))
00958 
00959 /**
00960   * @}
00961   */
00962 
00963 /* Private functions ---------------------------------------------------------*/
00964 /** @defgroup SAI_Private_Functions SAI Private Functions
00965   * @{
00966   */
00967 
00968 /**
00969   * @}
00970   */
00971 
00972 /**
00973   * @}
00974   */
00975 
00976 /**
00977   * @}
00978   */
00979 
00980 #ifdef __cplusplus
00981 }
00982 #endif
00983 
00984 #endif /* STM32H7xx_HAL_SAI_H */
00985