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