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