[303] | 1 | /**
|
---|
| 2 | ******************************************************************************
|
---|
| 3 | * @file stm32f4xx_hal_spdifrx.h
|
---|
| 4 | * @author MCD Application Team
|
---|
| 5 | * @version V1.4.1
|
---|
| 6 | * @date 09-October-2015
|
---|
| 7 | * @brief Header file of SPDIFRX HAL module.
|
---|
| 8 | ******************************************************************************
|
---|
| 9 | * @attention
|
---|
| 10 | *
|
---|
| 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
|
---|
| 12 | *
|
---|
| 13 | * Redistribution and use in source and binary forms, with or without modification,
|
---|
| 14 | * are permitted provided that the following conditions are met:
|
---|
| 15 | * 1. Redistributions of source code must retain the above copyright notice,
|
---|
| 16 | * this list of conditions and the following disclaimer.
|
---|
| 17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
| 18 | * this list of conditions and the following disclaimer in the documentation
|
---|
| 19 | * and/or other materials provided with the distribution.
|
---|
| 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
|
---|
| 21 | * may be used to endorse or promote products derived from this software
|
---|
| 22 | * without specific prior written permission.
|
---|
| 23 | *
|
---|
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
---|
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
---|
| 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
---|
| 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
---|
| 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
---|
| 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
---|
| 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
---|
| 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
---|
| 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 34 | *
|
---|
| 35 | ******************************************************************************
|
---|
| 36 | */
|
---|
| 37 |
|
---|
| 38 | /* Define to prevent recursive inclusion -------------------------------------*/
|
---|
| 39 | #ifndef __STM32F4xx_HAL_SPDIFRX_H
|
---|
| 40 | #define __STM32F4xx_HAL_SPDIFRX_H
|
---|
| 41 |
|
---|
| 42 | #ifdef __cplusplus
|
---|
| 43 | extern "C" {
|
---|
| 44 | #endif
|
---|
| 45 |
|
---|
| 46 | #if defined(STM32F446xx)
|
---|
| 47 |
|
---|
| 48 | /* Includes ------------------------------------------------------------------*/
|
---|
| 49 | #include "stm32f4xx_hal_def.h"
|
---|
| 50 |
|
---|
| 51 | /** @addtogroup STM32F4xx_HAL_Driver
|
---|
| 52 | * @{
|
---|
| 53 | */
|
---|
| 54 |
|
---|
| 55 | /** @addtogroup SPDIFRX
|
---|
| 56 | * @{
|
---|
| 57 | */
|
---|
| 58 |
|
---|
| 59 | /* Exported types ------------------------------------------------------------*/
|
---|
| 60 | /** @defgroup SPDIFRX_Exported_Types SPDIFRX Exported Types
|
---|
| 61 | * @{
|
---|
| 62 | */
|
---|
| 63 |
|
---|
| 64 | /**
|
---|
| 65 | * @brief SPDIFRX Init structure definition
|
---|
| 66 | */
|
---|
| 67 | typedef struct
|
---|
| 68 | {
|
---|
| 69 | uint32_t InputSelection; /*!< Specifies the SPDIF input selection.
|
---|
| 70 | This parameter can be a value of @ref SPDIFRX_Input_Selection */
|
---|
| 71 |
|
---|
| 72 | uint32_t Retries; /*!< Specifies the Maximum allowed re-tries during synchronization phase.
|
---|
| 73 | This parameter can be a value of @ref SPDIFRX_Max_Retries */
|
---|
| 74 |
|
---|
| 75 | uint32_t WaitForActivity; /*!< Specifies the wait for activity on SPDIF selected input.
|
---|
| 76 | This parameter can be a value of @ref SPDIFRX_Wait_For_Activity. */
|
---|
| 77 |
|
---|
| 78 | uint32_t ChannelSelection; /*!< Specifies whether the control flow will take the channel status from channel A or B.
|
---|
| 79 | This parameter can be a value of @ref SPDIFRX_Channel_Selection */
|
---|
| 80 |
|
---|
| 81 | uint32_t DataFormat; /*!< Specifies the Data samples format (LSB, MSB, ...).
|
---|
| 82 | This parameter can be a value of @ref SPDIFRX_Data_Format */
|
---|
| 83 |
|
---|
| 84 | uint32_t StereoMode; /*!< Specifies whether the peripheral is in stereo or mono mode.
|
---|
| 85 | This parameter can be a value of @ref SPDIFRX_Stereo_Mode */
|
---|
| 86 |
|
---|
| 87 | uint32_t PreambleTypeMask; /*!< Specifies whether The preamble type bits are copied or not into the received frame.
|
---|
| 88 | This parameter can be a value of @ref SPDIFRX_PT_Mask */
|
---|
| 89 |
|
---|
| 90 | uint32_t ChannelStatusMask; /*!< Specifies whether the channel status and user bits are copied or not into the received frame.
|
---|
| 91 | This parameter can be a value of @ref SPDIFRX_ChannelStatus_Mask */
|
---|
| 92 |
|
---|
| 93 | uint32_t ValidityBitMask; /*!< Specifies whether the validity bit is copied or not into the received frame.
|
---|
| 94 | This parameter can be a value of @ref SPDIFRX_V_Mask */
|
---|
| 95 |
|
---|
| 96 | uint32_t ParityErrorMask; /*!< Specifies whether the parity error bit is copied or not into the received frame.
|
---|
| 97 | This parameter can be a value of @ref SPDIFRX_PE_Mask */
|
---|
| 98 |
|
---|
| 99 | }SPDIFRX_InitTypeDef;
|
---|
| 100 |
|
---|
| 101 | /**
|
---|
| 102 | * @brief SPDIFRX SetDataFormat structure definition
|
---|
| 103 | */
|
---|
| 104 | typedef struct
|
---|
| 105 | {
|
---|
| 106 | uint32_t DataFormat; /*!< Specifies the Data samples format (LSB, MSB, ...).
|
---|
| 107 | This parameter can be a value of @ref SPDIFRX_Data_Format */
|
---|
| 108 |
|
---|
| 109 | uint32_t StereoMode; /*!< Specifies whether the peripheral is in stereo or mono mode.
|
---|
| 110 | This parameter can be a value of @ref SPDIFRX_Stereo_Mode */
|
---|
| 111 |
|
---|
| 112 | uint32_t PreambleTypeMask; /*!< Specifies whether The preamble type bits are copied or not into the received frame.
|
---|
| 113 | This parameter can be a value of @ref SPDIFRX_PT_Mask */
|
---|
| 114 |
|
---|
| 115 | uint32_t ChannelStatusMask; /*!< Specifies whether the channel status and user bits are copied or not into the received frame.
|
---|
| 116 | This parameter can be a value of @ref SPDIFRX_ChannelStatus_Mask */
|
---|
| 117 |
|
---|
| 118 | uint32_t ValidityBitMask; /*!< Specifies whether the validity bit is copied or not into the received frame.
|
---|
| 119 | This parameter can be a value of @ref SPDIFRX_V_Mask */
|
---|
| 120 |
|
---|
| 121 | uint32_t ParityErrorMask; /*!< Specifies whether the parity error bit is copied or not into the received frame.
|
---|
| 122 | This parameter can be a value of @ref SPDIFRX_PE_Mask */
|
---|
| 123 |
|
---|
| 124 | }SPDIFRX_SetDataFormatTypeDef;
|
---|
| 125 |
|
---|
| 126 | /**
|
---|
| 127 | * @brief HAL State structures definition
|
---|
| 128 | */
|
---|
| 129 | typedef enum
|
---|
| 130 | {
|
---|
| 131 | HAL_SPDIFRX_STATE_RESET = 0x00, /*!< SPDIFRX not yet initialized or disabled */
|
---|
| 132 | HAL_SPDIFRX_STATE_READY = 0x01, /*!< SPDIFRX initialized and ready for use */
|
---|
| 133 | HAL_SPDIFRX_STATE_BUSY = 0x02, /*!< SPDIFRX internal process is ongoing */
|
---|
| 134 | HAL_SPDIFRX_STATE_BUSY_RX = 0x03, /*!< SPDIFRX internal Data Flow RX process is ongoing */
|
---|
| 135 | HAL_SPDIFRX_STATE_BUSY_CX = 0x04, /*!< SPDIFRX internal Control Flow RX process is ongoing */
|
---|
| 136 | HAL_SPDIFRX_STATE_ERROR = 0x07 /*!< SPDIFRX error state */
|
---|
| 137 | }HAL_SPDIFRX_StateTypeDef;
|
---|
| 138 |
|
---|
| 139 | /**
|
---|
| 140 | * @brief SPDIFRX handle Structure definition
|
---|
| 141 | */
|
---|
| 142 | typedef struct
|
---|
| 143 | {
|
---|
| 144 | SPDIFRX_TypeDef *Instance; /* SPDIFRX registers base address */
|
---|
| 145 |
|
---|
| 146 | SPDIFRX_InitTypeDef Init; /* SPDIFRX communication parameters */
|
---|
| 147 |
|
---|
| 148 | uint32_t *pRxBuffPtr; /* Pointer to SPDIFRX Rx transfer buffer */
|
---|
| 149 |
|
---|
| 150 | uint32_t *pCsBuffPtr; /* Pointer to SPDIFRX Cx transfer buffer */
|
---|
| 151 |
|
---|
| 152 | __IO uint16_t RxXferSize; /* SPDIFRX Rx transfer size */
|
---|
| 153 |
|
---|
| 154 | __IO uint16_t RxXferCount; /* SPDIFRX Rx transfer counter
|
---|
| 155 | (This field is initialized at the
|
---|
| 156 | same value as transfer size at the
|
---|
| 157 | beginning of the transfer and
|
---|
| 158 | decremented when a sample is received.
|
---|
| 159 | NbSamplesReceived = RxBufferSize-RxBufferCount) */
|
---|
| 160 |
|
---|
| 161 | __IO uint16_t CsXferSize; /* SPDIFRX Rx transfer size */
|
---|
| 162 |
|
---|
| 163 | __IO uint16_t CsXferCount; /* SPDIFRX Rx transfer counter
|
---|
| 164 | (This field is initialized at the
|
---|
| 165 | same value as transfer size at the
|
---|
| 166 | beginning of the transfer and
|
---|
| 167 | decremented when a sample is received.
|
---|
| 168 | NbSamplesReceived = RxBufferSize-RxBufferCount) */
|
---|
| 169 |
|
---|
| 170 | DMA_HandleTypeDef *hdmaCsRx; /* SPDIFRX EC60958_channel_status and user_information DMA handle parameters */
|
---|
| 171 |
|
---|
| 172 | DMA_HandleTypeDef *hdmaDrRx; /* SPDIFRX Rx DMA handle parameters */
|
---|
| 173 |
|
---|
| 174 | __IO HAL_LockTypeDef Lock; /* SPDIFRX locking object */
|
---|
| 175 |
|
---|
| 176 | __IO HAL_SPDIFRX_StateTypeDef State; /* SPDIFRX communication state */
|
---|
| 177 |
|
---|
| 178 | __IO uint32_t ErrorCode; /* SPDIFRX Error code */
|
---|
| 179 |
|
---|
| 180 | }SPDIFRX_HandleTypeDef;
|
---|
| 181 | /**
|
---|
| 182 | * @}
|
---|
| 183 | */
|
---|
| 184 |
|
---|
| 185 | /* Exported constants --------------------------------------------------------*/
|
---|
| 186 | /** @defgroup SPDIFRX_Exported_Constants SPDIFRX Exported Constants
|
---|
| 187 | * @{
|
---|
| 188 | */
|
---|
| 189 | /** @defgroup SPDIFRX_ErrorCode SPDIFRX Error Code
|
---|
| 190 | * @{
|
---|
| 191 | */
|
---|
| 192 | #define HAL_SPDIFRX_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */
|
---|
| 193 | #define HAL_SPDIFRX_ERROR_TIMEOUT ((uint32_t)0x00000001) /*!< Timeout error */
|
---|
| 194 | #define HAL_SPDIFRX_ERROR_OVR ((uint32_t)0x00000002) /*!< OVR error */
|
---|
| 195 | #define HAL_SPDIFRX_ERROR_PE ((uint32_t)0x00000004) /*!< Parity error */
|
---|
| 196 | #define HAL_SPDIFRX_ERROR_DMA ((uint32_t)0x00000008) /*!< DMA transfer error */
|
---|
| 197 | #define HAL_SPDIFRX_ERROR_UNKNOWN ((uint32_t)0x00000010) /*!< Unknown Error error */
|
---|
| 198 | /**
|
---|
| 199 | * @}
|
---|
| 200 | */
|
---|
| 201 |
|
---|
| 202 | /** @defgroup SPDIFRX_Input_Selection SPDIFRX Input Selection
|
---|
| 203 | * @{
|
---|
| 204 | */
|
---|
| 205 | #define SPDIFRX_INPUT_IN0 ((uint32_t)0x00000000)
|
---|
| 206 | #define SPDIFRX_INPUT_IN1 ((uint32_t)0x00010000)
|
---|
| 207 | #define SPDIFRX_INPUT_IN2 ((uint32_t)0x00020000)
|
---|
| 208 | #define SPDIFRX_INPUT_IN3 ((uint32_t)0x00030000)
|
---|
| 209 | /**
|
---|
| 210 | * @}
|
---|
| 211 | */
|
---|
| 212 |
|
---|
| 213 | /** @defgroup SPDIFRX_Max_Retries SPDIFRX Maximum Retries
|
---|
| 214 | * @{
|
---|
| 215 | */
|
---|
| 216 | #define SPDIFRX_MAXRETRIES_NONE ((uint32_t)0x00000000)
|
---|
| 217 | #define SPDIFRX_MAXRETRIES_3 ((uint32_t)0x00001000)
|
---|
| 218 | #define SPDIFRX_MAXRETRIES_15 ((uint32_t)0x00002000)
|
---|
| 219 | #define SPDIFRX_MAXRETRIES_63 ((uint32_t)0x00003000)
|
---|
| 220 | /**
|
---|
| 221 | * @}
|
---|
| 222 | */
|
---|
| 223 |
|
---|
| 224 | /** @defgroup SPDIFRX_Wait_For_Activity SPDIFRX Wait For Activity
|
---|
| 225 | * @{
|
---|
| 226 | */
|
---|
| 227 | #define SPDIFRX_WAITFORACTIVITY_OFF ((uint32_t)0x00000000)
|
---|
| 228 | #define SPDIFRX_WAITFORACTIVITY_ON ((uint32_t)SPDIFRX_CR_WFA)
|
---|
| 229 | /**
|
---|
| 230 | * @}
|
---|
| 231 | */
|
---|
| 232 |
|
---|
| 233 | /** @defgroup SPDIFRX_PT_Mask SPDIFRX Preamble Type Mask
|
---|
| 234 | * @{
|
---|
| 235 | */
|
---|
| 236 | #define SPDIFRX_PREAMBLETYPEMASK_OFF ((uint32_t)0x00000000)
|
---|
| 237 | #define SPDIFRX_PREAMBLETYPEMASK_ON ((uint32_t)SPDIFRX_CR_PTMSK)
|
---|
| 238 | /**
|
---|
| 239 | * @}
|
---|
| 240 | */
|
---|
| 241 |
|
---|
| 242 | /** @defgroup SPDIFRX_ChannelStatus_Mask SPDIFRX Channel Status Mask
|
---|
| 243 | * @{
|
---|
| 244 | */
|
---|
| 245 | #define SPDIFRX_CHANNELSTATUS_OFF ((uint32_t)0x00000000) /* The channel status and user bits are copied into the SPDIF_DR */
|
---|
| 246 | #define SPDIFRX_CHANNELSTATUS_ON ((uint32_t)SPDIFRX_CR_CUMSK) /* The channel status and user bits are not copied into the SPDIF_DR, zeros are written instead*/
|
---|
| 247 | /**
|
---|
| 248 | * @}
|
---|
| 249 | */
|
---|
| 250 |
|
---|
| 251 | /** @defgroup SPDIFRX_V_Mask SPDIFRX Validity Mask
|
---|
| 252 | * @{
|
---|
| 253 | */
|
---|
| 254 | #define SPDIFRX_VALIDITYMASK_OFF ((uint32_t)0x00000000)
|
---|
| 255 | #define SPDIFRX_VALIDITYMASK_ON ((uint32_t)SPDIFRX_CR_VMSK)
|
---|
| 256 | /**
|
---|
| 257 | * @}
|
---|
| 258 | */
|
---|
| 259 |
|
---|
| 260 | /** @defgroup SPDIFRX_PE_Mask SPDIFRX Parity Error Mask
|
---|
| 261 | * @{
|
---|
| 262 | */
|
---|
| 263 | #define SPDIFRX_PARITYERRORMASK_OFF ((uint32_t)0x00000000)
|
---|
| 264 | #define SPDIFRX_PARITYERRORMASK_ON ((uint32_t)SPDIFRX_CR_PMSK)
|
---|
| 265 | /**
|
---|
| 266 | * @}
|
---|
| 267 | */
|
---|
| 268 |
|
---|
| 269 | /** @defgroup SPDIFRX_Channel_Selection SPDIFRX Channel Selection
|
---|
| 270 | * @{
|
---|
| 271 | */
|
---|
| 272 | #define SPDIFRX_CHANNEL_A ((uint32_t)0x00000000)
|
---|
| 273 | #define SPDIFRX_CHANNEL_B ((uint32_t)SPDIFRX_CR_CHSEL)
|
---|
| 274 | /**
|
---|
| 275 | * @}
|
---|
| 276 | */
|
---|
| 277 |
|
---|
| 278 | /** @defgroup SPDIFRX_Data_Format SPDIFRX Data Format
|
---|
| 279 | * @{
|
---|
| 280 | */
|
---|
| 281 | #define SPDIFRX_DATAFORMAT_LSB ((uint32_t)0x00000000)
|
---|
| 282 | #define SPDIFRX_DATAFORMAT_MSB ((uint32_t)0x00000010)
|
---|
| 283 | #define SPDIFRX_DATAFORMAT_32BITS ((uint32_t)0x00000020)
|
---|
| 284 | /**
|
---|
| 285 | * @}
|
---|
| 286 | */
|
---|
| 287 |
|
---|
| 288 | /** @defgroup SPDIFRX_Stereo_Mode SPDIFRX Stereo Mode
|
---|
| 289 | * @{
|
---|
| 290 | */
|
---|
| 291 | #define SPDIFRX_STEREOMODE_DISABLE ((uint32_t)0x00000000)
|
---|
| 292 | #define SPDIFRX_STEREOMODE_ENABLE ((uint32_t)SPDIFRX_CR_RXSTEO)
|
---|
| 293 | /**
|
---|
| 294 | * @}
|
---|
| 295 | */
|
---|
| 296 |
|
---|
| 297 | /** @defgroup SPDIFRX_State SPDIFRX State
|
---|
| 298 | * @{
|
---|
| 299 | */
|
---|
| 300 |
|
---|
| 301 | #define SPDIFRX_STATE_IDLE ((uint32_t)0xFFFFFFFC)
|
---|
| 302 | #define SPDIFRX_STATE_SYNC ((uint32_t)0x00000001)
|
---|
| 303 | #define SPDIFRX_STATE_RCV ((uint32_t)SPDIFRX_CR_SPDIFEN)
|
---|
| 304 | /**
|
---|
| 305 | * @}
|
---|
| 306 | */
|
---|
| 307 |
|
---|
| 308 | /** @defgroup SPDIFRX_Interrupts_Definition SPDIFRX Interrupts Definition
|
---|
| 309 | * @{
|
---|
| 310 | */
|
---|
| 311 | #define SPDIFRX_IT_RXNE ((uint32_t)SPDIFRX_IMR_RXNEIE)
|
---|
| 312 | #define SPDIFRX_IT_CSRNE ((uint32_t)SPDIFRX_IMR_CSRNEIE)
|
---|
| 313 | #define SPDIFRX_IT_PERRIE ((uint32_t)SPDIFRX_IMR_PERRIE)
|
---|
| 314 | #define SPDIFRX_IT_OVRIE ((uint32_t)SPDIFRX_IMR_OVRIE)
|
---|
| 315 | #define SPDIFRX_IT_SBLKIE ((uint32_t)SPDIFRX_IMR_SBLKIE)
|
---|
| 316 | #define SPDIFRX_IT_SYNCDIE ((uint32_t)SPDIFRX_IMR_SYNCDIE)
|
---|
| 317 | #define SPDIFRX_IT_IFEIE ((uint32_t)SPDIFRX_IMR_IFEIE )
|
---|
| 318 | /**
|
---|
| 319 | * @}
|
---|
| 320 | */
|
---|
| 321 |
|
---|
| 322 | /** @defgroup SPDIFRX_Flags_Definition SPDIFRX Flags Definition
|
---|
| 323 | * @{
|
---|
| 324 | */
|
---|
| 325 | #define SPDIFRX_FLAG_RXNE ((uint32_t)SPDIFRX_SR_RXNE)
|
---|
| 326 | #define SPDIFRX_FLAG_CSRNE ((uint32_t)SPDIFRX_SR_CSRNE)
|
---|
| 327 | #define SPDIFRX_FLAG_PERR ((uint32_t)SPDIFRX_SR_PERR)
|
---|
| 328 | #define SPDIFRX_FLAG_OVR ((uint32_t)SPDIFRX_SR_OVR)
|
---|
| 329 | #define SPDIFRX_FLAG_SBD ((uint32_t)SPDIFRX_SR_SBD)
|
---|
| 330 | #define SPDIFRX_FLAG_SYNCD ((uint32_t)SPDIFRX_SR_SYNCD)
|
---|
| 331 | #define SPDIFRX_FLAG_FERR ((uint32_t)SPDIFRX_SR_FERR)
|
---|
| 332 | #define SPDIFRX_FLAG_SERR ((uint32_t)SPDIFRX_SR_SERR)
|
---|
| 333 | #define SPDIFRX_FLAG_TERR ((uint32_t)SPDIFRX_SR_TERR)
|
---|
| 334 | /**
|
---|
| 335 | * @}
|
---|
| 336 | */
|
---|
| 337 |
|
---|
| 338 | /**
|
---|
| 339 | * @}
|
---|
| 340 | */
|
---|
| 341 |
|
---|
| 342 | /* Exported macros -----------------------------------------------------------*/
|
---|
| 343 | /** @defgroup SPDIFRX_Exported_macros SPDIFRX Exported Macros
|
---|
| 344 | * @{
|
---|
| 345 | */
|
---|
| 346 |
|
---|
| 347 | /** @brief Reset SPDIFRX handle state
|
---|
| 348 | * @param __HANDLE__: SPDIFRX handle.
|
---|
| 349 | * @retval None
|
---|
| 350 | */
|
---|
| 351 | #define __HAL_SPDIFRX_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = (uint16_t)SPDIFRX_CR_SPDIFEN)
|
---|
| 352 |
|
---|
| 353 | /** @brief Disable the specified SPDIFRX peripheral (IDLE State).
|
---|
| 354 | * @param __HANDLE__: specifies the SPDIFRX Handle.
|
---|
| 355 | * @retval None
|
---|
| 356 | */
|
---|
| 357 | #define __HAL_SPDIFRX_IDLE(__HANDLE__) ((__HANDLE__)->Instance->CR &= SPDIFRX_STATE_IDLE)
|
---|
| 358 |
|
---|
| 359 | /** @brief Enable the specified SPDIFRX peripheral (SYNC State).
|
---|
| 360 | * @param __HANDLE__: specifies the SPDIFRX Handle.
|
---|
| 361 | * @retval None
|
---|
| 362 | */
|
---|
| 363 | #define __HAL_SPDIFRX_SYNC(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_SYNC)
|
---|
| 364 |
|
---|
| 365 |
|
---|
| 366 | /** @brief Enable the specified SPDIFRX peripheral (RCV State).
|
---|
| 367 | * @param __HANDLE__: specifies the SPDIFRX Handle.
|
---|
| 368 | * @retval None
|
---|
| 369 | */
|
---|
| 370 | #define __HAL_SPDIFRX_RCV(__HANDLE__) ((__HANDLE__)->Instance->CR |= SPDIFRX_STATE_RCV)
|
---|
| 371 |
|
---|
| 372 |
|
---|
| 373 | /** @brief Enable or disable the specified SPDIFRX interrupts.
|
---|
| 374 | * @param __HANDLE__: specifies the SPDIFRX Handle.
|
---|
| 375 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable.
|
---|
| 376 | * This parameter can be one of the following values:
|
---|
| 377 | * @arg SPDIFRX_IT_RXNE
|
---|
| 378 | * @arg SPDIFRX_IT_CSRNE
|
---|
| 379 | * @arg SPDIFRX_IT_PERRIE
|
---|
| 380 | * @arg SPDIFRX_IT_OVRIE
|
---|
| 381 | * @arg SPDIFRX_IT_SBLKIE
|
---|
| 382 | * @arg SPDIFRX_IT_SYNCDIE
|
---|
| 383 | * @arg SPDIFRX_IT_IFEIE
|
---|
| 384 | * @retval None
|
---|
| 385 | */
|
---|
| 386 | #define __HAL_SPDIFRX_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
|
---|
| 387 | #define __HAL_SPDIFRX_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (uint16_t)(~(__INTERRUPT__)))
|
---|
| 388 |
|
---|
| 389 | /** @brief Checks if the specified SPDIFRX interrupt source is enabled or disabled.
|
---|
| 390 | * @param __HANDLE__: specifies the SPDIFRX Handle.
|
---|
| 391 | * @param __INTERRUPT__: specifies the SPDIFRX interrupt source to check.
|
---|
| 392 | * This parameter can be one of the following values:
|
---|
| 393 | * @arg SPDIFRX_IT_RXNE
|
---|
| 394 | * @arg SPDIFRX_IT_CSRNE
|
---|
| 395 | * @arg SPDIFRX_IT_PERRIE
|
---|
| 396 | * @arg SPDIFRX_IT_OVRIE
|
---|
| 397 | * @arg SPDIFRX_IT_SBLKIE
|
---|
| 398 | * @arg SPDIFRX_IT_SYNCDIE
|
---|
| 399 | * @arg SPDIFRX_IT_IFEIE
|
---|
| 400 | * @retval The new state of __IT__ (TRUE or FALSE).
|
---|
| 401 | */
|
---|
| 402 | #define __HAL_SPDIFRX_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
|
---|
| 403 |
|
---|
| 404 | /** @brief Checks whether the specified SPDIFRX flag is set or not.
|
---|
| 405 | * @param __HANDLE__: specifies the SPDIFRX Handle.
|
---|
| 406 | * @param __FLAG__: specifies the flag to check.
|
---|
| 407 | * This parameter can be one of the following values:
|
---|
| 408 | * @arg SPDIFRX_FLAG_RXNE
|
---|
| 409 | * @arg SPDIFRX_FLAG_CSRNE
|
---|
| 410 | * @arg SPDIFRX_FLAG_PERR
|
---|
| 411 | * @arg SPDIFRX_FLAG_OVR
|
---|
| 412 | * @arg SPDIFRX_FLAG_SBD
|
---|
| 413 | * @arg SPDIFRX_FLAG_SYNCD
|
---|
| 414 | * @arg SPDIFRX_FLAG_FERR
|
---|
| 415 | * @arg SPDIFRX_FLAG_SERR
|
---|
| 416 | * @arg SPDIFRX_FLAG_TERR
|
---|
| 417 | * @retval The new state of __FLAG__ (TRUE or FALSE).
|
---|
| 418 | */
|
---|
| 419 | #define __HAL_SPDIFRX_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
|
---|
| 420 |
|
---|
| 421 | /** @brief Clears the specified SPDIFRX SR flag, in setting the proper IFCR register bit.
|
---|
| 422 | * @param __HANDLE__: specifies the USART Handle.
|
---|
| 423 | * @param __IT_CLEAR__: specifies the interrupt clear register flag that needs to be set
|
---|
| 424 | * to clear the corresponding interrupt
|
---|
| 425 | * This parameter can be one of the following values:
|
---|
| 426 | * @arg SPDIFRX_FLAG_PERR
|
---|
| 427 | * @arg SPDIFRX_FLAG_OVR
|
---|
| 428 | * @arg SPDIFRX_SR_SBD
|
---|
| 429 | * @arg SPDIFRX_SR_SYNCD
|
---|
| 430 | * @retval None
|
---|
| 431 | */
|
---|
| 432 | #define __HAL_SPDIFRX_CLEAR_IT(__HANDLE__, __IT_CLEAR__) ((__HANDLE__)->Instance->IFCR = (uint32_t)(__IT_CLEAR__))
|
---|
| 433 |
|
---|
| 434 | /**
|
---|
| 435 | * @}
|
---|
| 436 | */
|
---|
| 437 |
|
---|
| 438 | /* Exported functions --------------------------------------------------------*/
|
---|
| 439 | /** @addtogroup SPDIFRX_Exported_Functions
|
---|
| 440 | * @{
|
---|
| 441 | */
|
---|
| 442 |
|
---|
| 443 | /** @addtogroup SPDIFRX_Exported_Functions_Group1
|
---|
| 444 | * @{
|
---|
| 445 | */
|
---|
| 446 | /* Initialization/de-initialization functions **********************************/
|
---|
| 447 | HAL_StatusTypeDef HAL_SPDIFRX_Init(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 448 | HAL_StatusTypeDef HAL_SPDIFRX_DeInit (SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 449 | void HAL_SPDIFRX_MspInit(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 450 | void HAL_SPDIFRX_MspDeInit(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 451 | HAL_StatusTypeDef HAL_SPDIFRX_SetDataFormat(SPDIFRX_HandleTypeDef *hspdif, SPDIFRX_SetDataFormatTypeDef sDataFormat);
|
---|
| 452 | /**
|
---|
| 453 | * @}
|
---|
| 454 | */
|
---|
| 455 |
|
---|
| 456 | /** @addtogroup SPDIFRX_Exported_Functions_Group2
|
---|
| 457 | * @{
|
---|
| 458 | */
|
---|
| 459 | /* I/O operation functions ***************************************************/
|
---|
| 460 | /* Blocking mode: Polling */
|
---|
| 461 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size, uint32_t Timeout);
|
---|
| 462 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size, uint32_t Timeout);
|
---|
| 463 |
|
---|
| 464 | /* Non-Blocking mode: Interrupt */
|
---|
| 465 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
|
---|
| 466 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
|
---|
| 467 | void HAL_SPDIFRX_IRQHandler(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 468 |
|
---|
| 469 | /* Non-Blocking mode: DMA */
|
---|
| 470 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
|
---|
| 471 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size);
|
---|
| 472 |
|
---|
| 473 | HAL_StatusTypeDef HAL_SPDIFRX_DMAStop(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 474 |
|
---|
| 475 | /* Callbacks used in non blocking modes (Interrupt and DMA) *******************/
|
---|
| 476 | void HAL_SPDIFRX_RxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 477 | void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 478 | void HAL_SPDIFRX_ErrorCallback(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 479 | void HAL_SPDIFRX_CxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 480 | void HAL_SPDIFRX_CxCpltCallback(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 481 | /**
|
---|
| 482 | * @}
|
---|
| 483 | */
|
---|
| 484 |
|
---|
| 485 | /** @addtogroup SPDIFRX_Exported_Functions_Group3
|
---|
| 486 | * @{
|
---|
| 487 | */
|
---|
| 488 | /* Peripheral Control and State functions ************************************/
|
---|
| 489 | HAL_SPDIFRX_StateTypeDef HAL_SPDIFRX_GetState(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 490 | uint32_t HAL_SPDIFRX_GetError(SPDIFRX_HandleTypeDef *hspdif);
|
---|
| 491 | /**
|
---|
| 492 | * @}
|
---|
| 493 | */
|
---|
| 494 |
|
---|
| 495 | /**
|
---|
| 496 | * @}
|
---|
| 497 | */
|
---|
| 498 | /* Private types -------------------------------------------------------------*/
|
---|
| 499 | /* Private variables ---------------------------------------------------------*/
|
---|
| 500 | /* Private constants ---------------------------------------------------------*/
|
---|
| 501 | /* Private macros ------------------------------------------------------------*/
|
---|
| 502 | /** @defgroup SPDIFRX_Private_Macros SPDIFRX Private Macros
|
---|
| 503 | * @{
|
---|
| 504 | */
|
---|
| 505 | #define IS_SPDIFRX_INPUT_SELECT(INPUT) (((INPUT) == SPDIFRX_INPUT_IN1) || \
|
---|
| 506 | ((INPUT) == SPDIFRX_INPUT_IN2) || \
|
---|
| 507 | ((INPUT) == SPDIFRX_INPUT_IN3) || \
|
---|
| 508 | ((INPUT) == SPDIFRX_INPUT_IN0))
|
---|
| 509 | #define IS_SPDIFRX_MAX_RETRIES(RET) (((RET) == SPDIFRX_MAXRETRIES_NONE) || \
|
---|
| 510 | ((RET) == SPDIFRX_MAXRETRIES_3) || \
|
---|
| 511 | ((RET) == SPDIFRX_MAXRETRIES_15) || \
|
---|
| 512 | ((RET) == SPDIFRX_MAXRETRIES_63))
|
---|
| 513 | #define IS_SPDIFRX_WAIT_FOR_ACTIVITY(VAL) (((VAL) == SPDIFRX_WAITFORACTIVITY_ON) || \
|
---|
| 514 | ((VAL) == SPDIFRX_WAITFORACTIVITY_OFF))
|
---|
| 515 | #define IS_PREAMBLE_TYPE_MASK(VAL) (((VAL) == SPDIFRX_PREAMBLETYPEMASK_ON) || \
|
---|
| 516 | ((VAL) == SPDIFRX_PREAMBLETYPEMASK_OFF))
|
---|
| 517 | #define IS_VALIDITY_MASK(VAL) (((VAL) == SPDIFRX_VALIDITYMASK_OFF) || \
|
---|
| 518 | ((VAL) == SPDIFRX_VALIDITYMASK_ON))
|
---|
| 519 | #define IS_PARITY_ERROR_MASK(VAL) (((VAL) == SPDIFRX_PARITYERRORMASK_OFF) || \
|
---|
| 520 | ((VAL) == SPDIFRX_PARITYERRORMASK_ON))
|
---|
| 521 | #define IS_SPDIFRX_CHANNEL(CHANNEL) (((CHANNEL) == SPDIFRX_CHANNEL_A) || \
|
---|
| 522 | ((CHANNEL) == SPDIFRX_CHANNEL_B))
|
---|
| 523 | #define IS_SPDIFRX_DATA_FORMAT(FORMAT) (((FORMAT) == SPDIFRX_DATAFORMAT_LSB) || \
|
---|
| 524 | ((FORMAT) == SPDIFRX_DATAFORMAT_MSB) || \
|
---|
| 525 | ((FORMAT) == SPDIFRX_DATAFORMAT_32BITS))
|
---|
| 526 | #define IS_STEREO_MODE(MODE) (((MODE) == SPDIFRX_STEREOMODE_DISABLE) || \
|
---|
| 527 | ((MODE) == SPDIFRX_STEREOMODE_ENABLE))
|
---|
| 528 |
|
---|
| 529 | #define IS_CHANNEL_STATUS_MASK(VAL) (((VAL) == SPDIFRX_CHANNELSTATUS_ON) || \
|
---|
| 530 | ((VAL) == SPDIFRX_CHANNELSTATUS_OFF))
|
---|
| 531 | /**
|
---|
| 532 | * @}
|
---|
| 533 | */
|
---|
| 534 |
|
---|
| 535 | /* Private functions ---------------------------------------------------------*/
|
---|
| 536 | /** @defgroup SPDIFRX_Private_Functions SPDIFRX Private Functions
|
---|
| 537 | * @{
|
---|
| 538 | */
|
---|
| 539 | /**
|
---|
| 540 | * @}
|
---|
| 541 | */
|
---|
| 542 |
|
---|
| 543 | /**
|
---|
| 544 | * @}
|
---|
| 545 | */
|
---|
| 546 |
|
---|
| 547 | /**
|
---|
| 548 | * @}
|
---|
| 549 | */
|
---|
| 550 | #endif /* STM32F446xx */
|
---|
| 551 |
|
---|
| 552 | #ifdef __cplusplus
|
---|
| 553 | }
|
---|
| 554 | #endif
|
---|
| 555 |
|
---|
| 556 |
|
---|
| 557 | #endif /* __STM32F4xx_HAL_SPDIFRX_H */
|
---|
| 558 |
|
---|
| 559 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
---|