I2C_EEPROM

Committer:
jhon309
Date:
Thu Aug 13 00:23:16 2015 +0000
Revision:
0:ac8863619623
I2C

Who changed what in which revision?

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