STM32F439xx HAL User Manual
stm32f4xx_hal_i2s.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_i2s.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of I2S HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00010   *
00011   * Redistribution and use in source and binary forms, with or without modification,
00012   * are permitted provided that the following conditions are met:
00013   *   1. Redistributions of source code must retain the above copyright notice,
00014   *      this list of conditions and the following disclaimer.
00015   *   2. Redistributions in binary form must reproduce the above copyright notice,
00016   *      this list of conditions and the following disclaimer in the documentation
00017   *      and/or other materials provided with the distribution.
00018   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00019   *      may be used to endorse or promote products derived from this software
00020   *      without specific prior written permission.
00021   *
00022   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00026   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032   *
00033   ******************************************************************************
00034   */
00035 
00036 /* Define to prevent recursive inclusion -------------------------------------*/
00037 #ifndef __STM32F4xx_HAL_I2S_H
00038 #define __STM32F4xx_HAL_I2S_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 /* Includes ------------------------------------------------------------------*/
00045 #include "stm32f4xx_hal_def.h"
00046 
00047 /** @addtogroup STM32F4xx_HAL_Driver
00048   * @{
00049   */
00050 
00051 /** @addtogroup I2S I2S
00052   * @{
00053   */
00054 
00055 /* Exported types ------------------------------------------------------------*/
00056 /** @defgroup I2S_Exported_Types I2S Exported Types
00057   * @{
00058   */
00059 
00060 /**
00061   * @brief I2S Init structure definition
00062   */
00063 typedef struct
00064 {
00065   uint32_t Mode;            /*!< Specifies the I2S operating mode.
00066                                  This parameter can be a value of @ref I2S_Mode */
00067 
00068   uint32_t Standard;        /*!< Specifies the standard used for the I2S communication.
00069                                  This parameter can be a value of @ref I2S_Standard */
00070 
00071   uint32_t DataFormat;      /*!< Specifies the data format for the I2S communication.
00072                                  This parameter can be a value of @ref I2S_Data_Format */
00073 
00074   uint32_t MCLKOutput;      /*!< Specifies whether the I2S MCLK output is enabled or not.
00075                                  This parameter can be a value of @ref I2S_MCLK_Output */
00076 
00077   uint32_t AudioFreq;       /*!< Specifies the frequency selected for the I2S communication.
00078                                  This parameter can be a value of @ref I2S_Audio_Frequency */
00079 
00080   uint32_t CPOL;            /*!< Specifies the idle state of the I2S clock.
00081                                  This parameter can be a value of @ref I2S_Clock_Polarity */
00082 
00083   uint32_t ClockSource;     /*!< Specifies the I2S Clock Source.
00084                                  This parameter can be a value of @ref I2S_Clock_Source */
00085 
00086   uint32_t FullDuplexMode;  /*!< Specifies the I2S FullDuplex mode.
00087                                  This parameter can be a value of @ref I2S_FullDuplex_Mode */
00088 
00089 }I2S_InitTypeDef;
00090 
00091 /**
00092   * @brief  HAL State structures definition
00093   */
00094 typedef enum
00095 {
00096   HAL_I2S_STATE_RESET      = 0x00U,  /*!< I2S not yet initialized or disabled                */
00097   HAL_I2S_STATE_READY      = 0x01U,  /*!< I2S initialized and ready for use                  */
00098   HAL_I2S_STATE_BUSY       = 0x02U,  /*!< I2S internal process is ongoing                    */
00099   HAL_I2S_STATE_BUSY_TX    = 0x03U,  /*!< Data Transmission process is ongoing               */
00100   HAL_I2S_STATE_BUSY_RX    = 0x04U,  /*!< Data Reception process is ongoing                  */
00101   HAL_I2S_STATE_BUSY_TX_RX = 0x05U,  /*!< Data Transmission and Reception process is ongoing */
00102   HAL_I2S_STATE_TIMEOUT    = 0x06U,  /*!< I2S timeout state                                  */
00103   HAL_I2S_STATE_ERROR      = 0x07U   /*!< I2S error state                                    */
00104 
00105 }HAL_I2S_StateTypeDef;
00106 
00107 /**
00108   * @brief I2S handle Structure definition
00109   */
00110 typedef struct __I2S_HandleTypeDef
00111 {
00112   SPI_TypeDef                *Instance;    /*!< I2S registers base address        */
00113 
00114   I2S_InitTypeDef            Init;         /*!< I2S communication parameters      */
00115 
00116   uint16_t                   *pTxBuffPtr;  /*!< Pointer to I2S Tx transfer buffer */
00117 
00118   __IO uint16_t              TxXferSize;   /*!< I2S Tx transfer size              */
00119 
00120   __IO uint16_t              TxXferCount;  /*!< I2S Tx transfer Counter           */
00121 
00122   uint16_t                   *pRxBuffPtr;  /*!< Pointer to I2S Rx transfer buffer */
00123 
00124   __IO uint16_t              RxXferSize;   /*!< I2S Rx transfer size              */
00125 
00126   __IO uint16_t              RxXferCount;  /*!< I2S Rx transfer counter
00127                                               (This field is initialized at the
00128                                                same value as transfer size at the
00129                                                beginning of the transfer and
00130                                                decremented when a sample is received
00131                                                NbSamplesReceived = RxBufferSize-RxBufferCount) */
00132 
00133   void (*IrqHandlerISR)      (struct __I2S_HandleTypeDef *hi2s);   /*!< I2S function pointer on IrqHandler   */
00134 
00135   DMA_HandleTypeDef          *hdmatx;      /*!< I2S Tx DMA handle parameters      */
00136 
00137   DMA_HandleTypeDef          *hdmarx;      /*!< I2S Rx DMA handle parameters      */
00138 
00139   __IO HAL_LockTypeDef       Lock;         /*!< I2S locking object                */
00140 
00141   __IO HAL_I2S_StateTypeDef  State;        /*!< I2S communication state           */
00142 
00143   __IO uint32_t              ErrorCode;    /*!< I2S Error code
00144                                               This parameter can be a value of @ref I2S_ErrorCode */
00145 
00146 }I2S_HandleTypeDef;
00147 /**
00148   * @}
00149   */
00150 
00151 /* Exported constants --------------------------------------------------------*/
00152 /** @defgroup I2S_Exported_Constants I2S Exported Constants
00153   * @{
00154   */
00155 /**
00156   * @defgroup  I2S_ErrorCode I2S Error Code
00157   * @{
00158   */
00159 #define HAL_I2S_ERROR_NONE               (0x00000000U)  /*!< No error                    */
00160 #define HAL_I2S_ERROR_TIMEOUT            (0x00000001U)  /*!< Timeout error               */
00161 #define HAL_I2S_ERROR_OVR                (0x00000002U)  /*!< OVR error                   */
00162 #define HAL_I2S_ERROR_UDR                (0x00000004U)  /*!< UDR error                   */
00163 #define HAL_I2S_ERROR_DMA                (0x00000008U)  /*!< DMA transfer error          */
00164 #define HAL_I2S_ERROR_PRESCALER          (0x00000010U)  /*!< Prescaler Calculation error */
00165 /**
00166   * @}
00167   */
00168 
00169 /** @defgroup I2S_Mode I2S Mode
00170   * @{
00171   */
00172 #define I2S_MODE_SLAVE_TX                (0x00000000U)
00173 #define I2S_MODE_SLAVE_RX                (0x00000100U)
00174 #define I2S_MODE_MASTER_TX               (0x00000200U)
00175 #define I2S_MODE_MASTER_RX               (0x00000300U)
00176 /**
00177   * @}
00178   */
00179 
00180 /** @defgroup I2S_Standard I2S Standard
00181   * @{
00182   */
00183 #define I2S_STANDARD_PHILIPS             (0x00000000U)
00184 #define I2S_STANDARD_MSB                 (0x00000010U)
00185 #define I2S_STANDARD_LSB                 (0x00000020U)
00186 #define I2S_STANDARD_PCM_SHORT           (0x00000030U)
00187 #define I2S_STANDARD_PCM_LONG            (0x000000B0U)
00188 /**
00189   * @}
00190   */
00191 
00192 /** @defgroup I2S_Data_Format I2S Data Format
00193   * @{
00194   */
00195 #define I2S_DATAFORMAT_16B               (0x00000000U)
00196 #define I2S_DATAFORMAT_16B_EXTENDED      (0x00000001U)
00197 #define I2S_DATAFORMAT_24B               (0x00000003U)
00198 #define I2S_DATAFORMAT_32B               (0x00000005U)
00199 /**
00200   * @}
00201   */
00202 
00203 /** @defgroup I2S_MCLK_Output I2S Mclk Output
00204   * @{
00205   */
00206 #define I2S_MCLKOUTPUT_ENABLE            SPI_I2SPR_MCKOE
00207 #define I2S_MCLKOUTPUT_DISABLE          (0x00000000U)
00208 /**
00209   * @}
00210   */
00211 
00212 /** @defgroup I2S_Audio_Frequency I2S Audio Frequency
00213   * @{
00214   */
00215 #define I2S_AUDIOFREQ_192K               (192000U)
00216 #define I2S_AUDIOFREQ_96K                (96000U)
00217 #define I2S_AUDIOFREQ_48K                (48000U)
00218 #define I2S_AUDIOFREQ_44K                (44100U)
00219 #define I2S_AUDIOFREQ_32K                (32000U)
00220 #define I2S_AUDIOFREQ_22K                (22050U)
00221 #define I2S_AUDIOFREQ_16K                (16000U)
00222 #define I2S_AUDIOFREQ_11K                (11025U)
00223 #define I2S_AUDIOFREQ_8K                 (8000U)
00224 #define I2S_AUDIOFREQ_DEFAULT            (2U)
00225 /**
00226   * @}
00227   */
00228 
00229 /** @defgroup I2S_FullDuplex_Mode I2S FullDuplex Mode
00230   * @{
00231   */
00232 #define I2S_FULLDUPLEXMODE_DISABLE                   (0x00000000U)
00233 #define I2S_FULLDUPLEXMODE_ENABLE                    (0x00000001U)
00234 /**
00235   * @}
00236   */
00237 
00238 /** @defgroup I2S_Clock_Polarity  I2S Clock Polarity
00239   * @{
00240   */
00241 #define I2S_CPOL_LOW                    (0x00000000U)
00242 #define I2S_CPOL_HIGH                   (SPI_I2SCFGR_CKPOL)
00243 /**
00244   * @}
00245   */
00246 
00247 /** @defgroup I2S_Interrupts_Definition I2S Interrupts Definition
00248   * @{
00249   */
00250 #define I2S_IT_TXE                      SPI_CR2_TXEIE
00251 #define I2S_IT_RXNE                     SPI_CR2_RXNEIE
00252 #define I2S_IT_ERR                      SPI_CR2_ERRIE
00253 /**
00254   * @}
00255   */
00256 
00257 /** @defgroup I2S_Flags_Definition I2S Flags Definition
00258   * @{
00259   */
00260 #define I2S_FLAG_TXE                    SPI_SR_TXE
00261 #define I2S_FLAG_RXNE                   SPI_SR_RXNE
00262 
00263 #define I2S_FLAG_UDR                    SPI_SR_UDR
00264 #define I2S_FLAG_OVR                    SPI_SR_OVR
00265 #define I2S_FLAG_FRE                    SPI_SR_FRE
00266 
00267 #define I2S_FLAG_CHSIDE                 SPI_SR_CHSIDE
00268 #define I2S_FLAG_BSY                    SPI_SR_BSY
00269 /**
00270   * @}
00271   */
00272 /** @defgroup I2S_Clock_Source I2S Clock Source Definition
00273   * @{
00274   */
00275 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
00276     defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
00277     defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || \
00278     defined(STM32F479xx)
00279 #define I2S_CLOCK_PLL                     (0x00000000U)
00280 #define I2S_CLOCK_EXTERNAL                (0x00000001U)
00281 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
00282           STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
00283 
00284 #if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
00285     defined(STM32F413xx) || defined(STM32F423xx)
00286 #define I2S_CLOCK_PLL                     (0x00000000U)
00287 #define I2S_CLOCK_EXTERNAL                (0x00000001U)
00288 #define I2S_CLOCK_PLLR                    (0x00000002U)
00289 #define I2S_CLOCK_PLLSRC                  (0x00000003U)
00290 #endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
00291 
00292 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
00293 #define I2S_CLOCK_PLLSRC                  (0x00000000U)
00294 #define I2S_CLOCK_EXTERNAL                (0x00000001U)
00295 #define I2S_CLOCK_PLLR                    (0x00000002U)
00296 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
00297 /**
00298   * @}
00299   */
00300 
00301 /**
00302   * @}
00303   */
00304 
00305 /* Exported macro ------------------------------------------------------------*/
00306 /** @defgroup I2S_Exported_Macros I2S Exported Macros
00307   * @{
00308   */
00309 
00310 /** @brief Reset I2S handle state
00311   * @param  __HANDLE__ specifies the I2S Handle.
00312   * @retval None
00313   */
00314 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET)
00315 
00316 /** @brief  Enable or disable the specified SPI peripheral (in I2S mode).
00317   * @param  __HANDLE__ specifies the I2S Handle.
00318   * @retval None
00319   */
00320 #define __HAL_I2S_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR |= SPI_I2SCFGR_I2SE)
00321 #define __HAL_I2S_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR &=(uint16_t)(~SPI_I2SCFGR_I2SE))
00322 
00323 /** @brief  Enable or disable the specified I2S interrupts.
00324   * @param  __HANDLE__ specifies the I2S Handle.
00325   * @param  __INTERRUPT__ specifies the interrupt source to enable or disable.
00326   *         This parameter can be one of the following values:
00327   *            @arg I2S_IT_TXE: Tx buffer empty interrupt enable
00328   *            @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
00329   *            @arg I2S_IT_ERR: Error interrupt enable
00330   * @retval None
00331   */
00332 #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
00333 #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &=(uint16_t)(~(__INTERRUPT__)))
00334 
00335 /** @brief  Checks if the specified I2S interrupt source is enabled or disabled.
00336   * @param  __HANDLE__ specifies the I2S Handle.
00337   *         This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
00338   * @param  __INTERRUPT__ specifies the I2S interrupt source to check.
00339   *          This parameter can be one of the following values:
00340   *            @arg I2S_IT_TXE: Tx buffer empty interrupt enable
00341   *            @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
00342   *            @arg I2S_IT_ERR: Error interrupt enable
00343   * @retval The new state of __IT__ (TRUE or FALSE).
00344   */
00345 #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
00346 
00347 /** @brief  Checks whether the specified I2S flag is set or not.
00348   * @param  __HANDLE__ specifies the I2S Handle.
00349   * @param  __FLAG__ specifies the flag to check.
00350   *         This parameter can be one of the following values:
00351   *            @arg I2S_FLAG_RXNE: Receive buffer not empty flag
00352   *            @arg I2S_FLAG_TXE: Transmit buffer empty flag
00353   *            @arg I2S_FLAG_UDR: Underrun flag
00354   *            @arg I2S_FLAG_OVR: Overrun flag
00355   *            @arg I2S_FLAG_FRE: Frame error flag
00356   *            @arg I2S_FLAG_CHSIDE: Channel Side flag
00357   *            @arg I2S_FLAG_BSY: Busy flag
00358   * @retval The new state of __FLAG__ (TRUE or FALSE).
00359   */
00360 #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
00361 
00362 /** @brief Clears the I2S OVR pending flag.
00363   * @param  __HANDLE__ specifies the I2S Handle.
00364   * @retval None
00365   */
00366 #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__)     \
00367   do{                                           \
00368     __IO uint32_t tmpreg = 0x00U;               \
00369     tmpreg = (__HANDLE__)->Instance->DR;        \
00370     tmpreg = (__HANDLE__)->Instance->SR;        \
00371     UNUSED(tmpreg);                             \
00372   } while(0)
00373 
00374 /** @brief Clears the I2S UDR pending flag.
00375   * @param  __HANDLE__ specifies the I2S Handle.
00376   * @retval None
00377   */
00378 #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__)     \
00379   do{                                           \
00380   __IO uint32_t tmpreg = 0x00U;                 \
00381   tmpreg = (__HANDLE__)->Instance->SR;          \
00382   UNUSED(tmpreg);                               \
00383   } while(0)
00384 /**
00385   * @}
00386   */
00387 
00388 /* Include I2S Extension module */
00389 #include "stm32f4xx_hal_i2s_ex.h"
00390 
00391 /* Exported functions --------------------------------------------------------*/
00392 /** @defgroup I2S_Exported_Functions I2S Exported Functions
00393   * @{
00394   */
00395 
00396 /** @defgroup I2S_Exported_Functions_Group1 I2S Initialization and de-initialization functions
00397   * @{
00398   */
00399 /* Initialization/de-initialization functions  **********************************/
00400 HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s);
00401 HAL_StatusTypeDef HAL_I2S_DeInit (I2S_HandleTypeDef *hi2s);
00402 void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s);
00403 void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s);
00404 /**
00405   * @}
00406   */
00407 
00408 /** @defgroup I2S_Exported_Functions_Group2 I2S IO operation functions
00409   * @{
00410   */
00411 /* I/O operation functions  *****************************************************/
00412 /* Blocking mode: Polling */
00413 HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
00414 HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
00415 
00416  /* Non-Blocking mode: Interrupt */
00417 HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
00418 HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
00419 void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s);
00420 
00421 /* Non-Blocking mode: DMA */
00422 HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
00423 HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
00424 
00425 HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s);
00426 HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s);
00427 HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s);
00428 
00429 /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/
00430 void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
00431 void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s);
00432 void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
00433 void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s);
00434 void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s);
00435 /**
00436   * @}
00437   */
00438 
00439 /** @defgroup I2S_Exported_Functions_Group3 I2S Peripheral Control and State functions
00440   * @{
00441   */
00442 /* Peripheral Control and State functions  ************************************/
00443 HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s);
00444 uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s);
00445 /**
00446   * @}
00447   */
00448 
00449 /**
00450   * @}
00451   */
00452 
00453 /* Private types -------------------------------------------------------------*/
00454 /* Private variables ---------------------------------------------------------*/
00455 /* Private constants ---------------------------------------------------------*/
00456 /** @defgroup I2S_Private_Constants I2S Private Constants
00457   * @{
00458   */
00459 
00460 /**
00461   * @}
00462   */
00463 
00464 /* Private macros ------------------------------------------------------------*/
00465 /** @defgroup I2S_Private_Macros I2S Private Macros
00466   * @{
00467   */
00468 #define IS_I2S_MODE(MODE) (((MODE) == I2S_MODE_SLAVE_TX)  || \
00469                            ((MODE) == I2S_MODE_SLAVE_RX)  || \
00470                            ((MODE) == I2S_MODE_MASTER_TX) || \
00471                            ((MODE) == I2S_MODE_MASTER_RX))
00472 
00473 #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_STANDARD_PHILIPS)   || \
00474                                    ((STANDARD) == I2S_STANDARD_MSB)       || \
00475                                    ((STANDARD) == I2S_STANDARD_LSB)       || \
00476                                    ((STANDARD) == I2S_STANDARD_PCM_SHORT) || \
00477                                    ((STANDARD) == I2S_STANDARD_PCM_LONG))
00478 
00479 #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DATAFORMAT_16B)          || \
00480                                     ((FORMAT) == I2S_DATAFORMAT_16B_EXTENDED) || \
00481                                     ((FORMAT) == I2S_DATAFORMAT_24B)          || \
00482                                     ((FORMAT) == I2S_DATAFORMAT_32B))
00483 
00484 #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOUTPUT_ENABLE) || \
00485                                     ((OUTPUT) == I2S_MCLKOUTPUT_DISABLE))
00486 
00487 #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AUDIOFREQ_8K) && \
00488                                   ((FREQ) <= I2S_AUDIOFREQ_192K)) || \
00489                                   ((FREQ) == I2S_AUDIOFREQ_DEFAULT))
00490 
00491 #define IS_I2S_FULLDUPLEX_MODE(MODE) (((MODE) == I2S_FULLDUPLEXMODE_DISABLE) || \
00492                                       ((MODE) == I2S_FULLDUPLEXMODE_ENABLE))
00493 
00494 #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_LOW) || \
00495                            ((CPOL) == I2S_CPOL_HIGH))
00496 
00497 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
00498     defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
00499     defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || \
00500     defined(STM32F479xx)
00501 #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
00502                                    ((CLOCK) == I2S_CLOCK_PLL))
00503 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
00504           STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
00505 
00506 #if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx)  ||\
00507     defined(STM32F412Rx) || defined(STM32F412Cx) || defined (STM32F413xx) ||\
00508     defined(STM32F423xx)
00509 #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
00510                                    ((CLOCK) == I2S_CLOCK_PLL)      ||\
00511                                    ((CLOCK) == I2S_CLOCK_PLLSRC)   ||\
00512                                    ((CLOCK) == I2S_CLOCK_PLLR))
00513 #endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
00514 
00515 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
00516 #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
00517                                    ((CLOCK) == I2S_CLOCK_PLLSRC)     ||\
00518                                    ((CLOCK) == I2S_CLOCK_PLLR))
00519 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
00520 
00521 /**
00522   * @}
00523   */
00524 
00525 /* Private functions ---------------------------------------------------------*/
00526 /**
00527   * @}
00528   */
00529 
00530 /**
00531   * @}
00532   */
00533 
00534 #ifdef __cplusplus
00535 }
00536 #endif
00537 
00538 
00539 #endif /* __STM32F4xx_HAL_I2S_H */
00540 
00541 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/