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:
Wed Apr 13 12:29:27 2016 +0000
Revision:
120:2eb10e18b8d7
Parent:
116:c0f6e94411f5
V1.1

Who changed what in which revision?

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