21 #ifndef STM32F7xx_HAL_SPDIFRX_H
22 #define STM32F7xx_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 } SPDIFRX_InitTypeDef;
93 uint32_t PreambleTypeMask;
96 uint32_t ChannelStatusMask;
99 uint32_t ValidityBitMask;
102 uint32_t ParityErrorMask;
105 } SPDIFRX_SetDataFormatTypeDef;
112 HAL_SPDIFRX_STATE_RESET = 0x00U,
113 HAL_SPDIFRX_STATE_READY = 0x01U,
114 HAL_SPDIFRX_STATE_BUSY = 0x02U,
115 HAL_SPDIFRX_STATE_BUSY_RX = 0x03U,
116 HAL_SPDIFRX_STATE_BUSY_CX = 0x04U,
117 HAL_SPDIFRX_STATE_ERROR = 0x07U
118 } HAL_SPDIFRX_StateTypeDef;
123 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
124 typedef struct __SPDIFRX_HandleTypeDef
131 SPDIFRX_InitTypeDef
Init;
133 uint32_t *pRxBuffPtr;
135 uint32_t *pCsBuffPtr;
137 __IO uint16_t RxXferSize;
139 __IO uint16_t RxXferCount;
146 __IO uint16_t CsXferSize;
148 __IO uint16_t CsXferCount;
161 __IO HAL_SPDIFRX_StateTypeDef State;
163 __IO uint32_t ErrorCode;
165 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
166 void (*RxHalfCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
167 void (*RxCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
168 void (*CxHalfCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
169 void (*CxCpltCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
170 void (*ErrorCallback)(
struct __SPDIFRX_HandleTypeDef *hspdif);
171 void (* MspInitCallback)(
struct __SPDIFRX_HandleTypeDef * hspdif);
172 void (* MspDeInitCallback)(
struct __SPDIFRX_HandleTypeDef * hspdif);
175 } SPDIFRX_HandleTypeDef;
180 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
186 HAL_SPDIFRX_RX_HALF_CB_ID = 0x00U,
187 HAL_SPDIFRX_RX_CPLT_CB_ID = 0x01U,
188 HAL_SPDIFRX_CX_HALF_CB_ID = 0x02U,
189 HAL_SPDIFRX_CX_CPLT_CB_ID = 0x03U,
190 HAL_SPDIFRX_ERROR_CB_ID = 0x04U,
191 HAL_SPDIFRX_MSPINIT_CB_ID = 0x05U,
192 HAL_SPDIFRX_MSPDEINIT_CB_ID = 0x06U
193 }HAL_SPDIFRX_CallbackIDTypeDef;
198 typedef void (*pSPDIFRX_CallbackTypeDef)(SPDIFRX_HandleTypeDef * hspdif);
208 #define HAL_SPDIFRX_ERROR_NONE ((uint32_t)0x00000000U)
209 #define HAL_SPDIFRX_ERROR_TIMEOUT ((uint32_t)0x00000001U)
210 #define HAL_SPDIFRX_ERROR_OVR ((uint32_t)0x00000002U)
211 #define HAL_SPDIFRX_ERROR_PE ((uint32_t)0x00000004U)
212 #define HAL_SPDIFRX_ERROR_DMA ((uint32_t)0x00000008U)
213 #define HAL_SPDIFRX_ERROR_UNKNOWN ((uint32_t)0x00000010U)
214 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
215 #define HAL_SPDIFRX_ERROR_INVALID_CALLBACK ((uint32_t)0x00000020U)
224 #define SPDIFRX_INPUT_IN0 ((uint32_t)0x00000000U)
225 #define SPDIFRX_INPUT_IN1 ((uint32_t)0x00010000U)
226 #define SPDIFRX_INPUT_IN2 ((uint32_t)0x00020000U)
227 #define SPDIFRX_INPUT_IN3 ((uint32_t)0x00030000U)
235 #define SPDIFRX_MAXRETRIES_NONE ((uint32_t)0x00000000U)
236 #define SPDIFRX_MAXRETRIES_3 ((uint32_t)0x00001000U)
237 #define SPDIFRX_MAXRETRIES_15 ((uint32_t)0x00002000U)
238 #define SPDIFRX_MAXRETRIES_63 ((uint32_t)0x00003000U)
246 #define SPDIFRX_WAITFORACTIVITY_OFF ((uint32_t)0x00000000U)
247 #define SPDIFRX_WAITFORACTIVITY_ON ((uint32_t)SPDIFRX_CR_WFA)
255 #define SPDIFRX_PREAMBLETYPEMASK_OFF ((uint32_t)0x00000000U)
256 #define SPDIFRX_PREAMBLETYPEMASK_ON ((uint32_t)SPDIFRX_CR_PTMSK)
264 #define SPDIFRX_CHANNELSTATUS_OFF ((uint32_t)0x00000000U)
265 #define SPDIFRX_CHANNELSTATUS_ON ((uint32_t)SPDIFRX_CR_CUMSK)
273 #define SPDIFRX_VALIDITYMASK_OFF ((uint32_t)0x00000000U)
274 #define SPDIFRX_VALIDITYMASK_ON ((uint32_t)SPDIFRX_CR_VMSK)
282 #define SPDIFRX_PARITYERRORMASK_OFF ((uint32_t)0x00000000U)
283 #define SPDIFRX_PARITYERRORMASK_ON ((uint32_t)SPDIFRX_CR_PMSK)
291 #define SPDIFRX_CHANNEL_A ((uint32_t)0x00000000U)
292 #define SPDIFRX_CHANNEL_B ((uint32_t)SPDIFRX_CR_CHSEL)
300 #define SPDIFRX_DATAFORMAT_LSB ((uint32_t)0x00000000U)
301 #define SPDIFRX_DATAFORMAT_MSB ((uint32_t)0x00000010U)
302 #define SPDIFRX_DATAFORMAT_32BITS ((uint32_t)0x00000020U)
310 #define SPDIFRX_STEREOMODE_DISABLE ((uint32_t)0x00000000U)
311 #define SPDIFRX_STEREOMODE_ENABLE ((uint32_t)SPDIFRX_CR_RXSTEO)
320 #define SPDIFRX_STATE_IDLE ((uint32_t)0xFFFFFFFCU)
321 #define SPDIFRX_STATE_SYNC ((uint32_t)0x00000001U)
322 #define SPDIFRX_STATE_RCV ((uint32_t)SPDIFRX_CR_SPDIFEN)
330 #define SPDIFRX_IT_RXNE ((uint32_t)SPDIFRX_IMR_RXNEIE)
331 #define SPDIFRX_IT_CSRNE ((uint32_t)SPDIFRX_IMR_CSRNEIE)
332 #define SPDIFRX_IT_PERRIE ((uint32_t)SPDIFRX_IMR_PERRIE)
333 #define SPDIFRX_IT_OVRIE ((uint32_t)SPDIFRX_IMR_OVRIE)
334 #define SPDIFRX_IT_SBLKIE ((uint32_t)SPDIFRX_IMR_SBLKIE)
335 #define SPDIFRX_IT_SYNCDIE ((uint32_t)SPDIFRX_IMR_SYNCDIE)
336 #define SPDIFRX_IT_IFEIE ((uint32_t)SPDIFRX_IMR_IFEIE )
344 #define SPDIFRX_FLAG_RXNE ((uint32_t)SPDIFRX_SR_RXNE)
345 #define SPDIFRX_FLAG_CSRNE ((uint32_t)SPDIFRX_SR_CSRNE)
346 #define SPDIFRX_FLAG_PERR ((uint32_t)SPDIFRX_SR_PERR)
347 #define SPDIFRX_FLAG_OVR ((uint32_t)SPDIFRX_SR_OVR)
348 #define SPDIFRX_FLAG_SBD ((uint32_t)SPDIFRX_SR_SBD)
349 #define SPDIFRX_FLAG_SYNCD ((uint32_t)SPDIFRX_SR_SYNCD)
350 #define SPDIFRX_FLAG_FERR ((uint32_t)SPDIFRX_SR_FERR)
351 #define SPDIFRX_FLAG_SERR ((uint32_t)SPDIFRX_SR_SERR)
352 #define SPDIFRX_FLAG_TERR ((uint32_t)SPDIFRX_SR_TERR)
370 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
371 #define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) do{\
372 (__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET;\
373 (__HANDLE__)->MspInitCallback = NULL;\
374 (__HANDLE__)->MspDeInitCallback = NULL;\
377 #define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SPDIFRX_STATE_RESET)
384 #define __HAL_SPDIFRX_IDLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= SPDIFRX_STATE_IDLE)
390 #define __HAL_SPDIFRX_SYNC(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_SYNC)
397 #define __HAL_SPDIFRX_RCV(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_RCV)
413 #define __HAL_SPDIFRX_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
414 #define __HAL_SPDIFRX_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (uint16_t)(~(__INTERRUPT__)))
429 #define __HAL_SPDIFRX_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
446 #define __HAL_SPDIFRX_GET_FLAG(__HANDLE__, __FLAG__) (((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) ? SET : RESET)
459 #define __HAL_SPDIFRX_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->IFCR = (uint32_t)(__IT_CLEAR__))
476 void HAL_SPDIFRX_MspInit(SPDIFRX_HandleTypeDef *hspdif);
477 void HAL_SPDIFRX_MspDeInit(SPDIFRX_HandleTypeDef *hspdif);
478 HAL_StatusTypeDef HAL_SPDIFRX_SetDataFormat(SPDIFRX_HandleTypeDef *hspdif, SPDIFRX_SetDataFormatTypeDef sDataFormat);
481 #if (USE_HAL_SPDIFRX_REGISTER_CALLBACKS == 1)
482 HAL_StatusTypeDef HAL_SPDIFRX_RegisterCallback(SPDIFRX_HandleTypeDef *hspdif, HAL_SPDIFRX_CallbackIDTypeDef CallbackID, pSPDIFRX_CallbackTypeDef pCallback);
483 HAL_StatusTypeDef HAL_SPDIFRX_UnRegisterCallback(SPDIFRX_HandleTypeDef *hspdif, HAL_SPDIFRX_CallbackIDTypeDef CallbackID);
494 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size, uint32_t Timeout);
495 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size, uint32_t Timeout);
498 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
499 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
500 void HAL_SPDIFRX_IRQHandler(SPDIFRX_HandleTypeDef *hspdif);
503 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
504 HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
508 void HAL_SPDIFRX_RxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
509 void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
510 void HAL_SPDIFRX_ErrorCallback(SPDIFRX_HandleTypeDef *hspdif);
511 void HAL_SPDIFRX_CxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
512 void HAL_SPDIFRX_CxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
521 HAL_SPDIFRX_StateTypeDef HAL_SPDIFRX_GetState(SPDIFRX_HandleTypeDef
const *
const hspdif);
522 uint32_t HAL_SPDIFRX_GetError(SPDIFRX_HandleTypeDef
const *
const hspdif);
537 #define IS_SPDIFRX_INPUT_SELECT(INPUT) (((INPUT) == SPDIFRX_INPUT_IN1) || \
538 ((INPUT) == SPDIFRX_INPUT_IN2) || \
539 ((INPUT) == SPDIFRX_INPUT_IN3) || \
540 ((INPUT) == SPDIFRX_INPUT_IN0))
542 #define IS_SPDIFRX_MAX_RETRIES(RET) (((RET) == SPDIFRX_MAXRETRIES_NONE) || \
543 ((RET) == SPDIFRX_MAXRETRIES_3) || \
544 ((RET) == SPDIFRX_MAXRETRIES_15) || \
545 ((RET) == SPDIFRX_MAXRETRIES_63))
547 #define IS_SPDIFRX_WAIT_FOR_ACTIVITY(VAL) (((VAL) == SPDIFRX_WAITFORACTIVITY_ON) || \
548 ((VAL) == SPDIFRX_WAITFORACTIVITY_OFF))
550 #define IS_PREAMBLE_TYPE_MASK(VAL) (((VAL) == SPDIFRX_PREAMBLETYPEMASK_ON) || \
551 ((VAL) == SPDIFRX_PREAMBLETYPEMASK_OFF))
553 #define IS_VALIDITY_MASK(VAL) (((VAL) == SPDIFRX_VALIDITYMASK_OFF) || \
554 ((VAL) == SPDIFRX_VALIDITYMASK_ON))
556 #define IS_PARITY_ERROR_MASK(VAL) (((VAL) == SPDIFRX_PARITYERRORMASK_OFF) || \
557 ((VAL) == SPDIFRX_PARITYERRORMASK_ON))
559 #define IS_SPDIFRX_CHANNEL(CHANNEL) (((CHANNEL) == SPDIFRX_CHANNEL_A) || \
560 ((CHANNEL) == SPDIFRX_CHANNEL_B))
562 #define IS_SPDIFRX_DATA_FORMAT(FORMAT) (((FORMAT) == SPDIFRX_DATAFORMAT_LSB) || \
563 ((FORMAT) == SPDIFRX_DATAFORMAT_MSB) || \
564 ((FORMAT) == SPDIFRX_DATAFORMAT_32BITS))
566 #define IS_STEREO_MODE(MODE) (((MODE) == SPDIFRX_STEREOMODE_DISABLE) || \
567 ((MODE) == SPDIFRX_STEREOMODE_ENABLE))
569 #define IS_CHANNEL_STATUS_MASK(VAL) (((VAL) == SPDIFRX_CHANNELSTATUS_ON) || \
570 ((VAL) == SPDIFRX_CHANNELSTATUS_OFF))