STM32F439xx HAL User Manual
|
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>© 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_EX_H 00038 #define __STM32F4xx_HAL_I2S_EX_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 #if defined(SPI_I2S_FULLDUPLEX_SUPPORT) 00051 /** @addtogroup I2SEx I2SEx 00052 * @{ 00053 */ 00054 00055 /* Exported types ------------------------------------------------------------*/ 00056 /* Exported constants --------------------------------------------------------*/ 00057 /* Exported macros -----------------------------------------------------------*/ 00058 /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros 00059 * @{ 00060 */ 00061 00062 #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE)) 00063 00064 /** @brief Enable or disable the specified I2SExt peripheral. 00065 * @param __HANDLE__ specifies the I2S Handle. 00066 * @retval None 00067 */ 00068 #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE) 00069 #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE) 00070 00071 /** @brief Enable or disable the specified I2SExt interrupts. 00072 * @param __HANDLE__ specifies the I2S Handle. 00073 * @param __INTERRUPT__ specifies the interrupt source to enable or disable. 00074 * This parameter can be one of the following values: 00075 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable 00076 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable 00077 * @arg I2S_IT_ERR: Error interrupt enable 00078 * @retval None 00079 */ 00080 #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__)) 00081 #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__)) 00082 00083 /** @brief Checks if the specified I2SExt interrupt source is enabled or disabled. 00084 * @param __HANDLE__ specifies the I2S Handle. 00085 * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. 00086 * @param __INTERRUPT__ specifies the I2S interrupt source to check. 00087 * This parameter can be one of the following values: 00088 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable 00089 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable 00090 * @arg I2S_IT_ERR: Error interrupt enable 00091 * @retval The new state of __IT__ (TRUE or FALSE). 00092 */ 00093 #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) 00094 00095 /** @brief Checks whether the specified I2SExt flag is set or not. 00096 * @param __HANDLE__ specifies the I2S Handle. 00097 * @param __FLAG__ specifies the flag to check. 00098 * This parameter can be one of the following values: 00099 * @arg I2S_FLAG_RXNE: Receive buffer not empty flag 00100 * @arg I2S_FLAG_TXE: Transmit buffer empty flag 00101 * @arg I2S_FLAG_UDR: Underrun flag 00102 * @arg I2S_FLAG_OVR: Overrun flag 00103 * @arg I2S_FLAG_FRE: Frame error flag 00104 * @arg I2S_FLAG_CHSIDE: Channel Side flag 00105 * @arg I2S_FLAG_BSY: Busy flag 00106 * @retval The new state of __FLAG__ (TRUE or FALSE). 00107 */ 00108 #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__)) 00109 00110 /** @brief Clears the I2SExt OVR pending flag. 00111 * @param __HANDLE__ specifies the I2S Handle. 00112 * @retval None 00113 */ 00114 #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \ 00115 __IO uint32_t tmpreg_ovr = 0x00U; \ 00116 tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\ 00117 tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\ 00118 UNUSED(tmpreg_ovr); \ 00119 }while(0U) 00120 /** @brief Clears the I2SExt UDR pending flag. 00121 * @param __HANDLE__ specifies the I2S Handle. 00122 * @retval None 00123 */ 00124 #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \ 00125 __IO uint32_t tmpreg_udr = 0x00U; \ 00126 tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\ 00127 UNUSED(tmpreg_udr); \ 00128 }while(0U) 00129 /** 00130 * @} 00131 */ 00132 00133 /* Exported functions --------------------------------------------------------*/ 00134 /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions 00135 * @{ 00136 */ 00137 00138 /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions 00139 * @{ 00140 */ 00141 00142 /* Extended features functions *************************************************/ 00143 /* Blocking mode: Polling */ 00144 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, 00145 uint16_t Size, uint32_t Timeout); 00146 /* Non-Blocking mode: Interrupt */ 00147 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, 00148 uint16_t Size); 00149 /* Non-Blocking mode: DMA */ 00150 HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, 00151 uint16_t Size); 00152 /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ 00153 void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s); 00154 void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s); 00155 void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s); 00156 /** 00157 * @} 00158 */ 00159 00160 /** 00161 * @} 00162 */ 00163 /* Private types -------------------------------------------------------------*/ 00164 /* Private variables ---------------------------------------------------------*/ 00165 /* Private constants ---------------------------------------------------------*/ 00166 /* Private macros ------------------------------------------------------------*/ 00167 00168 /** 00169 * @} 00170 */ 00171 00172 /* Private functions ---------------------------------------------------------*/ 00173 00174 /** 00175 * @} 00176 */ 00177 00178 #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */ 00179 /** 00180 * @} 00181 */ 00182 00183 #ifdef __cplusplus 00184 } 00185 #endif 00186 00187 00188 #endif /* __STM32F4xx_HAL_I2S_EX_H */ 00189 00190 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/