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:
Kojto
Date:
Tue Mar 15 14:34:00 2016 +0000
Revision:
116:c0f6e94411f5
Parent:
115:87f2f5183dfb
Release 116 of the mbed library

Changes:
- new targets - NUCLEO_L073RZ
- fixes to IOTSS BEID platform
- LPC824, LPC1549 and LPC11U68 - fix PWMOut SCT bugs
- STM32F7 - Cube driver
- STM32F4 - add RTC LSI macro, defined as 0
- STM32F3 - fix multiple ADC clock initialization
- retarget - binary mode fix for GCC

Who changed what in which revision?

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