Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
110:165afa46840b
.

Who changed what in which revision?

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