20#ifndef STM32H7xx_HAL_SPDIFRX_H
21#define STM32H7xx_HAL_SPDIFRX_H
51 uint32_t InputSelection;
57 uint32_t WaitForActivity;
60 uint32_t ChannelSelection;
69 uint32_t PreambleTypeMask;
72 uint32_t ChannelStatusMask;
75 uint32_t ValidityBitMask;
78 uint32_t ParityErrorMask;
80 FunctionalState SymbolClockGen;
83 FunctionalState BackupSymbolClockGen;
98 uint32_t PreambleTypeMask;
101 uint32_t ChannelStatusMask;
104 uint32_t ValidityBitMask;
107 uint32_t ParityErrorMask;
110} SPDIFRX_SetDataFormatTypeDef;
117 HAL_SPDIFRX_STATE_RESET = 0x00U,
118 HAL_SPDIFRX_STATE_READY = 0x01U,
119 HAL_SPDIFRX_STATE_BUSY = 0x02U,
120 HAL_SPDIFRX_STATE_BUSY_RX = 0x03U,
121 HAL_SPDIFRX_STATE_BUSY_CX = 0x04U,
122 HAL_SPDIFRX_STATE_ERROR = 0x07U
123} HAL_SPDIFRX_StateTypeDef;
128#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
129typedef struct __SPDIFRX_HandleTypeDef
136 SPDIFRX_InitTypeDef Init;
138 uint32_t *pRxBuffPtr;
140 uint32_t *pCsBuffPtr;
142 __IO uint16_t RxXferSize;
144 __IO uint16_t RxXferCount;
151 __IO uint16_t CsXferSize;
153 __IO uint16_t CsXferCount;
166 __IO HAL_SPDIFRX_StateTypeDef State;
168 __IO uint32_t ErrorCode;
170#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
171 void (*RxHalfCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
172 void (*RxCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
173 void (*CxHalfCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
174 void (*CxCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
175 void (*ErrorCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
176 void (* MspInitCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
177 void (* MspDeInitCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
180} SPDIFRX_HandleTypeDef;
185#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
191 HAL_SPDIFRX_RX_HALF_CB_ID = 0x00U,
192 HAL_SPDIFRX_RX_CPLT_CB_ID = 0x01U,
193 HAL_SPDIFRX_CX_HALF_CB_ID = 0x02U,
194 HAL_SPDIFRX_CX_CPLT_CB_ID = 0x03U,
195 HAL_SPDIFRX_ERROR_CB_ID = 0x04U,
196 HAL_SPDIFRX_MSPINIT_CB_ID = 0x05U,
197 HAL_SPDIFRX_MSPDEINIT_CB_ID = 0x06U
198} HAL_SPDIFRX_CallbackIDTypeDef;
203typedef void (*pSPDIFRX_CallbackTypeDef)(SPDIFRX_HandleTypeDef *hspdif);
215#define HAL_SPDIFRX_ERROR_NONE ((uint32_t)0x00000000U)
216#define HAL_SPDIFRX_ERROR_TIMEOUT ((uint32_t)0x00000001U)
217#define HAL_SPDIFRX_ERROR_OVR ((uint32_t)0x00000002U)
218#define HAL_SPDIFRX_ERROR_PE ((uint32_t)0x00000004U)
219#define HAL_SPDIFRX_ERROR_DMA ((uint32_t)0x00000008U)
220#define HAL_SPDIFRX_ERROR_UNKNOWN ((uint32_t)0x00000010U)
221#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
222#define HAL_SPDIFRX_ERROR_INVALID_CALLBACK ((uint32_t)0x00000020U)
232#define SPDIFRX_INPUT_IN0 ((uint32_t)0x00000000U)
233#define SPDIFRX_INPUT_IN1 ((uint32_t)0x00010000U)
234#define SPDIFRX_INPUT_IN2 ((uint32_t)0x00020000U)
235#define SPDIFRX_INPUT_IN3 ((uint32_t)0x00030000U)
244#define SPDIFRX_MAXRETRIES_NONE ((uint32_t)0x00000000U)
245#define SPDIFRX_MAXRETRIES_3 ((uint32_t)0x00001000U)
246#define SPDIFRX_MAXRETRIES_15 ((uint32_t)0x00002000U)
247#define SPDIFRX_MAXRETRIES_63 ((uint32_t)0x00003000U)
256#define SPDIFRX_WAITFORACTIVITY_OFF ((uint32_t)0x00000000U)
257#define SPDIFRX_WAITFORACTIVITY_ON ((uint32_t)SPDIFRX_CR_WFA)
266#define SPDIFRX_PREAMBLETYPEMASK_OFF ((uint32_t)0x00000000U)
267#define SPDIFRX_PREAMBLETYPEMASK_ON ((uint32_t)SPDIFRX_CR_PTMSK)
276#define SPDIFRX_CHANNELSTATUS_OFF ((uint32_t)0x00000000U)
277#define SPDIFRX_CHANNELSTATUS_ON ((uint32_t)SPDIFRX_CR_CUMSK)
286#define SPDIFRX_VALIDITYMASK_OFF ((uint32_t)0x00000000U)
287#define SPDIFRX_VALIDITYMASK_ON ((uint32_t)SPDIFRX_CR_VMSK)
296#define SPDIFRX_PARITYERRORMASK_OFF ((uint32_t)0x00000000U)
297#define SPDIFRX_PARITYERRORMASK_ON ((uint32_t)SPDIFRX_CR_PMSK)
306#define SPDIFRX_CHANNEL_A ((uint32_t)0x00000000U)
307#define SPDIFRX_CHANNEL_B ((uint32_t)SPDIFRX_CR_CHSEL)
316#define SPDIFRX_DATAFORMAT_LSB ((uint32_t)0x00000000U)
317#define SPDIFRX_DATAFORMAT_MSB ((uint32_t)0x00000010U)
318#define SPDIFRX_DATAFORMAT_32BITS ((uint32_t)0x00000020U)
327#define SPDIFRX_STEREOMODE_DISABLE ((uint32_t)0x00000000U)
328#define SPDIFRX_STEREOMODE_ENABLE ((uint32_t)SPDIFRX_CR_RXSTEO)
338#define SPDIFRX_STATE_IDLE ((uint32_t)0xFFFFFFFCU)
339#define SPDIFRX_STATE_SYNC ((uint32_t)0x00000001U)
340#define SPDIFRX_STATE_RCV ((uint32_t)SPDIFRX_CR_SPDIFEN)
349#define SPDIFRX_IT_RXNE ((uint32_t)SPDIFRX_IMR_RXNEIE)
350#define SPDIFRX_IT_CSRNE ((uint32_t)SPDIFRX_IMR_CSRNEIE)
351#define SPDIFRX_IT_PERRIE ((uint32_t)SPDIFRX_IMR_PERRIE)
352#define SPDIFRX_IT_OVRIE ((uint32_t)SPDIFRX_IMR_OVRIE)
353#define SPDIFRX_IT_SBLKIE ((uint32_t)SPDIFRX_IMR_SBLKIE)
354#define SPDIFRX_IT_SYNCDIE ((uint32_t)SPDIFRX_IMR_SYNCDIE)
355#define SPDIFRX_IT_IFEIE ((uint32_t)SPDIFRX_IMR_IFEIE )
364#define SPDIFRX_FLAG_RXNE ((uint32_t)SPDIFRX_SR_RXNE)
365#define SPDIFRX_FLAG_CSRNE ((uint32_t)SPDIFRX_SR_CSRNE)
366#define SPDIFRX_FLAG_PERR ((uint32_t)SPDIFRX_SR_PERR)
367#define SPDIFRX_FLAG_OVR ((uint32_t)SPDIFRX_SR_OVR)
368#define SPDIFRX_FLAG_SBD ((uint32_t)SPDIFRX_SR_SBD)
369#define SPDIFRX_FLAG_SYNCD ((uint32_t)SPDIFRX_SR_SYNCD)
370#define SPDIFRX_FLAG_FERR ((uint32_t)SPDIFRX_SR_FERR)
371#define SPDIFRX_FLAG_SERR ((uint32_t)SPDIFRX_SR_SERR)
372#define SPDIFRX_FLAG_TERR ((uint32_t)SPDIFRX_SR_TERR)
391#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
392#define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) do{\
393 (__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET;\
394 (__HANDLE__)->MspInitCallback = NULL;\
395 (__HANDLE__)->MspDeInitCallback = NULL;\
398#define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET)
405#define __HAL_SPDIFRX_IDLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= SPDIFRX_STATE_IDLE)
411#define __HAL_SPDIFRX_SYNC(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_SYNC)
418#define __HAL_SPDIFRX_RCV(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_RCV)
434#define __HAL_SPDIFRX_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
435#define __HAL_SPDIFRX_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR\
436 &= (uint16_t)(~(__INTERRUPT__)))
451#define __HAL_SPDIFRX_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR\
452 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
469#define __HAL_SPDIFRX_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR)\
470 & (__FLAG__)) == (__FLAG__)) ? SET : RESET)
483#define __HAL_SPDIFRX_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->IFCR = (uint32_t)(__IT_CLEAR__))
500void HAL_SPDIFRX_MspInit(SPDIFRX_HandleTypeDef *hspdif);
501void HAL_SPDIFRX_MspDeInit(SPDIFRX_HandleTypeDef *hspdif);
502HAL_StatusTypeDef HAL_SPDIFRX_SetDataFormat(SPDIFRX_HandleTypeDef *hspdif, SPDIFRX_SetDataFormatTypeDef sDataFormat);
505#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
506HAL_StatusTypeDef HAL_SPDIFRX_RegisterCallback(SPDIFRX_HandleTypeDef *hspdif, HAL_SPDIFRX_CallbackIDTypeDef CallbackID,
507 pSPDIFRX_CallbackTypeDef pCallback);
509 HAL_SPDIFRX_CallbackIDTypeDef CallbackID);
520HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size,
522HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size,
526HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
527HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
528void HAL_SPDIFRX_IRQHandler(SPDIFRX_HandleTypeDef *hspdif);
531HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
532HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
536void HAL_SPDIFRX_RxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
537void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
538void HAL_SPDIFRX_ErrorCallback(SPDIFRX_HandleTypeDef *hspdif);
539void HAL_SPDIFRX_CxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
540void HAL_SPDIFRX_CxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
549HAL_SPDIFRX_StateTypeDef HAL_SPDIFRX_GetState(SPDIFRX_HandleTypeDef
const *
const hspdif);
550uint32_t HAL_SPDIFRX_GetError(SPDIFRX_HandleTypeDef
const *
const hspdif);
566#define IS_SPDIFRX_INPUT_SELECT(INPUT) (((INPUT) == SPDIFRX_INPUT_IN1) || \
567 ((INPUT) == SPDIFRX_INPUT_IN2) || \
568 ((INPUT) == SPDIFRX_INPUT_IN3) || \
569 ((INPUT) == SPDIFRX_INPUT_IN0))
571#define IS_SPDIFRX_MAX_RETRIES(RET) (((RET) == SPDIFRX_MAXRETRIES_NONE) || \
572 ((RET) == SPDIFRX_MAXRETRIES_3) || \
573 ((RET) == SPDIFRX_MAXRETRIES_15) || \
574 ((RET) == SPDIFRX_MAXRETRIES_63))
576#define IS_SPDIFRX_WAIT_FOR_ACTIVITY(VAL) (((VAL) == SPDIFRX_WAITFORACTIVITY_ON) || \
577 ((VAL) == SPDIFRX_WAITFORACTIVITY_OFF))
579#define IS_PREAMBLE_TYPE_MASK(VAL) (((VAL) == SPDIFRX_PREAMBLETYPEMASK_ON) || \
580 ((VAL) == SPDIFRX_PREAMBLETYPEMASK_OFF))
582#define IS_VALIDITY_MASK(VAL) (((VAL) == SPDIFRX_VALIDITYMASK_OFF) || \
583 ((VAL) == SPDIFRX_VALIDITYMASK_ON))
585#define IS_PARITY_ERROR_MASK(VAL) (((VAL) == SPDIFRX_PARITYERRORMASK_OFF) || \
586 ((VAL) == SPDIFRX_PARITYERRORMASK_ON))
588#define IS_SPDIFRX_CHANNEL(CHANNEL) (((CHANNEL) == SPDIFRX_CHANNEL_A) || \
589 ((CHANNEL) == SPDIFRX_CHANNEL_B))
591#define IS_SPDIFRX_DATA_FORMAT(FORMAT) (((FORMAT) == SPDIFRX_DATAFORMAT_LSB) || \
592 ((FORMAT) == SPDIFRX_DATAFORMAT_MSB) || \
593 ((FORMAT) == SPDIFRX_DATAFORMAT_32BITS))
595#define IS_STEREO_MODE(MODE) (((MODE) == SPDIFRX_STEREOMODE_DISABLE) || \
596 ((MODE) == SPDIFRX_STEREOMODE_ENABLE))
598#define IS_CHANNEL_STATUS_MASK(VAL) (((VAL) == SPDIFRX_CHANNELSTATUS_ON) || \
599 ((VAL) == SPDIFRX_CHANNELSTATUS_OFF))
601#define IS_SYMBOL_CLOCK_GEN(VAL) (((VAL) == ENABLE) || ((VAL) == DISABLE))
#define __IO
Definition: core_cm4.h:239
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
SPDIF-RX Interface.
Definition: stm32h723xx.h:1391
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138