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