STM32F479xx HAL User Manual
stm32f4xx_hal_i2s_ex.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_i2s_ex.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of I2S HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef STM32F4xx_HAL_I2S_EX_H
00022 #define STM32F4xx_HAL_I2S_EX_H
00023 
00024 #ifdef __cplusplus
00025 extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal_def.h"
00030 
00031 /** @addtogroup STM32F4xx_HAL_Driver
00032   * @{
00033   */
00034 #if defined(SPI_I2S_FULLDUPLEX_SUPPORT)
00035 /** @addtogroup I2SEx I2SEx
00036   * @{
00037   */
00038 
00039 /* Exported types ------------------------------------------------------------*/
00040 /* Exported constants --------------------------------------------------------*/
00041 /* Exported macros -----------------------------------------------------------*/
00042 /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros
00043   * @{
00044   */
00045 
00046 #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
00047 
00048 /** @brief  Enable or disable the specified I2SExt peripheral.
00049   * @param  __HANDLE__ specifies the I2S Handle.
00050   * @retval None
00051   */
00052 #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
00053 #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
00054 
00055 /** @brief  Enable or disable the specified I2SExt interrupts.
00056   * @param  __HANDLE__ specifies the I2S Handle.
00057   * @param  __INTERRUPT__ specifies the interrupt source to enable or disable.
00058   *        This parameter can be one of the following values:
00059   *            @arg I2S_IT_TXE: Tx buffer empty interrupt enable
00060   *            @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
00061   *            @arg I2S_IT_ERR: Error interrupt enable
00062   * @retval None
00063   */
00064 #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__))
00065 #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__))
00066 
00067 /** @brief  Checks if the specified I2SExt interrupt source is enabled or disabled.
00068   * @param  __HANDLE__ specifies the I2S Handle.
00069   *         This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
00070   * @param  __INTERRUPT__ specifies the I2S interrupt source to check.
00071   *          This parameter can be one of the following values:
00072   *            @arg I2S_IT_TXE: Tx buffer empty interrupt enable
00073   *            @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
00074   *            @arg I2S_IT_ERR: Error interrupt enable
00075   * @retval The new state of __IT__ (TRUE or FALSE).
00076   */
00077 #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2\
00078                                                                  & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
00079 
00080 /** @brief  Checks whether the specified I2SExt flag is set or not.
00081   * @param  __HANDLE__ specifies the I2S Handle.
00082   * @param  __FLAG__ specifies the flag to check.
00083   *        This parameter can be one of the following values:
00084   *            @arg I2S_FLAG_RXNE: Receive buffer not empty flag
00085   *            @arg I2S_FLAG_TXE: Transmit buffer empty flag
00086   *            @arg I2S_FLAG_UDR: Underrun flag
00087   *            @arg I2S_FLAG_OVR: Overrun flag
00088   *            @arg I2S_FLAG_FRE: Frame error flag
00089   *            @arg I2S_FLAG_CHSIDE: Channel Side flag
00090   *            @arg I2S_FLAG_BSY: Busy flag
00091   * @retval The new state of __FLAG__ (TRUE or FALSE).
00092   */
00093 #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__))
00094 
00095 /** @brief Clears the I2SExt OVR pending flag.
00096   * @param  __HANDLE__ specifies the I2S Handle.
00097   * @retval None
00098   */
00099 #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{                                                 \
00100                                                    __IO uint32_t tmpreg_ovr = 0x00U;                \
00101                                                    tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\
00102                                                    tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\
00103                                                    UNUSED(tmpreg_ovr);                              \
00104                                                   }while(0U)
00105 /** @brief Clears the I2SExt UDR pending flag.
00106   * @param  __HANDLE__ specifies the I2S Handle.
00107   * @retval None
00108   */
00109 #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{                                                 \
00110                                                    __IO uint32_t tmpreg_udr = 0x00U;                \
00111                                                    tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\
00112                                                    UNUSED(tmpreg_udr);                              \
00113                                                   }while(0U)
00114 /** @brief Flush the I2S and I2SExt DR Registers.
00115   * @param  __HANDLE__ specifies the I2S Handle.
00116   * @retval None
00117   */
00118 #define __HAL_I2SEXT_FLUSH_RX_DR(__HANDLE__) do{                                                    \
00119                                                    __IO uint32_t tmpreg_dr = 0x00U;                 \
00120                                                    tmpreg_dr = I2SxEXT((__HANDLE__)->Instance)->DR; \
00121                                                    tmpreg_dr = ((__HANDLE__)->Instance->DR);        \
00122                                                    UNUSED(tmpreg_dr);                               \
00123                                                   }while(0U)
00124 /**
00125   * @}
00126   */
00127 
00128 /* Exported functions --------------------------------------------------------*/
00129 /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
00130   * @{
00131   */
00132 
00133 /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
00134   * @{
00135   */
00136 
00137 /* Extended features functions *************************************************/
00138 /* Blocking mode: Polling */
00139 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
00140                                             uint16_t Size, uint32_t Timeout);
00141 /* Non-Blocking mode: Interrupt */
00142 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
00143                                                uint16_t Size);
00144 /* Non-Blocking mode: DMA */
00145 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
00146                                                 uint16_t Size);
00147 /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
00148 void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
00149 void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
00150 void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
00151 /**
00152   * @}
00153   */
00154 
00155 /**
00156   * @}
00157   */
00158 /* Private types -------------------------------------------------------------*/
00159 /* Private variables ---------------------------------------------------------*/
00160 /* Private constants ---------------------------------------------------------*/
00161 /* Private macros ------------------------------------------------------------*/
00162 
00163 /**
00164   * @}
00165   */
00166 
00167 /* Private functions ---------------------------------------------------------*/
00168 
00169 /**
00170   * @}
00171   */
00172 
00173 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
00174 /**
00175   * @}
00176   */
00177 
00178 #ifdef __cplusplus
00179 }
00180 #endif
00181 
00182 
00183 #endif /* STM32F4xx_HAL_I2S_EX_H */
00184 
00185 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/