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