20#ifndef STM32H7xx_HAL_SPDIFRX_H
21#define STM32H7xx_HAL_SPDIFRX_H
51 uint32_t InputSelection;
57 uint32_t WaitForActivity;
60 uint32_t ChannelSelection;
70 uint32_t PreambleTypeMask;
74 uint32_t ChannelStatusMask;
78 uint32_t ValidityBitMask;
81 uint32_t ParityErrorMask;
84 FunctionalState SymbolClockGen;
87 FunctionalState BackupSymbolClockGen;
102 uint32_t PreambleTypeMask;
106 uint32_t ChannelStatusMask;
110 uint32_t ValidityBitMask;
113 uint32_t ParityErrorMask;
117} SPDIFRX_SetDataFormatTypeDef;
124 HAL_SPDIFRX_STATE_RESET = 0x00U,
125 HAL_SPDIFRX_STATE_READY = 0x01U,
126 HAL_SPDIFRX_STATE_BUSY = 0x02U,
127 HAL_SPDIFRX_STATE_BUSY_RX = 0x03U,
128 HAL_SPDIFRX_STATE_BUSY_CX = 0x04U,
129 HAL_SPDIFRX_STATE_ERROR = 0x07U
130} HAL_SPDIFRX_StateTypeDef;
135#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
136typedef struct __SPDIFRX_HandleTypeDef
143 SPDIFRX_InitTypeDef Init;
145 uint32_t *pRxBuffPtr;
147 uint32_t *pCsBuffPtr;
149 __IO uint16_t RxXferSize;
151 __IO uint16_t RxXferCount;
158 __IO uint16_t CsXferSize;
160 __IO uint16_t CsXferCount;
174 __IO HAL_SPDIFRX_StateTypeDef State;
176 __IO uint32_t ErrorCode;
178#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
179 void (*RxHalfCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
181 void (*RxCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
182 void (*CxHalfCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
184 void (*CxCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
185 void (*ErrorCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
186 void (* MspInitCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
187 void (* MspDeInitCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
190} SPDIFRX_HandleTypeDef;
192#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
198 HAL_SPDIFRX_RX_HALF_CB_ID = 0x00U,
199 HAL_SPDIFRX_RX_CPLT_CB_ID = 0x01U,
200 HAL_SPDIFRX_CX_HALF_CB_ID = 0x02U,
201 HAL_SPDIFRX_CX_CPLT_CB_ID = 0x03U,
202 HAL_SPDIFRX_ERROR_CB_ID = 0x04U,
203 HAL_SPDIFRX_MSPINIT_CB_ID = 0x05U,
204 HAL_SPDIFRX_MSPDEINIT_CB_ID = 0x06U
205} HAL_SPDIFRX_CallbackIDTypeDef;
210typedef void (*pSPDIFRX_CallbackTypeDef)(SPDIFRX_HandleTypeDef *hspdif);
225#define HAL_SPDIFRX_ERROR_NONE ((uint32_t)0x00000000U)
226#define HAL_SPDIFRX_ERROR_TIMEOUT ((uint32_t)0x00000001U)
227#define HAL_SPDIFRX_ERROR_OVR ((uint32_t)0x00000002U)
228#define HAL_SPDIFRX_ERROR_PE ((uint32_t)0x00000004U)
229#define HAL_SPDIFRX_ERROR_DMA ((uint32_t)0x00000008U)
230#define HAL_SPDIFRX_ERROR_UNKNOWN ((uint32_t)0x00000010U)
231#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
232#define HAL_SPDIFRX_ERROR_INVALID_CALLBACK ((uint32_t)0x00000020U)
242#define SPDIFRX_INPUT_IN0 ((uint32_t)0x00000000U)
243#define SPDIFRX_INPUT_IN1 ((uint32_t)0x00010000U)
244#define SPDIFRX_INPUT_IN2 ((uint32_t)0x00020000U)
245#define SPDIFRX_INPUT_IN3 ((uint32_t)0x00030000U)
254#define SPDIFRX_MAXRETRIES_NONE ((uint32_t)0x00000000U)
255#define SPDIFRX_MAXRETRIES_3 ((uint32_t)0x00001000U)
256#define SPDIFRX_MAXRETRIES_15 ((uint32_t)0x00002000U)
257#define SPDIFRX_MAXRETRIES_63 ((uint32_t)0x00003000U)
266#define SPDIFRX_WAITFORACTIVITY_OFF ((uint32_t)0x00000000U)
267#define SPDIFRX_WAITFORACTIVITY_ON ((uint32_t)SPDIFRX_CR_WFA)
276#define SPDIFRX_PREAMBLETYPEMASK_OFF ((uint32_t)0x00000000U)
277#define SPDIFRX_PREAMBLETYPEMASK_ON ((uint32_t)SPDIFRX_CR_PTMSK)
286#define SPDIFRX_CHANNELSTATUS_OFF ((uint32_t)0x00000000U)
288#define SPDIFRX_CHANNELSTATUS_ON ((uint32_t)SPDIFRX_CR_CUMSK)
298#define SPDIFRX_VALIDITYMASK_OFF ((uint32_t)0x00000000U)
299#define SPDIFRX_VALIDITYMASK_ON ((uint32_t)SPDIFRX_CR_VMSK)
308#define SPDIFRX_PARITYERRORMASK_OFF ((uint32_t)0x00000000U)
309#define SPDIFRX_PARITYERRORMASK_ON ((uint32_t)SPDIFRX_CR_PMSK)
318#define SPDIFRX_CHANNEL_A ((uint32_t)0x00000000U)
319#define SPDIFRX_CHANNEL_B ((uint32_t)SPDIFRX_CR_CHSEL)
328#define SPDIFRX_DATAFORMAT_LSB ((uint32_t)0x00000000U)
329#define SPDIFRX_DATAFORMAT_MSB ((uint32_t)0x00000010U)
330#define SPDIFRX_DATAFORMAT_32BITS ((uint32_t)0x00000020U)
339#define SPDIFRX_STEREOMODE_DISABLE ((uint32_t)0x00000000U)
340#define SPDIFRX_STEREOMODE_ENABLE ((uint32_t)SPDIFRX_CR_RXSTEO)
350#define SPDIFRX_STATE_IDLE ((uint32_t)0xFFFFFFFCU)
351#define SPDIFRX_STATE_SYNC ((uint32_t)0x00000001U)
352#define SPDIFRX_STATE_RCV ((uint32_t)SPDIFRX_CR_SPDIFEN)
361#define SPDIFRX_IT_RXNE ((uint32_t)SPDIFRX_IMR_RXNEIE)
362#define SPDIFRX_IT_CSRNE ((uint32_t)SPDIFRX_IMR_CSRNEIE)
363#define SPDIFRX_IT_PERRIE ((uint32_t)SPDIFRX_IMR_PERRIE)
364#define SPDIFRX_IT_OVRIE ((uint32_t)SPDIFRX_IMR_OVRIE)
365#define SPDIFRX_IT_SBLKIE ((uint32_t)SPDIFRX_IMR_SBLKIE)
366#define SPDIFRX_IT_SYNCDIE ((uint32_t)SPDIFRX_IMR_SYNCDIE)
367#define SPDIFRX_IT_IFEIE ((uint32_t)SPDIFRX_IMR_IFEIE )
376#define SPDIFRX_FLAG_RXNE ((uint32_t)SPDIFRX_SR_RXNE)
377#define SPDIFRX_FLAG_CSRNE ((uint32_t)SPDIFRX_SR_CSRNE)
378#define SPDIFRX_FLAG_PERR ((uint32_t)SPDIFRX_SR_PERR)
379#define SPDIFRX_FLAG_OVR ((uint32_t)SPDIFRX_SR_OVR)
380#define SPDIFRX_FLAG_SBD ((uint32_t)SPDIFRX_SR_SBD)
381#define SPDIFRX_FLAG_SYNCD ((uint32_t)SPDIFRX_SR_SYNCD)
382#define SPDIFRX_FLAG_FERR ((uint32_t)SPDIFRX_SR_FERR)
383#define SPDIFRX_FLAG_SERR ((uint32_t)SPDIFRX_SR_SERR)
384#define SPDIFRX_FLAG_TERR ((uint32_t)SPDIFRX_SR_TERR)
403#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
404#define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) do{\
405 (__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET;\
406 (__HANDLE__)->MspInitCallback = NULL;\
407 (__HANDLE__)->MspDeInitCallback = NULL;\
410#define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET)
417#define __HAL_SPDIFRX_IDLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= SPDIFRX_STATE_IDLE)
423#define __HAL_SPDIFRX_SYNC(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_SYNC)
430#define __HAL_SPDIFRX_RCV(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_RCV)
446#define __HAL_SPDIFRX_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
447#define __HAL_SPDIFRX_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR\
448 &= (uint16_t)(~(__INTERRUPT__)))
463#define __HAL_SPDIFRX_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR\
464 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
481#define __HAL_SPDIFRX_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR)\
482 & (__FLAG__)) == (__FLAG__)) ? SET : RESET)
495#define __HAL_SPDIFRX_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->IFCR = (uint32_t)(__IT_CLEAR__))
512void HAL_SPDIFRX_MspInit(SPDIFRX_HandleTypeDef *hspdif);
513void HAL_SPDIFRX_MspDeInit(SPDIFRX_HandleTypeDef *hspdif);
514HAL_StatusTypeDef HAL_SPDIFRX_SetDataFormat(SPDIFRX_HandleTypeDef *hspdif, SPDIFRX_SetDataFormatTypeDef sDataFormat);
517#if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
518HAL_StatusTypeDef HAL_SPDIFRX_RegisterCallback(SPDIFRX_HandleTypeDef *hspdif, HAL_SPDIFRX_CallbackIDTypeDef CallbackID,
519 pSPDIFRX_CallbackTypeDef pCallback);
521 HAL_SPDIFRX_CallbackIDTypeDef CallbackID);
532HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size,
534HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size,
538HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
539HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
540void HAL_SPDIFRX_IRQHandler(SPDIFRX_HandleTypeDef *hspdif);
543HAL_StatusTypeDef HAL_SPDIFRX_ReceiveCtrlFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
544HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
548void HAL_SPDIFRX_RxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
549void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
550void HAL_SPDIFRX_ErrorCallback(SPDIFRX_HandleTypeDef *hspdif);
551void HAL_SPDIFRX_CxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
552void HAL_SPDIFRX_CxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
561HAL_SPDIFRX_StateTypeDef HAL_SPDIFRX_GetState(SPDIFRX_HandleTypeDef
const *
const hspdif);
562uint32_t HAL_SPDIFRX_GetError(SPDIFRX_HandleTypeDef
const *
const hspdif);
578#define IS_SPDIFRX_INPUT_SELECT(INPUT) (((INPUT) == SPDIFRX_INPUT_IN1) || \
579 ((INPUT) == SPDIFRX_INPUT_IN2) || \
580 ((INPUT) == SPDIFRX_INPUT_IN3) || \
581 ((INPUT) == SPDIFRX_INPUT_IN0))
583#define IS_SPDIFRX_MAX_RETRIES(RET) (((RET) == SPDIFRX_MAXRETRIES_NONE) || \
584 ((RET) == SPDIFRX_MAXRETRIES_3) || \
585 ((RET) == SPDIFRX_MAXRETRIES_15) || \
586 ((RET) == SPDIFRX_MAXRETRIES_63))
588#define IS_SPDIFRX_WAIT_FOR_ACTIVITY(VAL) (((VAL) == SPDIFRX_WAITFORACTIVITY_ON) || \
589 ((VAL) == SPDIFRX_WAITFORACTIVITY_OFF))
591#define IS_PREAMBLE_TYPE_MASK(VAL) (((VAL) == SPDIFRX_PREAMBLETYPEMASK_ON) || \
592 ((VAL) == SPDIFRX_PREAMBLETYPEMASK_OFF))
594#define IS_VALIDITY_MASK(VAL) (((VAL) == SPDIFRX_VALIDITYMASK_OFF) || \
595 ((VAL) == SPDIFRX_VALIDITYMASK_ON))
597#define IS_PARITY_ERROR_MASK(VAL) (((VAL) == SPDIFRX_PARITYERRORMASK_OFF) || \
598 ((VAL) == SPDIFRX_PARITYERRORMASK_ON))
600#define IS_SPDIFRX_CHANNEL(CHANNEL) (((CHANNEL) == SPDIFRX_CHANNEL_A) || \
601 ((CHANNEL) == SPDIFRX_CHANNEL_B))
603#define IS_SPDIFRX_DATA_FORMAT(FORMAT) (((FORMAT) == SPDIFRX_DATAFORMAT_LSB) || \
604 ((FORMAT) == SPDIFRX_DATAFORMAT_MSB) || \
605 ((FORMAT) == SPDIFRX_DATAFORMAT_32BITS))
607#define IS_STEREO_MODE(MODE) (((MODE) == SPDIFRX_STEREOMODE_DISABLE) || \
608 ((MODE) == SPDIFRX_STEREOMODE_ENABLE))
610#define IS_CHANNEL_STATUS_MASK(VAL) (((VAL) == SPDIFRX_CHANNELSTATUS_ON) || \
611 ((VAL) == SPDIFRX_CHANNELSTATUS_OFF))
613#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