Elijah Orr / mbed-renbed

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Thu Oct 29 08:40:18 2015 +0000
Revision:
109:9296ab0bfc11
Release 109  of the mbed library

Changes:
- new platforms - NUCLEO_F042K6, WIZNWIKI_W7500ECO
- MTS targets - bootloaders update to 0.1.1
- STM F7 - RTC enable fixes
- STM F4 - i2c pending stop before start fix
- STM all targets - analogout normalization fix

Who changed what in which revision?

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