stm32f4xx_spdifrx.h 11 KB

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