my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Parent:
92:4fc01daae5a5
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

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