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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
<>
Date:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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