stm32f4xx_spdifrx.h 11 KB

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