Rev 56 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 56 | Rev 77 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | /** |
1 | /** |
| 2 | ****************************************************************************** |
2 | ****************************************************************************** |
| 3 | * @file stm32l1xx_hal_i2s.h |
3 | * @file stm32l1xx_hal_i2s.h |
| 4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
| 5 | * @brief Header file of I2S HAL module. |
5 | * @brief Header file of I2S HAL module. |
| 6 | ****************************************************************************** |
6 | ****************************************************************************** |
| 7 | * @attention |
7 | * @attention |
| 8 | * |
8 | * |
| 9 | * <h2><center>© Copyright (c) 2016 STMicroelectronics. |
9 | * Copyright (c) 2016 STMicroelectronics. |
| 10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
| 11 | * |
11 | * |
| 12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
| 13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
| 14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
| 15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
| 16 | * |
16 | ****************************************************************************** |
| 17 | ****************************************************************************** |
17 | */ |
| 18 | */ |
18 | |
| 19 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ |
|
| 20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | #ifndef STM32L1xx_HAL_I2S_H |
| 21 | #ifndef STM32L1xx_HAL_I2S_H |
21 | #define STM32L1xx_HAL_I2S_H |
| 22 | #define STM32L1xx_HAL_I2S_H |
22 | |
| 23 | 23 | #ifdef __cplusplus |
|
| 24 | #ifdef __cplusplus |
24 | extern "C" { |
| 25 | extern "C" { |
25 | #endif |
| 26 | #endif |
26 | |
| 27 | 27 | /* Includes ------------------------------------------------------------------*/ |
|
| 28 | /* Includes ------------------------------------------------------------------*/ |
28 | #include "stm32l1xx_hal_def.h" |
| 29 | #include "stm32l1xx_hal_def.h" |
29 | |
| 30 | 30 | #if defined(SPI_I2S_SUPPORT) |
|
| 31 | #if defined(SPI_I2S_SUPPORT) |
31 | /** @addtogroup STM32L1xx_HAL_Driver |
| 32 | /** @addtogroup STM32L1xx_HAL_Driver |
32 | * @{ |
| 33 | * @{ |
33 | */ |
| 34 | */ |
34 | |
| 35 | 35 | /** @addtogroup I2S |
|
| 36 | /** @addtogroup I2S |
36 | * @{ |
| 37 | * @{ |
37 | */ |
| 38 | */ |
38 | |
| 39 | 39 | /* Exported types ------------------------------------------------------------*/ |
|
| 40 | /* Exported types ------------------------------------------------------------*/ |
40 | /** @defgroup I2S_Exported_Types I2S Exported Types |
| 41 | /** @defgroup I2S_Exported_Types I2S Exported Types |
41 | * @{ |
| 42 | * @{ |
42 | */ |
| 43 | */ |
43 | |
| 44 | 44 | /** |
|
| 45 | /** |
45 | * @brief I2S Init structure definition |
| 46 | * @brief I2S Init structure definition |
46 | */ |
| 47 | */ |
47 | typedef struct |
| 48 | typedef struct |
48 | { |
| 49 | { |
49 | uint32_t Mode; /*!< Specifies the I2S operating mode. |
| 50 | uint32_t Mode; /*!< Specifies the I2S operating mode. |
50 | This parameter can be a value of @ref I2S_Mode */ |
| 51 | This parameter can be a value of @ref I2S_Mode */ |
51 | |
| 52 | 52 | uint32_t Standard; /*!< Specifies the standard used for the I2S communication. |
|
| 53 | uint32_t Standard; /*!< Specifies the standard used for the I2S communication. |
53 | This parameter can be a value of @ref I2S_Standard */ |
| 54 | This parameter can be a value of @ref I2S_Standard */ |
54 | |
| 55 | 55 | uint32_t DataFormat; /*!< Specifies the data format for the I2S communication. |
|
| 56 | uint32_t DataFormat; /*!< Specifies the data format for the I2S communication. |
56 | This parameter can be a value of @ref I2S_Data_Format */ |
| 57 | This parameter can be a value of @ref I2S_Data_Format */ |
57 | |
| 58 | 58 | uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not. |
|
| 59 | uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not. |
59 | This parameter can be a value of @ref I2S_MCLK_Output */ |
| 60 | This parameter can be a value of @ref I2S_MCLK_Output */ |
60 | |
| 61 | 61 | uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication. |
|
| 62 | uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication. |
62 | This parameter can be a value of @ref I2S_Audio_Frequency */ |
| 63 | This parameter can be a value of @ref I2S_Audio_Frequency */ |
63 | |
| 64 | 64 | uint32_t CPOL; /*!< Specifies the idle state of the I2S clock. |
|
| 65 | uint32_t CPOL; /*!< Specifies the idle state of the I2S clock. |
65 | This parameter can be a value of @ref I2S_Clock_Polarity */ |
| 66 | This parameter can be a value of @ref I2S_Clock_Polarity */ |
66 | } I2S_InitTypeDef; |
| 67 | } I2S_InitTypeDef; |
67 | |
| 68 | 68 | /** |
|
| 69 | /** |
69 | * @brief HAL State structures definition |
| 70 | * @brief HAL State structures definition |
70 | */ |
| 71 | */ |
71 | typedef enum |
| 72 | typedef enum |
72 | { |
| 73 | { |
73 | HAL_I2S_STATE_RESET = 0x00U, /*!< I2S not yet initialized or disabled */ |
| 74 | HAL_I2S_STATE_RESET = 0x00U, /*!< I2S not yet initialized or disabled */ |
74 | HAL_I2S_STATE_READY = 0x01U, /*!< I2S initialized and ready for use */ |
| 75 | HAL_I2S_STATE_READY = 0x01U, /*!< I2S initialized and ready for use */ |
75 | HAL_I2S_STATE_BUSY = 0x02U, /*!< I2S internal process is ongoing */ |
| 76 | HAL_I2S_STATE_BUSY = 0x02U, /*!< I2S internal process is ongoing */ |
76 | HAL_I2S_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */ |
| 77 | HAL_I2S_STATE_BUSY_TX = 0x03U, /*!< Data Transmission process is ongoing */ |
77 | HAL_I2S_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */ |
| 78 | HAL_I2S_STATE_BUSY_RX = 0x04U, /*!< Data Reception process is ongoing */ |
78 | HAL_I2S_STATE_TIMEOUT = 0x06U, /*!< I2S timeout state */ |
| 79 | HAL_I2S_STATE_TIMEOUT = 0x06U, /*!< I2S timeout state */ |
79 | HAL_I2S_STATE_ERROR = 0x07U /*!< I2S error state */ |
| 80 | HAL_I2S_STATE_ERROR = 0x07U /*!< I2S error state */ |
80 | } HAL_I2S_StateTypeDef; |
| 81 | } HAL_I2S_StateTypeDef; |
81 | |
| 82 | 82 | /** |
|
| 83 | /** |
83 | * @brief I2S handle Structure definition |
| 84 | * @brief I2S handle Structure definition |
84 | */ |
| 85 | */ |
85 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1) |
| 86 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1) |
86 | typedef struct __I2S_HandleTypeDef |
| 87 | typedef struct __I2S_HandleTypeDef |
87 | #else |
| 88 | #else |
88 | typedef struct |
| 89 | typedef struct |
89 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
| 90 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
90 | { |
| 91 | { |
91 | SPI_TypeDef *Instance; /*!< I2S registers base address */ |
| 92 | SPI_TypeDef *Instance; /*!< I2S registers base address */ |
92 | |
| 93 | 93 | I2S_InitTypeDef Init; /*!< I2S communication parameters */ |
|
| 94 | I2S_InitTypeDef Init; /*!< I2S communication parameters */ |
94 | |
| 95 | 95 | uint16_t *pTxBuffPtr; /*!< Pointer to I2S Tx transfer buffer */ |
|
| 96 | uint16_t *pTxBuffPtr; /*!< Pointer to I2S Tx transfer buffer */ |
96 | |
| 97 | 97 | __IO uint16_t TxXferSize; /*!< I2S Tx transfer size */ |
|
| 98 | __IO uint16_t TxXferSize; /*!< I2S Tx transfer size */ |
98 | |
| 99 | 99 | __IO uint16_t TxXferCount; /*!< I2S Tx transfer Counter */ |
|
| 100 | __IO uint16_t TxXferCount; /*!< I2S Tx transfer Counter */ |
100 | |
| 101 | 101 | uint16_t *pRxBuffPtr; /*!< Pointer to I2S Rx transfer buffer */ |
|
| 102 | uint16_t *pRxBuffPtr; /*!< Pointer to I2S Rx transfer buffer */ |
102 | |
| 103 | 103 | __IO uint16_t RxXferSize; /*!< I2S Rx transfer size */ |
|
| 104 | __IO uint16_t RxXferSize; /*!< I2S Rx transfer size */ |
104 | |
| 105 | 105 | __IO uint16_t RxXferCount; /*!< I2S Rx transfer counter |
|
| 106 | __IO uint16_t RxXferCount; /*!< I2S Rx transfer counter |
106 | (This field is initialized at the |
| 107 | (This field is initialized at the |
107 | same value as transfer size at the |
| 108 | same value as transfer size at the |
108 | beginning of the transfer and |
| 109 | beginning of the transfer and |
109 | decremented when a sample is received |
| 110 | decremented when a sample is received |
110 | NbSamplesReceived = RxBufferSize-RxBufferCount) */ |
| 111 | NbSamplesReceived = RxBufferSize-RxBufferCount) */ |
111 | DMA_HandleTypeDef *hdmatx; /*!< I2S Tx DMA handle parameters */ |
| 112 | DMA_HandleTypeDef *hdmatx; /*!< I2S Tx DMA handle parameters */ |
112 | |
| 113 | 113 | DMA_HandleTypeDef *hdmarx; /*!< I2S Rx DMA handle parameters */ |
|
| 114 | DMA_HandleTypeDef *hdmarx; /*!< I2S Rx DMA handle parameters */ |
114 | |
| 115 | 115 | __IO HAL_LockTypeDef Lock; /*!< I2S locking object */ |
|
| 116 | __IO HAL_LockTypeDef Lock; /*!< I2S locking object */ |
116 | |
| 117 | 117 | __IO HAL_I2S_StateTypeDef State; /*!< I2S communication state */ |
|
| 118 | __IO HAL_I2S_StateTypeDef State; /*!< I2S communication state */ |
118 | |
| 119 | 119 | __IO uint32_t ErrorCode; /*!< I2S Error code |
|
| 120 | __IO uint32_t ErrorCode; /*!< I2S Error code |
120 | This parameter can be a value of @ref I2S_Error */ |
| 121 | This parameter can be a value of @ref I2S_Error */ |
121 | |
| 122 | 122 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
|
| 123 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
123 | void (* TxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Tx Completed callback */ |
| 124 | void (* TxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Tx Completed callback */ |
124 | void (* RxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Rx Completed callback */ |
| 125 | void (* RxCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Rx Completed callback */ |
125 | void (* TxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Tx Half Completed callback */ |
| 126 | void (* TxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Tx Half Completed callback */ |
126 | void (* RxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Rx Half Completed callback */ |
| 127 | void (* RxHalfCpltCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Rx Half Completed callback */ |
127 | void (* ErrorCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Error callback */ |
| 128 | void (* ErrorCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Error callback */ |
128 | void (* MspInitCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Msp Init callback */ |
| 129 | void (* MspInitCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Msp Init callback */ |
129 | void (* MspDeInitCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Msp DeInit callback */ |
| 130 | void (* MspDeInitCallback)(struct __I2S_HandleTypeDef *hi2s); /*!< I2S Msp DeInit callback */ |
130 | |
| 131 | 131 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
|
| 132 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
132 | } I2S_HandleTypeDef; |
| 133 | } I2S_HandleTypeDef; |
133 | |
| 134 | 134 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
|
| 135 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
135 | /** |
| 136 | /** |
136 | * @brief HAL I2S Callback ID enumeration definition |
| 137 | * @brief HAL I2S Callback ID enumeration definition |
137 | */ |
| 138 | */ |
138 | typedef enum |
| 139 | typedef enum |
139 | { |
| 140 | { |
140 | HAL_I2S_TX_COMPLETE_CB_ID = 0x00U, /*!< I2S Tx Completed callback ID */ |
| 141 | HAL_I2S_TX_COMPLETE_CB_ID = 0x00U, /*!< I2S Tx Completed callback ID */ |
141 | HAL_I2S_RX_COMPLETE_CB_ID = 0x01U, /*!< I2S Rx Completed callback ID */ |
| 142 | HAL_I2S_RX_COMPLETE_CB_ID = 0x01U, /*!< I2S Rx Completed callback ID */ |
142 | HAL_I2S_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< I2S Tx Half Completed callback ID */ |
| 143 | HAL_I2S_TX_HALF_COMPLETE_CB_ID = 0x03U, /*!< I2S Tx Half Completed callback ID */ |
143 | HAL_I2S_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< I2S Rx Half Completed callback ID */ |
| 144 | HAL_I2S_RX_HALF_COMPLETE_CB_ID = 0x04U, /*!< I2S Rx Half Completed callback ID */ |
144 | HAL_I2S_ERROR_CB_ID = 0x06U, /*!< I2S Error callback ID */ |
| 145 | HAL_I2S_ERROR_CB_ID = 0x06U, /*!< I2S Error callback ID */ |
145 | HAL_I2S_MSPINIT_CB_ID = 0x07U, /*!< I2S Msp Init callback ID */ |
| 146 | HAL_I2S_MSPINIT_CB_ID = 0x07U, /*!< I2S Msp Init callback ID */ |
146 | HAL_I2S_MSPDEINIT_CB_ID = 0x08U /*!< I2S Msp DeInit callback ID */ |
| 147 | HAL_I2S_MSPDEINIT_CB_ID = 0x08U /*!< I2S Msp DeInit callback ID */ |
147 | |
| 148 | 148 | } HAL_I2S_CallbackIDTypeDef; |
|
| 149 | } HAL_I2S_CallbackIDTypeDef; |
149 | |
| 150 | 150 | /** |
|
| 151 | /** |
151 | * @brief HAL I2S Callback pointer definition |
| 152 | * @brief HAL I2S Callback pointer definition |
152 | */ |
| 153 | */ |
153 | typedef void (*pI2S_CallbackTypeDef)(I2S_HandleTypeDef *hi2s); /*!< pointer to an I2S callback function */ |
| 154 | typedef void (*pI2S_CallbackTypeDef)(I2S_HandleTypeDef *hi2s); /*!< pointer to an I2S callback function */ |
154 | |
| 155 | 155 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
|
| 156 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
156 | /** |
| 157 | /** |
157 | * @} |
| 158 | * @} |
158 | */ |
| 159 | */ |
159 | |
| 160 | 160 | /* Exported constants --------------------------------------------------------*/ |
|
| 161 | /* Exported constants --------------------------------------------------------*/ |
161 | /** @defgroup I2S_Exported_Constants I2S Exported Constants |
| 162 | /** @defgroup I2S_Exported_Constants I2S Exported Constants |
162 | * @{ |
| 163 | * @{ |
163 | */ |
| 164 | */ |
164 | /** @defgroup I2S_Error I2S Error |
| 165 | /** @defgroup I2S_Error I2S Error |
165 | * @{ |
| 166 | * @{ |
166 | */ |
| 167 | */ |
167 | #define HAL_I2S_ERROR_NONE (0x00000000U) /*!< No error */ |
| 168 | #define HAL_I2S_ERROR_NONE (0x00000000U) /*!< No error */ |
168 | #define HAL_I2S_ERROR_TIMEOUT (0x00000001U) /*!< Timeout error */ |
| 169 | #define HAL_I2S_ERROR_TIMEOUT (0x00000001U) /*!< Timeout error */ |
169 | #define HAL_I2S_ERROR_OVR (0x00000002U) /*!< OVR error */ |
| 170 | #define HAL_I2S_ERROR_OVR (0x00000002U) /*!< OVR error */ |
170 | #define HAL_I2S_ERROR_UDR (0x00000004U) /*!< UDR error */ |
| 171 | #define HAL_I2S_ERROR_UDR (0x00000004U) /*!< UDR error */ |
171 | #define HAL_I2S_ERROR_DMA (0x00000008U) /*!< DMA transfer error */ |
| 172 | #define HAL_I2S_ERROR_DMA (0x00000008U) /*!< DMA transfer error */ |
172 | #define HAL_I2S_ERROR_PRESCALER (0x00000010U) /*!< Prescaler Calculation error */ |
| 173 | #define HAL_I2S_ERROR_PRESCALER (0x00000010U) /*!< Prescaler Calculation error */ |
173 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
| 174 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
174 | #define HAL_I2S_ERROR_INVALID_CALLBACK (0x00000020U) /*!< Invalid Callback error */ |
| 175 | #define HAL_I2S_ERROR_INVALID_CALLBACK (0x00000020U) /*!< Invalid Callback error */ |
175 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
| 176 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
176 | #define HAL_I2S_ERROR_BUSY_LINE_RX (0x00000040U) /*!< Busy Rx Line error */ |
| 177 | #define HAL_I2S_ERROR_BUSY_LINE_RX (0x00000040U) /*!< Busy Rx Line error */ |
177 | /** |
| 178 | /** |
178 | * @} |
| 179 | * @} |
179 | */ |
| 180 | */ |
180 | |
| 181 | 181 | /** @defgroup I2S_Mode I2S Mode |
|
| 182 | /** @defgroup I2S_Mode I2S Mode |
182 | * @{ |
| 183 | * @{ |
183 | */ |
| 184 | */ |
184 | #define I2S_MODE_SLAVE_TX (0x00000000U) |
| 185 | #define I2S_MODE_SLAVE_TX (0x00000000U) |
185 | #define I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0) |
| 186 | #define I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0) |
186 | #define I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1) |
| 187 | #define I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1) |
187 | #define I2S_MODE_MASTER_RX ((SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1)) |
| 188 | #define I2S_MODE_MASTER_RX ((SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1)) |
188 | /** |
| 189 | /** |
189 | * @} |
| 190 | * @} |
190 | */ |
| 191 | */ |
191 | |
| 192 | 192 | /** @defgroup I2S_Standard I2S Standard |
|
| 193 | /** @defgroup I2S_Standard I2S Standard |
193 | * @{ |
| 194 | * @{ |
194 | */ |
| 195 | */ |
195 | #define I2S_STANDARD_PHILIPS (0x00000000U) |
| 196 | #define I2S_STANDARD_PHILIPS (0x00000000U) |
196 | #define I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0) |
| 197 | #define I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0) |
197 | #define I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1) |
| 198 | #define I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1) |
198 | #define I2S_STANDARD_PCM_SHORT ((SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1)) |
| 199 | #define I2S_STANDARD_PCM_SHORT ((SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1)) |
199 | #define I2S_STANDARD_PCM_LONG ((SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC)) |
| 200 | #define I2S_STANDARD_PCM_LONG ((SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC)) |
200 | /** |
| 201 | /** |
201 | * @} |
| 202 | * @} |
202 | */ |
| 203 | */ |
203 | |
| 204 | 204 | /** @defgroup I2S_Data_Format I2S Data Format |
|
| 205 | /** @defgroup I2S_Data_Format I2S Data Format |
205 | * @{ |
| 206 | * @{ |
206 | */ |
| 207 | */ |
207 | #define I2S_DATAFORMAT_16B (0x00000000U) |
| 208 | #define I2S_DATAFORMAT_16B (0x00000000U) |
208 | #define I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) |
| 209 | #define I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) |
209 | #define I2S_DATAFORMAT_24B ((SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0)) |
| 210 | #define I2S_DATAFORMAT_24B ((SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0)) |
210 | #define I2S_DATAFORMAT_32B ((SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1)) |
| 211 | #define I2S_DATAFORMAT_32B ((SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1)) |
211 | /** |
| 212 | /** |
212 | * @} |
| 213 | * @} |
213 | */ |
| 214 | */ |
214 | |
| 215 | 215 | /** @defgroup I2S_MCLK_Output I2S MCLK Output |
|
| 216 | /** @defgroup I2S_MCLK_Output I2S MCLK Output |
216 | * @{ |
| 217 | * @{ |
217 | */ |
| 218 | */ |
218 | #define I2S_MCLKOUTPUT_ENABLE (SPI_I2SPR_MCKOE) |
| 219 | #define I2S_MCLKOUTPUT_ENABLE (SPI_I2SPR_MCKOE) |
219 | #define I2S_MCLKOUTPUT_DISABLE (0x00000000U) |
| 220 | #define I2S_MCLKOUTPUT_DISABLE (0x00000000U) |
220 | /** |
| 221 | /** |
221 | * @} |
| 222 | * @} |
222 | */ |
| 223 | */ |
223 | |
| 224 | 224 | /** @defgroup I2S_Audio_Frequency I2S Audio Frequency |
|
| 225 | /** @defgroup I2S_Audio_Frequency I2S Audio Frequency |
225 | * @{ |
| 226 | * @{ |
226 | */ |
| 227 | */ |
227 | #define I2S_AUDIOFREQ_192K (192000U) |
| 228 | #define I2S_AUDIOFREQ_192K (192000U) |
228 | #define I2S_AUDIOFREQ_96K (96000U) |
| 229 | #define I2S_AUDIOFREQ_96K (96000U) |
229 | #define I2S_AUDIOFREQ_48K (48000U) |
| 230 | #define I2S_AUDIOFREQ_48K (48000U) |
230 | #define I2S_AUDIOFREQ_44K (44100U) |
| 231 | #define I2S_AUDIOFREQ_44K (44100U) |
231 | #define I2S_AUDIOFREQ_32K (32000U) |
| 232 | #define I2S_AUDIOFREQ_32K (32000U) |
232 | #define I2S_AUDIOFREQ_22K (22050U) |
| 233 | #define I2S_AUDIOFREQ_22K (22050U) |
233 | #define I2S_AUDIOFREQ_16K (16000U) |
| 234 | #define I2S_AUDIOFREQ_16K (16000U) |
234 | #define I2S_AUDIOFREQ_11K (11025U) |
| 235 | #define I2S_AUDIOFREQ_11K (11025U) |
235 | #define I2S_AUDIOFREQ_8K (8000U) |
| 236 | #define I2S_AUDIOFREQ_8K (8000U) |
236 | #define I2S_AUDIOFREQ_DEFAULT (2U) |
| 237 | #define I2S_AUDIOFREQ_DEFAULT (2U) |
237 | /** |
| 238 | /** |
238 | * @} |
| 239 | * @} |
239 | */ |
| 240 | */ |
240 | |
| 241 | 241 | /** @defgroup I2S_Clock_Polarity I2S Clock Polarity |
|
| 242 | /** @defgroup I2S_Clock_Polarity I2S Clock Polarity |
242 | * @{ |
| 243 | * @{ |
243 | */ |
| 244 | */ |
244 | #define I2S_CPOL_LOW (0x00000000U) |
| 245 | #define I2S_CPOL_LOW (0x00000000U) |
245 | #define I2S_CPOL_HIGH (SPI_I2SCFGR_CKPOL) |
| 246 | #define I2S_CPOL_HIGH (SPI_I2SCFGR_CKPOL) |
246 | /** |
| 247 | /** |
247 | * @} |
| 248 | * @} |
248 | */ |
| 249 | */ |
249 | |
| 250 | 250 | /** @defgroup I2S_Interrupts_Definition I2S Interrupts Definition |
|
| 251 | /** @defgroup I2S_Interrupts_Definition I2S Interrupts Definition |
251 | * @{ |
| 252 | * @{ |
252 | */ |
| 253 | */ |
253 | #define I2S_IT_TXE SPI_CR2_TXEIE |
| 254 | #define I2S_IT_TXE SPI_CR2_TXEIE |
254 | #define I2S_IT_RXNE SPI_CR2_RXNEIE |
| 255 | #define I2S_IT_RXNE SPI_CR2_RXNEIE |
255 | #define I2S_IT_ERR SPI_CR2_ERRIE |
| 256 | #define I2S_IT_ERR SPI_CR2_ERRIE |
256 | /** |
| 257 | /** |
257 | * @} |
| 258 | * @} |
258 | */ |
| 259 | */ |
259 | |
| 260 | 260 | /** @defgroup I2S_Flags_Definition I2S Flags Definition |
|
| 261 | /** @defgroup I2S_Flags_Definition I2S Flags Definition |
261 | * @{ |
| 262 | * @{ |
262 | */ |
| 263 | */ |
263 | #define I2S_FLAG_TXE SPI_SR_TXE |
| 264 | #define I2S_FLAG_TXE SPI_SR_TXE |
264 | #define I2S_FLAG_RXNE SPI_SR_RXNE |
| 265 | #define I2S_FLAG_RXNE SPI_SR_RXNE |
265 | |
| 266 | 266 | #define I2S_FLAG_UDR SPI_SR_UDR |
|
| 267 | #define I2S_FLAG_UDR SPI_SR_UDR |
267 | #define I2S_FLAG_OVR SPI_SR_OVR |
| 268 | #define I2S_FLAG_OVR SPI_SR_OVR |
268 | #define I2S_FLAG_FRE SPI_SR_FRE |
| 269 | #define I2S_FLAG_FRE SPI_SR_FRE |
269 | |
| 270 | 270 | #define I2S_FLAG_CHSIDE SPI_SR_CHSIDE |
|
| 271 | #define I2S_FLAG_CHSIDE SPI_SR_CHSIDE |
271 | #define I2S_FLAG_BSY SPI_SR_BSY |
| 272 | #define I2S_FLAG_BSY SPI_SR_BSY |
272 | |
| 273 | 273 | #if defined(SPI_CR2_FRF) |
|
| 274 | #if defined(SPI_CR2_FRF) |
274 | #define I2S_FLAG_MASK (SPI_SR_RXNE\ |
| 275 | #define I2S_FLAG_MASK (SPI_SR_RXNE\ |
275 | | SPI_SR_TXE | SPI_SR_UDR | SPI_SR_OVR | SPI_SR_FRE | SPI_SR_CHSIDE | SPI_SR_BSY) |
| 276 | | SPI_SR_TXE | SPI_SR_UDR | SPI_SR_OVR | SPI_SR_FRE | SPI_SR_CHSIDE | SPI_SR_BSY) |
276 | #else |
| 277 | #else |
277 | #define I2S_FLAG_MASK (SPI_SR_RXNE\ |
| 278 | #define I2S_FLAG_MASK (SPI_SR_RXNE\ |
278 | | SPI_SR_TXE | SPI_SR_UDR | SPI_SR_OVR | SPI_SR_CHSIDE | SPI_SR_BSY) |
| 279 | | SPI_SR_TXE | SPI_SR_UDR | SPI_SR_OVR | SPI_SR_CHSIDE | SPI_SR_BSY) |
279 | #endif |
| 280 | #endif |
280 | /** |
| 281 | /** |
281 | * @} |
| 282 | * @} |
282 | */ |
| 283 | */ |
283 | |
| 284 | 284 | /** |
|
| 285 | /** |
285 | * @} |
| 286 | * @} |
286 | */ |
| 287 | */ |
287 | |
| 288 | 288 | /* Exported macros -----------------------------------------------------------*/ |
|
| 289 | /* Exported macros -----------------------------------------------------------*/ |
289 | /** @defgroup I2S_Exported_macros I2S Exported Macros |
| 290 | /** @defgroup I2S_Exported_macros I2S Exported Macros |
290 | * @{ |
| 291 | * @{ |
291 | */ |
| 292 | */ |
292 | |
| 293 | 293 | /** @brief Reset I2S handle state |
|
| 294 | /** @brief Reset I2S handle state |
294 | * @param __HANDLE__ specifies the I2S Handle. |
| 295 | * @param __HANDLE__ specifies the I2S Handle. |
295 | * @retval None |
| 296 | * @retval None |
296 | */ |
| 297 | */ |
297 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
| 298 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
298 | #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
| 299 | #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) do{ \ |
299 | (__HANDLE__)->State = HAL_I2S_STATE_RESET; \ |
| 300 | (__HANDLE__)->State = HAL_I2S_STATE_RESET; \ |
300 | (__HANDLE__)->MspInitCallback = NULL; \ |
| 301 | (__HANDLE__)->MspInitCallback = NULL; \ |
301 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
| 302 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
302 | } while(0) |
| 303 | } while(0) |
303 | #else |
| 304 | #else |
304 | #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET) |
| 305 | #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET) |
305 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
| 306 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
306 | |
| 307 | 307 | /** @brief Enable the specified SPI peripheral (in I2S mode). |
|
| 308 | /** @brief Enable the specified SPI peripheral (in I2S mode). |
308 | * @param __HANDLE__ specifies the I2S Handle. |
| 309 | * @param __HANDLE__ specifies the I2S Handle. |
309 | * @retval None |
| 310 | * @retval None |
310 | */ |
| 311 | */ |
311 | #define __HAL_I2S_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->I2SCFGR, SPI_I2SCFGR_I2SE)) |
| 312 | #define __HAL_I2S_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->I2SCFGR, SPI_I2SCFGR_I2SE)) |
312 | |
| 313 | 313 | /** @brief Disable the specified SPI peripheral (in I2S mode). |
|
| 314 | /** @brief Disable the specified SPI peripheral (in I2S mode). |
314 | * @param __HANDLE__ specifies the I2S Handle. |
| 315 | * @param __HANDLE__ specifies the I2S Handle. |
315 | * @retval None |
| 316 | * @retval None |
316 | */ |
| 317 | */ |
317 | #define __HAL_I2S_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->I2SCFGR, SPI_I2SCFGR_I2SE)) |
| 318 | #define __HAL_I2S_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->I2SCFGR, SPI_I2SCFGR_I2SE)) |
318 | |
| 319 | 319 | /** @brief Enable the specified I2S interrupts. |
|
| 320 | /** @brief Enable the specified I2S interrupts. |
320 | * @param __HANDLE__ specifies the I2S Handle. |
| 321 | * @param __HANDLE__ specifies the I2S Handle. |
321 | * @param __INTERRUPT__ specifies the interrupt source to enable or disable. |
| 322 | * @param __INTERRUPT__ specifies the interrupt source to enable or disable. |
322 | * This parameter can be one of the following values: |
| 323 | * This parameter can be one of the following values: |
323 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
| 324 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
324 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
| 325 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
325 | * @arg I2S_IT_ERR: Error interrupt enable |
| 326 | * @arg I2S_IT_ERR: Error interrupt enable |
326 | * @retval None |
| 327 | * @retval None |
327 | */ |
| 328 | */ |
328 | #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) (SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))) |
| 329 | #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) (SET_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))) |
329 | |
| 330 | 330 | /** @brief Disable the specified I2S interrupts. |
|
| 331 | /** @brief Disable the specified I2S interrupts. |
331 | * @param __HANDLE__ specifies the I2S Handle. |
| 332 | * @param __HANDLE__ specifies the I2S Handle. |
332 | * @param __INTERRUPT__ specifies the interrupt source to enable or disable. |
| 333 | * @param __INTERRUPT__ specifies the interrupt source to enable or disable. |
333 | * This parameter can be one of the following values: |
| 334 | * This parameter can be one of the following values: |
334 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
| 335 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
335 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
| 336 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
336 | * @arg I2S_IT_ERR: Error interrupt enable |
| 337 | * @arg I2S_IT_ERR: Error interrupt enable |
337 | * @retval None |
| 338 | * @retval None |
338 | */ |
| 339 | */ |
339 | #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) (CLEAR_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))) |
| 340 | #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) (CLEAR_BIT((__HANDLE__)->Instance->CR2,(__INTERRUPT__))) |
340 | |
| 341 | 341 | /** @brief Checks if the specified I2S interrupt source is enabled or disabled. |
|
| 342 | /** @brief Checks if the specified I2S interrupt source is enabled or disabled. |
342 | * @param __HANDLE__ specifies the I2S Handle. |
| 343 | * @param __HANDLE__ specifies the I2S Handle. |
343 | * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. |
| 344 | * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral. |
344 | * @param __INTERRUPT__ specifies the I2S interrupt source to check. |
| 345 | * @param __INTERRUPT__ specifies the I2S interrupt source to check. |
345 | * This parameter can be one of the following values: |
| 346 | * This parameter can be one of the following values: |
346 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
| 347 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
347 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
| 348 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
348 | * @arg I2S_IT_ERR: Error interrupt enable |
| 349 | * @arg I2S_IT_ERR: Error interrupt enable |
349 | * @retval The new state of __IT__ (TRUE or FALSE). |
| 350 | * @retval The new state of __IT__ (TRUE or FALSE). |
350 | */ |
| 351 | */ |
351 | #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\ |
| 352 | #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2\ |
352 | & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
| 353 | & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
353 | |
| 354 | 354 | /** @brief Checks whether the specified I2S flag is set or not. |
|
| 355 | /** @brief Checks whether the specified I2S flag is set or not. |
355 | * @param __HANDLE__ specifies the I2S Handle. |
| 356 | * @param __HANDLE__ specifies the I2S Handle. |
356 | * @param __FLAG__ specifies the flag to check. |
| 357 | * @param __FLAG__ specifies the flag to check. |
357 | * This parameter can be one of the following values: |
| 358 | * This parameter can be one of the following values: |
358 | * @arg I2S_FLAG_RXNE: Receive buffer not empty flag |
| 359 | * @arg I2S_FLAG_RXNE: Receive buffer not empty flag |
359 | * @arg I2S_FLAG_TXE: Transmit buffer empty flag |
| 360 | * @arg I2S_FLAG_TXE: Transmit buffer empty flag |
360 | * @arg I2S_FLAG_UDR: Underrun flag |
| 361 | * @arg I2S_FLAG_UDR: Underrun flag |
361 | * @arg I2S_FLAG_OVR: Overrun flag |
| 362 | * @arg I2S_FLAG_OVR: Overrun flag |
362 | * @arg I2S_FLAG_FRE: Frame error flag |
| 363 | * @arg I2S_FLAG_FRE: Frame error flag |
363 | * @arg I2S_FLAG_CHSIDE: Channel Side flag |
| 364 | * @arg I2S_FLAG_CHSIDE: Channel Side flag |
364 | * @arg I2S_FLAG_BSY: Busy flag |
| 365 | * @arg I2S_FLAG_BSY: Busy flag |
365 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
| 366 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
366 | */ |
| 367 | */ |
367 | #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
| 368 | #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
368 | |
| 369 | 369 | /** @brief Clears the I2S OVR pending flag. |
|
| 370 | /** @brief Clears the I2S OVR pending flag. |
370 | * @param __HANDLE__ specifies the I2S Handle. |
| 371 | * @param __HANDLE__ specifies the I2S Handle. |
371 | * @retval None |
| 372 | * @retval None |
372 | */ |
| 373 | */ |
373 | #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) do{ \ |
| 374 | #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) do{ \ |
374 | __IO uint32_t tmpreg_ovr = 0x00U; \ |
| 375 | __IO uint32_t tmpreg_ovr = 0x00U; \ |
375 | tmpreg_ovr = (__HANDLE__)->Instance->DR; \ |
| 376 | tmpreg_ovr = (__HANDLE__)->Instance->DR; \ |
376 | tmpreg_ovr = (__HANDLE__)->Instance->SR; \ |
| 377 | tmpreg_ovr = (__HANDLE__)->Instance->SR; \ |
377 | UNUSED(tmpreg_ovr); \ |
| 378 | UNUSED(tmpreg_ovr); \ |
378 | }while(0U) |
| 379 | }while(0U) |
379 | /** @brief Clears the I2S UDR pending flag. |
| 380 | /** @brief Clears the I2S UDR pending flag. |
380 | * @param __HANDLE__ specifies the I2S Handle. |
| 381 | * @param __HANDLE__ specifies the I2S Handle. |
381 | * @retval None |
| 382 | * @retval None |
382 | */ |
| 383 | */ |
383 | #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) do{\ |
| 384 | #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) do{\ |
384 | __IO uint32_t tmpreg_udr = 0x00U;\ |
| 385 | __IO uint32_t tmpreg_udr = 0x00U;\ |
385 | tmpreg_udr = ((__HANDLE__)->Instance->SR);\ |
| 386 | tmpreg_udr = ((__HANDLE__)->Instance->SR);\ |
386 | UNUSED(tmpreg_udr); \ |
| 387 | UNUSED(tmpreg_udr); \ |
387 | }while(0U) |
| 388 | }while(0U) |
388 | /** @brief Flush the I2S DR Register. |
| 389 | /** @brief Flush the I2S DR Register. |
389 | * @param __HANDLE__ specifies the I2S Handle. |
| 390 | * @param __HANDLE__ specifies the I2S Handle. |
390 | * @retval None |
| 391 | * @retval None |
391 | */ |
| 392 | */ |
392 | #define __HAL_I2S_FLUSH_RX_DR(__HANDLE__) do{\ |
| 393 | #define __HAL_I2S_FLUSH_RX_DR(__HANDLE__) do{\ |
393 | __IO uint32_t tmpreg_dr = 0x00U;\ |
| 394 | __IO uint32_t tmpreg_dr = 0x00U;\ |
394 | tmpreg_dr = ((__HANDLE__)->Instance->DR);\ |
| 395 | tmpreg_dr = ((__HANDLE__)->Instance->DR);\ |
395 | UNUSED(tmpreg_dr); \ |
| 396 | UNUSED(tmpreg_dr); \ |
396 | }while(0U) |
| 397 | }while(0U) |
397 | /** |
| 398 | /** |
398 | * @} |
| 399 | * @} |
399 | */ |
| 400 | */ |
400 | |
| 401 | 401 | /* Exported functions --------------------------------------------------------*/ |
|
| 402 | /* Exported functions --------------------------------------------------------*/ |
402 | /** @addtogroup I2S_Exported_Functions |
| 403 | /** @addtogroup I2S_Exported_Functions |
403 | * @{ |
| 404 | * @{ |
404 | */ |
| 405 | */ |
405 | |
| 406 | 406 | /** @addtogroup I2S_Exported_Functions_Group1 |
|
| 407 | /** @addtogroup I2S_Exported_Functions_Group1 |
407 | * @{ |
| 408 | * @{ |
408 | */ |
| 409 | */ |
409 | /* Initialization/de-initialization functions ********************************/ |
| 410 | /* Initialization/de-initialization functions ********************************/ |
410 | HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s); |
| 411 | HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s); |
411 | HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s); |
| 412 | HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s); |
412 | void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s); |
| 413 | void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s); |
413 | void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s); |
| 414 | void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s); |
414 | |
| 415 | 415 | /* Callbacks Register/UnRegister functions ***********************************/ |
|
| 416 | /* Callbacks Register/UnRegister functions ***********************************/ |
416 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
| 417 | #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U) |
417 | HAL_StatusTypeDef HAL_I2S_RegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID, |
| 418 | HAL_StatusTypeDef HAL_I2S_RegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID, |
418 | pI2S_CallbackTypeDef pCallback); |
| 419 | pI2S_CallbackTypeDef pCallback); |
419 | HAL_StatusTypeDef HAL_I2S_UnRegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID); |
| 420 | HAL_StatusTypeDef HAL_I2S_UnRegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID); |
420 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
| 421 | #endif /* USE_HAL_I2S_REGISTER_CALLBACKS */ |
421 | /** |
| 422 | /** |
422 | * @} |
| 423 | * @} |
423 | */ |
| 424 | */ |
424 | |
| 425 | 425 | /** @addtogroup I2S_Exported_Functions_Group2 |
|
| 426 | /** @addtogroup I2S_Exported_Functions_Group2 |
426 | * @{ |
| 427 | * @{ |
427 | */ |
| 428 | */ |
428 | /* I/O operation functions ***************************************************/ |
| 429 | /* I/O operation functions ***************************************************/ |
429 | /* Blocking mode: Polling */ |
| 430 | /* Blocking mode: Polling */ |
430 | HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout); |
| 431 | HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout); |
431 | HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout); |
| 432 | HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout); |
432 | |
| 433 | 433 | /* Non-Blocking mode: Interrupt */ |
|
| 434 | /* Non-Blocking mode: Interrupt */ |
434 | HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
| 435 | HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
435 | HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
| 436 | HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
436 | void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s); |
| 437 | void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s); |
437 | |
| 438 | 438 | /* Non-Blocking mode: DMA */ |
|
| 439 | /* Non-Blocking mode: DMA */ |
439 | HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
| 440 | HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
440 | HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
| 441 | HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size); |
441 | |
| 442 | 442 | HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s); |
|
| 443 | HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s); |
443 | HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s); |
| 444 | HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s); |
444 | HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s); |
| 445 | HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s); |
445 | |
| 446 | 446 | /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/ |
|
| 447 | /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/ |
447 | void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s); |
| 448 | void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s); |
448 | void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s); |
| 449 | void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s); |
449 | void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s); |
| 450 | void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s); |
450 | void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s); |
| 451 | void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s); |
451 | void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s); |
| 452 | void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s); |
452 | /** |
| 453 | /** |
453 | * @} |
| 454 | * @} |
454 | */ |
| 455 | */ |
455 | |
| 456 | 456 | /** @addtogroup I2S_Exported_Functions_Group3 |
|
| 457 | /** @addtogroup I2S_Exported_Functions_Group3 |
457 | * @{ |
| 458 | * @{ |
458 | */ |
| 459 | */ |
459 | /* Peripheral Control and State functions ************************************/ |
| 460 | /* Peripheral Control and State functions ************************************/ |
460 | HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s); |
| 461 | HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s); |
461 | uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s); |
| 462 | uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s); |
462 | /** |
| 463 | /** |
463 | * @} |
| 464 | * @} |
464 | */ |
| 465 | */ |
465 | |
| 466 | 466 | /** |
|
| 467 | /** |
467 | * @} |
| 468 | * @} |
468 | */ |
| 469 | */ |
469 | |
| 470 | 470 | /* Private types -------------------------------------------------------------*/ |
|
| 471 | /* Private types -------------------------------------------------------------*/ |
471 | /* Private variables ---------------------------------------------------------*/ |
| 472 | /* Private variables ---------------------------------------------------------*/ |
472 | /* Private constants ---------------------------------------------------------*/ |
| 473 | /* Private constants ---------------------------------------------------------*/ |
473 | /* Private macros ------------------------------------------------------------*/ |
| 474 | /* Private macros ------------------------------------------------------------*/ |
474 | /** @defgroup I2S_Private_Macros I2S Private Macros |
| 475 | /** @defgroup I2S_Private_Macros I2S Private Macros |
475 | * @{ |
| 476 | * @{ |
476 | */ |
| 477 | */ |
477 | |
| 478 | 478 | /** @brief Check whether the specified SPI flag is set or not. |
|
| 479 | /** @brief Check whether the specified SPI flag is set or not. |
479 | * @param __SR__ copy of I2S SR register. |
| 480 | * @param __SR__ copy of I2S SR register. |
480 | * @param __FLAG__ specifies the flag to check. |
| 481 | * @param __FLAG__ specifies the flag to check. |
481 | * This parameter can be one of the following values: |
| 482 | * This parameter can be one of the following values: |
482 | * @arg I2S_FLAG_RXNE: Receive buffer not empty flag |
| 483 | * @arg I2S_FLAG_RXNE: Receive buffer not empty flag |
483 | * @arg I2S_FLAG_TXE: Transmit buffer empty flag |
| 484 | * @arg I2S_FLAG_TXE: Transmit buffer empty flag |
484 | * @arg I2S_FLAG_UDR: Underrun error flag |
| 485 | * @arg I2S_FLAG_UDR: Underrun error flag |
485 | * @arg I2S_FLAG_OVR: Overrun flag |
| 486 | * @arg I2S_FLAG_OVR: Overrun flag |
486 | * @arg I2S_FLAG_CHSIDE: Channel side flag |
| 487 | * @arg I2S_FLAG_CHSIDE: Channel side flag |
487 | * @arg I2S_FLAG_BSY: Busy flag |
| 488 | * @arg I2S_FLAG_BSY: Busy flag |
488 | * @retval SET or RESET. |
| 489 | * @retval SET or RESET. |
489 | */ |
| 490 | */ |
490 | #define I2S_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__)\ |
| 491 | #define I2S_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__)\ |
491 | & ((__FLAG__) & I2S_FLAG_MASK)) == ((__FLAG__) & I2S_FLAG_MASK)) ? SET : RESET) |
| 492 | & ((__FLAG__) & I2S_FLAG_MASK)) == ((__FLAG__) & I2S_FLAG_MASK)) ? SET : RESET) |
492 | |
| 493 | 493 | /** @brief Check whether the specified SPI Interrupt is set or not. |
|
| 494 | /** @brief Check whether the specified SPI Interrupt is set or not. |
494 | * @param __CR2__ copy of I2S CR2 register. |
| 495 | * @param __CR2__ copy of I2S CR2 register. |
495 | * @param __INTERRUPT__ specifies the SPI interrupt source to check. |
| 496 | * @param __INTERRUPT__ specifies the SPI interrupt source to check. |
496 | * This parameter can be one of the following values: |
| 497 | * This parameter can be one of the following values: |
497 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
| 498 | * @arg I2S_IT_TXE: Tx buffer empty interrupt enable |
498 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
| 499 | * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable |
499 | * @arg I2S_IT_ERR: Error interrupt enable |
| 500 | * @arg I2S_IT_ERR: Error interrupt enable |
500 | * @retval SET or RESET. |
| 501 | * @retval SET or RESET. |
501 | */ |
| 502 | */ |
502 | #define I2S_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__)\ |
| 503 | #define I2S_CHECK_IT_SOURCE(__CR2__, __INTERRUPT__) ((((__CR2__)\ |
503 | & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
| 504 | & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
504 | |
| 505 | 505 | /** @brief Checks if I2S Mode parameter is in allowed range. |
|
| 506 | /** @brief Checks if I2S Mode parameter is in allowed range. |
506 | * @param __MODE__ specifies the I2S Mode. |
| 507 | * @param __MODE__ specifies the I2S Mode. |
507 | * This parameter can be a value of @ref I2S_Mode |
| 508 | * This parameter can be a value of @ref I2S_Mode |
508 | * @retval None |
| 509 | * @retval None |
509 | */ |
| 510 | */ |
510 | #define IS_I2S_MODE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \ |
| 511 | #define IS_I2S_MODE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \ |
511 | ((__MODE__) == I2S_MODE_SLAVE_RX) || \ |
| 512 | ((__MODE__) == I2S_MODE_SLAVE_RX) || \ |
512 | ((__MODE__) == I2S_MODE_MASTER_TX) || \ |
| 513 | ((__MODE__) == I2S_MODE_MASTER_TX) || \ |
513 | ((__MODE__) == I2S_MODE_MASTER_RX)) |
| 514 | ((__MODE__) == I2S_MODE_MASTER_RX)) |
514 | |
| 515 | 515 | #define IS_I2S_STANDARD(__STANDARD__) (((__STANDARD__) == I2S_STANDARD_PHILIPS) || \ |
|
| 516 | #define IS_I2S_STANDARD(__STANDARD__) (((__STANDARD__) == I2S_STANDARD_PHILIPS) || \ |
516 | ((__STANDARD__) == I2S_STANDARD_MSB) || \ |
| 517 | ((__STANDARD__) == I2S_STANDARD_MSB) || \ |
517 | ((__STANDARD__) == I2S_STANDARD_LSB) || \ |
| 518 | ((__STANDARD__) == I2S_STANDARD_LSB) || \ |
518 | ((__STANDARD__) == I2S_STANDARD_PCM_SHORT) || \ |
| 519 | ((__STANDARD__) == I2S_STANDARD_PCM_SHORT) || \ |
519 | ((__STANDARD__) == I2S_STANDARD_PCM_LONG)) |
| 520 | ((__STANDARD__) == I2S_STANDARD_PCM_LONG)) |
520 | |
| 521 | 521 | #define IS_I2S_DATA_FORMAT(__FORMAT__) (((__FORMAT__) == I2S_DATAFORMAT_16B) || \ |
|
| 522 | #define IS_I2S_DATA_FORMAT(__FORMAT__) (((__FORMAT__) == I2S_DATAFORMAT_16B) || \ |
522 | ((__FORMAT__) == I2S_DATAFORMAT_16B_EXTENDED) || \ |
| 523 | ((__FORMAT__) == I2S_DATAFORMAT_16B_EXTENDED) || \ |
523 | ((__FORMAT__) == I2S_DATAFORMAT_24B) || \ |
| 524 | ((__FORMAT__) == I2S_DATAFORMAT_24B) || \ |
524 | ((__FORMAT__) == I2S_DATAFORMAT_32B)) |
| 525 | ((__FORMAT__) == I2S_DATAFORMAT_32B)) |
525 | |
| 526 | 526 | #define IS_I2S_MCLK_OUTPUT(__OUTPUT__) (((__OUTPUT__) == I2S_MCLKOUTPUT_ENABLE) || \ |
|
| 527 | #define IS_I2S_MCLK_OUTPUT(__OUTPUT__) (((__OUTPUT__) == I2S_MCLKOUTPUT_ENABLE) || \ |
527 | ((__OUTPUT__) == I2S_MCLKOUTPUT_DISABLE)) |
| 528 | ((__OUTPUT__) == I2S_MCLKOUTPUT_DISABLE)) |
528 | |
| 529 | 529 | #define IS_I2S_AUDIO_FREQ(__FREQ__) ((((__FREQ__) >= I2S_AUDIOFREQ_8K) && \ |
|
| 530 | #define IS_I2S_AUDIO_FREQ(__FREQ__) ((((__FREQ__) >= I2S_AUDIOFREQ_8K) && \ |
530 | ((__FREQ__) <= I2S_AUDIOFREQ_192K)) || \ |
| 531 | ((__FREQ__) <= I2S_AUDIOFREQ_192K)) || \ |
531 | ((__FREQ__) == I2S_AUDIOFREQ_DEFAULT)) |
| 532 | ((__FREQ__) == I2S_AUDIOFREQ_DEFAULT)) |
532 | |
| 533 | 533 | /** @brief Checks if I2S Serial clock steady state parameter is in allowed range. |
|
| 534 | /** @brief Checks if I2S Serial clock steady state parameter is in allowed range. |
534 | * @param __CPOL__ specifies the I2S serial clock steady state. |
| 535 | * @param __CPOL__ specifies the I2S serial clock steady state. |
535 | * This parameter can be a value of @ref I2S_Clock_Polarity |
| 536 | * This parameter can be a value of @ref I2S_Clock_Polarity |
536 | * @retval None |
| 537 | * @retval None |
537 | */ |
| 538 | */ |
538 | #define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_CPOL_LOW) || \ |
| 539 | #define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_CPOL_LOW) || \ |
539 | ((__CPOL__) == I2S_CPOL_HIGH)) |
| 540 | ((__CPOL__) == I2S_CPOL_HIGH)) |
540 | |
| 541 | 541 | /** |
|
| 542 | /** |
542 | * @} |
| 543 | * @} |
543 | */ |
| 544 | */ |
544 | |
| 545 | 545 | /** |
|
| 546 | /** |
546 | * @} |
| 547 | * @} |
547 | */ |
| 548 | */ |
548 | |
| 549 | 549 | /** |
|
| 550 | /** |
550 | * @} |
| 551 | * @} |
551 | */ |
| 552 | */ |
552 | #endif /* SPI_I2S_SUPPORT */ |
| 553 | #endif /* SPI_I2S_SUPPORT */ |
553 | |
| 554 | 554 | #ifdef __cplusplus |
|
| 555 | #ifdef __cplusplus |
555 | } |
| 556 | } |
556 | #endif |
| 557 | #endif |
557 | |
| 558 | 558 | #endif /* STM32L1xx_HAL_I2S_H */ |
|
| 559 | #endif /* STM32L1xx_HAL_I2S_H */ |
559 | |
| 560 | - | ||
| 561 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- | |