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