mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
93:e188a91d3eaa
Child:
123:b0220dba8be7
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

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