mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Tue Jun 24 14:45:08 2014 +0100
Revision:
237:f3da66175598
Child:
375:3d36234a1087
Synchronized with git revision 8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7

Full URL: https://github.com/mbedmicro/mbed/commit/8ef659bca81f12dfc896b5a7af7c2abbd1a1b8b7/

[NUCLEO_F334R8] Add platform files

Who changed what in which revision?

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