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 #define HAL_I2S_ERROR_TX_OVERFLOW ((uint32_t)0x00000010) /**< Transmit overflow error */
222 #define HAL_I2S_ERROR_RX_OVERFLOW ((uint32_t)0x00000020) /**< Receive overflow error */
223 /** @} */
224 
225 /** @defgroup I2S_Data_Size I2S Data Size
226  * @{
227  */
228 #define I2S_DATASIZE_12BIT LL_I2S_DATASIZE_12BIT /**< 12-bit serial data transfer */
229 #define I2S_DATASIZE_16BIT LL_I2S_DATASIZE_16BIT /**< 16-bit serial data transfer */
230 #define I2S_DATASIZE_20BIT LL_I2S_DATASIZE_20BIT /**< 20-bit serial data transfer */
231 #define I2S_DATASIZE_24BIT LL_I2S_DATASIZE_24BIT /**< 24-bit serial data transfer */
232 #define I2S_DATASIZE_32BIT LL_I2S_DATASIZE_32BIT /**< 32-bit serial data transfer */
233 /** @} */
234 
235 /** @defgroup I2S_Clock_Source I2S Clock Source
236  * @{
237  */
238 #define I2S_CLOCK_SRC_96M LL_I2S_CLOCK_SRC_96M /**< Inactive state of SCLK is low */
239 #define I2S_CLOCK_SRC_32M LL_I2S_CLOCK_SRC_32M /**< Inactive state of SCLK is high */
240 /** @} */
241 
242 /** @defgroup I2S_FIFO_LEVEL_MAX I2S FIFO Level Max
243  * @{
244  */
245 #define I2S_TX_FIFO_LEVEL_MAX 16 /**< I2S TX FIFO Level Max Value */
246 #define I2S_RX_FIFO_LEVEL_MAX 16 /**< I2S RX FIFO Level Max Value */
247 /** @} */
248 
249 /** @defgroup I2S_Flags_definition I2S Flags Definition
250  * @{
251  */
252 #define I2S_FLAG_TXFO LL_I2S_STATUS_TXFO /**< TX FIFO write overflow flag */
253 #define I2S_FLAG_TXFE LL_I2S_STATUS_TXFE /**< TX FIFO empty trigger flag */
254 #define I2S_FLAG_RXFO LL_I2S_STATUS_RXFO /**< RX FIFO receive overflow flag */
255 #define I2S_FLAG_RXDA LL_I2S_STATUS_RXDA /**< RX FIFO data available flag */
256 /** @} */
257 
258 /** @defgroup I2S_Interrupt_definition I2S Interrupt Definition
259  * @{
260  */
261 #define I2S_IT_TXFO LL_I2S_INT_TXFO /**< TX FIFO write overflow interrupt */
262 #define I2S_IT_TXFE LL_I2S_INT_TXFE /**< TX FIFO empty trigger interrupt */
263 #define I2S_IT_RXFO LL_I2S_INT_RXFO /**< RX FIFO receive overflow interrupt */
264 #define I2S_IT_RXDA LL_I2S_INT_RXDA /**< RX FIFO data available interrupt */
265 /** @} */
266 
267 /** @defgroup I2S_Timeout_definition I2S Timeout_definition
268  * @{
269  */
270 #define HAL_I2S_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
271 /** @} */
272 
273 /** @} */
274 
275 /* Exported macro ------------------------------------------------------------*/
276 /** @defgroup I2S_Exported_Macros I2S Exported Macros
277  * @{
278  */
279 
280 /** @brief Reset I2S handle states.
281  * @param __HANDLE__ I2S handle.
282  * @retval None
283  */
284 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_I2S_STATE_RESET)
285 
286 /** @brief Enable the specified I2S peripheral.
287  * @param __HANDLE__ Specifies the I2S Handle.
288  * @retval None
289  */
290 #define __HAL_I2S_ENABLE(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->ENABLE, I2S_ENABLE_EN)
291 
292 /** @brief Disable the specified I2S peripheral.
293  * @param __HANDLE__ Specifies the I2S Handle.
294  * @retval None
295  */
296 #define __HAL_I2S_DISABLE(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->ENABLE, I2S_ENABLE_EN)
297 
298 /** @brief Enable the specified I2S clock.
299  * @param __HANDLE__ Specifies the I2S Handle.
300  * @retval None
301  */
302 #define __HAL_I2S_ENABLE_CLOCK(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CLKEN, I2S_CLKEN_EN)
303 
304 /** @brief Disable the specified I2S clock.
305  * @param __HANDLE__ Specifies the I2S Handle.
306  * @retval None
307  */
308 #define __HAL_I2S_DISABLE_CLOCK(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CLKEN, I2S_CLKEN_EN)
309 
310 /** @brief Enable the specified I2S transmitter block.
311  * @param __HANDLE__ Specifies the I2S Handle.
312  * @retval None
313  */
314 #define __HAL_I2S_ENABLE_TX_BLOCK(__HANDLE__) ll_i2s_enable_txblock((__HANDLE__)->p_instance)
315 
316 /** @brief Disable the specified I2S transmitter block.
317  * @param __HANDLE__ Specifies the I2S Handle.
318  * @retval None
319  */
320 #define __HAL_I2S_DISABLE_TX_BLOCK(__HANDLE__) ll_i2s_disable_txblock((__HANDLE__)->p_instance)
321 
322 /** @brief Enable the specified I2S receiver block.
323  * @param __HANDLE__ Specifies the I2S Handle.
324  * @retval None
325  */
326 #define __HAL_I2S_ENABLE_RX_BLOCK(__HANDLE__) ll_i2s_enable_rxblock((__HANDLE__)->p_instance)
327 
328 /** @brief Disable the specified I2S receiver block.
329  * @param __HANDLE__ Specifies the I2S Handle.
330  * @retval None
331  */
332 #define __HAL_I2S_DISABLE_RX_BLOCK(__HANDLE__) ll_i2s_disable_rxblock((__HANDLE__)->p_instance)
333 
334 /** @brief Enable the specified I2S transmitter channel.
335  * @param __HANDLE__ Specifies the I2S Handle.
336  * @param __CH__ Specifies the I2S channel.
337  * @retval None
338  */
339 #define __HAL_I2S_ENABLE_TX_CHANNEL(__HANDLE__, __CH__) ll_i2s_enable_tx((__HANDLE__)->p_instance, (__CH__))
340 
341 /** @brief Disable the specified I2S transmitter channel.
342  * @param __HANDLE__ Specifies the I2S Handle.
343  * @param __CH__ Specifies the I2S channel.
344  * @retval None
345  */
346 #define __HAL_I2S_DISABLE_TX_CHANNEL(__HANDLE__, __CH__) ll_i2s_disable_tx((__HANDLE__)->p_instance, (__CH__))
347 
348 /** @brief Enable the specified I2S receiver channel.
349  * @param __HANDLE__ Specifies the I2S Handle.
350  * @param __CH__ Specifies the I2S channel.
351  * @retval None
352  */
353 #define __HAL_I2S_ENABLE_RX_CHANNEL(__HANDLE__, __CH__) ll_i2s_enable_rx((__HANDLE__)->p_instance, (__CH__))
354 
355 /** @brief Disable the specified I2S receiver channel.
356  * @param __HANDLE__ Specifies the I2S Handle.
357  * @param __CH__ Specifies the I2S channel.
358  * @retval None
359  */
360 #define __HAL_I2S_DISABLE_RX_CHANNEL(__HANDLE__, __CH__) ll_i2s_disable_rx((__HANDLE__)->p_instance, (__CH__))
361 
362 /** @brief Flush the I2S transmitter FIFO.
363  * @param __HANDLE__ Specifies the I2S Handle.
364  * @retval None
365  */
366 #define __HAL_I2S_FLUSH_TX_FIFO(__HANDLE__) ll_i2s_clr_txfifo_all((__HANDLE__)->p_instance)
367 
368 /** @brief Flush the I2S receiver FIFO.
369  * @param __HANDLE__ Specifies the I2S Handle.
370  * @retval None
371  */
372 #define __HAL_I2S_FLUSH_RX_FIFO(__HANDLE__) ll_i2s_clr_rxfifo_all((__HANDLE__)->p_instance)
373 
374 /** @brief Enable the I2S DMA Request.
375  * @param __HANDLE__ Specifies the I2S Handle.
376  * @retval None
377  */
378 #define __HAL_I2S_ENABLE_DMA(__HANDLE__) ll_i2s_enable_dma(__HANDLE__->p_instance)
379 
380 /** @brief Disable the I2S DMA Request.
381  * @param __HANDLE__ Specifies the I2S Handle.
382  * @retval None
383  */
384 #define __HAL_I2S_DISABLE_DMA(__HANDLE__) ll_i2s_disable_dma(__HANDLE__->p_instance)
385 
386 /** @brief Reset the I2S TX DMA request to the lowest enabled channel.
387  * @param __HANDLE__ Specifies the I2S Handle.
388  * @retval None
389  */
390 #define __HAL_I2S_RESET_TXDMA(__HANDLE__) WRITE_REG((__HANDLE__)->p_instance->TXDMA_RST, I2S_TXDMA_RST)
391 
392 /** @brief Reset the I2S RX DMA request to the lowest enabled channel.
393  * @param __HANDLE__ Specifies the I2S Handle.
394  * @retval None
395  */
396 #define __HAL_I2S_RESET_RXDMA(__HANDLE__) WRITE_REG((__HANDLE__)->p_instance->RXDMA_RST, I2S_RXDMA_RST)
397 
398 /** @brief Enable the specified I2S interrupts.
399  * @param __HANDLE__ Specifies the I2S Handle.
400  * @param __INTERRUPT__ Specifies the interrupt source to enable.
401  * This parameter can be one of the following values:
402  * @arg @ref I2S_IT_TXFO TX FIFO write overflow interrupt
403  * @arg @ref I2S_IT_TXFE TX FIFO empty trigger interrupt
404  * @arg @ref I2S_IT_RXFO RX FIFO receive overflow interrupt
405  * @arg @ref I2S_IT_RXDA RX FIFO data available interrupt
406  * @retval None
407  */
408 #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].INTMASK, (__INTERRUPT__))
409 
410 /** @brief Disable the specified I2S interrupts.
411  * @param __HANDLE__ Specifies the I2S handle.
412  * @param __INTERRUPT__ Specifies the interrupt source to disable.
413  * This parameter can be one of the following values:
414  * @arg @ref I2S_IT_TXFO TX FIFO write overflow interrupt
415  * @arg @ref I2S_IT_TXFE TX FIFO empty trigger interrupt
416  * @arg @ref I2S_IT_RXFO RX FIFO receive overflow interrupt
417  * @arg @ref I2S_IT_RXDA RX FIFO data available interrupt
418  * @retval None
419  */
420 #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].INTMASK, (__INTERRUPT__))
421 
422 /** @brief Check whether the specified I2S flag is set or not.
423  * @param __HANDLE__ Specifies the I2S Handle.
424  * @param __FLAG__ Specifies the flag to check.
425  * This parameter can be one of the following values:
426  * @arg @ref I2S_FLAG_TXFO TX FIFO write overflow flag
427  * @arg @ref I2S_FLAG_TXFE TX FIFO empty trigger flag
428  * @arg @ref I2S_FLAG_RXFO RX FIFO receive overflow flag
429  * @arg @ref I2S_FLAG_RXDA RX FIFO data available flag
430  * @retval The new state of __FLAG__ (TRUE or FALSE).
431  */
432 #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].INTSTAT, (__FLAG__)) != 0) ? SET : RESET)
433 
434 /** @brief Clear the specified I2S flag.
435  * @param __HANDLE__ Specifies the I2S Handle.
436  * @param __FLAG__ Specifies the flag to check.
437  * This parameter can be one of the following values:
438  * @arg @ref I2S_FLAG_TXFO TX FIFO write overflow flag
439  * @arg @ref I2S_FLAG_RXFO RX FIFO receive overflow flag
440  * @retval None
441  */
442 #define __HAL_I2S_CLEAR_FLAG(__HANDLE__, __FLAG__) do { \
443  if ((__FLAG__) & I2S_FLAG_RXFO) \
444  { \
445  READ_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].RXOVR, I2S_RXOVR_RXCHO);\
446  } \
447  if ((__FLAG__) & I2S_FLAG_TXFO) \
448  { \
449  READ_BITS((__HANDLE__)->p_instance->I2S_CHANNEL[0].TXOVR, I2S_TXOVR_TXCHO);\
450  } \
451  } while(0);
452 
453 /** @} */
454 
455 /* Private macros ------------------------------------------------------------*/
456 /** @defgroup I2S_Private_Macro I2S Private Macros
457  * @{
458  */
459 
460 /** @brief Check if I2S Direction Mode is valid.
461  * @param __MODE__ I2S Direction Mode.
462  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
463  */
464 #define IS_I2S_DIRECTION(__MODE__) (((__MODE__) == I2S_DIRECTION_FULL_DUPLEX) || \
465  ((__MODE__) == I2S_DIRECTION_SIMPLEX_TX) || \
466  ((__MODE__) == I2S_DIRECTION_SIMPLEX_RX))
467 
468 /** @brief Check if I2S Data Size is valid.
469  * @param __DATASIZE__ I2S Data Size.
470  * @retval SET (__DATASIZE__ is valid) or RESET (__DATASIZE__ is invalid)
471  */
472 #define IS_I2S_DATASIZE(__DATASIZE__) (((__DATASIZE__) == I2S_DATASIZE_12BIT) || \
473  ((__DATASIZE__) == I2S_DATASIZE_16BIT) || \
474  ((__DATASIZE__) == I2S_DATASIZE_20BIT) || \
475  ((__DATASIZE__) == I2S_DATASIZE_24BIT) || \
476  ((__DATASIZE__) == I2S_DATASIZE_32BIT))
477 
478 /** @brief Check if I2S Clock Polarity is valid.
479  * @param __CPOL__ I2S Clock Polarity.
480  * @retval SET (__CPOL__ is valid) or RESET (__CPOL__ is invalid)
481  */
482 #define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_POLARITY_LOW) || \
483  ((__CPOL__) == I2S_POLARITY_HIGH))
484 
485 /** @brief Check if I2S Audio Frequency is valid.
486  * @param __FREQUENCY__ I2S Audio Frequency.
487  * @retval SET (__FREQUENCY__ is valid) or RESET (__FREQUENCY__ is invalid)
488  */
489 #define IS_I2S_AUDIO_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) > 0) && ((__FREQUENCY__) <= 1500000))
490 
491 /** @brief Check if I2S FIFO Threshold is valid.
492  * @param __THR__ I2S FIFO Threshold.
493  * @retval SET (__THR__ is valid) or RESET (__THR__ is invalid)
494  */
495 #define IS_I2S_FIFO_THRESHOLD(__THR__) (((__THR__) >= 0) && ((__THR__) <= I2S_TX_FIFO_LEVEL_MAX))
496 
497 /** @} */
498 
499 /** @} */
500 
501 /* Exported functions --------------------------------------------------------*/
502 /** @addtogroup HAL_I2S_DRIVER_FUNCTIONS Functions
503  * @{
504  */
505 
506 /** @defgroup I2S_Exported_Functions_Group1 Initialization and de-initialization functions
507  * @brief Initialization and de-initializations functions
508  *
509 @verbatim
510  ===============================================================================
511  ##### Initialization and de-initialization functions #####
512  ===============================================================================
513  [..] This subsection provides a set of functions allowing to initialize and
514  de-initialize the I2Sx peripheral:
515 
516  (+) User must implement hal_i2s_msp_init() function in which he configures
517  all related peripherals resources (GPIO, DMA, IT and NVIC ).
518 
519  (+) Call the function hal_i2s_init() to configure the selected device with
520  the selected configuration:
521  (++) Data Size
522  (++) Clock Polarity
523  (++) Audio Frequency
524 
525  (+) Call the function hal_i2s_deinit() to restore the default configuration
526  of the selected I2Sx peripheral.
527 
528 @endverbatim
529  * @{
530  */
531 
532 /**
533  ****************************************************************************************
534  * @brief Initialize the I2S according to the specified parameters
535  * in the i2s_init_t and initialize the associated handle.
536  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
537  * @retval ::HAL_OK: Operation is OK.
538  * @retval ::HAL_ERROR: Parameter error or operation not supported.
539  * @retval ::HAL_BUSY: Driver is busy.
540  * @retval ::HAL_TIMEOUT: Timeout occurred.
541  ****************************************************************************************
542  */
544 
545 /**
546  ****************************************************************************************
547  * @brief De-initialize the I2S peripheral.
548  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
549  * @retval ::HAL_OK: Operation is OK.
550  * @retval ::HAL_ERROR: Parameter error or operation not supported.
551  * @retval ::HAL_BUSY: Driver is busy.
552  * @retval ::HAL_TIMEOUT: Timeout occurred.
553  ****************************************************************************************
554  */
556 
557 /**
558  ****************************************************************************************
559  * @brief Initialize the I2S MSP.
560  * @note This function should not be modified. When the callback is needed,
561  the hal_i2s_msp_deinit can be implemented in the user file.
562  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
563  ****************************************************************************************
564  */
566 
567 /**
568  ****************************************************************************************
569  * @brief De-initialize the I2S MSP.
570  * @note This function should not be modified. When the callback is needed,
571  the hal_i2s_msp_deinit can be implemented in the user file.
572  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
573  ****************************************************************************************
574  */
576 
577 /** @} */
578 
579 /** @defgroup I2S_Exported_Functions_Group2 IO operation functions
580  * @brief Data transfers functions
581  *
582 @verbatim
583  ==============================================================================
584  ##### IO operation functions #####
585  ===============================================================================
586  [..]
587  This subsection provides a set of functions allowing to manage the I2S
588  data transfers.
589 
590  [..] The I2S supports master and slave mode:
591 
592  (#) There are two modes of transfer:
593  (++) Blocking mode: The communication is performed in polling mode.
594  The HAL status of all data processing is returned by the same function
595  after finishing transfer.
596  (++) No-Blocking mode: The communication is performed using Interrupts
597  or DMA, These APIs return the HAL status.
598  The end of the data processing will be indicated through the
599  dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when
600  using DMA mode.
601  The hal_i2s_tx_cplt_callback(), hal_i2s_rx_cplt_callback() and hal_i2s_tx_rx_cplt_callback() user callbacks
602  will be executed respectively at the end of the transmit or Receive process
603  The hal_i2s_error_callback() user callback will be executed when a communication error is detected.
604 
605  (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
606  exist for 1-Line (simplex) and 2-Line (full duplex) modes.
607 
608 @endverbatim
609  * @{
610  */
611 
612 /**
613  ****************************************************************************************
614  * @brief Transmit an amount of data in blocking mode.
615  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
616  * @param[in] p_data: Pointer to data buffer
617  * @param[in] length: Amount of data to be sent in halfword, data of a channel.
618  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
619  * @param[in] timeout: Timeout duration
620  * @retval ::HAL_OK: Operation is OK.
621  * @retval ::HAL_ERROR: Parameter error or operation not supported.
622  * @retval ::HAL_BUSY: Driver is busy.
623  * @retval ::HAL_TIMEOUT: Timeout occurred.
624  ****************************************************************************************
625  */
626 hal_status_t hal_i2s_transmit(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length, uint32_t timeout);
627 
628 /**
629  ****************************************************************************************
630  * @brief Receive an amount of data in blocking mode.
631  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
632  * @param[out] p_data: Pointer to data buffer
633  * @param[in] length: Amount of data to be received in halfword, data of a channel.
634  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
635  * @param[in] timeout: Timeout duration
636  * @retval ::HAL_OK: Operation is OK.
637  * @retval ::HAL_ERROR: Parameter error or operation not supported.
638  * @retval ::HAL_BUSY: Driver is busy.
639  * @retval ::HAL_TIMEOUT: Timeout occurred.
640  ****************************************************************************************
641  */
642 hal_status_t hal_i2s_receive(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length, uint32_t timeout);
643 
644 /**
645  ****************************************************************************************
646  * @brief Transmit and Receive an amount of data in blocking mode.
647  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration information for the specified I2S module.
648  * @param[in] p_tx_data: Pointer to transmission data buffer
649  * @param[out] p_rx_data: Pointer to reception data buffer
650  * @param[in] length: Amount of data to be sent and received in bytes
651  * @param[in] timeout: Timeout duration
652  * @retval ::HAL_OK: Operation is OK.
653  * @retval ::HAL_ERROR: Parameter error or operation not supported.
654  * @retval ::HAL_BUSY: Driver is busy.
655  * @retval ::HAL_TIMEOUT: Timeout occurred.
656  ****************************************************************************************
657  */
658 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);
659 
660 /**
661  ****************************************************************************************
662  * @brief Transmit an amount of data in non-blocking mode with Interrupt.
663  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
664  * @param[in] p_data: Pointer to data buffer
665  * @param[in] length: Amount of data to be sent in halfword, data of a channel.
666  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
667  * @retval ::HAL_OK: Operation is OK.
668  * @retval ::HAL_ERROR: Parameter error or operation not supported.
669  * @retval ::HAL_BUSY: Driver is busy.
670  * @retval ::HAL_TIMEOUT: Timeout occurred.
671  ****************************************************************************************
672  */
673 hal_status_t hal_i2s_transmit_it(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
674 
675 /**
676  ****************************************************************************************
677  * @brief Receive an amount of data in non-blocking mode with Interrupt.
678  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
679  * @param[out] p_data: Pointer to data buffer
680  * @param[in] length: Amount of data to be sent in halfword, data of a channel.
681  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
682  * @retval ::HAL_OK: Operation is OK.
683  * @retval ::HAL_ERROR: Parameter error or operation not supported.
684  * @retval ::HAL_BUSY: Driver is busy.
685  * @retval ::HAL_TIMEOUT: Timeout occurred.
686  ****************************************************************************************
687  */
688 hal_status_t hal_i2s_receive_it(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
689 
690 /**
691  ****************************************************************************************
692  * @brief Transmit and Receive an amount of data in non-blocking mode with Interrupt.
693  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration information for the specified SPI module.
694  * @param[in] p_tx_data: Pointer to transmission data buffer
695  * @param[out] p_rx_data: Pointer to reception data buffer
696  * @param[in] length: Amount of data to be sent and received in bytes
697  * @retval ::HAL_OK: Operation is OK.
698  * @retval ::HAL_ERROR: Parameter error or operation not supported.
699  * @retval ::HAL_BUSY: Driver is busy.
700  * @retval ::HAL_TIMEOUT: Timeout occurred.
701  ****************************************************************************************
702  */
703 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);
704 
705 /**
706  ****************************************************************************************
707  * @brief Transmit an amount of data in non-blocking mode with DMA.
708  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
709  * @param[in] p_data: Pointer to data buffer
710  * @param[in] length: Amount of data to be sent in halfword, data of a channel, ranging between 1 and 4095.
711  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
712  * @retval ::HAL_OK: Operation is OK.
713  * @retval ::HAL_ERROR: Parameter error or operation not supported.
714  * @retval ::HAL_BUSY: Driver is busy.
715  * @retval ::HAL_TIMEOUT: Timeout occurred.
716  ****************************************************************************************
717  */
718 hal_status_t hal_i2s_transmit_dma(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
719 
720 /**
721  ****************************************************************************************
722  * @brief Receive an amount of data in non-blocking mode with DMA.
723  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
724  * @param[out] p_data: Pointer to data buffer
725  * @param[in] length: Amount of data to be sent in halfword, data of a channel, ranging between 1 and 4095.
726  * For example, when 32 bytes of data need to be sent in each of the left and right channels, length = 16.
727  * @retval ::HAL_OK: Operation is OK.
728  * @retval ::HAL_ERROR: Parameter error or operation not supported.
729  * @retval ::HAL_BUSY: Driver is busy.
730  * @retval ::HAL_TIMEOUT: Timeout occurred.
731  ****************************************************************************************
732  */
733 hal_status_t hal_i2s_receive_dma(i2s_handle_t *p_i2s, uint16_t *p_data, uint32_t length);
734 
735 /**
736  ****************************************************************************************
737  * @brief Transmit and Receive an amount of data in non-blocking mode with DMA.
738  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration information for the specified I2S module.
739  * @param[in] p_tx_data: Pointer to transmission data buffer
740  * @param[out] p_rx_data: Pointer to reception data buffer
741  * @param[in] length: Amount of data to be sent in bytes, ranging between 0 and 4095.
742  * @retval ::HAL_OK: Operation is OK.
743  * @retval ::HAL_ERROR: Parameter error or operation not supported.
744  * @retval ::HAL_BUSY: Driver is busy.
745  * @retval ::HAL_TIMEOUT: Timeout occurred.
746  ****************************************************************************************
747  */
748 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);
749 
750 /**
751  ****************************************************************************************
752  * @brief Start the I2S master clock.
753  * @note In case of SLAVE mode, this function will not take effect.
754  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
755  * @retval ::HAL_OK: Operation is OK.
756  * @retval ::HAL_ERROR: Parameter error or operation not supported.
757  * @retval ::HAL_BUSY: Driver is busy.
758  * @retval ::HAL_TIMEOUT: Timeout occurred.
759  ****************************************************************************************
760  */
762 
763 /**
764  ****************************************************************************************
765  * @brief Stop the I2S master clock.
766  * @note In case of SLAVE mode, this function will not take effect.
767  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
768  * @retval ::HAL_OK: Operation is OK.
769  * @retval ::HAL_ERROR: Parameter error or operation not supported.
770  * @retval ::HAL_BUSY: Driver is busy.
771  * @retval ::HAL_TIMEOUT: Timeout occurred.
772  ****************************************************************************************
773  */
775 
776 /**
777  ****************************************************************************************
778  * @brief Abort ongoing transfer (blocking mode).
779  * @param[in] p_i2s: I2S handle.
780  * @note This procedure could be used for aborting any ongoing transfer (TX and RX),
781  * started in Interrupt or DMA mode.
782  * This procedure performs following operations :
783  * - Disable I2S Interrupts (depending of transfer direction)
784  * - Disable the DMA transfer in the peripheral register (if enabled)
785  * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
786  * - Set handle State to READY
787  * @note This procedure is executed in blocking mode: When exiting function, Abort is considered as completed.
788  * @retval ::HAL_OK: Operation is OK.
789  * @retval ::HAL_ERROR: Parameter error or operation not supported.
790  * @retval ::HAL_BUSY: Driver is busy.
791  * @retval ::HAL_TIMEOUT: Timeout occurred.
792  ****************************************************************************************
793  */
795 
796 /** @} */
797 
798 /** @addtogroup I2S_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
799  * @brief IRQ Handler and Callbacks functions
800  * @{
801  */
802 
803 /**
804  ****************************************************************************************
805  * @brief Handle I2S interrupt request.
806  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
807  ****************************************************************************************
808  */
810 
811 /**
812  ****************************************************************************************
813  * @brief TX Transfer completed callback.
814  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
815  ****************************************************************************************
816  */
818 
819 /**
820  ****************************************************************************************
821  * @brief RX Transfer completed callback.
822  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
823  ****************************************************************************************
824  */
826 
827 /**
828  ****************************************************************************************
829  * @brief TX/RX Transfer completed callback.
830  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
831  ****************************************************************************************
832  */
834 
835 /**
836  ****************************************************************************************
837  * @brief I2S error callback.
838  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
839  ****************************************************************************************
840  */
842 
843 /** @} */
844 
845 /** @defgroup I2S_Exported_Functions_Group3 Peripheral State and Errors functions
846  * @brief I2S control functions
847  *
848 @verbatim
849  ===============================================================================
850  ##### Peripheral State and Errors functions #####
851  ===============================================================================
852  [..]
853  This subsection provides a set of functions allowing to control the I2S.
854  (+) hal_i2s_get_state() API can be helpful to check in run-time the state of the I2S peripheral
855  (+) hal_i2s_get_error() check in run-time Errors occurring during communication
856  (+) hal_i2s_set_timeout() set the timeout during internal process
857  (+) hal_i2s_set_tx_fifo_threshold() set the TX FIFO Threshold
858  (+) hal_i2s_set_rx_fifo_threshold() set the RX FIFO Threshold
859  (+) hal_i2s_get_tx_fifo_threshold() get the TX FIFO Threshold
860  (+) hal_i2s_get_rx_fifo_threshold() get the RX FIFO Threshold
861 @endverbatim
862  * @{
863  */
864 
865 /**
866  ****************************************************************************************
867  * @brief Return the I2S handle state.
868  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
869  * @retval ::HAL_I2S_STATE_RESET: Peripheral not initialized.
870  * @retval ::HAL_I2S_STATE_READY: Peripheral initialized and ready for use.
871  * @retval ::HAL_I2S_STATE_BUSY: An internal process is ongoing.
872  * @retval ::HAL_I2S_STATE_BUSY_TX: Data Transmii2son process is ongoing.
873  * @retval ::HAL_I2S_STATE_BUSY_RX: Data Reception process is ongoing.
874  * @retval ::HAL_I2S_STATE_ABORT: Peripheral with abort request ongoing.
875  * @retval ::HAL_I2S_STATE_ERROR: Peripheral in error.
876  ****************************************************************************************
877  */
879 
880 /**
881  ****************************************************************************************
882  * @brief Return the I2S error code.
883  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
884  * @return I2S error code in bitmap format
885  ****************************************************************************************
886  */
888 
889 /**
890  ****************************************************************************************
891  * @brief Set the TX FIFO threshold.
892  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
893  * @param[in] threshold: TX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
894  * @retval ::HAL_OK: Operation is OK.
895  * @retval ::HAL_ERROR: Parameter error or operation not supported.
896  * @retval ::HAL_BUSY: Driver is busy.
897  * @retval ::HAL_TIMEOUT: Timeout occurred.
898  ****************************************************************************************
899  */
901 
902 /**
903  ****************************************************************************************
904  * @brief Set the RX FIFO threshold.
905  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
906  * @param[in] threshold: RX FIFO threshold value ranging bwtween 0x0U ~ 0x7U.
907  * @retval ::HAL_OK: Operation is OK.
908  * @retval ::HAL_ERROR: Parameter error or operation not supported.
909  * @retval ::HAL_BUSY: Driver is busy.
910  * @retval ::HAL_TIMEOUT: Timeout occurred.
911  ****************************************************************************************
912  */
914 
915 /**
916  ****************************************************************************************
917  * @brief Get the TX FIFO threshold.
918  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
919  * @return TX FIFO threshold
920  ****************************************************************************************
921  */
923 
924 /**
925  ****************************************************************************************
926  * @brief Get the RX FIFO threshold.
927  * @param[in] p_i2s: Pointer to an I2S handle which contains the configuration information for the specified I2S module.
928  * @return RX FIFO threshold
929  ****************************************************************************************
930  */
932 
933 /**
934  ****************************************************************************************
935  * @brief Suspend some registers related to I2S configuration before sleep.
936  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration
937  * information for the specified I2S module.
938  * @retval ::HAL_OK: Operation is OK.
939  * @retval ::HAL_ERROR: Parameter error or operation not supported.
940  * @retval ::HAL_BUSY: Driver is busy.
941  * @retval ::HAL_TIMEOUT: Timeout occurred.
942  ****************************************************************************************
943  */
945 
946 /**
947  ****************************************************************************************
948  * @brief Restore some registers related to I2S configuration after sleep.
949  * This function must be used in conjunction with the hal_i2s_suspend_reg().
950  * @param[in] p_i2s: Pointer to a I2S handle which contains the configuration
951  * information for the specified I2S module.
952  * @retval ::HAL_OK: Operation is OK.
953  * @retval ::HAL_ERROR: Parameter error or operation not supported.
954  * @retval ::HAL_BUSY: Driver is busy.
955  * @retval ::HAL_TIMEOUT: Timeout occurred.
956  ****************************************************************************************
957  */
959 
960 
961 /** @} */
962 
963 /** @} */
964 
965 #ifdef __cplusplus
966 }
967 #endif
968 
969 #endif /* __GR55xx_HAL_I2S_H__ */
970 
971 /** @} */
972 
973 /** @} */
974 
975 /** @} */
_i2s_init::data_size
uint32_t data_size
Definition: gr55xx_hal_i2s.h:105
HAL_I2S_STATE_BUSY_TX
@ HAL_I2S_STATE_BUSY_TX
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
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
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)
Definition: gr55xx_hal_i2s.h:147
HAL_I2S_STATE_ABORT
@ HAL_I2S_STATE_ABORT
Definition: gr55xx_hal_i2s.h:83
_i2s_handle::p_instance
i2s_regs_t * p_instance
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)
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
Definition: gr55xx_hal_i2s.h:159
_i2s_handle::p_tx_buffer
uint16_t * p_tx_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
Definition: gr55xx_hal_i2s.h:77
_i2s_init::audio_freq
uint32_t audio_freq
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)
Definition: gr55xx_hal_i2s.h:187
_hal_i2s_callback::i2s_msp_init
void(* i2s_msp_init)(i2s_handle_t *p_i2s)
Definition: gr55xx_hal_i2s.h:183
_hal_i2s_callback::i2s_msp_deinit
void(* i2s_msp_deinit)(i2s_handle_t *p_i2s)
Definition: gr55xx_hal_i2s.h:184
_i2s_handle::init
i2s_init_t init
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
Definition: gr55xx_hal_i2s.h:139
HAL_I2S_STATE_READY
@ HAL_I2S_STATE_READY
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
Definition: gr55xx_hal_i2s.h:161
_i2s_init::clock_source
uint32_t clock_source
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. This function must be used in conjun...
_hal_i2s_callback::i2s_tx_rx_cplt_callback
void(* i2s_tx_rx_cplt_callback)(i2s_handle_t *p_i2s)
Definition: gr55xx_hal_i2s.h:188
HAL_I2S_STATE_BUSY
@ HAL_I2S_STATE_BUSY
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
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
Definition: gr55xx_hal_i2s.h:137
_i2s_handle::retention
uint32_t retention[7]
Definition: gr55xx_hal_i2s.h:163
_hal_i2s_callback::i2s_rx_cplt_callback
void(* i2s_rx_cplt_callback)(i2s_handle_t *p_i2s)
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
Definition: gr55xx_hal_i2s.h:155
HAL_I2S_STATE_ERROR
@ HAL_I2S_STATE_ERROR
Definition: gr55xx_hal_i2s.h:84
HAL_I2S_STATE_BUSY_TX_RX
@ HAL_I2S_STATE_BUSY_TX_RX
Definition: gr55xx_hal_i2s.h:82
_i2s_handle::p_dmarx
dma_handle_t * p_dmarx
Definition: gr55xx_hal_i2s.h:153
_hal_i2s_callback::i2s_error_callback
void(* i2s_error_callback)(i2s_handle_t *p_i2s)
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
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
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
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.