001
targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_i2s_ex.h@0:13413ea9a877, 2022-06-12 (annotated)
- Committer:
- ganlikun
- Date:
- Sun Jun 12 14:02:44 2022 +0000
- Revision:
- 0:13413ea9a877
00
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ganlikun | 0:13413ea9a877 | 1 | /** |
ganlikun | 0:13413ea9a877 | 2 | ****************************************************************************** |
ganlikun | 0:13413ea9a877 | 3 | * @file stm32f4xx_hal_i2s_ex.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 I2S HAL module. |
ganlikun | 0:13413ea9a877 | 8 | ****************************************************************************** |
ganlikun | 0:13413ea9a877 | 9 | * @attention |
ganlikun | 0:13413ea9a877 | 10 | * |
ganlikun | 0:13413ea9a877 | 11 | * <h2><center>© 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_I2S_EX_H |
ganlikun | 0:13413ea9a877 | 40 | #define __STM32F4xx_HAL_I2S_EX_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(SPI_I2S_FULLDUPLEX_SUPPORT) |
ganlikun | 0:13413ea9a877 | 53 | /** @addtogroup I2SEx I2SEx |
ganlikun | 0:13413ea9a877 | 54 | * @{ |
ganlikun | 0:13413ea9a877 | 55 | */ |
ganlikun | 0:13413ea9a877 | 56 | |
ganlikun | 0:13413ea9a877 | 57 | /* Exported types ------------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 58 | /* Exported constants --------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 59 | /* Exported macros -----------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 60 | /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros |
ganlikun | 0:13413ea9a877 | 61 | * @{ |
ganlikun | 0:13413ea9a877 | 62 | */ |
ganlikun | 0:13413ea9a877 | 63 | |
ganlikun | 0:13413ea9a877 | 64 | #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE)) |
ganlikun | 0:13413ea9a877 | 65 | |
ganlikun | 0:13413ea9a877 | 66 | /** @brief Enable or disable the specified I2SExt peripheral. |
ganlikun | 0:13413ea9a877 | 67 | * @param __HANDLE__: specifies the I2S Handle. |
ganlikun | 0:13413ea9a877 | 68 | * @retval None |
ganlikun | 0:13413ea9a877 | 69 | */ |
ganlikun | 0:13413ea9a877 | 70 | #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE) |
ganlikun | 0:13413ea9a877 | 71 | #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE) |
ganlikun | 0:13413ea9a877 | 72 | |
ganlikun | 0:13413ea9a877 | 73 | /** @brief Enable or disable the specified I2SExt interrupts. |
ganlikun | 0:13413ea9a877 | 74 | * @param __HANDLE__: specifies the I2S Handle. |
ganlikun | 0:13413ea9a877 | 75 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable. |
ganlikun | 0:13413ea9a877 | 76 | * This parameter can be one of the following values: |
ganlikun | 0:13413ea9a877 | 77 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
ganlikun | 0:13413ea9a877 | 78 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
ganlikun | 0:13413ea9a877 | 79 | * @arg I2S_IT_ERR: Error interrupt enable |
ganlikun | 0:13413ea9a877 | 80 | * @retval None |
ganlikun | 0:13413ea9a877 | 81 | */ |
ganlikun | 0:13413ea9a877 | 82 | #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__)) |
ganlikun | 0:13413ea9a877 | 83 | #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__)) |
ganlikun | 0:13413ea9a877 | 84 | |
ganlikun | 0:13413ea9a877 | 85 | /** @brief Checks if the specified I2SExt interrupt source is enabled or disabled. |
ganlikun | 0:13413ea9a877 | 86 | * @param __HANDLE__: specifies the I2S Handle. |
ganlikun | 0:13413ea9a877 | 87 | * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. |
ganlikun | 0:13413ea9a877 | 88 | * @param __INTERRUPT__: specifies the I2S interrupt source to check. |
ganlikun | 0:13413ea9a877 | 89 | * This parameter can be one of the following values: |
ganlikun | 0:13413ea9a877 | 90 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
ganlikun | 0:13413ea9a877 | 91 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
ganlikun | 0:13413ea9a877 | 92 | * @arg I2S_IT_ERR: Error interrupt enable |
ganlikun | 0:13413ea9a877 | 93 | * @retval The new state of __IT__ (TRUE or FALSE). |
ganlikun | 0:13413ea9a877 | 94 | */ |
ganlikun | 0:13413ea9a877 | 95 | #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
ganlikun | 0:13413ea9a877 | 96 | |
ganlikun | 0:13413ea9a877 | 97 | /** @brief Checks whether the specified I2SExt flag is set or not. |
ganlikun | 0:13413ea9a877 | 98 | * @param __HANDLE__: specifies the I2S Handle. |
ganlikun | 0:13413ea9a877 | 99 | * @param __FLAG__: specifies the flag to check. |
ganlikun | 0:13413ea9a877 | 100 | * This parameter can be one of the following values: |
ganlikun | 0:13413ea9a877 | 101 | * @arg I2S_FLAG_RXNE: Receive buffer not empty flag |
ganlikun | 0:13413ea9a877 | 102 | * @arg I2S_FLAG_TXE: Transmit buffer empty flag |
ganlikun | 0:13413ea9a877 | 103 | * @arg I2S_FLAG_UDR: Underrun flag |
ganlikun | 0:13413ea9a877 | 104 | * @arg I2S_FLAG_OVR: Overrun flag |
ganlikun | 0:13413ea9a877 | 105 | * @arg I2S_FLAG_FRE: Frame error flag |
ganlikun | 0:13413ea9a877 | 106 | * @arg I2S_FLAG_CHSIDE: Channel Side flag |
ganlikun | 0:13413ea9a877 | 107 | * @arg I2S_FLAG_BSY: Busy flag |
ganlikun | 0:13413ea9a877 | 108 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
ganlikun | 0:13413ea9a877 | 109 | */ |
ganlikun | 0:13413ea9a877 | 110 | #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__)) |
ganlikun | 0:13413ea9a877 | 111 | |
ganlikun | 0:13413ea9a877 | 112 | /** @brief Clears the I2SExt OVR pending flag. |
ganlikun | 0:13413ea9a877 | 113 | * @param __HANDLE__: specifies the I2S Handle. |
ganlikun | 0:13413ea9a877 | 114 | * @retval None |
ganlikun | 0:13413ea9a877 | 115 | */ |
ganlikun | 0:13413ea9a877 | 116 | #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \ |
ganlikun | 0:13413ea9a877 | 117 | __IO uint32_t tmpreg_ovr = 0x00U; \ |
ganlikun | 0:13413ea9a877 | 118 | tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\ |
ganlikun | 0:13413ea9a877 | 119 | tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\ |
ganlikun | 0:13413ea9a877 | 120 | UNUSED(tmpreg_ovr); \ |
ganlikun | 0:13413ea9a877 | 121 | }while(0U) |
ganlikun | 0:13413ea9a877 | 122 | /** @brief Clears the I2SExt UDR pending flag. |
ganlikun | 0:13413ea9a877 | 123 | * @param __HANDLE__: specifies the I2S Handle. |
ganlikun | 0:13413ea9a877 | 124 | * @retval None |
ganlikun | 0:13413ea9a877 | 125 | */ |
ganlikun | 0:13413ea9a877 | 126 | #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \ |
ganlikun | 0:13413ea9a877 | 127 | __IO uint32_t tmpreg_udr = 0x00U; \ |
ganlikun | 0:13413ea9a877 | 128 | tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\ |
ganlikun | 0:13413ea9a877 | 129 | UNUSED(tmpreg_udr); \ |
ganlikun | 0:13413ea9a877 | 130 | }while(0U) |
ganlikun | 0:13413ea9a877 | 131 | /** |
ganlikun | 0:13413ea9a877 | 132 | * @} |
ganlikun | 0:13413ea9a877 | 133 | */ |
ganlikun | 0:13413ea9a877 | 134 | |
ganlikun | 0:13413ea9a877 | 135 | /* Exported functions --------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 136 | /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions |
ganlikun | 0:13413ea9a877 | 137 | * @{ |
ganlikun | 0:13413ea9a877 | 138 | */ |
ganlikun | 0:13413ea9a877 | 139 | |
ganlikun | 0:13413ea9a877 | 140 | /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions |
ganlikun | 0:13413ea9a877 | 141 | * @{ |
ganlikun | 0:13413ea9a877 | 142 | */ |
ganlikun | 0:13413ea9a877 | 143 | |
ganlikun | 0:13413ea9a877 | 144 | /* Extended features functions *************************************************/ |
ganlikun | 0:13413ea9a877 | 145 | /* Blocking mode: Polling */ |
ganlikun | 0:13413ea9a877 | 146 | HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, |
ganlikun | 0:13413ea9a877 | 147 | uint16_t Size, uint32_t Timeout); |
ganlikun | 0:13413ea9a877 | 148 | /* Non-Blocking mode: Interrupt */ |
ganlikun | 0:13413ea9a877 | 149 | HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, |
ganlikun | 0:13413ea9a877 | 150 | uint16_t Size); |
ganlikun | 0:13413ea9a877 | 151 | /* Non-Blocking mode: DMA */ |
ganlikun | 0:13413ea9a877 | 152 | HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, |
ganlikun | 0:13413ea9a877 | 153 | uint16_t Size); |
ganlikun | 0:13413ea9a877 | 154 | /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ |
ganlikun | 0:13413ea9a877 | 155 | void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s); |
ganlikun | 0:13413ea9a877 | 156 | void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s); |
ganlikun | 0:13413ea9a877 | 157 | /** |
ganlikun | 0:13413ea9a877 | 158 | * @} |
ganlikun | 0:13413ea9a877 | 159 | */ |
ganlikun | 0:13413ea9a877 | 160 | |
ganlikun | 0:13413ea9a877 | 161 | /** |
ganlikun | 0:13413ea9a877 | 162 | * @} |
ganlikun | 0:13413ea9a877 | 163 | */ |
ganlikun | 0:13413ea9a877 | 164 | /* Private types -------------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 165 | /* Private variables ---------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 166 | /* Private constants ---------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 167 | /* Private macros ------------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 168 | |
ganlikun | 0:13413ea9a877 | 169 | /** |
ganlikun | 0:13413ea9a877 | 170 | * @} |
ganlikun | 0:13413ea9a877 | 171 | */ |
ganlikun | 0:13413ea9a877 | 172 | |
ganlikun | 0:13413ea9a877 | 173 | /* Private functions ---------------------------------------------------------*/ |
ganlikun | 0:13413ea9a877 | 174 | |
ganlikun | 0:13413ea9a877 | 175 | /** |
ganlikun | 0:13413ea9a877 | 176 | * @} |
ganlikun | 0:13413ea9a877 | 177 | */ |
ganlikun | 0:13413ea9a877 | 178 | |
ganlikun | 0:13413ea9a877 | 179 | #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */ |
ganlikun | 0:13413ea9a877 | 180 | /** |
ganlikun | 0:13413ea9a877 | 181 | * @} |
ganlikun | 0:13413ea9a877 | 182 | */ |
ganlikun | 0:13413ea9a877 | 183 | |
ganlikun | 0:13413ea9a877 | 184 | #ifdef __cplusplus |
ganlikun | 0:13413ea9a877 | 185 | } |
ganlikun | 0:13413ea9a877 | 186 | #endif |
ganlikun | 0:13413ea9a877 | 187 | |
ganlikun | 0:13413ea9a877 | 188 | |
ganlikun | 0:13413ea9a877 | 189 | #endif /* __STM32F4xx_HAL_I2S_EX_H */ |
ganlikun | 0:13413ea9a877 | 190 | |
ganlikun | 0:13413ea9a877 | 191 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
ganlikun | 0:13413ea9a877 | 192 |