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