gr55xx_hal_i2s.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_i2s.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of I2S HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_I2S I2S
47  * @brief I2S HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_I2S_H__
53 #define __GR55xx_HAL_I2S_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_i2s.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_I2S_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /** @defgroup HAL_I2S_state HAL I2S state
69  * @{
70  */
71 
72 /**
73  * @brief HAL I2S State Enumerations definition
74  */
75 typedef enum
76 {
77  HAL_I2S_STATE_RESET = 0x00, /**< Peripheral not initialized */
78  HAL_I2S_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
79  HAL_I2S_STATE_BUSY = 0x02, /**< An internal process is ongoing */
80  HAL_I2S_STATE_BUSY_TX = 0x12, /**< Data Transmission process is ongoing */
81  HAL_I2S_STATE_BUSY_RX = 0x22, /**< Data Reception process is ongoing */
82  HAL_I2S_STATE_BUSY_TX_RX = 0x32, /**< Data Transmission and Reception process is ongoing */
83  HAL_I2S_STATE_ABORT = 0x08, /**< Peripheral with abort request ongoing */
84  HAL_I2S_STATE_ERROR = 0x04 /**< Peripheral in error */
85 
87 
88 /** @} */
89 
90 /** @} */
91 
92 /** @addtogroup HAL_I2S_STRUCTURES Structures
93  * @{
94  */
95 
96 /** @defgroup I2S_Configuration I2S Configuration
97  * @{
98  */
99 
100 /**
101  * @brief I2S init Structure definition
102  */
103 typedef struct _i2s_init
104 {
105  uint32_t data_size; /**< Specifies the data size for I2S communication.
106  This parameter can be a value of @ref I2S_Data_Size */
107 
108  uint32_t clock_source; /**< Specifies the source of the I2S clock.
109  This parameter can be a value of @ref I2S_Clock_Source */
110 
111  uint32_t audio_freq; /**< Specifies the frequency selected for the I2S communication.
112  @note The communication clock is derived from the master
113  clock. The slave clock does not need to be set. */
114 #if I2S_CHANNEL_NUM > 1
115  uint32_t channel_active; /**< Specifies the active channels for I2S communication.
116  This parameter can be one or more value of @ref I2S_Channel */
117 #endif
118 
120 /** @} */
121 
122 /** @defgroup I2S_handle I2S handle
123  * @{
124  */
125 
126 /**
127  * @brief I2S handle Structure definition
128  */
129 typedef struct _i2s_handle
130 {
131  i2s_regs_t *p_instance; /**< I2S registers base address */
132 
133  i2s_init_t init; /**< I2S communication parameters */
134 
135  uint16_t *p_tx_buffer; /**< Pointer to I2S TX transfer Buffer */
136 
137  __IO uint32_t tx_xfer_size; /**< I2S TX Transfer size */
138 
139  __IO uint32_t tx_xfer_count; /**< I2S TX Transfer Counter */
140 
141  uint16_t *p_rx_buffer; /**< Pointer to I2S RX transfer Buffer */
142 
143  __IO uint32_t rx_xfer_size; /**< I2S RX Transfer size */
144 
145  __IO uint32_t rx_xfer_count; /**< I2S RX Transfer Counter */
146 
147  void (*write_fifo)(struct _i2s_handle *p_i2s); /**< Pointer to I2S Tx transfer FIFO write function */
148 
149  void (*read_fifo)(struct _i2s_handle *p_i2s); /**< Pointer to I2S Rx transfer FIFO read function */
150 
151  dma_handle_t *p_dmatx; /**< I2S TX DMA Handle parameters */
152 
153  dma_handle_t *p_dmarx; /**< I2S RX DMA Handle parameters */
154 
155  __IO hal_lock_t lock; /**< Locking object */
156 
157  __IO hal_i2s_state_t state; /**< I2S communication state */
158 
159  __IO uint32_t error_code; /**< I2S Error code */
160 
161  uint32_t timeout; /**< Timeout for the I2S memory access */
162 
163  uint32_t retention[7]; /**< I2S important register information. */
165 /** @} */
166 
167 /** @} */
168 
169 /** @addtogroup HAL_I2S_CALLBACK_STRUCTURES Callback Structures
170  * @{
171  */
172 
173 /** @defgroup HAL_I2S_Callback Callback
174  * @{
175  */
176 
177 /**
178  * @brief HAL_I2S Callback function definition
179  */
180 
181 typedef struct _hal_i2s_callback
182 {
183  void (*i2s_msp_init)(i2s_handle_t *p_i2s); /**< I2S init MSP callback */
184  void (*i2s_msp_deinit)(i2s_handle_t *p_i2s); /**< I2S de-init MSP callback */
185  void (*i2s_error_callback)(i2s_handle_t *p_i2s); /**< I2S error callback */
186  void (*i2s_rx_cplt_callback)(i2s_handle_t *p_i2s); /**< I2S rx transfer completed callback */
187  void (*i2s_tx_cplt_callback)(i2s_handle_t *p_i2s); /**< I2S tx transfer completed callbac */
188  void (*i2s_tx_rx_cplt_callback)(i2s_handle_t *p_i2s); /**< I2S tx/rx transfer completed callback */
190 
191 /** @} */
192 
193 /** @} */
194 
195 /**
196  * @defgroup HAL_I2S_MACRO Defines
197  * @{
198  */
199 
200 /* Exported constants --------------------------------------------------------*/
201 /** @defgroup I2S_Exported_Constants I2S Exported Constants
202  * @{
203  */
204 
205 /** @defgroup I2S_Direction I2S Direction
206  * @{
207  */
208 #define I2S_DIRECTION_FULL_DUPLEX LL_I2S_FULL_DUPLEX /**< Full Duplex: Transmit & Receive */
209 #define I2S_DIRECTION_SIMPLEX_TX LL_I2S_SIMPLEX_TX /**< Simplex TX: Transmit only */
210 #define I2S_DIRECTION_SIMPLEX_RX LL_I2S_SIMPLEX_RX /**< Simplex RX: Receive only */
211 /** @} */
212 
213 /** @defgroup I2S_Error_Code I2S Error Code
214  * @{
215  */
216 #define HAL_I2S_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
217 #define HAL_I2S_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
218 #define HAL_I2S_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
219 #define HAL_I2S_ERROR_DMA ((uint32_t)0x00000004) /**< DMA transfer error */
220 #define HAL_I2S_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
221 /** @} */
222 
223 /** @defgroup I2S_Data_Size I2S Data Size
224  * @{
225  */
226 #define I2S_DATASIZE_12BIT LL_I2S_DATASIZE_12BIT /**< 12-bit serial data transfer */
227 #define I2S_DATASIZE_16BIT LL_I2S_DATASIZE_16BIT /**< 16-bit serial data transfer */
228 #define I2S_DATASIZE_20BIT LL_I2S_DATASIZE_20BIT /**< 20-bit serial data transfer */
229 #define I2S_DATASIZE_24BIT LL_I2S_DATASIZE_24BIT /**< 24-bit serial data transfer */
230 #define I2S_DATASIZE_32BIT LL_I2S_DATASIZE_32BIT /**< 32-bit serial data transfer */
231 /** @} */
232 
233 /** @defgroup I2S_Clock_Source I2S Clock Source
234  * @{
235  */
236 #define I2S_CLOCK_SRC_96M LL_I2S_CLOCK_SRC_96M /**< Inactive state of SCLK is low */
237 #define I2S_CLOCK_SRC_32M LL_I2S_CLOCK_SRC_32M /**< Inactive state of SCLK is high */
238 /** @} */
239 
240 /** @defgroup I2S_FIFO_LEVEL_MAX I2S FIFO Level Max
241  * @{
242  */
243 #define I2S_TX_FIFO_LEVEL_MAX 16 /**< I2S TX FIFO Level Max Value */
244 #define I2S_RX_FIFO_LEVEL_MAX 16 /**< I2S RX FIFO Level Max Value */
245 /** @} */
246 
247 /** @defgroup I2S_Flags_definition I2S Flags Definition
248  * @{
249  */
250 #define I2S_FLAG_TXFO LL_I2S_STATUS_TXFO /**< TX FIFO write overflow flag */
251 #define I2S_FLAG_TXFE LL_I2S_STATUS_TXFE /**< TX FIFO empty trigger flag */
252 #define I2S_FLAG_RXFO LL_I2S_STATUS_RXFO /**< RX FIFO receive overflow flag */
253 #define I2S_FLAG_RXDA LL_I2S_STATUS_RXDA /**< RX FIFO data available flag */
254 /** @} */
255 
256 /** @defgroup I2S_Interrupt_definition I2S Interrupt Definition
257  * @{
258  */
259 #define I2S_IT_TXFO LL_I2S_INT_TXFO /**< TX FIFO write overflow interrupt */
260 #define I2S_IT_TXFE LL_I2S_INT_TXFE /**< TX FIFO empty trigger interrupt */
261 #define I2S_IT_RXFO LL_I2S_INT_RXFO /**< RX FIFO receive overflow interrupt */
262 #define I2S_IT_RXDA LL_I2S_INT_RXDA /**< RX FIFO data available interrupt */
263 /** @} */
264 
265 /** @defgroup I2S_Timeout_definition I2S Timeout_definition
266  * @{
267  */
268 #define HAL_I2S_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
269 /** @} */
270 
271 /** @} */
272 
273 /* Exported macro ------------------------------------------------------------*/
274 /** @defgroup I2S_Exported_Macros I2S Exported Macros
275  * @{
276  */
277 
278 /** @brief Reset I2S handle states.
279  * @param __HANDLE__ I2S handle.
280  * @retval None
281  */
282 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_I2S_STATE_RESET)
283 
284 /** @brief Enable the specified I2S peripheral.
285  * @param __HANDLE__ Specifies the I2S Handle.
286  * @retval None
287  */
288 #define __HAL_I2S_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->ENABLE, I2S_ENABLE_EN)
289 
290 /** @brief Disable the specified I2S peripheral.
291  * @param __HANDLE__ Specifies the I2S Handle.
292  * @retval None
293  */
294 #define __HAL_I2S_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->ENABLE, I2S_ENABLE_EN)
295 
296 /** @brief Enable the specified I2S clock.
297  * @param __HANDLE__ Specifies the I2S Handle.
298  * @retval None
299  */
300 #define __HAL_I2S_ENABLE_CLOCK(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CLKEN, I2S_CLKEN_EN)
301 
302 /** @brief Disable the specified I2S clock.
303  * @param __HANDLE__ Specifies the I2S Handle.
304  * @retval None
305  */
306 #define __HAL_I2S_DISABLE_CLOCK(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CLKEN, I2S_CLKEN_EN)
307 
308 /** @brief Enable the specified I2S transmitter block.
309  * @param __HANDLE__ Specifies the I2S Handle.
310  * @retval None
311  */
312 #define __HAL_I2S_ENABLE_TX_BLOCK(__HANDLE__) ll_i2s_enable_txblock((__HANDLE__)->p_instance)
313 
314 /** @brief Disable the specified I2S transmitter block.
315  * @param __HANDLE__ Specifies the I2S Handle.
316  * @retval None
317  */
318 #define __HAL_I2S_DISABLE_TX_BLOCK(__HANDLE__) ll_i2s_disable_txblock((__HANDLE__)->p_instance)
319 
320 /** @brief Enable the specified I2S receiver block.
321  * @param __HANDLE__ Specifies the I2S Handle.
322  * @retval None
323  */
324 #define __HAL_I2S_ENABLE_RX_BLOCK(__HANDLE__) ll_i2s_enable_rxblock((__HANDLE__)->p_instance)
325 
326 /** @brief Disable the specified I2S receiver block.
327  * @param __HANDLE__ Specifies the I2S Handle.
328  * @retval None
329  */
330 #define __HAL_I2S_DISABLE_RX_BLOCK(__HANDLE__) ll_i2s_disable_rxblock((__HANDLE__)->p_instance)
331 
332 /** @brief Enable the specified I2S transmitter channel.
333  * @param __HANDLE__ Specifies the I2S Handle.
334  * @param __CH__ Specifies the I2S channel.
335  * @retval None
336  */
337 #define __HAL_I2S_ENABLE_TX_CHANNEL(__HANDLE__, __CH__) ll_i2s_enable_tx((__HANDLE__)->p_instance, (__CH__))
338 
339 /** @brief Disable the specified I2S transmitter channel.
340  * @param __HANDLE__ Specifies the I2S Handle.
341  * @param __CH__ Specifies the I2S channel.
342  * @retval None
343  */
344 #define __HAL_I2S_DISABLE_TX_CHANNEL(__HANDLE__, __CH__) ll_i2s_disable_tx((__HANDLE__)->p_instance, (__CH__))
345 
346 /** @brief Enable the specified I2S receiver channel.
347  * @param __HANDLE__ Specifies the I2S Handle.
348  * @param __CH__ Specifies the I2S channel.
349  * @retval None
350  */
351 #define __HAL_I2S_ENABLE_RX_CHANNEL(__HANDLE__, __CH__) ll_i2s_enable_rx((__HANDLE__)->p_instance, (__CH__))
352 
353 /** @brief Disable the specified I2S receiver channel.
354  * @param __HANDLE__ Specifies the I2S Handle.
355  * @param __CH__ Specifies the I2S channel.
356  * @retval None
357  */
358 #define __HAL_I2S_DISABLE_RX_CHANNEL(__HANDLE__, __CH__) ll_i2s_disable_rx((__HANDLE__)->p_instance, (__CH__))
359 
360 /** @brief Flush the I2S transmitter FIFO.
361  * @param __HANDLE__ Specifies the I2S Handle.
362  * @retval None
363  */
364 #define __HAL_I2S_FLUSH_TX_FIFO(__HANDLE__) ll_i2s_clr_txfifo_all((__HANDLE__)->p_instance)
365 
366 /** @brief Flush the I2S receiver FIFO.
367  * @param __HANDLE__ Specifies the I2S Handle.
368  * @retval None
369  */
370 #define __HAL_I2S_FLUSH_RX_FIFO(__HANDLE__) ll_i2s_clr_rxfifo_all((__HANDLE__)->p_instance)
371 
372 /** @brief Enable the I2S DMA Request.
373  * @param __HANDLE__ Specifies the I2S Handle.
374  * @retval None
375  */
376 #define __HAL_I2S_ENABLE_DMA(__HANDLE__) ll_i2s_enable_dma(__HANDLE__->p_instance)
377 
378 /** @brief Disable the I2S DMA Request.
379  * @param __HANDLE__ Specifies the I2S Handle.
380  * @retval None
381  */
382 #define __HAL_I2S_DISABLE_DMA(__HANDLE__) ll_i2s_disable_dma(__HANDLE__->p_instance)
383 
384 /** @brief Reset the I2S TX DMA request to the lowest enabled channel.
385  * @param __HANDLE__ Specifies the I2S Handle.
386  * @retval None
387  */
388 #define __HAL_I2S_RESET_TXDMA(__HANDLE__) WRITE_REG((__HANDLE__)->p_instance->TXDMA_RST, I2S_TXDMA_RST)
389 
390 /** @brief Reset the I2S RX DMA request to the lowest enabled channel.
391  * @param __HANDLE__ Specifies the I2S Handle.
392  * @retval None
393  */
394 #define __HAL_I2S_RESET_RXDMA(__HANDLE__) WRITE_REG((__HANDLE__)->p_instance->RXDMA_RST, I2S_RXDMA_RST)
395 
396 /** @brief Enable the specified I2S interrupts.
397  * @param __HANDLE__ Specifies the I2S Handle.
398  * @param __INTERRUPT__ Specifies the interrupt source to enable.
399  * This parameter can be one of the following values:
400  * @arg @ref I2S_IT_TXFO TX FIFO write overflow interrupt
401  * @arg @ref I2S_IT_TXFE TX FIFO empty trigger interrupt
402  * @arg @ref I2S_IT_RXFO RX FIFO receive overflow interrupt
403  * @arg @ref I2S_IT_RXDA RX FIFO data available interrupt
404  * @retval None
405  */
406 #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].INTMASK, (__INTERRUPT__))
407 
408 /** @brief Disable the specified I2S interrupts.
409  * @param __HANDLE__ Specifies the I2S handle.
410  * @param __INTERRUPT__ Specifies the interrupt source to disable.
411  * This parameter can be one of the following values:
412  * @arg @ref I2S_IT_TXFO TX FIFO write overflow interrupt
413  * @arg @ref I2S_IT_TXFE TX FIFO empty trigger interrupt
414  * @arg @ref I2S_IT_RXFO RX FIFO receive overflow interrupt
415  * @arg @ref I2S_IT_RXDA RX FIFO data available interrupt
416  * @retval None
417  */
418 #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].INTMASK, (__INTERRUPT__))
419 
420 /** @brief Check whether the specified I2S flag is set or not.
421  * @param __HANDLE__ Specifies the I2S Handle.
422  * @param __FLAG__ Specifies the flag to check.
423  * This parameter can be one of the following values:
424  * @arg @ref I2S_FLAG_TXFO TX FIFO write overflow flag
425  * @arg @ref I2S_FLAG_TXFE TX FIFO empty trigger flag
426  * @arg @ref I2S_FLAG_RXFO RX FIFO receive overflow flag
427  * @arg @ref I2S_FLAG_RXDA RX FIFO data available flag
428  * @retval The new state of __FLAG__ (TRUE or FALSE).
429  */
430 #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].INTSTAT, (__FLAG__)) != 0) ? SET : RESET)
431 
432 /** @brief Clear the specified I2S flag.
433  * @param __HANDLE__ Specifies the I2S Handle.
434  * @param __FLAG__ Specifies the flag to check.
435  * This parameter can be one of the following values:
436  * @arg @ref I2S_FLAG_TXFO TX FIFO write overflow flag
437  * @arg @ref I2S_FLAG_RXFO RX FIFO receive overflow flag
438  * @retval None
439  */
440 #define __HAL_I2S_CLEAR_FLAG(__HANDLE__, __FLAG__) do { \
441  if ((__FLAG__) & I2S_FLAG_RXFO) \
442  { \
443  READ_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].RXOVR, I2S_RXOVR_RXCHO);\
444  } \
445  if ((__FLAG__) & I2S_FLAG_TXFO) \
446  { \
447  READ_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].TXOVR, I2S_TXOVR_TXCHO);\
448  } \
449  } while(0);
450 
451 /** @} */
452 
453 /* Private macros ------------------------------------------------------------*/
454 /** @defgroup I2S_Private_Macro I2S Private Macros
455  * @{
456  */
457 
458 /** @brief Check if I2S Direction Mode is valid.
459  * @param __MODE__ I2S Direction Mode.
460  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
461  */
462 #define IS_I2S_DIRECTION(__MODE__) (((__MODE__) == I2S_DIRECTION_FULL_DUPLEX) || \
463  ((__MODE__) == I2S_DIRECTION_SIMPLEX_TX) || \
464  ((__MODE__) == I2S_DIRECTION_SIMPLEX_RX))
465 
466 /** @brief Check if I2S Data Size is valid.
467  * @param __DATASIZE__ I2S Data Size.
468  * @retval SET (__DATASIZE__ is valid) or RESET (__DATASIZE__ is invalid)
469  */
470 #define IS_I2S_DATASIZE(__DATASIZE__) (((__DATASIZE__) == I2S_DATASIZE_12BIT) || \
471  ((__DATASIZE__) == I2S_DATASIZE_16BIT) || \
472  ((__DATASIZE__) == I2S_DATASIZE_20BIT) || \
473  ((__DATASIZE__) == I2S_DATASIZE_24BIT) || \
474  ((__DATASIZE__) == I2S_DATASIZE_32BIT))
475 
476 /** @brief Check if I2S Clock Polarity is valid.
477  * @param __CPOL__ I2S Clock Polarity.
478  * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
479  */
480 #define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_POLARITY_LOW) || \
481  ((__CPOL__) == I2S_POLARITY_HIGH))
482 
483 /** @brief Check if I2S Audio Frequency is valid.
484  * @param __FREQUENCY__ I2S Audio Frequency.
485  * @retval SET (__FREQUENCY__ is valid) or RESET (__FREQUENCY__ is invalid)
486  */
487 #define IS_I2S_AUDIO_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) > 0) && ((__FREQUENCY__) <= 1500000))
488 
489 /** @brief Check if I2S FIFO Threshold is valid.
490  * @param __THR__ I2S FIFO Threshold.
491  * @retval SET (__THR__ is valid) or RESET (__THR__ is invalid)
492  */
493 #define IS_I2S_FIFO_THRESHOLD(__THR__) (((__THR__) >= 0) && ((__THR__) <= I2S_TX_FIFO_LEVEL_MAX))
494 
495 /** @} */
496 
497 /** @} */
498 
499 /* Exported functions --------------------------------------------------------*/
500 /** @addtogroup HAL_I2S_DRIVER_FUNCTIONS Functions
501  * @{
502  */
503 
504 /** @defgroup I2S_Exported_Functions_Group1 Initialization and de-initialization functions
505  * @brief Initialization and de-initializations functions
506  *
507 @verbatim
508  ===============================================================================
509  ##### Initialization and de-initialization functions #####
510  ===============================================================================
511  [..] This subsection provides a set of functions allowing to initialize and
512  de-initialize the I2Sx peripheral:
513 
514  (+) User must implement hal_i2s_msp_init() function in which he configures
515  all related peripherals resources (GPIO, DMA, IT and NVIC ).
516 
517  (+) Call the function hal_i2s_init() to configure the selected device with
518  the selected configuration:
519  (++) Data Size
520  (++) Clock Polarity
521  (++) Audio Frequency
522 
523  (+) Call the function hal_i2s_deinit() to restore the default configuration
524  of the selected I2Sx peripheral.
525 
526 @endverbatim
527  * @{
528  */
529 
530 /**
531  ****************************************************************************************
532  * @brief Initialize the I2S according to the specified parameters
533  * in the i2s_init_t and initialize the associated handle.
534  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
535  * @retval ::HAL_OK: Operation is OK.
536  * @retval ::HAL_ERROR: Parameter error or operation not supported.
537  * @retval ::HAL_BUSY: Driver is busy.
538  * @retval ::HAL_TIMEOUT: Timeout occurred.
539  ****************************************************************************************
540  */
542 
543 /**
544  ****************************************************************************************
545  * @brief De-initialize the I2S peripheral.
546  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
547  * @retval ::HAL_OK: Operation is OK.
548  * @retval ::HAL_ERROR: Parameter error or operation not supported.
549  * @retval ::HAL_BUSY: Driver is busy.
550  * @retval ::HAL_TIMEOUT: Timeout occurred.
551  ****************************************************************************************
552  */
554 
555 /**
556  ****************************************************************************************
557  * @brief Initialize the I2S MSP.
558  * @note This function should not be modified. When the callback is needed,
559  the hal_i2s_msp_deinit can be implemented in the user file.
560  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
561  ****************************************************************************************
562  */
564 
565 /**
566  ****************************************************************************************
567  * @brief De-initialize the I2S MSP.
568  * @note This function should not be modified. When the callback is needed,
569  the hal_i2s_msp_deinit can be implemented in the user file.
570  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
571  ****************************************************************************************
572  */
574 
575 /** @} */
576 
577 /** @defgroup I2S_Exported_Functions_Group2 IO operation functions
578  * @brief Data transfers functions
579  *
580 @verbatim
581  ==============================================================================
582  ##### IO operation functions #####
583  ===============================================================================
584  [..]
585  This subsection provides a set of functions allowing to manage the I2S
586  data transfers.
587 
588  [..] The I2S supports master and slave mode:
589 
590  (#) There are two modes of transfer:
591  (++) Blocking mode: The communication is performed in polling mode.
592  The HAL status of all data processing is returned by the same function
593  after finishing transfer.
594  (++) No-Blocking mode: The communication is performed using Interrupts
595  or DMA, These APIs return the HAL status.
596  The end of the data processing will be indicated through the
597  dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when
598  using DMA mode.
599  The hal_i2s_tx_cplt_callback(), hal_i2s_rx_cplt_callback() and hal_i2s_tx_rx_cplt_callback() user callbacks
600  will be executed respectively at the end of the transmit or Receive process
601  The hal_i2s_error_callback() user callback will be executed when a communication error is detected.
602 
603  (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
604  exist for 1-Line (simplex) and 2-Line (full duplex) modes.
605 
606 @endverbatim
607  * @{
608  */
609 
610 /**
611  ****************************************************************************************
612  * @brief Transmit an amount of data in blocking mode.
613  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
614  * @param[in] p_data: Pointer to data buffer
615  * @param[in] length: Amount of data to be sent in halfword, data of a channel.
616  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
617  * @param[in] timeout: Timeout duration
618  * @retval ::HAL_OK: Operation is OK.
619  * @retval ::HAL_ERROR: Parameter error or operation not supported.
620  * @retval ::HAL_BUSY: Driver is busy.
621  * @retval ::HAL_TIMEOUT: Timeout occurred.
622  ****************************************************************************************
623  */
624 hal_status_t hal_i2s_transmit(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length, uint32_t timeout);
625 
626 /**
627  ****************************************************************************************
628  * @brief Receive an amount of data in blocking mode.
629  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
630  * @param[out] p_data: Pointer to data buffer
631  * @param[in] length: Amount of data to be received in halfword, data of a channel.
632  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
633  * @param[in] timeout: Timeout duration
634  * @retval ::HAL_OK: Operation is OK.
635  * @retval ::HAL_ERROR: Parameter error or operation not supported.
636  * @retval ::HAL_BUSY: Driver is busy.
637  * @retval ::HAL_TIMEOUT: Timeout occurred.
638  ****************************************************************************************
639  */
640 hal_status_t hal_i2s_receive(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length, uint32_t timeout);
641 
642 /**
643  ****************************************************************************************
644  * @brief Transmit and Receive an amount of data in blocking mode.
645  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration information for the specified I2S module.
646  * @param[in] p_tx_data: Pointer to transmission data buffer
647  * @param[out] p_rx_data: Pointer to reception data buffer
648  * @param[in] length: Amount of data to be sent and received in bytes
649  * @param[in] timeout: Timeout duration
650  * @retval ::HAL_OK: Operation is OK.
651  * @retval ::HAL_ERROR: Parameter error or operation not supported.
652  * @retval ::HAL_BUSY: Driver is busy.
653  * @retval ::HAL_TIMEOUT: Timeout occurred.
654  ****************************************************************************************
655  */
656 hal_status_t hal_i2s_transmit_receive(i2s_handle_t *p_i2s, uint16_t *p_tx_data, uint16_t *p_rx_data, uint32_t length, uint32_t timeout);
657 
658 /**
659  ****************************************************************************************
660  * @brief Transmit an amount of data in non-blocking mode with Interrupt.
661  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
662  * @param[in] p_data: Pointer to data buffer
663  * @param[in] length: Amount of data to be sent in halfword, data of a channel.
664  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
665  * @retval ::HAL_OK: Operation is OK.
666  * @retval ::HAL_ERROR: Parameter error or operation not supported.
667  * @retval ::HAL_BUSY: Driver is busy.
668  * @retval ::HAL_TIMEOUT: Timeout occurred.
669  ****************************************************************************************
670  */
671 hal_status_t hal_i2s_transmit_it(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
672 
673 /**
674  ****************************************************************************************
675  * @brief Receive an amount of data in non-blocking mode with Interrupt.
676  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
677  * @param[out] p_data: Pointer to data buffer
678  * @param[in] length: Amount of data to be sent in halfword, data of a channel.
679  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
680  * @retval ::HAL_OK: Operation is OK.
681  * @retval ::HAL_ERROR: Parameter error or operation not supported.
682  * @retval ::HAL_BUSY: Driver is busy.
683  * @retval ::HAL_TIMEOUT: Timeout occurred.
684  ****************************************************************************************
685  */
686 hal_status_t hal_i2s_receive_it(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
687 
688 /**
689  ****************************************************************************************
690  * @brief Transmit and Receive an amount of data in non-blocking mode with Interrupt.
691  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration information for the specified SPI module.
692  * @param[in] p_tx_data: Pointer to transmission data buffer
693  * @param[out] p_rx_data: Pointer to reception data buffer
694  * @param[in] length: Amount of data to be sent and received in bytes
695  * @retval ::HAL_OK: Operation is OK.
696  * @retval ::HAL_ERROR: Parameter error or operation not supported.
697  * @retval ::HAL_BUSY: Driver is busy.
698  * @retval ::HAL_TIMEOUT: Timeout occurred.
699  ****************************************************************************************
700  */
701 hal_status_t hal_i2s_transmit_receive_it(i2s_handle_t *p_i2s, uint16_t *p_tx_data, uint16_t *p_rx_data, uint32_t length);
702 
703 /**
704  ****************************************************************************************
705  * @brief Transmit an amount of data in non-blocking mode with DMA.
706  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
707  * @param[in] p_data: Pointer to data buffer
708  * @param[in] length: Amount of data to be sent in halfword, data of a channel, ranging between 1 and 4095.
709  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
710  * @retval ::HAL_OK: Operation is OK.
711  * @retval ::HAL_ERROR: Parameter error or operation not supported.
712  * @retval ::HAL_BUSY: Driver is busy.
713  * @retval ::HAL_TIMEOUT: Timeout occurred.
714  ****************************************************************************************
715  */
716 hal_status_t hal_i2s_transmit_dma(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
717 
718 /**
719  ****************************************************************************************
720  * @brief Receive an amount of data in non-blocking mode with DMA.
721  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
722  * @param[out] p_data: Pointer to data buffer
723  * @param[in] length: Amount of data to be sent in halfword, data of a channel, ranging between 1 and 4095.
724  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
725  * @retval ::HAL_OK: Operation is OK.
726  * @retval ::HAL_ERROR: Parameter error or operation not supported.
727  * @retval ::HAL_BUSY: Driver is busy.
728  * @retval ::HAL_TIMEOUT: Timeout occurred.
729  ****************************************************************************************
730  */
731 hal_status_t hal_i2s_receive_dma(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
732 
733 /**
734  ****************************************************************************************
735  * @brief Transmit and Receive an amount of data in non-blocking mode with DMA.
736  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration information for the specified I2S module.
737  * @param[in] p_tx_data: Pointer to transmission data buffer
738  * @param[out] p_rx_data: Pointer to reception data buffer
739  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
740  * @retval ::HAL_OK: Operation is OK.
741  * @retval ::HAL_ERROR: Parameter error or operation not supported.
742  * @retval ::HAL_BUSY: Driver is busy.
743  * @retval ::HAL_TIMEOUT: Timeout occurred.
744  ****************************************************************************************
745  */
746 hal_status_t hal_i2s_transmit_receive_dma(i2s_handle_t *p_i2s, uint16_t *p_tx_data, uint16_t *p_rx_data, uint32_t length);
747 
748 /**
749  ****************************************************************************************
750  * @brief Start the I2S master clock.
751  * @note In case of SLAVE mode, this function will not take effect.
752  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
753  * @retval ::HAL_OK: Operation is OK.
754  * @retval ::HAL_ERROR: Parameter error or operation not supported.
755  * @retval ::HAL_BUSY: Driver is busy.
756  * @retval ::HAL_TIMEOUT: Timeout occurred.
757  ****************************************************************************************
758  */
760 
761 /**
762  ****************************************************************************************
763  * @brief Stop the I2S master clock.
764  * @note In case of SLAVE mode, this function will not take effect.
765  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
766  * @retval ::HAL_OK: Operation is OK.
767  * @retval ::HAL_ERROR: Parameter error or operation not supported.
768  * @retval ::HAL_BUSY: Driver is busy.
769  * @retval ::HAL_TIMEOUT: Timeout occurred.
770  ****************************************************************************************
771  */
773 
774 /**
775  ****************************************************************************************
776  * @brief Abort ongoing transfer (blocking mode).
777  * @param[in] p_i2s: I2S handle.
778  * @note This procedure could be used for aborting any ongoing transfer (TX and RX),
779  * started in Interrupt or DMA mode.
780  * This procedure performs following operations :
781  * - Disable I2S Interrupts (depending of transfer direction)
782  * - Disable the DMA transfer in the peripheral register (if enabled)
783  * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
784  * - Set handle State to READY
785  * @note This procedure is executed in blocking mode: When exiting function, Abort is considered as completed.
786  * @retval ::HAL_OK: Operation is OK.
787  * @retval ::HAL_ERROR: Parameter error or operation not supported.
788  * @retval ::HAL_BUSY: Driver is busy.
789  * @retval ::HAL_TIMEOUT: Timeout occurred.
790  ****************************************************************************************
791  */
793 
794 /** @} */
795 
796 /** @addtogroup I2S_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
797  * @brief IRQ Handler and Callbacks functions
798  * @{
799  */
800 
801 /**
802  ****************************************************************************************
803  * @brief Handle I2S interrupt request.
804  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
805  ****************************************************************************************
806  */
808 
809 /**
810  ****************************************************************************************
811  * @brief TX Transfer completed callback.
812  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
813  ****************************************************************************************
814  */
816 
817 /**
818  ****************************************************************************************
819  * @brief RX Transfer completed callback.
820  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
821  ****************************************************************************************
822  */
824 
825 /**
826  ****************************************************************************************
827  * @brief TX/RX Transfer completed callback.
828  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
829  ****************************************************************************************
830  */
832 
833 /**
834  ****************************************************************************************
835  * @brief I2S error callback.
836  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
837  ****************************************************************************************
838  */
840 
841 /** @} */
842 
843 /** @defgroup I2S_Exported_Functions_Group3 Peripheral State and Errors functions
844  * @brief I2S control functions
845  *
846 @verbatim
847  ===============================================================================
848  ##### Peripheral State and Errors functions #####
849  ===============================================================================
850  [..]
851  This subsection provides a set of functions allowing to control the I2S.
852  (+) hal_i2s_get_state() API can be helpful to check in run-time the state of the I2S peripheral
853  (+) hal_i2s_get_error() check in run-time Errors occurring during communication
854  (+) hal_i2s_set_timeout() set the timeout during internal process
855  (+) hal_i2s_set_tx_fifo_threshold() set the TX FIFO Threshold
856  (+) hal_i2s_set_rx_fifo_threshold() set the RX FIFO Threshold
857  (+) hal_i2s_get_tx_fifo_threshold() get the TX FIFO Threshold
858  (+) hal_i2s_get_rx_fifo_threshold() get the RX FIFO Threshold
859 @endverbatim
860  * @{
861  */
862 
863 /**
864  ****************************************************************************************
865  * @brief Return the I2S handle state.
866  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
867  * @retval ::HAL_I2S_STATE_RESET: Peripheral not initialized.
868  * @retval ::HAL_I2S_STATE_READY: Peripheral initialized and ready for use.
869  * @retval ::HAL_I2S_STATE_BUSY: An internal process is ongoing.
870  * @retval ::HAL_I2S_STATE_BUSY_TX: Data Transmii2son process is ongoing.
871  * @retval ::HAL_I2S_STATE_BUSY_RX: Data Reception process is ongoing.
872  * @retval ::HAL_I2S_STATE_ABORT: Peripheral with abort request ongoing.
873  * @retval ::HAL_I2S_STATE_ERROR: Peripheral in error.
874  ****************************************************************************************
875  */
877 
878 /**
879  ****************************************************************************************
880  * @brief Return the I2S error code.
881  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
882  * @return I2S error code in bitmap format
883  ****************************************************************************************
884  */
886 
887 /**
888  ****************************************************************************************
889  * @brief Set the TX FIFO threshold.
890  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
891  * @param[in] threshold: TX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
892  * @retval ::HAL_OK: Operation is OK.
893  * @retval ::HAL_ERROR: Parameter error or operation not supported.
894  * @retval ::HAL_BUSY: Driver is busy.
895  * @retval ::HAL_TIMEOUT: Timeout occurred.
896  ****************************************************************************************
897  */
899 
900 /**
901  ****************************************************************************************
902  * @brief Set the RX FIFO threshold.
903  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
904  * @param[in] threshold: RX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
905  * @retval ::HAL_OK: Operation is OK.
906  * @retval ::HAL_ERROR: Parameter error or operation not supported.
907  * @retval ::HAL_BUSY: Driver is busy.
908  * @retval ::HAL_TIMEOUT: Timeout occurred.
909  ****************************************************************************************
910  */
912 
913 /**
914  ****************************************************************************************
915  * @brief Get the TX FIFO threshold.
916  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
917  * @return TX FIFO threshold
918  ****************************************************************************************
919  */
921 
922 /**
923  ****************************************************************************************
924  * @brief Get the RX FIFO threshold.
925  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
926  * @return RX FIFO threshold
927  ****************************************************************************************
928  */
930 
931 /**
932  ****************************************************************************************
933  * @brief Suspend some registers related to I2S configuration before sleep.
934  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration
935  * information for the specified I2S module.
936  * @retval ::HAL_OK: Operation is OK.
937  * @retval ::HAL_ERROR: Parameter error or operation not supported.
938  * @retval ::HAL_BUSY: Driver is busy.
939  * @retval ::HAL_TIMEOUT: Timeout occurred.
940  ****************************************************************************************
941  */
943 
944 /**
945  ****************************************************************************************
946  * @brief Restore some registers related to I2S configuration after sleep.
947  * This function must be used in conjunction with the hal_i2s_suspend_reg().
948  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration
949  * information for the specified I2S module.
950  * @retval ::HAL_OK: Operation is OK.
951  * @retval ::HAL_ERROR: Parameter error or operation not supported.
952  * @retval ::HAL_BUSY: Driver is busy.
953  * @retval ::HAL_TIMEOUT: Timeout occurred.
954  ****************************************************************************************
955  */
957 
958 
959 /** @} */
960 
961 /** @} */
962 
963 #ifdef __cplusplus
964 }
965 #endif
966 
967 #endif /* __GR55xx_HAL_I2S_H__ */
968 
969 /** @} */
970 
971 /** @} */
972 
973 /** @} */
_i2s_init::data_size
uint32_t data_size
Specifies the data size for I2S communication.
Definition: gr55xx_hal_i2s.h:105
HAL_I2S_STATE_BUSY_TX
@ HAL_I2S_STATE_BUSY_TX
Data Transmission process is ongoing
Definition: gr55xx_hal_i2s.h:80
hal_i2s_init
hal_status_t hal_i2s_init(i2s_handle_t *p_i2s)
Initialize the I2S according to the specified parameters in the i2s_init_t and initialize the associa...
hal_i2s_receive_it
hal_status_t hal_i2s_receive_it(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode with Interrupt.
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
hal_i2s_deinit
hal_status_t hal_i2s_deinit(i2s_handle_t *p_i2s)
De-initialize the I2S peripheral.
_i2s_handle::p_rx_buffer
uint16_t * p_rx_buffer
Pointer to I2S RX transfer Buffer.
Definition: gr55xx_hal_i2s.h:141
hal_i2s_transmit_receive_dma
hal_status_t hal_i2s_transmit_receive_dma(i2s_handle_t *p_i2s, uint16_t *p_tx_data, uint16_t *p_rx_data, uint32_t length)
Transmit and Receive an amount of data in non-blocking mode with DMA.
hal_i2s_tx_cplt_callback
void hal_i2s_tx_cplt_callback(i2s_handle_t *p_i2s)
TX Transfer completed callback.
HAL_I2S_STATE_BUSY_RX
@ HAL_I2S_STATE_BUSY_RX
Data Reception process is ongoing
Definition: gr55xx_hal_i2s.h:81
hal_i2s_receive
hal_status_t hal_i2s_receive(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length, uint32_t timeout)
Receive an amount of data in blocking mode.
_i2s_handle::write_fifo
void(* write_fifo)(struct _i2s_handle *p_i2s)
Pointer to I2S Tx transfer FIFO write function.
Definition: gr55xx_hal_i2s.h:147
HAL_I2S_STATE_ABORT
@ HAL_I2S_STATE_ABORT
Peripheral with abort request ongoing
Definition: gr55xx_hal_i2s.h:83
_i2s_handle::p_instance
i2s_regs_t * p_instance
I2S registers base address
Definition: gr55xx_hal_i2s.h:131
hal_i2s_error_callback
void hal_i2s_error_callback(i2s_handle_t *p_i2s)
I2S error callback.
_i2s_handle::read_fifo
void(* read_fifo)(struct _i2s_handle *p_i2s)
Pointer to I2S Rx transfer FIFO read function
Definition: gr55xx_hal_i2s.h:149
hal_i2s_abort
hal_status_t hal_i2s_abort(i2s_handle_t *p_i2s)
Abort ongoing transfer (blocking mode).
i2s_init_t
struct _i2s_init i2s_init_t
I2S init Structure definition.
_i2s_handle::error_code
__IO uint32_t error_code
I2S Error code
Definition: gr55xx_hal_i2s.h:159
_i2s_handle::p_tx_buffer
uint16_t * p_tx_buffer
Pointer to I2S TX transfer Buffer.
Definition: gr55xx_hal_i2s.h:135
hal_i2s_receive_dma
hal_status_t hal_i2s_receive_dma(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length)
Receive an amount of data in non-blocking mode with DMA.
HAL_I2S_STATE_RESET
@ HAL_I2S_STATE_RESET
Peripheral not initialized
Definition: gr55xx_hal_i2s.h:77
_i2s_init::audio_freq
uint32_t audio_freq
Specifies the frequency selected for the I2S communication.
Definition: gr55xx_hal_i2s.h:111
hal_i2s_transmit_receive_it
hal_status_t hal_i2s_transmit_receive_it(i2s_handle_t *p_i2s, uint16_t *p_tx_data, uint16_t *p_rx_data, uint32_t length)
Transmit and Receive an amount of data in non-blocking mode with Interrupt.
_hal_i2s_callback::i2s_tx_cplt_callback
void(* i2s_tx_cplt_callback)(i2s_handle_t *p_i2s)
I2S tx transfer completed callbac
Definition: gr55xx_hal_i2s.h:187
_hal_i2s_callback::i2s_msp_init
void(* i2s_msp_init)(i2s_handle_t *p_i2s)
I2S init MSP callback
Definition: gr55xx_hal_i2s.h:183
_hal_i2s_callback::i2s_msp_deinit
void(* i2s_msp_deinit)(i2s_handle_t *p_i2s)
I2S de-init MSP callback
Definition: gr55xx_hal_i2s.h:184
_i2s_handle::init
i2s_init_t init
I2S communication parameters
Definition: gr55xx_hal_i2s.h:133
hal_i2s_tx_rx_cplt_callback
void hal_i2s_tx_rx_cplt_callback(i2s_handle_t *p_i2s)
TX/RX Transfer completed callback.
hal_i2s_transmit_it
hal_status_t hal_i2s_transmit_it(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with Interrupt.
_i2s_handle::tx_xfer_count
__IO uint32_t tx_xfer_count
I2S TX Transfer Counter
Definition: gr55xx_hal_i2s.h:139
HAL_I2S_STATE_READY
@ HAL_I2S_STATE_READY
Peripheral initialized and ready for use
Definition: gr55xx_hal_i2s.h:78
hal_i2s_rx_cplt_callback
void hal_i2s_rx_cplt_callback(i2s_handle_t *p_i2s)
RX Transfer completed callback.
hal_i2s_get_tx_fifo_threshold
uint32_t hal_i2s_get_tx_fifo_threshold(i2s_handle_t *p_i2s)
Get the TX FIFO threshold.
hal_i2s_transmit_dma
hal_status_t hal_i2s_transmit_dma(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length)
Transmit an amount of data in non-blocking mode with DMA.
_i2s_handle::timeout
uint32_t timeout
Timeout for the I2S memory access.
Definition: gr55xx_hal_i2s.h:161
_i2s_init::clock_source
uint32_t clock_source
Specifies the source of the I2S clock.
Definition: gr55xx_hal_i2s.h:108
i2s_handle_t
struct _i2s_handle i2s_handle_t
I2S handle Structure definition.
hal_i2s_resume_reg
hal_status_t hal_i2s_resume_reg(i2s_handle_t *p_i2s)
Restore some registers related to I2S configuration after sleep.
_hal_i2s_callback::i2s_tx_rx_cplt_callback
void(* i2s_tx_rx_cplt_callback)(i2s_handle_t *p_i2s)
I2S tx/rx transfer completed callback
Definition: gr55xx_hal_i2s.h:188
HAL_I2S_STATE_BUSY
@ HAL_I2S_STATE_BUSY
An internal process is ongoing
Definition: gr55xx_hal_i2s.h:79
gr55xx_ll_i2s.h
Header file containing functions prototypes of I2S LL library.
hal_i2s_get_state
hal_i2s_state_t hal_i2s_get_state(i2s_handle_t *p_i2s)
Return the I2S handle state.
hal_i2s_get_rx_fifo_threshold
uint32_t hal_i2s_get_rx_fifo_threshold(i2s_handle_t *p_i2s)
Get the RX FIFO threshold.
_i2s_handle
I2S handle Structure definition.
Definition: gr55xx_hal_i2s.h:130
_i2s_handle::state
__IO hal_i2s_state_t state
I2S communication state
Definition: gr55xx_hal_i2s.h:157
hal_i2s_start_clock
hal_status_t hal_i2s_start_clock(i2s_handle_t *p_i2s)
Start the I2S master clock.
_i2s_handle::tx_xfer_size
__IO uint32_t tx_xfer_size
I2S TX Transfer size
Definition: gr55xx_hal_i2s.h:137
_i2s_handle::retention
uint32_t retention[7]
I2S important register information.
Definition: gr55xx_hal_i2s.h:163
_hal_i2s_callback::i2s_rx_cplt_callback
void(* i2s_rx_cplt_callback)(i2s_handle_t *p_i2s)
I2S rx transfer completed callback
Definition: gr55xx_hal_i2s.h:186
hal_i2s_transmit_receive
hal_status_t hal_i2s_transmit_receive(i2s_handle_t *p_i2s, uint16_t *p_tx_data, uint16_t *p_rx_data, uint32_t length, uint32_t timeout)
Transmit and Receive an amount of data in blocking mode.
_i2s_init
I2S init Structure definition.
Definition: gr55xx_hal_i2s.h:104
_hal_i2s_callback
HAL_I2S Callback function definition.
Definition: gr55xx_hal_i2s.h:182
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
_i2s_handle::lock
__IO hal_lock_t lock
Locking object
Definition: gr55xx_hal_i2s.h:155
HAL_I2S_STATE_ERROR
@ HAL_I2S_STATE_ERROR
Peripheral in error
Definition: gr55xx_hal_i2s.h:84
HAL_I2S_STATE_BUSY_TX_RX
@ HAL_I2S_STATE_BUSY_TX_RX
Data Transmission and Reception process is ongoing
Definition: gr55xx_hal_i2s.h:82
_i2s_handle::p_dmarx
dma_handle_t * p_dmarx
I2S RX DMA Handle parameters
Definition: gr55xx_hal_i2s.h:153
_hal_i2s_callback::i2s_error_callback
void(* i2s_error_callback)(i2s_handle_t *p_i2s)
I2S error callback
Definition: gr55xx_hal_i2s.h:185
hal_i2s_suspend_reg
hal_status_t hal_i2s_suspend_reg(i2s_handle_t *p_i2s)
Suspend some registers related to I2S configuration before sleep.
hal_i2s_transmit
hal_status_t hal_i2s_transmit(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length, uint32_t timeout)
Transmit an amount of data in blocking mode.
hal_i2s_callback_t
struct _hal_i2s_callback hal_i2s_callback_t
HAL_I2S Callback function definition.
hal_i2s_set_tx_fifo_threshold
hal_status_t hal_i2s_set_tx_fifo_threshold(i2s_handle_t *p_i2s, uint32_t threshold)
Set the TX FIFO threshold.
hal_i2s_get_error
uint32_t hal_i2s_get_error(i2s_handle_t *p_i2s)
Return the I2S error code.
hal_i2s_msp_init
void hal_i2s_msp_init(i2s_handle_t *p_i2s)
Initialize the I2S MSP.
_i2s_handle::rx_xfer_count
__IO uint32_t rx_xfer_count
I2S RX Transfer Counter
Definition: gr55xx_hal_i2s.h:145
hal_i2s_irq_handler
void hal_i2s_irq_handler(i2s_handle_t *p_i2s)
Handle I2S interrupt request.
hal_i2s_state_t
hal_i2s_state_t
HAL I2S State Enumerations definition.
Definition: gr55xx_hal_i2s.h:76
hal_i2s_msp_deinit
void hal_i2s_msp_deinit(i2s_handle_t *p_i2s)
De-initialize the I2S MSP.
hal_i2s_stop_clock
hal_status_t hal_i2s_stop_clock(i2s_handle_t *p_i2s)
Stop the I2S master clock.
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:179
_i2s_handle::p_dmatx
dma_handle_t * p_dmatx
I2S TX DMA Handle parameters
Definition: gr55xx_hal_i2s.h:151
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_i2s_handle::rx_xfer_size
__IO uint32_t rx_xfer_size
I2S RX Transfer size
Definition: gr55xx_hal_i2s.h:143
hal_i2s_set_rx_fifo_threshold
hal_status_t hal_i2s_set_rx_fifo_threshold(i2s_handle_t *p_i2s, uint32_t threshold)
Set the RX FIFO threshold.