stm32f4xx_spdifrx.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_spdifrx.h
  4. * @author MCD Application Team
  5. * @version V1.8.1
  6. * @date 27-January-2022
  7. * @brief This file contains all the functions prototypes for the SPDIFRX firmware
  8. * library.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * Copyright (c) 2016 STMicroelectronics.
  13. * All rights reserved.
  14. *
  15. * This software is licensed under terms that can be found in the LICENSE file
  16. * in the root directory of this software component.
  17. * If no LICENSE file comes with this software, it is provided AS-IS.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef __STM32F4xx_SPDIFRX_H
  23. #define __STM32F4xx_SPDIFRX_H
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. /* Includes ------------------------------------------------------------------*/
  28. #include "stm32f4xx.h"
  29. /** @addtogroup STM32F4xx_StdPeriph_Driver
  30. * @{
  31. */
  32. /** @addtogroup SPDIFRX
  33. * @{
  34. */
  35. #if defined(STM32F446xx)
  36. /* Exported types ------------------------------------------------------------*/
  37. /**
  38. * @brief SPDIFRX Init structure definition
  39. */
  40. typedef struct
  41. {
  42. uint32_t SPDIFRX_InputSelection; /*!< Specifies the SPDIFRX input selection.
  43. This parameter can be a value of @ref SPDIFRX_Input_Selection */
  44. uint32_t SPDIFRX_Retries; /*!< Specifies the Maximum allowed re-tries during synchronization phase.
  45. This parameter can be a value of @ref SPDIFRX_Max_Retries */
  46. uint32_t SPDIFRX_WaitForActivity; /*!< Specifies the wait for activity on SPDIFRX selected input.
  47. This parameter can be a value of @ref SPDIFRX_Wait_For_Activity. */
  48. uint32_t SPDIFRX_ChannelSelection; /*!< Specifies whether the control flow will take the channel status from channel A or B.
  49. This parameter can be a value of @ref SPDIFRX_Channel_Selection */
  50. uint32_t SPDIFRX_DataFormat; /*!< Specifies the Data samples format (LSB, MSB, ...).
  51. This parameter can be a value of @ref SPDIFRX_Data_Format */
  52. uint32_t SPDIFRX_StereoMode; /*!< Specifies whether the peripheral is in stereo or mono mode.
  53. This parameter can be a value of @ref SPDIFRX_Stereo_Mode */
  54. }SPDIFRX_InitTypeDef;
  55. /* Exported constants --------------------------------------------------------*/
  56. /** @defgroup SPDIFRX_Exported_Constants
  57. * @{
  58. */
  59. #define IS_SPDIFRX_PERIPH(PERIPH) (((PERIPH) == SPDIFRX))
  60. /** @defgroup SPDIFRX_Input_Selection SPDIFRX Input Selection
  61. * @{
  62. */
  63. #define SPDIFRX_Input_IN0 ((uint32_t)0x00000000)
  64. #define SPDIFRX_Input_IN1 ((uint32_t)0x00010000)
  65. #define SPDIFRX_Input_IN2 ((uint32_t)0x00020000)
  66. #define SPDIFRX_Input_IN3 ((uint32_t)0x00030000)
  67. #define IS_SPDIFRX_INPUT_SELECT(INPUT) (((INPUT) == SPDIFRX_Input_IN1) || \
  68. ((INPUT) == SPDIFRX_Input_IN2) || \
  69. ((INPUT) == SPDIFRX_Input_IN3) || \
  70. ((INPUT) == SPDIFRX_Input_IN0))
  71. /**
  72. * @}
  73. */
  74. /** @defgroup SPDIFRX_Max_Retries SPDIFRX Max Retries
  75. * @{
  76. */
  77. #define SPDIFRX_1MAX_RETRIES ((uint32_t)0x00000000)
  78. #define SPDIFRX_4MAX_RETRIES ((uint32_t)0x00001000)
  79. #define SPDIFRX_16MAX_RETRIES ((uint32_t)0x00002000)
  80. #define SPDIFRX_64MAX_RETRIES ((uint32_t)0x00003000)
  81. #define IS_SPDIFRX_MAX_RETRIES(RET) (((RET) == SPDIFRX_1MAX_RETRIES) || \
  82. ((RET) == SPDIFRX_4MAX_RETRIES) || \
  83. ((RET) == SPDIFRX_16MAX_RETRIES) || \
  84. ((RET) == SPDIFRX_64MAX_RETRIES))
  85. /**
  86. * @}
  87. */
  88. /** @defgroup SPDIFRX_Wait_For_Activity SPDIFRX Wait For Activity
  89. * @{
  90. */
  91. #define SPDIFRX_WaitForActivity_Off ((uint32_t)0x00000000)
  92. #define SPDIFRX_WaitForActivity_On ((uint32_t)SPDIFRX_CR_WFA)
  93. #define IS_SPDIFRX_WAIT_FOR_ACTIVITY(VAL) (((VAL) == SPDIFRX_WaitForActivity_On) || \
  94. ((VAL) == SPDIFRX_WaitForActivity_Off))
  95. /**
  96. * @}
  97. */
  98. /** @defgroup SPDIFRX_ChannelSelection SPDIFRX Channel Selection
  99. * @{
  100. */
  101. #define SPDIFRX_Select_Channel_A ((uint32_t)0x00000000)
  102. #define SPDIFRX_Select_Channel_B ((uint32_t)SPDIFRX_CR_CHSEL)
  103. #define IS_SPDIFRX_CHANNEL(CHANNEL) (((CHANNEL) == SPDIFRX_Select_Channel_A) || \
  104. ((CHANNEL) == SPDIFRX_Select_Channel_B))
  105. /**
  106. * @}
  107. */
  108. /** @defgroup SPDIFRX_Block_Synchronization SPDIFRX Block Synchronization
  109. * @{
  110. */
  111. #define SPDIFRX_LSB_DataFormat ((uint32_t)0x00000000)
  112. #define SPDIFRX_MSB_DataFormat ((uint32_t)0x00000010)
  113. #define SPDIFRX_32BITS_DataFormat ((uint32_t)0x00000020)
  114. #define IS_SPDIFRX_DATA_FORMAT(FORMAT) (((FORMAT) == SPDIFRX_LSB_DataFormat) || \
  115. ((FORMAT) == SPDIFRX_MSB_DataFormat) || \
  116. ((FORMAT) == SPDIFRX_32BITS_DataFormat))
  117. /**
  118. * @}
  119. */
  120. /** @defgroup SPDIFRX_StereoMode SPDIFRX StereoMode
  121. * @{
  122. */
  123. #define SPDIFRX_StereoMode_Disabled ((uint32_t)0x00000000)
  124. #define SPDIFRX_StereoMode_Enabled ((uint32_t)SPDIFRX_CR_RXSTEO)
  125. #define IS_STEREO_MODE(MODE) (((MODE) == SPDIFRX_StereoMode_Disabled) || \
  126. ((MODE) == SPDIFRX_StereoMode_Enabled))
  127. /**
  128. * @}
  129. */
  130. /** @defgroup SPDIFRX_State SPDIFRX State
  131. * @{
  132. */
  133. #define SPDIFRX_STATE_IDLE ((uint32_t)0x00000000)
  134. #define SPDIFRX_STATE_SYNC ((uint32_t)0x00000001)
  135. #define SPDIFRX_STATE_RCV ((uint32_t)SPDIFRX_CR_SPDIFEN)
  136. #define IS_SPDIFRX_STATE(STATE) (((STATE) == SPDIFRX_STATE_IDLE) || \
  137. ((STATE) == SPDIFRX_STATE_SYNC) || \
  138. ((STATE) == SPDIFRX_STATE_RCV))
  139. /**
  140. * @}
  141. */
  142. /** @defgroup SPDIFRX_Interrupts_Definition SPDIFRX Interrupts Definition
  143. * @{
  144. */
  145. #define SPDIFRX_IT_RXNE ((uint32_t)SPDIFRX_IMR_RXNEIE)
  146. #define SPDIFRX_IT_CSRNE ((uint32_t)SPDIFRX_IMR_CSRNEIE)
  147. #define SPDIFRX_IT_PERRIE ((uint32_t)SPDIFRX_IMR_PERRIE)
  148. #define SPDIFRX_IT_OVRIE ((uint32_t)SPDIFRX_IMR_OVRIE)
  149. #define SPDIFRX_IT_SBLKIE ((uint32_t)SPDIFRX_IMR_SBLKIE)
  150. #define SPDIFRX_IT_SYNCDIE ((uint32_t)SPDIFRX_IMR_SYNCDIE)
  151. #define SPDIFRX_IT_IFEIE ((uint32_t)SPDIFRX_IMR_IFEIE )
  152. #define IS_SPDIFRX_CONFIG_IT(IT) (((IT) == SPDIFRX_IT_RXNE) || \
  153. ((IT) == SPDIFRX_IT_CSRNE) || \
  154. ((IT) == SPDIFRX_IT_PERRIE) || \
  155. ((IT) == SPDIFRX_IT_OVRIE) || \
  156. ((IT) == SPDIFRX_IT_SBLKIE) || \
  157. ((IT) == SPDIFRX_IT_SYNCDIE) || \
  158. ((IT) == SPDIFRX_IT_IFEIE))
  159. /**
  160. * @}
  161. */
  162. /** @defgroup SPDIFRX_Flags_Definition SPDIFRX Flags Definition
  163. * @{
  164. */
  165. #define SPDIFRX_FLAG_RXNE ((uint32_t)SPDIFRX_SR_RXNE)
  166. #define SPDIFRX_FLAG_CSRNE ((uint32_t)SPDIFRX_SR_CSRNE)
  167. #define SPDIFRX_FLAG_PERR ((uint32_t)SPDIFRX_SR_PERR)
  168. #define SPDIFRX_FLAG_OVR ((uint32_t)SPDIFRX_SR_OVR)
  169. #define SPDIFRX_FLAG_SBD ((uint32_t)SPDIFRX_SR_SBD)
  170. #define SPDIFRX_FLAG_SYNCD ((uint32_t)SPDIFRX_SR_SYNCD)
  171. #define SPDIFRX_FLAG_FERR ((uint32_t)SPDIFRX_SR_FERR)
  172. #define SPDIFRX_FLAG_SERR ((uint32_t)SPDIFRX_SR_SERR)
  173. #define SPDIFRX_FLAG_TERR ((uint32_t)SPDIFRX_SR_TERR)
  174. #define IS_SPDIFRX_FLAG(FLAG) (((FLAG) == SPDIFRX_FLAG_RXNE) || ((FLAG) == SPDIFRX_FLAG_CSRNE) || \
  175. ((FLAG) == SPDIFRX_FLAG_PERR) || ((FLAG) == SPDIFRX_FLAG_OVR) || \
  176. ((FLAG) == SPDIFRX_SR_SBD) || ((FLAG) == SPDIFRX_SR_SYNCD) || \
  177. ((FLAG) == SPDIFRX_SR_FERR) || ((FLAG) == SPDIFRX_SR_SERR) || \
  178. ((FLAG) == SPDIFRX_SR_TERR))
  179. #define IS_SPDIFRX_CLEAR_FLAG(FLAG) (((FLAG) == SPDIFRX_FLAG_PERR) || ((FLAG) == SPDIFRX_FLAG_OVR) || \
  180. ((FLAG) == SPDIFRX_SR_SBD) || ((FLAG) == SPDIFRX_SR_SYNCD))
  181. /**
  182. * @}
  183. */
  184. /**
  185. * @}
  186. */
  187. /* Exported macro ------------------------------------------------------------*/
  188. /* Exported functions --------------------------------------------------------*/
  189. /* Function used to set the SPDIFRX configuration to the default reset state *****/
  190. void SPDIFRX_DeInit(void);
  191. /* Initialization and Configuration functions *********************************/
  192. void SPDIFRX_Init(SPDIFRX_InitTypeDef* SPDIFRX_InitStruct);
  193. void SPDIFRX_StructInit(SPDIFRX_InitTypeDef* SPDIFRX_InitStruct);
  194. void SPDIFRX_Cmd(uint32_t SPDIFRX_State);
  195. void SPDIFRX_SetPreambleTypeBit(FunctionalState NewState);
  196. void SPDIFRX_SetUserDataChannelStatusBits(FunctionalState NewState);
  197. void SPDIFRX_SetValidityBit(FunctionalState NewState);
  198. void SPDIFRX_SetParityBit(FunctionalState NewState);
  199. /* Data transfers functions ***************************************************/
  200. uint32_t SPDIFRX_ReceiveData(void);
  201. /* DMA transfers management functions *****************************************/
  202. void SPDIFRX_RxDMACmd(FunctionalState NewState);
  203. void SPDIFRX_CbDMACmd(FunctionalState NewState);
  204. /* Interrupts and flags management functions **********************************/
  205. void SPDIFRX_ITConfig(uint32_t SPDIFRX_IT, FunctionalState NewState);
  206. FlagStatus SPDIFRX_GetFlagStatus(uint32_t SPDIFRX_FLAG);
  207. void SPDIFRX_ClearFlag(uint32_t SPDIFRX_FLAG);
  208. ITStatus SPDIFRX_GetITStatus(uint32_t SPDIFRX_IT);
  209. void SPDIFRX_ClearITPendingBit(uint32_t SPDIFRX_IT);
  210. #endif /* STM32F446xx */
  211. /**
  212. * @}
  213. */
  214. /**
  215. * @}
  216. */
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220. #endif /*__STM32F4xx_SPDIFRX_H */