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:
100:cbbeb26dbd92
.

Who changed what in which revision?

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