Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
99:dbbf35b96557
.

Who changed what in which revision?

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