Merge maintenance-8.x.x fixes into master
[inav.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Inc / stm32h7xx_hal_spdifrx.h
blob7c58960964747c796761a0672360f8410377f81a
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal_spdifrx.h
4 * @author MCD Application Team
5 * @brief Header file of SPDIFRX HAL module.
6 ******************************************************************************
7 * @attention
9 * Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.
12 * This software is licensed under terms that can be found in the LICENSE file
13 * in the root directory of this software component.
14 * If no LICENSE file comes with this software, it is provided AS-IS.
16 ******************************************************************************
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32H7xx_HAL_SPDIFRX_H
21 #define STM32H7xx_HAL_SPDIFRX_H
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32h7xx_hal_def.h"
31 /** @addtogroup STM32H7xx_HAL_Driver
32 * @{
34 #if defined (SPDIFRX)
36 /** @addtogroup SPDIFRX
37 * @{
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup SPDIFRX_Exported_Types SPDIFRX Exported Types
42 * @{
45 /**
46 * @brief SPDIFRX Init structure definition
48 typedef struct
50 uint32_t InputSelection; /*!< Specifies the SPDIF input selection.
51 This parameter can be a value of @ref SPDIFRX_Input_Selection */
53 uint32_t Retries; /*!< Specifies the Maximum allowed re-tries during synchronization phase.
54 This parameter can be a value of @ref SPDIFRX_Max_Retries */
56 uint32_t WaitForActivity; /*!< Specifies the wait for activity on SPDIF selected input.
57 This parameter can be a value of @ref SPDIFRX_Wait_For_Activity. */
59 uint32_t ChannelSelection; /*!< Specifies whether the control flow will take the channel status
60 from channel A or B.
61 This parameter can be a value of @ref SPDIFRX_Channel_Selection */
63 uint32_t DataFormat; /*!< Specifies the Data samples format (LSB, MSB, ...).
64 This parameter can be a value of @ref SPDIFRX_Data_Format */
66 uint32_t StereoMode; /*!< Specifies whether the peripheral is in stereo or mono mode.
67 This parameter can be a value of @ref SPDIFRX_Stereo_Mode */
69 uint32_t PreambleTypeMask; /*!< Specifies whether The preamble type bits are copied or not
70 into the received frame.
71 This parameter can be a value of @ref SPDIFRX_PT_Mask */
73 uint32_t ChannelStatusMask; /*!< Specifies whether the channel status and user bits are copied or not
74 into the received frame.
75 This parameter can be a value of @ref SPDIFRX_ChannelStatus_Mask */
77 uint32_t ValidityBitMask; /*!< Specifies whether the validity bit is copied or not into the received frame.
78 This parameter can be a value of @ref SPDIFRX_V_Mask */
80 uint32_t ParityErrorMask; /*!< Specifies whether the parity error bit is copied or not
81 into the received frame.
82 This parameter can be a value of @ref SPDIFRX_PE_Mask */
83 FunctionalState SymbolClockGen; /*!< Enable/Disable the SPDIFRX Symbol Clock generation.
84 This parameter can be set to Enable or Disable */
86 FunctionalState BackupSymbolClockGen; /*!< Enable/Disable the SPDIFRX Backup Symbol Clock generation.
87 This parameter can be set to Enable or Disable */
88 } SPDIFRX_InitTypeDef;
90 /**
91 * @brief SPDIFRX SetDataFormat structure definition
93 typedef struct
95 uint32_t DataFormat; /*!< Specifies the Data samples format (LSB, MSB, ...).
96 This parameter can be a value of @ref SPDIFRX_Data_Format */
98 uint32_t StereoMode; /*!< Specifies whether the peripheral is in stereo or mono mode.
99 This parameter can be a value of @ref SPDIFRX_Stereo_Mode */
101 uint32_t PreambleTypeMask; /*!< Specifies whether The preamble type bits are copied or not
102 into the received frame.
103 This parameter can be a value of @ref SPDIFRX_PT_Mask */
105 uint32_t ChannelStatusMask; /*!< Specifies whether the channel status and user bits are copied or not
106 into the received frame.
107 This parameter can be a value of @ref SPDIFRX_ChannelStatus_Mask */
109 uint32_t ValidityBitMask; /*!< Specifies whether the validity bit is copied or not into the received frame.
110 This parameter can be a value of @ref SPDIFRX_V_Mask */
112 uint32_t ParityErrorMask; /*!< Specifies whether the parity error bit is copied or not
113 into the received frame.
114 This parameter can be a value of @ref SPDIFRX_PE_Mask */
116 } SPDIFRX_SetDataFormatTypeDef;
119 * @brief HAL State structures definition
121 typedef enum
123 HAL_SPDIFRX_STATE_RESET = 0x00U, /*!< SPDIFRX not yet initialized or disabled */
124 HAL_SPDIFRX_STATE_READY = 0x01U, /*!< SPDIFRX initialized and ready for use */
125 HAL_SPDIFRX_STATE_BUSY = 0x02U, /*!< SPDIFRX internal process is ongoing */
126 HAL_SPDIFRX_STATE_BUSY_RX = 0x03U, /*!< SPDIFRX internal Data Flow RX process is ongoing */
127 HAL_SPDIFRX_STATE_BUSY_CX = 0x04U, /*!< SPDIFRX internal Control Flow RX process is ongoing */
128 HAL_SPDIFRX_STATE_ERROR = 0x07U /*!< SPDIFRX error state */
129 } HAL_SPDIFRX_StateTypeDef;
132 * @brief SPDIFRX handle Structure definition
134 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
135 typedef struct __SPDIFRX_HandleTypeDef
136 #else
137 typedef struct
138 #endif /* USE_HAL_SPDIFRX_REGISTER_CALLBACKS */
140 SPDIFRX_TypeDef *Instance; /* SPDIFRX registers base address */
142 SPDIFRX_InitTypeDef Init; /* SPDIFRX communication parameters */
144 uint32_t *pRxBuffPtr; /* Pointer to SPDIFRX Rx transfer buffer */
146 uint32_t *pCsBuffPtr; /* Pointer to SPDIFRX Cx transfer buffer */
148 __IO uint16_t RxXferSize; /* SPDIFRX Rx transfer size */
150 __IO uint16_t RxXferCount; /* SPDIFRX Rx transfer counter
151 (This field is initialized at the
152 same value as transfer size at the
153 beginning of the transfer and
154 decremented when a sample is received.
155 NbSamplesReceived = RxBufferSize-RxBufferCount) */
157 __IO uint16_t CsXferSize; /* SPDIFRX Rx transfer size */
159 __IO uint16_t CsXferCount; /* SPDIFRX Rx transfer counter
160 (This field is initialized at the
161 same value as transfer size at the
162 beginning of the transfer and
163 decremented when a sample is received.
164 NbSamplesReceived = RxBufferSize-RxBufferCount) */
166 DMA_HandleTypeDef *hdmaCsRx; /* SPDIFRX EC60958_channel_status and user_information
167 DMA handle parameters */
169 DMA_HandleTypeDef *hdmaDrRx; /* SPDIFRX Rx DMA handle parameters */
171 __IO HAL_LockTypeDef Lock; /* SPDIFRX locking object */
173 __IO HAL_SPDIFRX_StateTypeDef State; /* SPDIFRX communication state */
175 __IO uint32_t ErrorCode; /* SPDIFRX Error code */
177 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
178 void (*RxHalfCpltCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX Data flow half completed
179 callback */
180 void (*RxCpltCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX Data flow completed callback */
181 void (*CxHalfCpltCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX Control flow half completed
182 callback */
183 void (*CxCpltCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX Control flow completed callback */
184 void (*ErrorCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX error callback */
185 void (* MspInitCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX Msp Init callback */
186 void (* MspDeInitCallback)(struct __SPDIFRX_HandleTypeDef *hspdif); /*!< SPDIFRX Msp DeInit callback */
187 #endif /* USE_HAL_SPDIFRX_REGISTER_CALLBACKS */
189 } SPDIFRX_HandleTypeDef;
191 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
193 * @brief HAL SPDIFRX Callback ID enumeration definition
195 typedef enum
197 HAL_SPDIFRX_RX_HALF_CB_ID = 0x00U, /*!< SPDIFRX Data flow half completed callback ID */
198 HAL_SPDIFRX_RX_CPLT_CB_ID = 0x01U, /*!< SPDIFRX Data flow completed callback */
199 HAL_SPDIFRX_CX_HALF_CB_ID = 0x02U, /*!< SPDIFRX Control flow half completed callback */
200 HAL_SPDIFRX_CX_CPLT_CB_ID = 0x03U, /*!< SPDIFRX Control flow completed callback */
201 HAL_SPDIFRX_ERROR_CB_ID = 0x04U, /*!< SPDIFRX error callback */
202 HAL_SPDIFRX_MSPINIT_CB_ID = 0x05U, /*!< SPDIFRX Msp Init callback ID */
203 HAL_SPDIFRX_MSPDEINIT_CB_ID = 0x06U /*!< SPDIFRX Msp DeInit callback ID */
204 } HAL_SPDIFRX_CallbackIDTypeDef;
207 * @brief HAL SPDIFRX Callback pointer definition
209 typedef void (*pSPDIFRX_CallbackTypeDef)(SPDIFRX_HandleTypeDef *hspdif); /*!< pointer to an SPDIFRX callback
210 function */
211 #endif /* USE_HAL_SPDIFRX_REGISTER_CALLBACKS */
213 * @}
215 /* Exported constants --------------------------------------------------------*/
216 /** @defgroup SPDIFRX_Exported_Constants SPDIFRX Exported Constants
217 * @{
219 /** @defgroup SPDIFRX_ErrorCode SPDIFRX Error Code
220 * @{
222 #define HAL_SPDIFRX_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
223 #define HAL_SPDIFRX_ERROR_TIMEOUT ((uint32_t)0x00000001U) /*!< Timeout error */
224 #define HAL_SPDIFRX_ERROR_OVR ((uint32_t)0x00000002U) /*!< OVR error */
225 #define HAL_SPDIFRX_ERROR_PE ((uint32_t)0x00000004U) /*!< Parity error */
226 #define HAL_SPDIFRX_ERROR_DMA ((uint32_t)0x00000008U) /*!< DMA transfer error */
227 #define HAL_SPDIFRX_ERROR_UNKNOWN ((uint32_t)0x00000010U) /*!< Unknown Error error */
228 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
229 #define HAL_SPDIFRX_ERROR_INVALID_CALLBACK ((uint32_t)0x00000020U) /*!< Invalid Callback error */
230 #endif /* USE_HAL_SPDIFRX_REGISTER_CALLBACKS */
232 * @}
235 /** @defgroup SPDIFRX_Input_Selection SPDIFRX Input Selection
236 * @{
238 #define SPDIFRX_INPUT_IN0 ((uint32_t)0x00000000U)
239 #define SPDIFRX_INPUT_IN1 ((uint32_t)0x00010000U)
240 #define SPDIFRX_INPUT_IN2 ((uint32_t)0x00020000U)
241 #define SPDIFRX_INPUT_IN3 ((uint32_t)0x00030000U)
243 * @}
246 /** @defgroup SPDIFRX_Max_Retries SPDIFRX Maximum Retries
247 * @{
249 #define SPDIFRX_MAXRETRIES_NONE ((uint32_t)0x00000000U)
250 #define SPDIFRX_MAXRETRIES_3 ((uint32_t)0x00001000U)
251 #define SPDIFRX_MAXRETRIES_15 ((uint32_t)0x00002000U)
252 #define SPDIFRX_MAXRETRIES_63 ((uint32_t)0x00003000U)
254 * @}
257 /** @defgroup SPDIFRX_Wait_For_Activity SPDIFRX Wait For Activity
258 * @{
260 #define SPDIFRX_WAITFORACTIVITY_OFF ((uint32_t)0x00000000U)
261 #define SPDIFRX_WAITFORACTIVITY_ON ((uint32_t)SPDIFRX_CR_WFA)
263 * @}
266 /** @defgroup SPDIFRX_PT_Mask SPDIFRX Preamble Type Mask
267 * @{
269 #define SPDIFRX_PREAMBLETYPEMASK_OFF ((uint32_t)0x00000000U)
270 #define SPDIFRX_PREAMBLETYPEMASK_ON ((uint32_t)SPDIFRX_CR_PTMSK)
272 * @}
275 /** @defgroup SPDIFRX_ChannelStatus_Mask SPDIFRX Channel Status Mask
276 * @{
278 #define SPDIFRX_CHANNELSTATUS_OFF ((uint32_t)0x00000000U) /* The channel status and user bits are copied
279 into the SPDIF_DR */
280 #define SPDIFRX_CHANNELSTATUS_ON ((uint32_t)SPDIFRX_CR_CUMSK) /* The channel status and user bits are not copied
281 into the SPDIF_DR, zeros are written instead*/
283 * @}
286 /** @defgroup SPDIFRX_V_Mask SPDIFRX Validity Mask
287 * @{
289 #define SPDIFRX_VALIDITYMASK_OFF ((uint32_t)0x00000000U)
290 #define SPDIFRX_VALIDITYMASK_ON ((uint32_t)SPDIFRX_CR_VMSK)
292 * @}
295 /** @defgroup SPDIFRX_PE_Mask SPDIFRX Parity Error Mask
296 * @{
298 #define SPDIFRX_PARITYERRORMASK_OFF ((uint32_t)0x00000000U)
299 #define SPDIFRX_PARITYERRORMASK_ON ((uint32_t)SPDIFRX_CR_PMSK)
301 * @}
304 /** @defgroup SPDIFRX_Channel_Selection SPDIFRX Channel Selection
305 * @{
307 #define SPDIFRX_CHANNEL_A ((uint32_t)0x00000000U)
308 #define SPDIFRX_CHANNEL_B ((uint32_t)SPDIFRX_CR_CHSEL)
310 * @}
313 /** @defgroup SPDIFRX_Data_Format SPDIFRX Data Format
314 * @{
316 #define SPDIFRX_DATAFORMAT_LSB ((uint32_t)0x00000000U)
317 #define SPDIFRX_DATAFORMAT_MSB ((uint32_t)0x00000010U)
318 #define SPDIFRX_DATAFORMAT_32BITS ((uint32_t)0x00000020U)
320 * @}
323 /** @defgroup SPDIFRX_Stereo_Mode SPDIFRX Stereo Mode
324 * @{
326 #define SPDIFRX_STEREOMODE_DISABLE ((uint32_t)0x00000000U)
327 #define SPDIFRX_STEREOMODE_ENABLE ((uint32_t)SPDIFRX_CR_RXSTEO)
329 * @}
332 /** @defgroup SPDIFRX_State SPDIFRX State
333 * @{
336 #define SPDIFRX_STATE_IDLE ((uint32_t)0xFFFFFFFCU)
337 #define SPDIFRX_STATE_SYNC ((uint32_t)0x00000001U)
338 #define SPDIFRX_STATE_RCV ((uint32_t)SPDIFRX_CR_SPDIFEN)
340 * @}
343 /** @defgroup SPDIFRX_Interrupts_Definition SPDIFRX Interrupts Definition
344 * @{
346 #define SPDIFRX_IT_RXNE ((uint32_t)SPDIFRX_IMR_RXNEIE)
347 #define SPDIFRX_IT_CSRNE ((uint32_t)SPDIFRX_IMR_CSRNEIE)
348 #define SPDIFRX_IT_PERRIE ((uint32_t)SPDIFRX_IMR_PERRIE)
349 #define SPDIFRX_IT_OVRIE ((uint32_t)SPDIFRX_IMR_OVRIE)
350 #define SPDIFRX_IT_SBLKIE ((uint32_t)SPDIFRX_IMR_SBLKIE)
351 #define SPDIFRX_IT_SYNCDIE ((uint32_t)SPDIFRX_IMR_SYNCDIE)
352 #define SPDIFRX_IT_IFEIE ((uint32_t)SPDIFRX_IMR_IFEIE )
354 * @}
357 /** @defgroup SPDIFRX_Flags_Definition SPDIFRX Flags Definition
358 * @{
360 #define SPDIFRX_FLAG_RXNE ((uint32_t)SPDIFRX_SR_RXNE)
361 #define SPDIFRX_FLAG_CSRNE ((uint32_t)SPDIFRX_SR_CSRNE)
362 #define SPDIFRX_FLAG_PERR ((uint32_t)SPDIFRX_SR_PERR)
363 #define SPDIFRX_FLAG_OVR ((uint32_t)SPDIFRX_SR_OVR)
364 #define SPDIFRX_FLAG_SBD ((uint32_t)SPDIFRX_SR_SBD)
365 #define SPDIFRX_FLAG_SYNCD ((uint32_t)SPDIFRX_SR_SYNCD)
366 #define SPDIFRX_FLAG_FERR ((uint32_t)SPDIFRX_SR_FERR)
367 #define SPDIFRX_FLAG_SERR ((uint32_t)SPDIFRX_SR_SERR)
368 #define SPDIFRX_FLAG_TERR ((uint32_t)SPDIFRX_SR_TERR)
370 * @}
374 * @}
377 /* Exported macros -----------------------------------------------------------*/
378 /** @defgroup SPDIFRX_Exported_macros SPDIFRX Exported Macros
379 * @{
382 /** @brief Reset SPDIFRX handle state
383 * @param __HANDLE__ SPDIFRX handle.
384 * @retval None
386 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
387 #define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) do{\
388 (__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET;\
389 (__HANDLE__)->MspInitCallback = NULL;\
390 (__HANDLE__)->MspDeInitCallback = NULL;\
391 }while(0)
392 #else
393 #define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET)
394 #endif /* USE_HAL_SPDIFRX_REGISTER_CALLBACKS */
396 /** @brief Disable the specified SPDIFRX peripheral (IDLE State).
397 * @param __HANDLE__ specifies the SPDIFRX Handle.
398 * @retval None
400 #define __HAL_SPDIFRX_IDLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= SPDIFRX_STATE_IDLE)
402 /** @brief Enable the specified SPDIFRX peripheral (SYNC State).
403 * @param __HANDLE__ specifies the SPDIFRX Handle.
404 * @retval None
406 #define __HAL_SPDIFRX_SYNC(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_SYNC)
409 /** @brief Enable the specified SPDIFRX peripheral (RCV State).
410 * @param __HANDLE__ specifies the SPDIFRX Handle.
411 * @retval None
413 #define __HAL_SPDIFRX_RCV(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_RCV)
416 /** @brief Enable or disable the specified SPDIFRX interrupts.
417 * @param __HANDLE__ specifies the SPDIFRX Handle.
418 * @param __INTERRUPT__ specifies the interrupt source to enable or disable.
419 * This parameter can be one of the following values:
420 * @arg SPDIFRX_IT_RXNE
421 * @arg SPDIFRX_IT_CSRNE
422 * @arg SPDIFRX_IT_PERRIE
423 * @arg SPDIFRX_IT_OVRIE
424 * @arg SPDIFRX_IT_SBLKIE
425 * @arg SPDIFRX_IT_SYNCDIE
426 * @arg SPDIFRX_IT_IFEIE
427 * @retval None
429 #define __HAL_SPDIFRX_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
430 #define __HAL_SPDIFRX_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR\
431 &= (uint16_t)(~(__INTERRUPT__)))
433 /** @brief Checks if the specified SPDIFRX interrupt source is enabled or disabled.
434 * @param __HANDLE__ specifies the SPDIFRX Handle.
435 * @param __INTERRUPT__ specifies the SPDIFRX interrupt source to check.
436 * This parameter can be one of the following values:
437 * @arg SPDIFRX_IT_RXNE
438 * @arg SPDIFRX_IT_CSRNE
439 * @arg SPDIFRX_IT_PERRIE
440 * @arg SPDIFRX_IT_OVRIE
441 * @arg SPDIFRX_IT_SBLKIE
442 * @arg SPDIFRX_IT_SYNCDIE
443 * @arg SPDIFRX_IT_IFEIE
444 * @retval The new state of __IT__ (TRUE or FALSE).
446 #define __HAL_SPDIFRX_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR\
447 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
449 /** @brief Checks whether the specified SPDIFRX flag is set or not.
450 * @param __HANDLE__ specifies the SPDIFRX Handle.
451 * @param __FLAG__ specifies the flag to check.
452 * This parameter can be one of the following values:
453 * @arg SPDIFRX_FLAG_RXNE
454 * @arg SPDIFRX_FLAG_CSRNE
455 * @arg SPDIFRX_FLAG_PERR
456 * @arg SPDIFRX_FLAG_OVR
457 * @arg SPDIFRX_FLAG_SBD
458 * @arg SPDIFRX_FLAG_SYNCD
459 * @arg SPDIFRX_FLAG_FERR
460 * @arg SPDIFRX_FLAG_SERR
461 * @arg SPDIFRX_FLAG_TERR
462 * @retval The new state of __FLAG__ (TRUE or FALSE).
464 #define __HAL_SPDIFRX_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR)\
465 & (__FLAG__)) == (__FLAG__)) ? SET : RESET)
467 /** @brief Clears the specified SPDIFRX SR flag, in setting the proper IFCR register bit.
468 * @param __HANDLE__ specifies the USART Handle.
469 * @param __IT_CLEAR__ specifies the interrupt clear register flag that needs to be set
470 * to clear the corresponding interrupt
471 * This parameter can be one of the following values:
472 * @arg SPDIFRX_FLAG_PERR
473 * @arg SPDIFRX_FLAG_OVR
474 * @arg SPDIFRX_SR_SBD
475 * @arg SPDIFRX_SR_SYNCD
476 * @retval None
478 #define __HAL_SPDIFRX_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->IFCR = (uint32_t)(__IT_CLEAR__))
481 * @}
484 /* Exported functions --------------------------------------------------------*/
485 /** @addtogroup SPDIFRX_Exported_Functions
486 * @{
489 /** @addtogroup SPDIFRX_Exported_Functions_Group1
490 * @{
492 /* Initialization/de-initialization functions **********************************/
493 HAL_StatusTypeDef HAL_SPDIFRX_Init(SPDIFRX_HandleTypeDef *hspdif);
494 HAL_StatusTypeDef HAL_SPDIFRX_DeInit(SPDIFRX_HandleTypeDef *hspdif);
495 void HAL_SPDIFRX_MspInit(SPDIFRX_HandleTypeDef *hspdif);
496 void HAL_SPDIFRX_MspDeInit(SPDIFRX_HandleTypeDef *hspdif);
497 HAL_StatusTypeDef HAL_SPDIFRX_SetDataFormat(SPDIFRX_HandleTypeDef *hspdif, SPDIFRX_SetDataFormatTypeDef sDataFormat);
499 /* Callbacks Register/UnRegister functions ***********************************/
500 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
501 HAL_StatusTypeDef HAL_SPDIFRX_RegisterCallback(SPDIFRX_HandleTypeDef *hspdif, HAL_SPDIFRX_CallbackIDTypeDef CallbackID,
502 pSPDIFRX_CallbackTypeDef pCallback);
503 HAL_StatusTypeDef HAL_SPDIFRX_UnRegisterCallback(SPDIFRX_HandleTypeDef *hspdif,
504 HAL_SPDIFRX_CallbackIDTypeDef CallbackID);
505 #endif /* USE_HAL_SPDIFRX_REGISTER_CALLBACKS */
507 * @}
510 /** @addtogroup SPDIFRX_Exported_Functions_Group2
511 * @{
513 /* I/O operation functions ***************************************************/
514 /* Blocking mode: Polling */
515 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size,
516 uint32_t Timeout);
517 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size,
518 uint32_t Timeout);
520 /* Non-Blocking mode: Interrupt */
521 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
522 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
523 void HAL_SPDIFRX_IRQHandler(SPDIFRX_HandleTypeDef *hspdif);
525 /* Non-Blocking mode: DMA */
526 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
527 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
528 HAL_StatusTypeDef HAL_SPDIFRX_DMAStop(SPDIFRX_HandleTypeDef *hspdif);
530 /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/
531 void HAL_SPDIFRX_RxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
532 void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
533 void HAL_SPDIFRX_ErrorCallback(SPDIFRX_HandleTypeDef *hspdif);
534 void HAL_SPDIFRX_CxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
535 void HAL_SPDIFRX_CxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
537 * @}
540 /** @addtogroup SPDIFRX_Exported_Functions_Group3
541 * @{
543 /* Peripheral Control and State functions ************************************/
544 HAL_SPDIFRX_StateTypeDef HAL_SPDIFRX_GetState(SPDIFRX_HandleTypeDef const *const hspdif);
545 uint32_t HAL_SPDIFRX_GetError(SPDIFRX_HandleTypeDef const *const hspdif);
547 * @}
551 * @}
553 /* Private types -------------------------------------------------------------*/
554 /* Private variables ---------------------------------------------------------*/
555 /* Private constants ---------------------------------------------------------*/
556 /* Private macros ------------------------------------------------------------*/
557 /** @defgroup SPDIFRX_Private_Macros SPDIFRX Private Macros
558 * @{
560 #define IS_SPDIFRX_INPUT_SELECT(INPUT) (((INPUT) == SPDIFRX_INPUT_IN1) || \
561 ((INPUT) == SPDIFRX_INPUT_IN2) || \
562 ((INPUT) == SPDIFRX_INPUT_IN3) || \
563 ((INPUT) == SPDIFRX_INPUT_IN0))
565 #define IS_SPDIFRX_MAX_RETRIES(RET) (((RET) == SPDIFRX_MAXRETRIES_NONE) || \
566 ((RET) == SPDIFRX_MAXRETRIES_3) || \
567 ((RET) == SPDIFRX_MAXRETRIES_15) || \
568 ((RET) == SPDIFRX_MAXRETRIES_63))
570 #define IS_SPDIFRX_WAIT_FOR_ACTIVITY(VAL) (((VAL) == SPDIFRX_WAITFORACTIVITY_ON) || \
571 ((VAL) == SPDIFRX_WAITFORACTIVITY_OFF))
573 #define IS_PREAMBLE_TYPE_MASK(VAL) (((VAL) == SPDIFRX_PREAMBLETYPEMASK_ON) || \
574 ((VAL) == SPDIFRX_PREAMBLETYPEMASK_OFF))
576 #define IS_VALIDITY_MASK(VAL) (((VAL) == SPDIFRX_VALIDITYMASK_OFF) || \
577 ((VAL) == SPDIFRX_VALIDITYMASK_ON))
579 #define IS_PARITY_ERROR_MASK(VAL) (((VAL) == SPDIFRX_PARITYERRORMASK_OFF) || \
580 ((VAL) == SPDIFRX_PARITYERRORMASK_ON))
582 #define IS_SPDIFRX_CHANNEL(CHANNEL) (((CHANNEL) == SPDIFRX_CHANNEL_A) || \
583 ((CHANNEL) == SPDIFRX_CHANNEL_B))
585 #define IS_SPDIFRX_DATA_FORMAT(FORMAT) (((FORMAT) == SPDIFRX_DATAFORMAT_LSB) || \
586 ((FORMAT) == SPDIFRX_DATAFORMAT_MSB) || \
587 ((FORMAT) == SPDIFRX_DATAFORMAT_32BITS))
589 #define IS_STEREO_MODE(MODE) (((MODE) == SPDIFRX_STEREOMODE_DISABLE) || \
590 ((MODE) == SPDIFRX_STEREOMODE_ENABLE))
592 #define IS_CHANNEL_STATUS_MASK(VAL) (((VAL) == SPDIFRX_CHANNELSTATUS_ON) || \
593 ((VAL) == SPDIFRX_CHANNELSTATUS_OFF))
595 #define IS_SYMBOL_CLOCK_GEN(VAL) (((VAL) == ENABLE) || ((VAL) == DISABLE))
597 * @}
600 /* Private functions ---------------------------------------------------------*/
601 /** @defgroup SPDIFRX_Private_Functions SPDIFRX Private Functions
602 * @{
605 * @}
609 * @}
611 #endif /* SPDIFRX */
613 * @}
617 #ifdef __cplusplus
619 #endif
622 #endif /* STM32H7xx_HAL_SPDIFRX_H */