Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
110:165afa46840b
.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 108:34e6b704fe68 1 /**
Kojto 108:34e6b704fe68 2 ******************************************************************************
Kojto 108:34e6b704fe68 3 * @file stm32f4xx_hal_i2s.h
Kojto 108:34e6b704fe68 4 * @author MCD Application Team
Kojto 110:165afa46840b 5 * @version V1.4.1
Kojto 110:165afa46840b 6 * @date 09-October-2015
Kojto 108:34e6b704fe68 7 * @brief Header file of I2S HAL module.
Kojto 108:34e6b704fe68 8 ******************************************************************************
Kojto 108:34e6b704fe68 9 * @attention
Kojto 108:34e6b704fe68 10 *
Kojto 108:34e6b704fe68 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Kojto 108:34e6b704fe68 12 *
Kojto 108:34e6b704fe68 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 108:34e6b704fe68 14 * are permitted provided that the following conditions are met:
Kojto 108:34e6b704fe68 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 108:34e6b704fe68 16 * this list of conditions and the following disclaimer.
Kojto 108:34e6b704fe68 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 108:34e6b704fe68 18 * this list of conditions and the following disclaimer in the documentation
Kojto 108:34e6b704fe68 19 * and/or other materials provided with the distribution.
Kojto 108:34e6b704fe68 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 108:34e6b704fe68 21 * may be used to endorse or promote products derived from this software
Kojto 108:34e6b704fe68 22 * without specific prior written permission.
Kojto 108:34e6b704fe68 23 *
Kojto 108:34e6b704fe68 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 108:34e6b704fe68 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 108:34e6b704fe68 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 108:34e6b704fe68 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 108:34e6b704fe68 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 108:34e6b704fe68 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 108:34e6b704fe68 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 108:34e6b704fe68 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 108:34e6b704fe68 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 108:34e6b704fe68 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 108:34e6b704fe68 34 *
Kojto 108:34e6b704fe68 35 ******************************************************************************
Kojto 108:34e6b704fe68 36 */
Kojto 108:34e6b704fe68 37
Kojto 108:34e6b704fe68 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 108:34e6b704fe68 39 #ifndef __STM32F4xx_HAL_I2S_H
Kojto 108:34e6b704fe68 40 #define __STM32F4xx_HAL_I2S_H
Kojto 108:34e6b704fe68 41
Kojto 108:34e6b704fe68 42 #ifdef __cplusplus
Kojto 108:34e6b704fe68 43 extern "C" {
Kojto 108:34e6b704fe68 44 #endif
Kojto 108:34e6b704fe68 45
Kojto 108:34e6b704fe68 46 /* Includes ------------------------------------------------------------------*/
Kojto 108:34e6b704fe68 47 #include "stm32f4xx_hal_def.h"
Kojto 108:34e6b704fe68 48
Kojto 108:34e6b704fe68 49 /** @addtogroup STM32F4xx_HAL_Driver
Kojto 108:34e6b704fe68 50 * @{
Kojto 108:34e6b704fe68 51 */
Kojto 108:34e6b704fe68 52
Kojto 108:34e6b704fe68 53 /** @addtogroup I2S
Kojto 108:34e6b704fe68 54 * @{
Kojto 108:34e6b704fe68 55 */
Kojto 108:34e6b704fe68 56
Kojto 108:34e6b704fe68 57 /* Exported types ------------------------------------------------------------*/
Kojto 108:34e6b704fe68 58 /** @defgroup I2S_Exported_Types I2S Exported Types
Kojto 108:34e6b704fe68 59 * @{
Kojto 108:34e6b704fe68 60 */
Kojto 108:34e6b704fe68 61
Kojto 108:34e6b704fe68 62 /**
Kojto 108:34e6b704fe68 63 * @brief I2S Init structure definition
Kojto 108:34e6b704fe68 64 */
Kojto 108:34e6b704fe68 65 typedef struct
Kojto 108:34e6b704fe68 66 {
Kojto 108:34e6b704fe68 67 uint32_t Mode; /*!< Specifies the I2S operating mode.
Kojto 108:34e6b704fe68 68 This parameter can be a value of @ref I2S_Mode */
Kojto 108:34e6b704fe68 69
Kojto 108:34e6b704fe68 70 uint32_t Standard; /*!< Specifies the standard used for the I2S communication.
Kojto 108:34e6b704fe68 71 This parameter can be a value of @ref I2S_Standard */
Kojto 108:34e6b704fe68 72
Kojto 108:34e6b704fe68 73 uint32_t DataFormat; /*!< Specifies the data format for the I2S communication.
Kojto 108:34e6b704fe68 74 This parameter can be a value of @ref I2S_Data_Format */
Kojto 108:34e6b704fe68 75
Kojto 108:34e6b704fe68 76 uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not.
Kojto 108:34e6b704fe68 77 This parameter can be a value of @ref I2S_MCLK_Output */
Kojto 108:34e6b704fe68 78
Kojto 108:34e6b704fe68 79 uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication.
Kojto 108:34e6b704fe68 80 This parameter can be a value of @ref I2S_Audio_Frequency */
Kojto 108:34e6b704fe68 81
Kojto 108:34e6b704fe68 82 uint32_t CPOL; /*!< Specifies the idle state of the I2S clock.
Kojto 108:34e6b704fe68 83 This parameter can be a value of @ref I2S_Clock_Polarity */
Kojto 108:34e6b704fe68 84
Kojto 108:34e6b704fe68 85 uint32_t ClockSource; /*!< Specifies the I2S Clock Source.
Kojto 108:34e6b704fe68 86 This parameter can be a value of @ref I2S_Clock_Source */
Kojto 108:34e6b704fe68 87
Kojto 108:34e6b704fe68 88 uint32_t FullDuplexMode; /*!< Specifies the I2S FullDuplex mode.
Kojto 108:34e6b704fe68 89 This parameter can be a value of @ref I2S_FullDuplex_Mode */
Kojto 108:34e6b704fe68 90
Kojto 108:34e6b704fe68 91 }I2S_InitTypeDef;
Kojto 108:34e6b704fe68 92
Kojto 108:34e6b704fe68 93 /**
Kojto 108:34e6b704fe68 94 * @brief HAL State structures definition
Kojto 108:34e6b704fe68 95 */
Kojto 108:34e6b704fe68 96 typedef enum
Kojto 108:34e6b704fe68 97 {
Kojto 108:34e6b704fe68 98 HAL_I2S_STATE_RESET = 0x00, /*!< I2S not yet initialized or disabled */
Kojto 108:34e6b704fe68 99 HAL_I2S_STATE_READY = 0x01, /*!< I2S initialized and ready for use */
Kojto 108:34e6b704fe68 100 HAL_I2S_STATE_BUSY = 0x02, /*!< I2S internal process is ongoing */
Kojto 108:34e6b704fe68 101 HAL_I2S_STATE_BUSY_TX = 0x12, /*!< Data Transmission process is ongoing */
Kojto 108:34e6b704fe68 102 HAL_I2S_STATE_BUSY_RX = 0x22, /*!< Data Reception process is ongoing */
Kojto 108:34e6b704fe68 103 HAL_I2S_STATE_BUSY_TX_RX = 0x32, /*!< Data Transmission and Reception process is ongoing */
Kojto 108:34e6b704fe68 104 HAL_I2S_STATE_TIMEOUT = 0x03, /*!< I2S timeout state */
Kojto 108:34e6b704fe68 105 HAL_I2S_STATE_ERROR = 0x04 /*!< I2S error state */
Kojto 108:34e6b704fe68 106
Kojto 108:34e6b704fe68 107 }HAL_I2S_StateTypeDef;
Kojto 108:34e6b704fe68 108
Kojto 108:34e6b704fe68 109 /**
Kojto 108:34e6b704fe68 110 * @brief I2S handle Structure definition
Kojto 108:34e6b704fe68 111 */
Kojto 108:34e6b704fe68 112 typedef struct
Kojto 108:34e6b704fe68 113 {
Kojto 108:34e6b704fe68 114 SPI_TypeDef *Instance; /* I2S registers base address */
Kojto 108:34e6b704fe68 115
Kojto 108:34e6b704fe68 116 I2S_InitTypeDef Init; /* I2S communication parameters */
Kojto 108:34e6b704fe68 117
Kojto 108:34e6b704fe68 118 uint16_t *pTxBuffPtr; /* Pointer to I2S Tx transfer buffer */
Kojto 108:34e6b704fe68 119
Kojto 108:34e6b704fe68 120 __IO uint16_t TxXferSize; /* I2S Tx transfer size */
Kojto 108:34e6b704fe68 121
Kojto 108:34e6b704fe68 122 __IO uint16_t TxXferCount; /* I2S Tx transfer Counter */
Kojto 108:34e6b704fe68 123
Kojto 108:34e6b704fe68 124 uint16_t *pRxBuffPtr; /* Pointer to I2S Rx transfer buffer */
Kojto 108:34e6b704fe68 125
Kojto 108:34e6b704fe68 126 __IO uint16_t RxXferSize; /* I2S Rx transfer size */
Kojto 108:34e6b704fe68 127
Kojto 108:34e6b704fe68 128 __IO uint16_t RxXferCount; /* I2S Rx transfer counter */
Kojto 108:34e6b704fe68 129
Kojto 108:34e6b704fe68 130 DMA_HandleTypeDef *hdmatx; /* I2S Tx DMA handle parameters */
Kojto 108:34e6b704fe68 131
Kojto 108:34e6b704fe68 132 DMA_HandleTypeDef *hdmarx; /* I2S Rx DMA handle parameters */
Kojto 108:34e6b704fe68 133
Kojto 108:34e6b704fe68 134 __IO HAL_LockTypeDef Lock; /* I2S locking object */
Kojto 108:34e6b704fe68 135
Kojto 108:34e6b704fe68 136 __IO HAL_I2S_StateTypeDef State; /* I2S communication state */
Kojto 108:34e6b704fe68 137
Kojto 108:34e6b704fe68 138 __IO uint32_t ErrorCode; /* I2S Error code */
Kojto 108:34e6b704fe68 139
Kojto 108:34e6b704fe68 140 }I2S_HandleTypeDef;
Kojto 108:34e6b704fe68 141 /**
Kojto 108:34e6b704fe68 142 * @}
Kojto 108:34e6b704fe68 143 */
Kojto 108:34e6b704fe68 144
Kojto 108:34e6b704fe68 145 /* Exported constants --------------------------------------------------------*/
Kojto 108:34e6b704fe68 146 /** @defgroup I2S_Exported_Constants I2S Exported Constants
Kojto 108:34e6b704fe68 147 * @{
Kojto 108:34e6b704fe68 148 */
Kojto 108:34e6b704fe68 149
Kojto 108:34e6b704fe68 150 /** @defgroup I2S_Error_Code I2S Error Code
Kojto 108:34e6b704fe68 151 * @brief I2S Error Code
Kojto 108:34e6b704fe68 152 * @{
Kojto 108:34e6b704fe68 153 */
Kojto 108:34e6b704fe68 154 #define HAL_I2S_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
Kojto 108:34e6b704fe68 155 #define HAL_I2S_ERROR_UDR ((uint32_t)0x00000001) /*!< I2S Underrun error */
Kojto 108:34e6b704fe68 156 #define HAL_I2S_ERROR_OVR ((uint32_t)0x00000002) /*!< I2S Overrun error */
Kojto 108:34e6b704fe68 157 #define HAL_I2SEX_ERROR_UDR ((uint32_t)0x00000004) /*!< I2S extended Underrun error */
Kojto 108:34e6b704fe68 158 #define HAL_I2SEX_ERROR_OVR ((uint32_t)0x00000008) /*!< I2S extended Overrun error */
Kojto 108:34e6b704fe68 159 #define HAL_I2S_ERROR_FRE ((uint32_t)0x00000010) /*!< I2S Frame format error */
Kojto 108:34e6b704fe68 160 #define HAL_I2S_ERROR_DMA ((uint32_t)0x00000020) /*!< DMA transfer error */
Kojto 108:34e6b704fe68 161 /**
Kojto 108:34e6b704fe68 162 * @}
Kojto 108:34e6b704fe68 163 */
Kojto 108:34e6b704fe68 164
Kojto 108:34e6b704fe68 165 /** @defgroup I2S_Mode I2S Mode
Kojto 108:34e6b704fe68 166 * @{
Kojto 108:34e6b704fe68 167 */
Kojto 108:34e6b704fe68 168 #define I2S_MODE_SLAVE_TX ((uint32_t)0x00000000)
Kojto 108:34e6b704fe68 169 #define I2S_MODE_SLAVE_RX ((uint32_t)0x00000100)
Kojto 108:34e6b704fe68 170 #define I2S_MODE_MASTER_TX ((uint32_t)0x00000200)
Kojto 108:34e6b704fe68 171 #define I2S_MODE_MASTER_RX ((uint32_t)0x00000300)
Kojto 108:34e6b704fe68 172 /**
Kojto 108:34e6b704fe68 173 * @}
Kojto 108:34e6b704fe68 174 */
Kojto 108:34e6b704fe68 175
Kojto 108:34e6b704fe68 176 /** @defgroup I2S_Standard I2S Standard
Kojto 108:34e6b704fe68 177 * @{
Kojto 108:34e6b704fe68 178 */
Kojto 108:34e6b704fe68 179 #define I2S_STANDARD_PHILIPS ((uint32_t)0x00000000)
Kojto 108:34e6b704fe68 180 #define I2S_STANDARD_MSB ((uint32_t)0x00000010)
Kojto 108:34e6b704fe68 181 #define I2S_STANDARD_LSB ((uint32_t)0x00000020)
Kojto 108:34e6b704fe68 182 #define I2S_STANDARD_PCM_SHORT ((uint32_t)0x00000030)
Kojto 108:34e6b704fe68 183 #define I2S_STANDARD_PCM_LONG ((uint32_t)0x000000B0)
Kojto 108:34e6b704fe68 184 /**
Kojto 108:34e6b704fe68 185 * @}
Kojto 108:34e6b704fe68 186 */
Kojto 108:34e6b704fe68 187
Kojto 108:34e6b704fe68 188 /** @defgroup I2S_Data_Format I2S Data Format
Kojto 108:34e6b704fe68 189 * @{
Kojto 108:34e6b704fe68 190 */
Kojto 108:34e6b704fe68 191 #define I2S_DATAFORMAT_16B ((uint32_t)0x00000000)
Kojto 108:34e6b704fe68 192 #define I2S_DATAFORMAT_16B_EXTENDED ((uint32_t)0x00000001)
Kojto 108:34e6b704fe68 193 #define I2S_DATAFORMAT_24B ((uint32_t)0x00000003)
Kojto 108:34e6b704fe68 194 #define I2S_DATAFORMAT_32B ((uint32_t)0x00000005)
Kojto 108:34e6b704fe68 195 /**
Kojto 108:34e6b704fe68 196 * @}
Kojto 108:34e6b704fe68 197 */
Kojto 108:34e6b704fe68 198
Kojto 108:34e6b704fe68 199 /** @defgroup I2S_MCLK_Output I2S Mclk Output
Kojto 108:34e6b704fe68 200 * @{
Kojto 108:34e6b704fe68 201 */
Kojto 108:34e6b704fe68 202 #define I2S_MCLKOUTPUT_ENABLE ((uint32_t)SPI_I2SPR_MCKOE)
Kojto 108:34e6b704fe68 203 #define I2S_MCLKOUTPUT_DISABLE ((uint32_t)0x00000000)
Kojto 108:34e6b704fe68 204 /**
Kojto 108:34e6b704fe68 205 * @}
Kojto 108:34e6b704fe68 206 */
Kojto 108:34e6b704fe68 207
Kojto 108:34e6b704fe68 208 /** @defgroup I2S_Audio_Frequency I2S Audio Frequency
Kojto 108:34e6b704fe68 209 * @{
Kojto 108:34e6b704fe68 210 */
Kojto 108:34e6b704fe68 211 #define I2S_AUDIOFREQ_192K ((uint32_t)192000)
Kojto 108:34e6b704fe68 212 #define I2S_AUDIOFREQ_96K ((uint32_t)96000)
Kojto 108:34e6b704fe68 213 #define I2S_AUDIOFREQ_48K ((uint32_t)48000)
Kojto 108:34e6b704fe68 214 #define I2S_AUDIOFREQ_44K ((uint32_t)44100)
Kojto 108:34e6b704fe68 215 #define I2S_AUDIOFREQ_32K ((uint32_t)32000)
Kojto 108:34e6b704fe68 216 #define I2S_AUDIOFREQ_22K ((uint32_t)22050)
Kojto 108:34e6b704fe68 217 #define I2S_AUDIOFREQ_16K ((uint32_t)16000)
Kojto 108:34e6b704fe68 218 #define I2S_AUDIOFREQ_11K ((uint32_t)11025)
Kojto 108:34e6b704fe68 219 #define I2S_AUDIOFREQ_8K ((uint32_t)8000)
Kojto 108:34e6b704fe68 220 #define I2S_AUDIOFREQ_DEFAULT ((uint32_t)2)
Kojto 108:34e6b704fe68 221 /**
Kojto 108:34e6b704fe68 222 * @}
Kojto 108:34e6b704fe68 223 */
Kojto 108:34e6b704fe68 224
Kojto 108:34e6b704fe68 225 /** @defgroup I2S_FullDuplex_Mode I2S FullDuplex Mode
Kojto 108:34e6b704fe68 226 * @{
Kojto 108:34e6b704fe68 227 */
Kojto 108:34e6b704fe68 228 #define I2S_FULLDUPLEXMODE_DISABLE ((uint32_t)0x00000000)
Kojto 108:34e6b704fe68 229 #define I2S_FULLDUPLEXMODE_ENABLE ((uint32_t)0x00000001)
Kojto 108:34e6b704fe68 230 /**
Kojto 108:34e6b704fe68 231 * @}
Kojto 108:34e6b704fe68 232 */
Kojto 108:34e6b704fe68 233
Kojto 108:34e6b704fe68 234 /** @defgroup I2S_Clock_Polarity I2S Clock Polarity
Kojto 108:34e6b704fe68 235 * @{
Kojto 108:34e6b704fe68 236 */
Kojto 108:34e6b704fe68 237 #define I2S_CPOL_LOW ((uint32_t)0x00000000)
Kojto 108:34e6b704fe68 238 #define I2S_CPOL_HIGH ((uint32_t)SPI_I2SCFGR_CKPOL)
Kojto 108:34e6b704fe68 239 /**
Kojto 108:34e6b704fe68 240 * @}
Kojto 108:34e6b704fe68 241 */
Kojto 108:34e6b704fe68 242
Kojto 108:34e6b704fe68 243 /** @defgroup I2S_Interrupts_Definition I2S Interrupts Definition
Kojto 108:34e6b704fe68 244 * @{
Kojto 108:34e6b704fe68 245 */
Kojto 108:34e6b704fe68 246 #define I2S_IT_TXE SPI_CR2_TXEIE
Kojto 108:34e6b704fe68 247 #define I2S_IT_RXNE SPI_CR2_RXNEIE
Kojto 108:34e6b704fe68 248 #define I2S_IT_ERR SPI_CR2_ERRIE
Kojto 108:34e6b704fe68 249 /**
Kojto 108:34e6b704fe68 250 * @}
Kojto 108:34e6b704fe68 251 */
Kojto 108:34e6b704fe68 252
Kojto 108:34e6b704fe68 253 /** @defgroup I2S_Flags_Definition I2S Flags Definition
Kojto 108:34e6b704fe68 254 * @{
Kojto 108:34e6b704fe68 255 */
Kojto 108:34e6b704fe68 256 #define I2S_FLAG_TXE SPI_SR_TXE
Kojto 108:34e6b704fe68 257 #define I2S_FLAG_RXNE SPI_SR_RXNE
Kojto 108:34e6b704fe68 258
Kojto 108:34e6b704fe68 259 #define I2S_FLAG_UDR SPI_SR_UDR
Kojto 108:34e6b704fe68 260 #define I2S_FLAG_OVR SPI_SR_OVR
Kojto 108:34e6b704fe68 261 #define I2S_FLAG_FRE SPI_SR_FRE
Kojto 108:34e6b704fe68 262
Kojto 108:34e6b704fe68 263 #define I2S_FLAG_CHSIDE SPI_SR_CHSIDE
Kojto 108:34e6b704fe68 264 #define I2S_FLAG_BSY SPI_SR_BSY
Kojto 108:34e6b704fe68 265 /**
Kojto 108:34e6b704fe68 266 * @}
Kojto 108:34e6b704fe68 267 */
Kojto 108:34e6b704fe68 268
Kojto 108:34e6b704fe68 269 /**
Kojto 108:34e6b704fe68 270 * @}
Kojto 108:34e6b704fe68 271 */
Kojto 108:34e6b704fe68 272
Kojto 108:34e6b704fe68 273 /* Exported macro ------------------------------------------------------------*/
Kojto 108:34e6b704fe68 274 /** @defgroup I2S_Exported_Macros I2S Exported Macros
Kojto 108:34e6b704fe68 275 * @{
Kojto 108:34e6b704fe68 276 */
Kojto 108:34e6b704fe68 277
Kojto 108:34e6b704fe68 278 /** @brief Reset I2S handle state
Kojto 108:34e6b704fe68 279 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 280 * @retval None
Kojto 108:34e6b704fe68 281 */
Kojto 108:34e6b704fe68 282 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET)
Kojto 108:34e6b704fe68 283
Kojto 108:34e6b704fe68 284 /** @brief Enable or disable the specified SPI peripheral (in I2S mode).
Kojto 108:34e6b704fe68 285 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 286 * @retval None
Kojto 108:34e6b704fe68 287 */
Kojto 108:34e6b704fe68 288 #define __HAL_I2S_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR |= SPI_I2SCFGR_I2SE)
Kojto 108:34e6b704fe68 289 #define __HAL_I2S_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
Kojto 108:34e6b704fe68 290
Kojto 108:34e6b704fe68 291 /** @brief Enable or disable the specified I2S interrupts.
Kojto 108:34e6b704fe68 292 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 293 * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
Kojto 108:34e6b704fe68 294 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 295 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
Kojto 108:34e6b704fe68 296 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
Kojto 108:34e6b704fe68 297 * @arg I2S_IT_ERR: Error interrupt enable
Kojto 108:34e6b704fe68 298 * @retval None
Kojto 108:34e6b704fe68 299 */
Kojto 108:34e6b704fe68 300 #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
Kojto 108:34e6b704fe68 301 #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= ~(__INTERRUPT__))
Kojto 108:34e6b704fe68 302
Kojto 108:34e6b704fe68 303 /** @brief Checks if the specified I2S interrupt source is enabled or disabled.
Kojto 108:34e6b704fe68 304 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 305 * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
Kojto 108:34e6b704fe68 306 * @param __INTERRUPT__: specifies the I2S interrupt source to check.
Kojto 108:34e6b704fe68 307 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 308 * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
Kojto 108:34e6b704fe68 309 * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
Kojto 108:34e6b704fe68 310 * @arg I2S_IT_ERR: Error interrupt enable
Kojto 108:34e6b704fe68 311 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 108:34e6b704fe68 312 */
Kojto 108:34e6b704fe68 313 #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
Kojto 108:34e6b704fe68 314
Kojto 108:34e6b704fe68 315 /** @brief Checks whether the specified I2S flag is set or not.
Kojto 108:34e6b704fe68 316 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 317 * @param __FLAG__: specifies the flag to check.
Kojto 108:34e6b704fe68 318 * This parameter can be one of the following values:
Kojto 108:34e6b704fe68 319 * @arg I2S_FLAG_RXNE: Receive buffer not empty flag
Kojto 108:34e6b704fe68 320 * @arg I2S_FLAG_TXE: Transmit buffer empty flag
Kojto 108:34e6b704fe68 321 * @arg I2S_FLAG_UDR: Underrun flag
Kojto 108:34e6b704fe68 322 * @arg I2S_FLAG_OVR: Overrun flag
Kojto 108:34e6b704fe68 323 * @arg I2S_FLAG_FRE: Frame error flag
Kojto 108:34e6b704fe68 324 * @arg I2S_FLAG_CHSIDE: Channel Side flag
Kojto 108:34e6b704fe68 325 * @arg I2S_FLAG_BSY: Busy flag
Kojto 108:34e6b704fe68 326 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 108:34e6b704fe68 327 */
Kojto 108:34e6b704fe68 328 #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 108:34e6b704fe68 329
Kojto 108:34e6b704fe68 330 /** @brief Clears the I2S OVR pending flag.
Kojto 108:34e6b704fe68 331 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 332 * @retval None
Kojto 108:34e6b704fe68 333 */
Kojto 108:34e6b704fe68 334 #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) \
Kojto 108:34e6b704fe68 335 do{ \
Kojto 108:34e6b704fe68 336 __IO uint32_t tmpreg; \
Kojto 108:34e6b704fe68 337 tmpreg = (__HANDLE__)->Instance->DR; \
Kojto 108:34e6b704fe68 338 tmpreg = (__HANDLE__)->Instance->SR; \
Kojto 108:34e6b704fe68 339 UNUSED(tmpreg); \
Kojto 108:34e6b704fe68 340 } while(0)
Kojto 108:34e6b704fe68 341
Kojto 108:34e6b704fe68 342 /** @brief Clears the I2S UDR pending flag.
Kojto 108:34e6b704fe68 343 * @param __HANDLE__: specifies the I2S Handle.
Kojto 108:34e6b704fe68 344 * @retval None
Kojto 108:34e6b704fe68 345 */
Kojto 108:34e6b704fe68 346 #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) \
Kojto 108:34e6b704fe68 347 do{ \
Kojto 108:34e6b704fe68 348 __IO uint32_t tmpreg; \
Kojto 108:34e6b704fe68 349 tmpreg = (__HANDLE__)->Instance->SR; \
Kojto 108:34e6b704fe68 350 UNUSED(tmpreg); \
Kojto 108:34e6b704fe68 351 } while(0)
Kojto 108:34e6b704fe68 352 /**
Kojto 108:34e6b704fe68 353 * @}
Kojto 108:34e6b704fe68 354 */
Kojto 108:34e6b704fe68 355
Kojto 108:34e6b704fe68 356 /* Include I2S Extension module */
Kojto 108:34e6b704fe68 357 #include "stm32f4xx_hal_i2s_ex.h"
Kojto 108:34e6b704fe68 358
Kojto 108:34e6b704fe68 359 /* Exported functions --------------------------------------------------------*/
Kojto 108:34e6b704fe68 360 /** @addtogroup I2S_Exported_Functions
Kojto 108:34e6b704fe68 361 * @{
Kojto 108:34e6b704fe68 362 */
Kojto 108:34e6b704fe68 363
Kojto 108:34e6b704fe68 364 /** @addtogroup I2S_Exported_Functions_Group1
Kojto 108:34e6b704fe68 365 * @{
Kojto 108:34e6b704fe68 366 */
Kojto 108:34e6b704fe68 367 /* Initialization/de-initialization functions **********************************/
Kojto 108:34e6b704fe68 368 HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 369 HAL_StatusTypeDef HAL_I2S_DeInit (I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 370 void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 371 void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 372 /**
Kojto 108:34e6b704fe68 373 * @}
Kojto 108:34e6b704fe68 374 */
Kojto 108:34e6b704fe68 375
Kojto 108:34e6b704fe68 376 /** @addtogroup I2S_Exported_Functions_Group2
Kojto 108:34e6b704fe68 377 * @{
Kojto 108:34e6b704fe68 378 */
Kojto 108:34e6b704fe68 379 /* I/O operation functions *****************************************************/
Kojto 108:34e6b704fe68 380 /* Blocking mode: Polling */
Kojto 108:34e6b704fe68 381 HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 108:34e6b704fe68 382 HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout);
Kojto 108:34e6b704fe68 383
Kojto 108:34e6b704fe68 384 /* Non-Blocking mode: Interrupt */
Kojto 108:34e6b704fe68 385 HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
Kojto 108:34e6b704fe68 386 HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
Kojto 108:34e6b704fe68 387 void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 388
Kojto 108:34e6b704fe68 389 /* Non-Blocking mode: DMA */
Kojto 108:34e6b704fe68 390 HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
Kojto 108:34e6b704fe68 391 HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size);
Kojto 108:34e6b704fe68 392
Kojto 108:34e6b704fe68 393 HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 394 HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 395 HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 396
Kojto 108:34e6b704fe68 397 /* Peripheral Control and State functions **************************************/
Kojto 108:34e6b704fe68 398 HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 399 uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 400
Kojto 108:34e6b704fe68 401 /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/
Kojto 108:34e6b704fe68 402 void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 403 void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 404 void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 405 void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 406 void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 407 /**
Kojto 108:34e6b704fe68 408 * @}
Kojto 108:34e6b704fe68 409 */
Kojto 108:34e6b704fe68 410
Kojto 108:34e6b704fe68 411 /**
Kojto 108:34e6b704fe68 412 * @}
Kojto 108:34e6b704fe68 413 */
Kojto 108:34e6b704fe68 414
Kojto 108:34e6b704fe68 415 /* Private types -------------------------------------------------------------*/
Kojto 108:34e6b704fe68 416 /* Private variables ---------------------------------------------------------*/
Kojto 108:34e6b704fe68 417 /* Private constants ---------------------------------------------------------*/
Kojto 108:34e6b704fe68 418 /** @defgroup I2S_Private_Constants I2S Private Constants
Kojto 108:34e6b704fe68 419 * @{
Kojto 108:34e6b704fe68 420 */
Kojto 108:34e6b704fe68 421
Kojto 108:34e6b704fe68 422 /**
Kojto 108:34e6b704fe68 423 * @}
Kojto 108:34e6b704fe68 424 */
Kojto 108:34e6b704fe68 425
Kojto 108:34e6b704fe68 426 /* Private macros ------------------------------------------------------------*/
Kojto 108:34e6b704fe68 427 /** @defgroup I2S_Private_Macros I2S Private Macros
Kojto 108:34e6b704fe68 428 * @{
Kojto 108:34e6b704fe68 429 */
Kojto 108:34e6b704fe68 430 #define IS_I2S_MODE(MODE) (((MODE) == I2S_MODE_SLAVE_TX) || \
Kojto 108:34e6b704fe68 431 ((MODE) == I2S_MODE_SLAVE_RX) || \
Kojto 108:34e6b704fe68 432 ((MODE) == I2S_MODE_MASTER_TX) || \
Kojto 108:34e6b704fe68 433 ((MODE) == I2S_MODE_MASTER_RX))
Kojto 108:34e6b704fe68 434
Kojto 108:34e6b704fe68 435 #define IS_I2S_STANDARD(STANDARD) (((STANDARD) == I2S_STANDARD_PHILIPS) || \
Kojto 108:34e6b704fe68 436 ((STANDARD) == I2S_STANDARD_MSB) || \
Kojto 108:34e6b704fe68 437 ((STANDARD) == I2S_STANDARD_LSB) || \
Kojto 108:34e6b704fe68 438 ((STANDARD) == I2S_STANDARD_PCM_SHORT) || \
Kojto 108:34e6b704fe68 439 ((STANDARD) == I2S_STANDARD_PCM_LONG))
Kojto 108:34e6b704fe68 440
Kojto 108:34e6b704fe68 441 #define IS_I2S_DATA_FORMAT(FORMAT) (((FORMAT) == I2S_DATAFORMAT_16B) || \
Kojto 108:34e6b704fe68 442 ((FORMAT) == I2S_DATAFORMAT_16B_EXTENDED) || \
Kojto 108:34e6b704fe68 443 ((FORMAT) == I2S_DATAFORMAT_24B) || \
Kojto 108:34e6b704fe68 444 ((FORMAT) == I2S_DATAFORMAT_32B))
Kojto 108:34e6b704fe68 445
Kojto 108:34e6b704fe68 446 #define IS_I2S_MCLK_OUTPUT(OUTPUT) (((OUTPUT) == I2S_MCLKOUTPUT_ENABLE) || \
Kojto 108:34e6b704fe68 447 ((OUTPUT) == I2S_MCLKOUTPUT_DISABLE))
Kojto 108:34e6b704fe68 448
Kojto 108:34e6b704fe68 449 #define IS_I2S_AUDIO_FREQ(FREQ) ((((FREQ) >= I2S_AUDIOFREQ_8K) && \
Kojto 108:34e6b704fe68 450 ((FREQ) <= I2S_AUDIOFREQ_192K)) || \
Kojto 108:34e6b704fe68 451 ((FREQ) == I2S_AUDIOFREQ_DEFAULT))
Kojto 108:34e6b704fe68 452
Kojto 108:34e6b704fe68 453 #define IS_I2S_FULLDUPLEX_MODE(MODE) (((MODE) == I2S_FULLDUPLEXMODE_DISABLE) || \
Kojto 108:34e6b704fe68 454 ((MODE) == I2S_FULLDUPLEXMODE_ENABLE))
Kojto 108:34e6b704fe68 455
Kojto 108:34e6b704fe68 456 #define IS_I2S_CPOL(CPOL) (((CPOL) == I2S_CPOL_LOW) || \
Kojto 108:34e6b704fe68 457 ((CPOL) == I2S_CPOL_HIGH))
Kojto 110:165afa46840b 458
Kojto 108:34e6b704fe68 459 /**
Kojto 108:34e6b704fe68 460 * @}
Kojto 108:34e6b704fe68 461 */
Kojto 108:34e6b704fe68 462
Kojto 108:34e6b704fe68 463 /* Private functions ---------------------------------------------------------*/
Kojto 108:34e6b704fe68 464 /** @defgroup I2S_Private_Functions I2S Private Functions
Kojto 108:34e6b704fe68 465 * @{
Kojto 108:34e6b704fe68 466 */
Kojto 108:34e6b704fe68 467 void I2S_DMATxCplt(DMA_HandleTypeDef *hdma);
Kojto 108:34e6b704fe68 468 void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
Kojto 108:34e6b704fe68 469 void I2S_DMARxCplt(DMA_HandleTypeDef *hdma);
Kojto 108:34e6b704fe68 470 void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
Kojto 108:34e6b704fe68 471 void I2S_DMAError(DMA_HandleTypeDef *hdma);
Kojto 108:34e6b704fe68 472 HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, uint32_t Status, uint32_t Timeout);
Kojto 108:34e6b704fe68 473 HAL_StatusTypeDef I2S_Transmit_IT(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 474 HAL_StatusTypeDef I2S_Receive_IT(I2S_HandleTypeDef *hi2s);
Kojto 108:34e6b704fe68 475 /**
Kojto 108:34e6b704fe68 476 * @}
Kojto 108:34e6b704fe68 477 */
Kojto 108:34e6b704fe68 478
Kojto 108:34e6b704fe68 479 /**
Kojto 108:34e6b704fe68 480 * @}
Kojto 108:34e6b704fe68 481 */
Kojto 108:34e6b704fe68 482
Kojto 108:34e6b704fe68 483 /**
Kojto 108:34e6b704fe68 484 * @}
Kojto 108:34e6b704fe68 485 */
Kojto 108:34e6b704fe68 486
Kojto 108:34e6b704fe68 487 #ifdef __cplusplus
Kojto 108:34e6b704fe68 488 }
Kojto 108:34e6b704fe68 489 #endif
Kojto 108:34e6b704fe68 490
Kojto 108:34e6b704fe68 491
Kojto 108:34e6b704fe68 492 #endif /* __STM32F4xx_HAL_I2S_H */
Kojto 108:34e6b704fe68 493
Kojto 108:34e6b704fe68 494 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/