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