inport from local
Dependents: Hobbyking_Cheetah_0511
targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_spdifrx.c@0:85b3fd62ea1a, 2020-03-16 (annotated)
- Committer:
- NYX
- Date:
- Mon Mar 16 06:35:48 2020 +0000
- Revision:
- 0:85b3fd62ea1a
reinport to mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
NYX | 0:85b3fd62ea1a | 1 | /** |
NYX | 0:85b3fd62ea1a | 2 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 3 | * @file stm32f4xx_hal_spdifrx.c |
NYX | 0:85b3fd62ea1a | 4 | * @author MCD Application Team |
NYX | 0:85b3fd62ea1a | 5 | * @version V1.7.1 |
NYX | 0:85b3fd62ea1a | 6 | * @date 14-April-2017 |
NYX | 0:85b3fd62ea1a | 7 | * @brief This file provides firmware functions to manage the following |
NYX | 0:85b3fd62ea1a | 8 | * functionalities of the SPDIFRX audio interface: |
NYX | 0:85b3fd62ea1a | 9 | * + Initialization and Configuration |
NYX | 0:85b3fd62ea1a | 10 | * + Data transfers functions |
NYX | 0:85b3fd62ea1a | 11 | * + DMA transfers management |
NYX | 0:85b3fd62ea1a | 12 | * + Interrupts and flags management |
NYX | 0:85b3fd62ea1a | 13 | @verbatim |
NYX | 0:85b3fd62ea1a | 14 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 15 | ##### How to use this driver ##### |
NYX | 0:85b3fd62ea1a | 16 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 17 | [..] |
NYX | 0:85b3fd62ea1a | 18 | The SPDIFRX HAL driver can be used as follow: |
NYX | 0:85b3fd62ea1a | 19 | |
NYX | 0:85b3fd62ea1a | 20 | (#) Declare SPDIFRX_HandleTypeDef handle structure. |
NYX | 0:85b3fd62ea1a | 21 | (#) Initialize the SPDIFRX low level resources by implement the HAL_SPDIFRX_MspInit() API: |
NYX | 0:85b3fd62ea1a | 22 | (##) Enable the SPDIFRX interface clock. |
NYX | 0:85b3fd62ea1a | 23 | (##) SPDIFRX pins configuration: |
NYX | 0:85b3fd62ea1a | 24 | (+++) Enable the clock for the SPDIFRX GPIOs. |
NYX | 0:85b3fd62ea1a | 25 | (+++) Configure these SPDIFRX pins as alternate function pull-up. |
NYX | 0:85b3fd62ea1a | 26 | (##) NVIC configuration if you need to use interrupt process (HAL_SPDIFRX_ReceiveControlFlow_IT() and HAL_SPDIFRX_ReceiveDataFlow_IT() API's). |
NYX | 0:85b3fd62ea1a | 27 | (+++) Configure the SPDIFRX interrupt priority. |
NYX | 0:85b3fd62ea1a | 28 | (+++) Enable the NVIC SPDIFRX IRQ handle. |
NYX | 0:85b3fd62ea1a | 29 | (##) DMA Configuration if you need to use DMA process (HAL_SPDIFRX_ReceiveDataFlow_DMA() and HAL_SPDIFRX_ReceiveControlFlow_DMA() API's). |
NYX | 0:85b3fd62ea1a | 30 | (+++) Declare a DMA handle structure for the reception of the Data Flow channel. |
NYX | 0:85b3fd62ea1a | 31 | (+++) Declare a DMA handle structure for the reception of the Control Flow channel. |
NYX | 0:85b3fd62ea1a | 32 | (+++) Enable the DMAx interface clock. |
NYX | 0:85b3fd62ea1a | 33 | (+++) Configure the declared DMA handle structure CtrlRx/DataRx with the required parameters. |
NYX | 0:85b3fd62ea1a | 34 | (+++) Configure the DMA Channel. |
NYX | 0:85b3fd62ea1a | 35 | (+++) Associate the initialized DMA handle to the SPDIFRX DMA CtrlRx/DataRx handle. |
NYX | 0:85b3fd62ea1a | 36 | (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the |
NYX | 0:85b3fd62ea1a | 37 | DMA CtrlRx/DataRx channel. |
NYX | 0:85b3fd62ea1a | 38 | |
NYX | 0:85b3fd62ea1a | 39 | (#) Program the input selection, re-tries number, wait for activity, channel status selection, data format, stereo mode and masking of user bits |
NYX | 0:85b3fd62ea1a | 40 | using HAL_SPDIFRX_Init() function. |
NYX | 0:85b3fd62ea1a | 41 | |
NYX | 0:85b3fd62ea1a | 42 | -@- The specific SPDIFRX interrupts (RXNE/CSRNE and Error Interrupts) will be managed using the macros |
NYX | 0:85b3fd62ea1a | 43 | __SPDIFRX_ENABLE_IT() and __SPDIFRX_DISABLE_IT() inside the receive process. |
NYX | 0:85b3fd62ea1a | 44 | -@- Make sure that ck_spdif clock is configured. |
NYX | 0:85b3fd62ea1a | 45 | |
NYX | 0:85b3fd62ea1a | 46 | (#) Three operation modes are available within this driver : |
NYX | 0:85b3fd62ea1a | 47 | |
NYX | 0:85b3fd62ea1a | 48 | *** Polling mode for reception operation (for debug purpose) *** |
NYX | 0:85b3fd62ea1a | 49 | ================================================================ |
NYX | 0:85b3fd62ea1a | 50 | [..] |
NYX | 0:85b3fd62ea1a | 51 | (+) Receive data flow in blocking mode using HAL_SPDIFRX_ReceiveDataFlow() |
NYX | 0:85b3fd62ea1a | 52 | (+) Receive control flow of data in blocking mode using HAL_SPDIFRX_ReceiveControlFlow() |
NYX | 0:85b3fd62ea1a | 53 | |
NYX | 0:85b3fd62ea1a | 54 | *** Interrupt mode for reception operation *** |
NYX | 0:85b3fd62ea1a | 55 | ========================================= |
NYX | 0:85b3fd62ea1a | 56 | [..] |
NYX | 0:85b3fd62ea1a | 57 | (+) Receive an amount of data (Data Flow) in non blocking mode using HAL_SPDIFRX_ReceiveDataFlow_IT() |
NYX | 0:85b3fd62ea1a | 58 | (+) Receive an amount of data (Control Flow) in non blocking mode using HAL_SPDIFRX_ReceiveControlFlow_IT() |
NYX | 0:85b3fd62ea1a | 59 | (+) At reception end of half transfer HAL_SPDIFRX_RxHalfCpltCallback is executed and user can |
NYX | 0:85b3fd62ea1a | 60 | add his own code by customization of function pointer HAL_SPDIFRX_RxHalfCpltCallback |
NYX | 0:85b3fd62ea1a | 61 | (+) At reception end of transfer HAL_SPDIFRX_RxCpltCallback is executed and user can |
NYX | 0:85b3fd62ea1a | 62 | add his own code by customization of function pointer HAL_SPDIFRX_RxCpltCallback |
NYX | 0:85b3fd62ea1a | 63 | (+) In case of transfer Error, HAL_SPDIFRX_ErrorCallback() function is executed and user can |
NYX | 0:85b3fd62ea1a | 64 | add his own code by customization of function pointer HAL_SPDIFRX_ErrorCallback |
NYX | 0:85b3fd62ea1a | 65 | |
NYX | 0:85b3fd62ea1a | 66 | *** DMA mode for reception operation *** |
NYX | 0:85b3fd62ea1a | 67 | ======================================== |
NYX | 0:85b3fd62ea1a | 68 | [..] |
NYX | 0:85b3fd62ea1a | 69 | (+) Receive an amount of data (Data Flow) in non blocking mode (DMA) using HAL_SPDIFRX_ReceiveDataFlow_DMA() |
NYX | 0:85b3fd62ea1a | 70 | (+) Receive an amount of data (Control Flow) in non blocking mode (DMA) using HAL_SPDIFRX_ReceiveControlFlow_DMA() |
NYX | 0:85b3fd62ea1a | 71 | (+) At reception end of half transfer HAL_SPDIFRX_RxHalfCpltCallback is executed and user can |
NYX | 0:85b3fd62ea1a | 72 | add his own code by customization of function pointer HAL_SPDIFRX_RxHalfCpltCallback |
NYX | 0:85b3fd62ea1a | 73 | (+) At reception end of transfer HAL_SPDIFRX_RxCpltCallback is executed and user can |
NYX | 0:85b3fd62ea1a | 74 | add his own code by customization of function pointer HAL_SPDIFRX_RxCpltCallback |
NYX | 0:85b3fd62ea1a | 75 | (+) In case of transfer Error, HAL_SPDIFRX_ErrorCallback() function is executed and user can |
NYX | 0:85b3fd62ea1a | 76 | add his own code by customization of function pointer HAL_SPDIFRX_ErrorCallback |
NYX | 0:85b3fd62ea1a | 77 | (+) Stop the DMA Transfer using HAL_SPDIFRX_DMAStop() |
NYX | 0:85b3fd62ea1a | 78 | |
NYX | 0:85b3fd62ea1a | 79 | *** SPDIFRX HAL driver macros list *** |
NYX | 0:85b3fd62ea1a | 80 | ============================================= |
NYX | 0:85b3fd62ea1a | 81 | [..] |
NYX | 0:85b3fd62ea1a | 82 | Below the list of most used macros in SPDIFRX HAL driver. |
NYX | 0:85b3fd62ea1a | 83 | (+) __HAL_SPDIFRX_IDLE: Disable the specified SPDIFRX peripheral (IDEL State) |
NYX | 0:85b3fd62ea1a | 84 | (+) __HAL_SPDIFRX_SYNC: Enable the synchronization state of the specified SPDIFRX peripheral (SYNC State) |
NYX | 0:85b3fd62ea1a | 85 | (+) __HAL_SPDIFRX_RCV: Enable the receive state of the specified SPDIFRX peripheral (RCV State) |
NYX | 0:85b3fd62ea1a | 86 | (+) __HAL_SPDIFRX_ENABLE_IT : Enable the specified SPDIFRX interrupts |
NYX | 0:85b3fd62ea1a | 87 | (+) __HAL_SPDIFRX_DISABLE_IT : Disable the specified SPDIFRX interrupts |
NYX | 0:85b3fd62ea1a | 88 | (+) __HAL_SPDIFRX_GET_FLAG: Check whether the specified SPDIFRX flag is set or not. |
NYX | 0:85b3fd62ea1a | 89 | |
NYX | 0:85b3fd62ea1a | 90 | [..] |
NYX | 0:85b3fd62ea1a | 91 | (@) You can refer to the SPDIFRX HAL driver header file for more useful macros |
NYX | 0:85b3fd62ea1a | 92 | |
NYX | 0:85b3fd62ea1a | 93 | @endverbatim |
NYX | 0:85b3fd62ea1a | 94 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 95 | * @attention |
NYX | 0:85b3fd62ea1a | 96 | * |
NYX | 0:85b3fd62ea1a | 97 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
NYX | 0:85b3fd62ea1a | 98 | * |
NYX | 0:85b3fd62ea1a | 99 | * Redistribution and use in source and binary forms, with or without modification, |
NYX | 0:85b3fd62ea1a | 100 | * are permitted provided that the following conditions are met: |
NYX | 0:85b3fd62ea1a | 101 | * 1. Redistributions of source code must retain the above copyright notice, |
NYX | 0:85b3fd62ea1a | 102 | * this list of conditions and the following disclaimer. |
NYX | 0:85b3fd62ea1a | 103 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
NYX | 0:85b3fd62ea1a | 104 | * this list of conditions and the following disclaimer in the documentation |
NYX | 0:85b3fd62ea1a | 105 | * and/or other materials provided with the distribution. |
NYX | 0:85b3fd62ea1a | 106 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
NYX | 0:85b3fd62ea1a | 107 | * may be used to endorse or promote products derived from this software |
NYX | 0:85b3fd62ea1a | 108 | * without specific prior written permission. |
NYX | 0:85b3fd62ea1a | 109 | * |
NYX | 0:85b3fd62ea1a | 110 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
NYX | 0:85b3fd62ea1a | 111 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
NYX | 0:85b3fd62ea1a | 112 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
NYX | 0:85b3fd62ea1a | 113 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
NYX | 0:85b3fd62ea1a | 114 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
NYX | 0:85b3fd62ea1a | 115 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
NYX | 0:85b3fd62ea1a | 116 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
NYX | 0:85b3fd62ea1a | 117 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
NYX | 0:85b3fd62ea1a | 118 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
NYX | 0:85b3fd62ea1a | 119 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
NYX | 0:85b3fd62ea1a | 120 | * |
NYX | 0:85b3fd62ea1a | 121 | ****************************************************************************** |
NYX | 0:85b3fd62ea1a | 122 | */ |
NYX | 0:85b3fd62ea1a | 123 | |
NYX | 0:85b3fd62ea1a | 124 | /* Includes ------------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 125 | #include "stm32f4xx_hal.h" |
NYX | 0:85b3fd62ea1a | 126 | |
NYX | 0:85b3fd62ea1a | 127 | /** @addtogroup STM32F4xx_HAL_Driver |
NYX | 0:85b3fd62ea1a | 128 | * @{ |
NYX | 0:85b3fd62ea1a | 129 | */ |
NYX | 0:85b3fd62ea1a | 130 | /** @defgroup SPDIFRX SPDIFRX |
NYX | 0:85b3fd62ea1a | 131 | * @brief SPDIFRX HAL module driver |
NYX | 0:85b3fd62ea1a | 132 | * @{ |
NYX | 0:85b3fd62ea1a | 133 | */ |
NYX | 0:85b3fd62ea1a | 134 | |
NYX | 0:85b3fd62ea1a | 135 | #ifdef HAL_SPDIFRX_MODULE_ENABLED |
NYX | 0:85b3fd62ea1a | 136 | |
NYX | 0:85b3fd62ea1a | 137 | #if defined(STM32F446xx) |
NYX | 0:85b3fd62ea1a | 138 | |
NYX | 0:85b3fd62ea1a | 139 | /* Private typedef -----------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 140 | /* Private define ------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 141 | #define SPDIFRX_TIMEOUT_VALUE 0xFFFF |
NYX | 0:85b3fd62ea1a | 142 | |
NYX | 0:85b3fd62ea1a | 143 | /* Private macro -------------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 144 | /* Private variables ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 145 | /* Private function prototypes -----------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 146 | |
NYX | 0:85b3fd62ea1a | 147 | /** @addtogroup SPDIFRX_Private_Functions |
NYX | 0:85b3fd62ea1a | 148 | * @{ |
NYX | 0:85b3fd62ea1a | 149 | */ |
NYX | 0:85b3fd62ea1a | 150 | static void SPDIFRX_DMARxCplt(DMA_HandleTypeDef *hdma); |
NYX | 0:85b3fd62ea1a | 151 | static void SPDIFRX_DMARxHalfCplt(DMA_HandleTypeDef *hdma); |
NYX | 0:85b3fd62ea1a | 152 | static void SPDIFRX_DMACxCplt(DMA_HandleTypeDef *hdma); |
NYX | 0:85b3fd62ea1a | 153 | static void SPDIFRX_DMACxHalfCplt(DMA_HandleTypeDef *hdma); |
NYX | 0:85b3fd62ea1a | 154 | static void SPDIFRX_DMAError(DMA_HandleTypeDef *hdma); |
NYX | 0:85b3fd62ea1a | 155 | static void SPDIFRX_ReceiveControlFlow_IT(SPDIFRX_HandleTypeDef *hspdif); |
NYX | 0:85b3fd62ea1a | 156 | static void SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif); |
NYX | 0:85b3fd62ea1a | 157 | static HAL_StatusTypeDef SPDIFRX_WaitOnFlagUntilTimeout(SPDIFRX_HandleTypeDef *hspdif, uint32_t Flag, FlagStatus Status, uint32_t Timeout); |
NYX | 0:85b3fd62ea1a | 158 | |
NYX | 0:85b3fd62ea1a | 159 | /** |
NYX | 0:85b3fd62ea1a | 160 | * @} |
NYX | 0:85b3fd62ea1a | 161 | */ |
NYX | 0:85b3fd62ea1a | 162 | /* Exported functions ---------------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 163 | |
NYX | 0:85b3fd62ea1a | 164 | /** @defgroup SPDIFRX_Exported_Functions SPDIFRX Exported Functions |
NYX | 0:85b3fd62ea1a | 165 | * @{ |
NYX | 0:85b3fd62ea1a | 166 | */ |
NYX | 0:85b3fd62ea1a | 167 | |
NYX | 0:85b3fd62ea1a | 168 | /** @defgroup SPDIFRX_Exported_Functions_Group1 Initialization and de-initialization functions |
NYX | 0:85b3fd62ea1a | 169 | * @brief Initialization and Configuration functions |
NYX | 0:85b3fd62ea1a | 170 | * |
NYX | 0:85b3fd62ea1a | 171 | @verbatim |
NYX | 0:85b3fd62ea1a | 172 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 173 | ##### Initialization and de-initialization functions ##### |
NYX | 0:85b3fd62ea1a | 174 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 175 | [..] This subsection provides a set of functions allowing to initialize and |
NYX | 0:85b3fd62ea1a | 176 | de-initialize the SPDIFRX peripheral: |
NYX | 0:85b3fd62ea1a | 177 | |
NYX | 0:85b3fd62ea1a | 178 | (+) User must Implement HAL_SPDIFRX_MspInit() function in which he configures |
NYX | 0:85b3fd62ea1a | 179 | all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). |
NYX | 0:85b3fd62ea1a | 180 | |
NYX | 0:85b3fd62ea1a | 181 | (+) Call the function HAL_SPDIFRX_Init() to configure the SPDIFRX peripheral with |
NYX | 0:85b3fd62ea1a | 182 | the selected configuration: |
NYX | 0:85b3fd62ea1a | 183 | (++) Input Selection (IN0, IN1,...) |
NYX | 0:85b3fd62ea1a | 184 | (++) Maximum allowed re-tries during synchronization phase |
NYX | 0:85b3fd62ea1a | 185 | (++) Wait for activity on SPDIF selected input |
NYX | 0:85b3fd62ea1a | 186 | (++) Channel status selection (from channel A or B) |
NYX | 0:85b3fd62ea1a | 187 | (++) Data format (LSB, MSB, ...) |
NYX | 0:85b3fd62ea1a | 188 | (++) Stereo mode |
NYX | 0:85b3fd62ea1a | 189 | (++) User bits masking (PT,C,U,V,...) |
NYX | 0:85b3fd62ea1a | 190 | |
NYX | 0:85b3fd62ea1a | 191 | (+) Call the function HAL_SPDIFRX_DeInit() to restore the default configuration |
NYX | 0:85b3fd62ea1a | 192 | of the selected SPDIFRXx peripheral. |
NYX | 0:85b3fd62ea1a | 193 | @endverbatim |
NYX | 0:85b3fd62ea1a | 194 | * @{ |
NYX | 0:85b3fd62ea1a | 195 | */ |
NYX | 0:85b3fd62ea1a | 196 | |
NYX | 0:85b3fd62ea1a | 197 | /** |
NYX | 0:85b3fd62ea1a | 198 | * @brief Initializes the SPDIFRX according to the specified parameters |
NYX | 0:85b3fd62ea1a | 199 | * in the SPDIFRX_InitTypeDef and create the associated handle. |
NYX | 0:85b3fd62ea1a | 200 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 201 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 202 | */ |
NYX | 0:85b3fd62ea1a | 203 | HAL_StatusTypeDef HAL_SPDIFRX_Init(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 204 | { |
NYX | 0:85b3fd62ea1a | 205 | uint32_t tmpreg = 0U; |
NYX | 0:85b3fd62ea1a | 206 | |
NYX | 0:85b3fd62ea1a | 207 | /* Check the SPDIFRX handle allocation */ |
NYX | 0:85b3fd62ea1a | 208 | if(hspdif == NULL) |
NYX | 0:85b3fd62ea1a | 209 | { |
NYX | 0:85b3fd62ea1a | 210 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 211 | } |
NYX | 0:85b3fd62ea1a | 212 | |
NYX | 0:85b3fd62ea1a | 213 | /* Check the SPDIFRX parameters */ |
NYX | 0:85b3fd62ea1a | 214 | assert_param(IS_STEREO_MODE(hspdif->Init.StereoMode)); |
NYX | 0:85b3fd62ea1a | 215 | assert_param(IS_SPDIFRX_INPUT_SELECT(hspdif->Init.InputSelection)); |
NYX | 0:85b3fd62ea1a | 216 | assert_param(IS_SPDIFRX_MAX_RETRIES(hspdif->Init.Retries)); |
NYX | 0:85b3fd62ea1a | 217 | assert_param(IS_SPDIFRX_WAIT_FOR_ACTIVITY(hspdif->Init.WaitForActivity)); |
NYX | 0:85b3fd62ea1a | 218 | assert_param(IS_SPDIFRX_CHANNEL(hspdif->Init.ChannelSelection)); |
NYX | 0:85b3fd62ea1a | 219 | assert_param(IS_SPDIFRX_DATA_FORMAT(hspdif->Init.DataFormat)); |
NYX | 0:85b3fd62ea1a | 220 | assert_param(IS_PREAMBLE_TYPE_MASK(hspdif->Init.PreambleTypeMask)); |
NYX | 0:85b3fd62ea1a | 221 | assert_param(IS_CHANNEL_STATUS_MASK(hspdif->Init.ChannelStatusMask)); |
NYX | 0:85b3fd62ea1a | 222 | assert_param(IS_VALIDITY_MASK(hspdif->Init.ValidityBitMask)); |
NYX | 0:85b3fd62ea1a | 223 | assert_param(IS_PARITY_ERROR_MASK(hspdif->Init.ParityErrorMask)); |
NYX | 0:85b3fd62ea1a | 224 | |
NYX | 0:85b3fd62ea1a | 225 | if(hspdif->State == HAL_SPDIFRX_STATE_RESET) |
NYX | 0:85b3fd62ea1a | 226 | { |
NYX | 0:85b3fd62ea1a | 227 | /* Allocate lock resource and initialize it */ |
NYX | 0:85b3fd62ea1a | 228 | hspdif->Lock = HAL_UNLOCKED; |
NYX | 0:85b3fd62ea1a | 229 | /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */ |
NYX | 0:85b3fd62ea1a | 230 | HAL_SPDIFRX_MspInit(hspdif); |
NYX | 0:85b3fd62ea1a | 231 | } |
NYX | 0:85b3fd62ea1a | 232 | |
NYX | 0:85b3fd62ea1a | 233 | /* SPDIFRX peripheral state is BUSY*/ |
NYX | 0:85b3fd62ea1a | 234 | hspdif->State = HAL_SPDIFRX_STATE_BUSY; |
NYX | 0:85b3fd62ea1a | 235 | |
NYX | 0:85b3fd62ea1a | 236 | /* Disable SPDIFRX interface (IDLE State) */ |
NYX | 0:85b3fd62ea1a | 237 | __HAL_SPDIFRX_IDLE(hspdif); |
NYX | 0:85b3fd62ea1a | 238 | |
NYX | 0:85b3fd62ea1a | 239 | /* Reset the old SPDIFRX CR configuration */ |
NYX | 0:85b3fd62ea1a | 240 | tmpreg = hspdif->Instance->CR; |
NYX | 0:85b3fd62ea1a | 241 | |
NYX | 0:85b3fd62ea1a | 242 | tmpreg &= ~((uint16_t) SPDIFRX_CR_RXSTEO | SPDIFRX_CR_DRFMT | SPDIFRX_CR_PMSK | |
NYX | 0:85b3fd62ea1a | 243 | SPDIFRX_CR_VMSK | SPDIFRX_CR_CUMSK | SPDIFRX_CR_PTMSK | |
NYX | 0:85b3fd62ea1a | 244 | SPDIFRX_CR_CHSEL | SPDIFRX_CR_NBTR | SPDIFRX_CR_WFA | |
NYX | 0:85b3fd62ea1a | 245 | SPDIFRX_CR_INSEL); |
NYX | 0:85b3fd62ea1a | 246 | |
NYX | 0:85b3fd62ea1a | 247 | /* Sets the new configuration of the SPDIFRX peripheral */ |
NYX | 0:85b3fd62ea1a | 248 | tmpreg |= ((uint16_t) hspdif->Init.StereoMode | |
NYX | 0:85b3fd62ea1a | 249 | hspdif->Init.InputSelection | |
NYX | 0:85b3fd62ea1a | 250 | hspdif->Init.Retries | |
NYX | 0:85b3fd62ea1a | 251 | hspdif->Init.WaitForActivity | |
NYX | 0:85b3fd62ea1a | 252 | hspdif->Init.ChannelSelection | |
NYX | 0:85b3fd62ea1a | 253 | hspdif->Init.DataFormat | |
NYX | 0:85b3fd62ea1a | 254 | hspdif->Init.PreambleTypeMask | |
NYX | 0:85b3fd62ea1a | 255 | hspdif->Init.ChannelStatusMask | |
NYX | 0:85b3fd62ea1a | 256 | hspdif->Init.ValidityBitMask | |
NYX | 0:85b3fd62ea1a | 257 | hspdif->Init.ParityErrorMask); |
NYX | 0:85b3fd62ea1a | 258 | |
NYX | 0:85b3fd62ea1a | 259 | hspdif->Instance->CR = tmpreg; |
NYX | 0:85b3fd62ea1a | 260 | |
NYX | 0:85b3fd62ea1a | 261 | hspdif->ErrorCode = HAL_SPDIFRX_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 262 | |
NYX | 0:85b3fd62ea1a | 263 | /* SPDIFRX peripheral state is READY*/ |
NYX | 0:85b3fd62ea1a | 264 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 265 | |
NYX | 0:85b3fd62ea1a | 266 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 267 | } |
NYX | 0:85b3fd62ea1a | 268 | |
NYX | 0:85b3fd62ea1a | 269 | /** |
NYX | 0:85b3fd62ea1a | 270 | * @brief DeInitializes the SPDIFRX peripheral |
NYX | 0:85b3fd62ea1a | 271 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 272 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 273 | */ |
NYX | 0:85b3fd62ea1a | 274 | HAL_StatusTypeDef HAL_SPDIFRX_DeInit(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 275 | { |
NYX | 0:85b3fd62ea1a | 276 | /* Check the SPDIFRX handle allocation */ |
NYX | 0:85b3fd62ea1a | 277 | if(hspdif == NULL) |
NYX | 0:85b3fd62ea1a | 278 | { |
NYX | 0:85b3fd62ea1a | 279 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 280 | } |
NYX | 0:85b3fd62ea1a | 281 | |
NYX | 0:85b3fd62ea1a | 282 | /* Check the parameters */ |
NYX | 0:85b3fd62ea1a | 283 | assert_param(IS_SPDIFRX_ALL_INSTANCE(hspdif->Instance)); |
NYX | 0:85b3fd62ea1a | 284 | |
NYX | 0:85b3fd62ea1a | 285 | hspdif->State = HAL_SPDIFRX_STATE_BUSY; |
NYX | 0:85b3fd62ea1a | 286 | |
NYX | 0:85b3fd62ea1a | 287 | /* Disable SPDIFRX interface (IDLE state) */ |
NYX | 0:85b3fd62ea1a | 288 | __HAL_SPDIFRX_IDLE(hspdif); |
NYX | 0:85b3fd62ea1a | 289 | |
NYX | 0:85b3fd62ea1a | 290 | /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */ |
NYX | 0:85b3fd62ea1a | 291 | HAL_SPDIFRX_MspDeInit(hspdif); |
NYX | 0:85b3fd62ea1a | 292 | |
NYX | 0:85b3fd62ea1a | 293 | hspdif->ErrorCode = HAL_SPDIFRX_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 294 | |
NYX | 0:85b3fd62ea1a | 295 | /* SPDIFRX peripheral state is RESET*/ |
NYX | 0:85b3fd62ea1a | 296 | hspdif->State = HAL_SPDIFRX_STATE_RESET; |
NYX | 0:85b3fd62ea1a | 297 | |
NYX | 0:85b3fd62ea1a | 298 | /* Release Lock */ |
NYX | 0:85b3fd62ea1a | 299 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 300 | |
NYX | 0:85b3fd62ea1a | 301 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 302 | } |
NYX | 0:85b3fd62ea1a | 303 | |
NYX | 0:85b3fd62ea1a | 304 | /** |
NYX | 0:85b3fd62ea1a | 305 | * @brief SPDIFRX MSP Init |
NYX | 0:85b3fd62ea1a | 306 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 307 | * @retval None |
NYX | 0:85b3fd62ea1a | 308 | */ |
NYX | 0:85b3fd62ea1a | 309 | __weak void HAL_SPDIFRX_MspInit(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 310 | { |
NYX | 0:85b3fd62ea1a | 311 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 312 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 313 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 314 | the HAL_SPDIFRX_MspInit could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 315 | */ |
NYX | 0:85b3fd62ea1a | 316 | } |
NYX | 0:85b3fd62ea1a | 317 | |
NYX | 0:85b3fd62ea1a | 318 | /** |
NYX | 0:85b3fd62ea1a | 319 | * @brief SPDIFRX MSP DeInit |
NYX | 0:85b3fd62ea1a | 320 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 321 | * @retval None |
NYX | 0:85b3fd62ea1a | 322 | */ |
NYX | 0:85b3fd62ea1a | 323 | __weak void HAL_SPDIFRX_MspDeInit(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 324 | { |
NYX | 0:85b3fd62ea1a | 325 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 326 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 327 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 328 | the HAL_SPDIFRX_MspDeInit could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 329 | */ |
NYX | 0:85b3fd62ea1a | 330 | } |
NYX | 0:85b3fd62ea1a | 331 | |
NYX | 0:85b3fd62ea1a | 332 | /** |
NYX | 0:85b3fd62ea1a | 333 | * @brief Sets the SPDIFRX dtat format according to the specified parameters |
NYX | 0:85b3fd62ea1a | 334 | * in the SPDIFRX_InitTypeDef. |
NYX | 0:85b3fd62ea1a | 335 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 336 | * @param sDataFormat: SPDIFRX data format |
NYX | 0:85b3fd62ea1a | 337 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 338 | */ |
NYX | 0:85b3fd62ea1a | 339 | HAL_StatusTypeDef HAL_SPDIFRX_SetDataFormat(SPDIFRX_HandleTypeDef *hspdif, SPDIFRX_SetDataFormatTypeDef sDataFormat) |
NYX | 0:85b3fd62ea1a | 340 | { |
NYX | 0:85b3fd62ea1a | 341 | uint32_t tmpreg = 0U; |
NYX | 0:85b3fd62ea1a | 342 | |
NYX | 0:85b3fd62ea1a | 343 | /* Check the SPDIFRX handle allocation */ |
NYX | 0:85b3fd62ea1a | 344 | if(hspdif == NULL) |
NYX | 0:85b3fd62ea1a | 345 | { |
NYX | 0:85b3fd62ea1a | 346 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 347 | } |
NYX | 0:85b3fd62ea1a | 348 | |
NYX | 0:85b3fd62ea1a | 349 | /* Check the SPDIFRX parameters */ |
NYX | 0:85b3fd62ea1a | 350 | assert_param(IS_STEREO_MODE(sDataFormat.StereoMode)); |
NYX | 0:85b3fd62ea1a | 351 | assert_param(IS_SPDIFRX_DATA_FORMAT(sDataFormat.DataFormat)); |
NYX | 0:85b3fd62ea1a | 352 | assert_param(IS_PREAMBLE_TYPE_MASK(sDataFormat.PreambleTypeMask)); |
NYX | 0:85b3fd62ea1a | 353 | assert_param(IS_CHANNEL_STATUS_MASK(sDataFormat.ChannelStatusMask)); |
NYX | 0:85b3fd62ea1a | 354 | assert_param(IS_VALIDITY_MASK(sDataFormat.ValidityBitMask)); |
NYX | 0:85b3fd62ea1a | 355 | assert_param(IS_PARITY_ERROR_MASK(sDataFormat.ParityErrorMask)); |
NYX | 0:85b3fd62ea1a | 356 | |
NYX | 0:85b3fd62ea1a | 357 | /* Reset the old SPDIFRX CR configuration */ |
NYX | 0:85b3fd62ea1a | 358 | tmpreg = hspdif->Instance->CR; |
NYX | 0:85b3fd62ea1a | 359 | |
NYX | 0:85b3fd62ea1a | 360 | if(((tmpreg & SPDIFRX_STATE_RCV) == SPDIFRX_STATE_RCV) && |
NYX | 0:85b3fd62ea1a | 361 | (((tmpreg & SPDIFRX_CR_DRFMT) != sDataFormat.DataFormat) || |
NYX | 0:85b3fd62ea1a | 362 | ((tmpreg & SPDIFRX_CR_RXSTEO) != sDataFormat.StereoMode))) |
NYX | 0:85b3fd62ea1a | 363 | { |
NYX | 0:85b3fd62ea1a | 364 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 365 | } |
NYX | 0:85b3fd62ea1a | 366 | |
NYX | 0:85b3fd62ea1a | 367 | tmpreg &= ~((uint16_t) SPDIFRX_CR_RXSTEO | SPDIFRX_CR_DRFMT | SPDIFRX_CR_PMSK | |
NYX | 0:85b3fd62ea1a | 368 | SPDIFRX_CR_VMSK | SPDIFRX_CR_CUMSK | SPDIFRX_CR_PTMSK); |
NYX | 0:85b3fd62ea1a | 369 | |
NYX | 0:85b3fd62ea1a | 370 | /* Sets the new configuration of the SPDIFRX peripheral */ |
NYX | 0:85b3fd62ea1a | 371 | tmpreg |= ((uint16_t) sDataFormat.StereoMode | |
NYX | 0:85b3fd62ea1a | 372 | sDataFormat.DataFormat | |
NYX | 0:85b3fd62ea1a | 373 | sDataFormat.PreambleTypeMask | |
NYX | 0:85b3fd62ea1a | 374 | sDataFormat.ChannelStatusMask | |
NYX | 0:85b3fd62ea1a | 375 | sDataFormat.ValidityBitMask | |
NYX | 0:85b3fd62ea1a | 376 | sDataFormat.ParityErrorMask); |
NYX | 0:85b3fd62ea1a | 377 | |
NYX | 0:85b3fd62ea1a | 378 | hspdif->Instance->CR = tmpreg; |
NYX | 0:85b3fd62ea1a | 379 | |
NYX | 0:85b3fd62ea1a | 380 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 381 | } |
NYX | 0:85b3fd62ea1a | 382 | |
NYX | 0:85b3fd62ea1a | 383 | /** |
NYX | 0:85b3fd62ea1a | 384 | * @} |
NYX | 0:85b3fd62ea1a | 385 | */ |
NYX | 0:85b3fd62ea1a | 386 | |
NYX | 0:85b3fd62ea1a | 387 | /** @defgroup SPDIFRX_Exported_Functions_Group2 IO operation functions |
NYX | 0:85b3fd62ea1a | 388 | * @brief Data transfers functions |
NYX | 0:85b3fd62ea1a | 389 | * |
NYX | 0:85b3fd62ea1a | 390 | @verbatim |
NYX | 0:85b3fd62ea1a | 391 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 392 | ##### IO operation functions ##### |
NYX | 0:85b3fd62ea1a | 393 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 394 | [..] |
NYX | 0:85b3fd62ea1a | 395 | This subsection provides a set of functions allowing to manage the SPDIFRX data |
NYX | 0:85b3fd62ea1a | 396 | transfers. |
NYX | 0:85b3fd62ea1a | 397 | |
NYX | 0:85b3fd62ea1a | 398 | (#) There is two mode of transfer: |
NYX | 0:85b3fd62ea1a | 399 | (++) Blocking mode : The communication is performed in the polling mode. |
NYX | 0:85b3fd62ea1a | 400 | The status of all data processing is returned by the same function |
NYX | 0:85b3fd62ea1a | 401 | after finishing transfer. |
NYX | 0:85b3fd62ea1a | 402 | (++) No-Blocking mode : The communication is performed using Interrupts |
NYX | 0:85b3fd62ea1a | 403 | or DMA. These functions return the status of the transfer start-up. |
NYX | 0:85b3fd62ea1a | 404 | The end of the data processing will be indicated through the |
NYX | 0:85b3fd62ea1a | 405 | dedicated SPDIFRX IRQ when using Interrupt mode or the DMA IRQ when |
NYX | 0:85b3fd62ea1a | 406 | using DMA mode. |
NYX | 0:85b3fd62ea1a | 407 | |
NYX | 0:85b3fd62ea1a | 408 | (#) Blocking mode functions are : |
NYX | 0:85b3fd62ea1a | 409 | (++) HAL_SPDIFRX_ReceiveDataFlow() |
NYX | 0:85b3fd62ea1a | 410 | (++) HAL_SPDIFRX_ReceiveControlFlow() |
NYX | 0:85b3fd62ea1a | 411 | (+@) Do not use blocking mode to receive both control and data flow at the same time. |
NYX | 0:85b3fd62ea1a | 412 | |
NYX | 0:85b3fd62ea1a | 413 | (#) No-Blocking mode functions with Interrupt are : |
NYX | 0:85b3fd62ea1a | 414 | (++) HAL_SPDIFRX_ReceiveControlFlow_IT() |
NYX | 0:85b3fd62ea1a | 415 | (++) HAL_SPDIFRX_ReceiveDataFlow_IT() |
NYX | 0:85b3fd62ea1a | 416 | |
NYX | 0:85b3fd62ea1a | 417 | (#) No-Blocking mode functions with DMA are : |
NYX | 0:85b3fd62ea1a | 418 | (++) HAL_SPDIFRX_ReceiveControlFlow_DMA() |
NYX | 0:85b3fd62ea1a | 419 | (++) HAL_SPDIFRX_ReceiveDataFlow_DMA() |
NYX | 0:85b3fd62ea1a | 420 | |
NYX | 0:85b3fd62ea1a | 421 | (#) A set of Transfer Complete Callbacks are provided in No_Blocking mode: |
NYX | 0:85b3fd62ea1a | 422 | (++) HAL_SPDIFRX_RxCpltCallback() |
NYX | 0:85b3fd62ea1a | 423 | (++) HAL_SPDIFRX_ErrorCallback() |
NYX | 0:85b3fd62ea1a | 424 | |
NYX | 0:85b3fd62ea1a | 425 | @endverbatim |
NYX | 0:85b3fd62ea1a | 426 | * @{ |
NYX | 0:85b3fd62ea1a | 427 | */ |
NYX | 0:85b3fd62ea1a | 428 | |
NYX | 0:85b3fd62ea1a | 429 | /** |
NYX | 0:85b3fd62ea1a | 430 | * @brief Receives an amount of data (Data Flow) in blocking mode. |
NYX | 0:85b3fd62ea1a | 431 | * @param hspdif: pointer to SPDIFRX_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 432 | * the configuration information for SPDIFRX module. |
NYX | 0:85b3fd62ea1a | 433 | * @param pData: Pointer to data buffer |
NYX | 0:85b3fd62ea1a | 434 | * @param Size: Amount of data to be received |
NYX | 0:85b3fd62ea1a | 435 | * @param Timeout: Timeout duration |
NYX | 0:85b3fd62ea1a | 436 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 437 | */ |
NYX | 0:85b3fd62ea1a | 438 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size, uint32_t Timeout) |
NYX | 0:85b3fd62ea1a | 439 | { |
NYX | 0:85b3fd62ea1a | 440 | if((pData == NULL ) || (Size == 0)) |
NYX | 0:85b3fd62ea1a | 441 | { |
NYX | 0:85b3fd62ea1a | 442 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 443 | } |
NYX | 0:85b3fd62ea1a | 444 | |
NYX | 0:85b3fd62ea1a | 445 | if(hspdif->State == HAL_SPDIFRX_STATE_READY) |
NYX | 0:85b3fd62ea1a | 446 | { |
NYX | 0:85b3fd62ea1a | 447 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 448 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 449 | |
NYX | 0:85b3fd62ea1a | 450 | hspdif->State = HAL_SPDIFRX_STATE_BUSY; |
NYX | 0:85b3fd62ea1a | 451 | |
NYX | 0:85b3fd62ea1a | 452 | /* Start synchronisation */ |
NYX | 0:85b3fd62ea1a | 453 | __HAL_SPDIFRX_SYNC(hspdif); |
NYX | 0:85b3fd62ea1a | 454 | |
NYX | 0:85b3fd62ea1a | 455 | /* Wait until SYNCD flag is set */ |
NYX | 0:85b3fd62ea1a | 456 | if(SPDIFRX_WaitOnFlagUntilTimeout(hspdif, SPDIFRX_FLAG_SYNCD, RESET, Timeout) != HAL_OK) |
NYX | 0:85b3fd62ea1a | 457 | { |
NYX | 0:85b3fd62ea1a | 458 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 459 | } |
NYX | 0:85b3fd62ea1a | 460 | |
NYX | 0:85b3fd62ea1a | 461 | /* Start reception */ |
NYX | 0:85b3fd62ea1a | 462 | __HAL_SPDIFRX_RCV(hspdif); |
NYX | 0:85b3fd62ea1a | 463 | |
NYX | 0:85b3fd62ea1a | 464 | /* Receive data flow */ |
NYX | 0:85b3fd62ea1a | 465 | while(Size > 0) |
NYX | 0:85b3fd62ea1a | 466 | { |
NYX | 0:85b3fd62ea1a | 467 | /* Wait until RXNE flag is set */ |
NYX | 0:85b3fd62ea1a | 468 | if(SPDIFRX_WaitOnFlagUntilTimeout(hspdif, SPDIFRX_FLAG_RXNE, RESET, Timeout) != HAL_OK) |
NYX | 0:85b3fd62ea1a | 469 | { |
NYX | 0:85b3fd62ea1a | 470 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 471 | } |
NYX | 0:85b3fd62ea1a | 472 | |
NYX | 0:85b3fd62ea1a | 473 | (*pData++) = hspdif->Instance->DR; |
NYX | 0:85b3fd62ea1a | 474 | Size--; |
NYX | 0:85b3fd62ea1a | 475 | } |
NYX | 0:85b3fd62ea1a | 476 | |
NYX | 0:85b3fd62ea1a | 477 | /* SPDIFRX ready */ |
NYX | 0:85b3fd62ea1a | 478 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 479 | |
NYX | 0:85b3fd62ea1a | 480 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 481 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 482 | |
NYX | 0:85b3fd62ea1a | 483 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 484 | } |
NYX | 0:85b3fd62ea1a | 485 | else |
NYX | 0:85b3fd62ea1a | 486 | { |
NYX | 0:85b3fd62ea1a | 487 | return HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 488 | } |
NYX | 0:85b3fd62ea1a | 489 | } |
NYX | 0:85b3fd62ea1a | 490 | |
NYX | 0:85b3fd62ea1a | 491 | /** |
NYX | 0:85b3fd62ea1a | 492 | * @brief Receives an amount of data (Control Flow) in blocking mode. |
NYX | 0:85b3fd62ea1a | 493 | * @param hspdif: pointer to a SPDIFRX_HandleTypeDef structure that contains |
NYX | 0:85b3fd62ea1a | 494 | * the configuration information for SPDIFRX module. |
NYX | 0:85b3fd62ea1a | 495 | * @param pData: Pointer to data buffer |
NYX | 0:85b3fd62ea1a | 496 | * @param Size: Amount of data to be received |
NYX | 0:85b3fd62ea1a | 497 | * @param Timeout: Timeout duration |
NYX | 0:85b3fd62ea1a | 498 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 499 | */ |
NYX | 0:85b3fd62ea1a | 500 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size, uint32_t Timeout) |
NYX | 0:85b3fd62ea1a | 501 | { |
NYX | 0:85b3fd62ea1a | 502 | if((pData == NULL ) || (Size == 0)) |
NYX | 0:85b3fd62ea1a | 503 | { |
NYX | 0:85b3fd62ea1a | 504 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 505 | } |
NYX | 0:85b3fd62ea1a | 506 | |
NYX | 0:85b3fd62ea1a | 507 | if(hspdif->State == HAL_SPDIFRX_STATE_READY) |
NYX | 0:85b3fd62ea1a | 508 | { |
NYX | 0:85b3fd62ea1a | 509 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 510 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 511 | |
NYX | 0:85b3fd62ea1a | 512 | hspdif->State = HAL_SPDIFRX_STATE_BUSY; |
NYX | 0:85b3fd62ea1a | 513 | |
NYX | 0:85b3fd62ea1a | 514 | /* Start synchronization */ |
NYX | 0:85b3fd62ea1a | 515 | __HAL_SPDIFRX_SYNC(hspdif); |
NYX | 0:85b3fd62ea1a | 516 | |
NYX | 0:85b3fd62ea1a | 517 | /* Wait until SYNCD flag is set */ |
NYX | 0:85b3fd62ea1a | 518 | if(SPDIFRX_WaitOnFlagUntilTimeout(hspdif, SPDIFRX_FLAG_SYNCD, RESET, Timeout) != HAL_OK) |
NYX | 0:85b3fd62ea1a | 519 | { |
NYX | 0:85b3fd62ea1a | 520 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 521 | } |
NYX | 0:85b3fd62ea1a | 522 | |
NYX | 0:85b3fd62ea1a | 523 | /* Start reception */ |
NYX | 0:85b3fd62ea1a | 524 | __HAL_SPDIFRX_RCV(hspdif); |
NYX | 0:85b3fd62ea1a | 525 | |
NYX | 0:85b3fd62ea1a | 526 | /* Receive control flow */ |
NYX | 0:85b3fd62ea1a | 527 | while(Size > 0) |
NYX | 0:85b3fd62ea1a | 528 | { |
NYX | 0:85b3fd62ea1a | 529 | /* Wait until CSRNE flag is set */ |
NYX | 0:85b3fd62ea1a | 530 | if(SPDIFRX_WaitOnFlagUntilTimeout(hspdif, SPDIFRX_FLAG_CSRNE, RESET, Timeout) != HAL_OK) |
NYX | 0:85b3fd62ea1a | 531 | { |
NYX | 0:85b3fd62ea1a | 532 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 533 | } |
NYX | 0:85b3fd62ea1a | 534 | |
NYX | 0:85b3fd62ea1a | 535 | (*pData++) = hspdif->Instance->CSR; |
NYX | 0:85b3fd62ea1a | 536 | Size--; |
NYX | 0:85b3fd62ea1a | 537 | } |
NYX | 0:85b3fd62ea1a | 538 | |
NYX | 0:85b3fd62ea1a | 539 | /* SPDIFRX ready */ |
NYX | 0:85b3fd62ea1a | 540 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 541 | |
NYX | 0:85b3fd62ea1a | 542 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 543 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 544 | |
NYX | 0:85b3fd62ea1a | 545 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 546 | } |
NYX | 0:85b3fd62ea1a | 547 | else |
NYX | 0:85b3fd62ea1a | 548 | { |
NYX | 0:85b3fd62ea1a | 549 | return HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 550 | } |
NYX | 0:85b3fd62ea1a | 551 | } |
NYX | 0:85b3fd62ea1a | 552 | /** |
NYX | 0:85b3fd62ea1a | 553 | * @brief Receive an amount of data (Data Flow) in non-blocking mode with Interrupt |
NYX | 0:85b3fd62ea1a | 554 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 555 | * @param pData: a 32-bit pointer to the Receive data buffer. |
NYX | 0:85b3fd62ea1a | 556 | * @param Size: number of data sample to be received . |
NYX | 0:85b3fd62ea1a | 557 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 558 | */ |
NYX | 0:85b3fd62ea1a | 559 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size) |
NYX | 0:85b3fd62ea1a | 560 | { |
NYX | 0:85b3fd62ea1a | 561 | __IO uint32_t count = SPDIFRX_TIMEOUT_VALUE * (SystemCoreClock / 24U / 1000U); |
NYX | 0:85b3fd62ea1a | 562 | |
NYX | 0:85b3fd62ea1a | 563 | if((hspdif->State == HAL_SPDIFRX_STATE_READY) || (hspdif->State == HAL_SPDIFRX_STATE_BUSY_CX)) |
NYX | 0:85b3fd62ea1a | 564 | { |
NYX | 0:85b3fd62ea1a | 565 | if((pData == NULL) || (Size == 0)) |
NYX | 0:85b3fd62ea1a | 566 | { |
NYX | 0:85b3fd62ea1a | 567 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 568 | } |
NYX | 0:85b3fd62ea1a | 569 | |
NYX | 0:85b3fd62ea1a | 570 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 571 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 572 | |
NYX | 0:85b3fd62ea1a | 573 | hspdif->pRxBuffPtr = pData; |
NYX | 0:85b3fd62ea1a | 574 | hspdif->RxXferSize = Size; |
NYX | 0:85b3fd62ea1a | 575 | hspdif->RxXferCount = Size; |
NYX | 0:85b3fd62ea1a | 576 | |
NYX | 0:85b3fd62ea1a | 577 | hspdif->ErrorCode = HAL_SPDIFRX_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 578 | |
NYX | 0:85b3fd62ea1a | 579 | /* Check if a receive process is ongoing or not */ |
NYX | 0:85b3fd62ea1a | 580 | hspdif->State = HAL_SPDIFRX_STATE_BUSY_RX; |
NYX | 0:85b3fd62ea1a | 581 | |
NYX | 0:85b3fd62ea1a | 582 | /* Enable the SPDIFRX PE Error Interrupt */ |
NYX | 0:85b3fd62ea1a | 583 | __HAL_SPDIFRX_ENABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 584 | |
NYX | 0:85b3fd62ea1a | 585 | /* Enable the SPDIFRX OVR Error Interrupt */ |
NYX | 0:85b3fd62ea1a | 586 | __HAL_SPDIFRX_ENABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 587 | |
NYX | 0:85b3fd62ea1a | 588 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 589 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 590 | |
NYX | 0:85b3fd62ea1a | 591 | /* Enable the SPDIFRX RXNE interrupt */ |
NYX | 0:85b3fd62ea1a | 592 | __HAL_SPDIFRX_ENABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 593 | |
NYX | 0:85b3fd62ea1a | 594 | if ((SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != SPDIFRX_STATE_SYNC || (SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != 0x00U) |
NYX | 0:85b3fd62ea1a | 595 | { |
NYX | 0:85b3fd62ea1a | 596 | /* Start synchronization */ |
NYX | 0:85b3fd62ea1a | 597 | __HAL_SPDIFRX_SYNC(hspdif); |
NYX | 0:85b3fd62ea1a | 598 | |
NYX | 0:85b3fd62ea1a | 599 | /* Wait until SYNCD flag is set */ |
NYX | 0:85b3fd62ea1a | 600 | do |
NYX | 0:85b3fd62ea1a | 601 | { |
NYX | 0:85b3fd62ea1a | 602 | if (count-- == 0U) |
NYX | 0:85b3fd62ea1a | 603 | { |
NYX | 0:85b3fd62ea1a | 604 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
NYX | 0:85b3fd62ea1a | 605 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 606 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 607 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 608 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 609 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SBLKIE); |
NYX | 0:85b3fd62ea1a | 610 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SYNCDIE); |
NYX | 0:85b3fd62ea1a | 611 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_IFEIE); |
NYX | 0:85b3fd62ea1a | 612 | |
NYX | 0:85b3fd62ea1a | 613 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 614 | |
NYX | 0:85b3fd62ea1a | 615 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 616 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 617 | |
NYX | 0:85b3fd62ea1a | 618 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 619 | } |
NYX | 0:85b3fd62ea1a | 620 | } |
NYX | 0:85b3fd62ea1a | 621 | while (__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_SYNCD) == RESET); |
NYX | 0:85b3fd62ea1a | 622 | |
NYX | 0:85b3fd62ea1a | 623 | /* Start reception */ |
NYX | 0:85b3fd62ea1a | 624 | __HAL_SPDIFRX_RCV(hspdif); |
NYX | 0:85b3fd62ea1a | 625 | } |
NYX | 0:85b3fd62ea1a | 626 | |
NYX | 0:85b3fd62ea1a | 627 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 628 | } |
NYX | 0:85b3fd62ea1a | 629 | else |
NYX | 0:85b3fd62ea1a | 630 | { |
NYX | 0:85b3fd62ea1a | 631 | return HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 632 | } |
NYX | 0:85b3fd62ea1a | 633 | } |
NYX | 0:85b3fd62ea1a | 634 | |
NYX | 0:85b3fd62ea1a | 635 | /** |
NYX | 0:85b3fd62ea1a | 636 | * @brief Receive an amount of data (Control Flow) with Interrupt |
NYX | 0:85b3fd62ea1a | 637 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 638 | * @param pData: a 32-bit pointer to the Receive data buffer. |
NYX | 0:85b3fd62ea1a | 639 | * @param Size: number of data sample (Control Flow) to be received : |
NYX | 0:85b3fd62ea1a | 640 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 641 | */ |
NYX | 0:85b3fd62ea1a | 642 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow_IT(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size) |
NYX | 0:85b3fd62ea1a | 643 | { |
NYX | 0:85b3fd62ea1a | 644 | __IO uint32_t count = SPDIFRX_TIMEOUT_VALUE * (SystemCoreClock / 24U / 1000U); |
NYX | 0:85b3fd62ea1a | 645 | |
NYX | 0:85b3fd62ea1a | 646 | if((hspdif->State == HAL_SPDIFRX_STATE_READY) || (hspdif->State == HAL_SPDIFRX_STATE_BUSY_RX)) |
NYX | 0:85b3fd62ea1a | 647 | { |
NYX | 0:85b3fd62ea1a | 648 | if((pData == NULL ) || (Size == 0)) |
NYX | 0:85b3fd62ea1a | 649 | { |
NYX | 0:85b3fd62ea1a | 650 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 651 | } |
NYX | 0:85b3fd62ea1a | 652 | |
NYX | 0:85b3fd62ea1a | 653 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 654 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 655 | |
NYX | 0:85b3fd62ea1a | 656 | hspdif->pCsBuffPtr = pData; |
NYX | 0:85b3fd62ea1a | 657 | hspdif->CsXferSize = Size; |
NYX | 0:85b3fd62ea1a | 658 | hspdif->CsXferCount = Size; |
NYX | 0:85b3fd62ea1a | 659 | |
NYX | 0:85b3fd62ea1a | 660 | hspdif->ErrorCode = HAL_SPDIFRX_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 661 | |
NYX | 0:85b3fd62ea1a | 662 | /* Check if a receive process is ongoing or not */ |
NYX | 0:85b3fd62ea1a | 663 | hspdif->State = HAL_SPDIFRX_STATE_BUSY_CX; |
NYX | 0:85b3fd62ea1a | 664 | |
NYX | 0:85b3fd62ea1a | 665 | /* Enable the SPDIFRX PE Error Interrupt */ |
NYX | 0:85b3fd62ea1a | 666 | __HAL_SPDIFRX_ENABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 667 | |
NYX | 0:85b3fd62ea1a | 668 | /* Enable the SPDIFRX OVR Error Interrupt */ |
NYX | 0:85b3fd62ea1a | 669 | __HAL_SPDIFRX_ENABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 670 | |
NYX | 0:85b3fd62ea1a | 671 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 672 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 673 | |
NYX | 0:85b3fd62ea1a | 674 | /* Enable the SPDIFRX CSRNE interrupt */ |
NYX | 0:85b3fd62ea1a | 675 | __HAL_SPDIFRX_ENABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 676 | |
NYX | 0:85b3fd62ea1a | 677 | if ((SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != SPDIFRX_STATE_SYNC || (SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != 0x00U) |
NYX | 0:85b3fd62ea1a | 678 | { |
NYX | 0:85b3fd62ea1a | 679 | /* Start synchronization */ |
NYX | 0:85b3fd62ea1a | 680 | __HAL_SPDIFRX_SYNC(hspdif); |
NYX | 0:85b3fd62ea1a | 681 | |
NYX | 0:85b3fd62ea1a | 682 | /* Wait until SYNCD flag is set */ |
NYX | 0:85b3fd62ea1a | 683 | do |
NYX | 0:85b3fd62ea1a | 684 | { |
NYX | 0:85b3fd62ea1a | 685 | if (count-- == 0U) |
NYX | 0:85b3fd62ea1a | 686 | { |
NYX | 0:85b3fd62ea1a | 687 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
NYX | 0:85b3fd62ea1a | 688 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 689 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 690 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 691 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 692 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SBLKIE); |
NYX | 0:85b3fd62ea1a | 693 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SYNCDIE); |
NYX | 0:85b3fd62ea1a | 694 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_IFEIE); |
NYX | 0:85b3fd62ea1a | 695 | |
NYX | 0:85b3fd62ea1a | 696 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 697 | |
NYX | 0:85b3fd62ea1a | 698 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 699 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 700 | |
NYX | 0:85b3fd62ea1a | 701 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 702 | } |
NYX | 0:85b3fd62ea1a | 703 | } |
NYX | 0:85b3fd62ea1a | 704 | while (__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_SYNCD) == RESET); |
NYX | 0:85b3fd62ea1a | 705 | |
NYX | 0:85b3fd62ea1a | 706 | /* Start reception */ |
NYX | 0:85b3fd62ea1a | 707 | __HAL_SPDIFRX_RCV(hspdif); |
NYX | 0:85b3fd62ea1a | 708 | } |
NYX | 0:85b3fd62ea1a | 709 | |
NYX | 0:85b3fd62ea1a | 710 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 711 | } |
NYX | 0:85b3fd62ea1a | 712 | else |
NYX | 0:85b3fd62ea1a | 713 | { |
NYX | 0:85b3fd62ea1a | 714 | return HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 715 | } |
NYX | 0:85b3fd62ea1a | 716 | } |
NYX | 0:85b3fd62ea1a | 717 | |
NYX | 0:85b3fd62ea1a | 718 | /** |
NYX | 0:85b3fd62ea1a | 719 | * @brief Receive an amount of data (Data Flow) mode with DMA |
NYX | 0:85b3fd62ea1a | 720 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 721 | * @param pData: a 32-bit pointer to the Receive data buffer. |
NYX | 0:85b3fd62ea1a | 722 | * @param Size: number of data sample to be received : |
NYX | 0:85b3fd62ea1a | 723 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 724 | */ |
NYX | 0:85b3fd62ea1a | 725 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveDataFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size) |
NYX | 0:85b3fd62ea1a | 726 | { |
NYX | 0:85b3fd62ea1a | 727 | __IO uint32_t count = SPDIFRX_TIMEOUT_VALUE * (SystemCoreClock / 24U / 1000U); |
NYX | 0:85b3fd62ea1a | 728 | |
NYX | 0:85b3fd62ea1a | 729 | if((pData == NULL) || (Size == 0)) |
NYX | 0:85b3fd62ea1a | 730 | { |
NYX | 0:85b3fd62ea1a | 731 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 732 | } |
NYX | 0:85b3fd62ea1a | 733 | |
NYX | 0:85b3fd62ea1a | 734 | if((hspdif->State == HAL_SPDIFRX_STATE_READY) || (hspdif->State == HAL_SPDIFRX_STATE_BUSY_CX)) |
NYX | 0:85b3fd62ea1a | 735 | { |
NYX | 0:85b3fd62ea1a | 736 | hspdif->pRxBuffPtr = pData; |
NYX | 0:85b3fd62ea1a | 737 | hspdif->RxXferSize = Size; |
NYX | 0:85b3fd62ea1a | 738 | hspdif->RxXferCount = Size; |
NYX | 0:85b3fd62ea1a | 739 | |
NYX | 0:85b3fd62ea1a | 740 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 741 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 742 | |
NYX | 0:85b3fd62ea1a | 743 | hspdif->ErrorCode = HAL_SPDIFRX_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 744 | hspdif->State = HAL_SPDIFRX_STATE_BUSY_RX; |
NYX | 0:85b3fd62ea1a | 745 | |
NYX | 0:85b3fd62ea1a | 746 | /* Set the SPDIFRX Rx DMA Half transfer complete callback */ |
NYX | 0:85b3fd62ea1a | 747 | hspdif->hdmaDrRx->XferHalfCpltCallback = SPDIFRX_DMARxHalfCplt; |
NYX | 0:85b3fd62ea1a | 748 | |
NYX | 0:85b3fd62ea1a | 749 | /* Set the SPDIFRX Rx DMA transfer complete callback */ |
NYX | 0:85b3fd62ea1a | 750 | hspdif->hdmaDrRx->XferCpltCallback = SPDIFRX_DMARxCplt; |
NYX | 0:85b3fd62ea1a | 751 | |
NYX | 0:85b3fd62ea1a | 752 | /* Set the DMA error callback */ |
NYX | 0:85b3fd62ea1a | 753 | hspdif->hdmaDrRx->XferErrorCallback = SPDIFRX_DMAError; |
NYX | 0:85b3fd62ea1a | 754 | |
NYX | 0:85b3fd62ea1a | 755 | /* Enable the DMA request */ |
NYX | 0:85b3fd62ea1a | 756 | HAL_DMA_Start_IT(hspdif->hdmaDrRx, (uint32_t)&hspdif->Instance->DR, (uint32_t)hspdif->pRxBuffPtr, Size); |
NYX | 0:85b3fd62ea1a | 757 | |
NYX | 0:85b3fd62ea1a | 758 | /* Enable RXDMAEN bit in SPDIFRX CR register for data flow reception*/ |
NYX | 0:85b3fd62ea1a | 759 | hspdif->Instance->CR |= SPDIFRX_CR_RXDMAEN; |
NYX | 0:85b3fd62ea1a | 760 | |
NYX | 0:85b3fd62ea1a | 761 | if ((SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != SPDIFRX_STATE_SYNC || (SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != 0x00U) |
NYX | 0:85b3fd62ea1a | 762 | { |
NYX | 0:85b3fd62ea1a | 763 | /* Start synchronization */ |
NYX | 0:85b3fd62ea1a | 764 | __HAL_SPDIFRX_SYNC(hspdif); |
NYX | 0:85b3fd62ea1a | 765 | |
NYX | 0:85b3fd62ea1a | 766 | /* Wait until SYNCD flag is set */ |
NYX | 0:85b3fd62ea1a | 767 | do |
NYX | 0:85b3fd62ea1a | 768 | { |
NYX | 0:85b3fd62ea1a | 769 | if (count-- == 0U) |
NYX | 0:85b3fd62ea1a | 770 | { |
NYX | 0:85b3fd62ea1a | 771 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
NYX | 0:85b3fd62ea1a | 772 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 773 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 774 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 775 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 776 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SBLKIE); |
NYX | 0:85b3fd62ea1a | 777 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SYNCDIE); |
NYX | 0:85b3fd62ea1a | 778 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_IFEIE); |
NYX | 0:85b3fd62ea1a | 779 | |
NYX | 0:85b3fd62ea1a | 780 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 781 | |
NYX | 0:85b3fd62ea1a | 782 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 783 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 784 | |
NYX | 0:85b3fd62ea1a | 785 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 786 | } |
NYX | 0:85b3fd62ea1a | 787 | } |
NYX | 0:85b3fd62ea1a | 788 | while (__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_SYNCD) == RESET); |
NYX | 0:85b3fd62ea1a | 789 | |
NYX | 0:85b3fd62ea1a | 790 | /* Start reception */ |
NYX | 0:85b3fd62ea1a | 791 | __HAL_SPDIFRX_RCV(hspdif); |
NYX | 0:85b3fd62ea1a | 792 | } |
NYX | 0:85b3fd62ea1a | 793 | |
NYX | 0:85b3fd62ea1a | 794 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 795 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 796 | |
NYX | 0:85b3fd62ea1a | 797 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 798 | } |
NYX | 0:85b3fd62ea1a | 799 | else |
NYX | 0:85b3fd62ea1a | 800 | { |
NYX | 0:85b3fd62ea1a | 801 | return HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 802 | } |
NYX | 0:85b3fd62ea1a | 803 | } |
NYX | 0:85b3fd62ea1a | 804 | |
NYX | 0:85b3fd62ea1a | 805 | /** |
NYX | 0:85b3fd62ea1a | 806 | * @brief Receive an amount of data (Control Flow) with DMA |
NYX | 0:85b3fd62ea1a | 807 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 808 | * @param pData: a 32-bit pointer to the Receive data buffer. |
NYX | 0:85b3fd62ea1a | 809 | * @param Size: number of data (Control Flow) sample to be received : |
NYX | 0:85b3fd62ea1a | 810 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 811 | */ |
NYX | 0:85b3fd62ea1a | 812 | HAL_StatusTypeDef HAL_SPDIFRX_ReceiveControlFlow_DMA(SPDIFRX_HandleTypeDef *hspdif, uint32_t *pData, uint16_t Size) |
NYX | 0:85b3fd62ea1a | 813 | { |
NYX | 0:85b3fd62ea1a | 814 | __IO uint32_t count = SPDIFRX_TIMEOUT_VALUE * (SystemCoreClock / 24U / 1000U); |
NYX | 0:85b3fd62ea1a | 815 | |
NYX | 0:85b3fd62ea1a | 816 | if((pData == NULL) || (Size == 0)) |
NYX | 0:85b3fd62ea1a | 817 | { |
NYX | 0:85b3fd62ea1a | 818 | return HAL_ERROR; |
NYX | 0:85b3fd62ea1a | 819 | } |
NYX | 0:85b3fd62ea1a | 820 | |
NYX | 0:85b3fd62ea1a | 821 | if((hspdif->State == HAL_SPDIFRX_STATE_READY) || (hspdif->State == HAL_SPDIFRX_STATE_BUSY_RX)) |
NYX | 0:85b3fd62ea1a | 822 | { |
NYX | 0:85b3fd62ea1a | 823 | hspdif->pCsBuffPtr = pData; |
NYX | 0:85b3fd62ea1a | 824 | hspdif->CsXferSize = Size; |
NYX | 0:85b3fd62ea1a | 825 | hspdif->CsXferCount = Size; |
NYX | 0:85b3fd62ea1a | 826 | |
NYX | 0:85b3fd62ea1a | 827 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 828 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 829 | |
NYX | 0:85b3fd62ea1a | 830 | hspdif->ErrorCode = HAL_SPDIFRX_ERROR_NONE; |
NYX | 0:85b3fd62ea1a | 831 | hspdif->State = HAL_SPDIFRX_STATE_BUSY_CX; |
NYX | 0:85b3fd62ea1a | 832 | |
NYX | 0:85b3fd62ea1a | 833 | /* Set the SPDIFRX Rx DMA Half transfer complete callback */ |
NYX | 0:85b3fd62ea1a | 834 | hspdif->hdmaCsRx->XferHalfCpltCallback = SPDIFRX_DMACxHalfCplt; |
NYX | 0:85b3fd62ea1a | 835 | |
NYX | 0:85b3fd62ea1a | 836 | /* Set the SPDIFRX Rx DMA transfer complete callback */ |
NYX | 0:85b3fd62ea1a | 837 | hspdif->hdmaCsRx->XferCpltCallback = SPDIFRX_DMACxCplt; |
NYX | 0:85b3fd62ea1a | 838 | |
NYX | 0:85b3fd62ea1a | 839 | /* Set the DMA error callback */ |
NYX | 0:85b3fd62ea1a | 840 | hspdif->hdmaCsRx->XferErrorCallback = SPDIFRX_DMAError; |
NYX | 0:85b3fd62ea1a | 841 | |
NYX | 0:85b3fd62ea1a | 842 | /* Enable the DMA request */ |
NYX | 0:85b3fd62ea1a | 843 | HAL_DMA_Start_IT(hspdif->hdmaCsRx, (uint32_t)&hspdif->Instance->CSR, (uint32_t)hspdif->pCsBuffPtr, Size); |
NYX | 0:85b3fd62ea1a | 844 | |
NYX | 0:85b3fd62ea1a | 845 | /* Enable CBDMAEN bit in SPDIFRX CR register for control flow reception*/ |
NYX | 0:85b3fd62ea1a | 846 | hspdif->Instance->CR |= SPDIFRX_CR_CBDMAEN; |
NYX | 0:85b3fd62ea1a | 847 | |
NYX | 0:85b3fd62ea1a | 848 | if ((SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != SPDIFRX_STATE_SYNC || (SPDIFRX->CR & SPDIFRX_CR_SPDIFEN) != 0x00U) |
NYX | 0:85b3fd62ea1a | 849 | { |
NYX | 0:85b3fd62ea1a | 850 | /* Start synchronization */ |
NYX | 0:85b3fd62ea1a | 851 | __HAL_SPDIFRX_SYNC(hspdif); |
NYX | 0:85b3fd62ea1a | 852 | |
NYX | 0:85b3fd62ea1a | 853 | /* Wait until SYNCD flag is set */ |
NYX | 0:85b3fd62ea1a | 854 | do |
NYX | 0:85b3fd62ea1a | 855 | { |
NYX | 0:85b3fd62ea1a | 856 | if (count-- == 0U) |
NYX | 0:85b3fd62ea1a | 857 | { |
NYX | 0:85b3fd62ea1a | 858 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
NYX | 0:85b3fd62ea1a | 859 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 860 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 861 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 862 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 863 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SBLKIE); |
NYX | 0:85b3fd62ea1a | 864 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SYNCDIE); |
NYX | 0:85b3fd62ea1a | 865 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_IFEIE); |
NYX | 0:85b3fd62ea1a | 866 | |
NYX | 0:85b3fd62ea1a | 867 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 868 | |
NYX | 0:85b3fd62ea1a | 869 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 870 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 871 | |
NYX | 0:85b3fd62ea1a | 872 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 873 | } |
NYX | 0:85b3fd62ea1a | 874 | } |
NYX | 0:85b3fd62ea1a | 875 | while (__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_SYNCD) == RESET); |
NYX | 0:85b3fd62ea1a | 876 | |
NYX | 0:85b3fd62ea1a | 877 | /* Start reception */ |
NYX | 0:85b3fd62ea1a | 878 | __HAL_SPDIFRX_RCV(hspdif); |
NYX | 0:85b3fd62ea1a | 879 | } |
NYX | 0:85b3fd62ea1a | 880 | |
NYX | 0:85b3fd62ea1a | 881 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 882 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 883 | |
NYX | 0:85b3fd62ea1a | 884 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 885 | } |
NYX | 0:85b3fd62ea1a | 886 | else |
NYX | 0:85b3fd62ea1a | 887 | { |
NYX | 0:85b3fd62ea1a | 888 | return HAL_BUSY; |
NYX | 0:85b3fd62ea1a | 889 | } |
NYX | 0:85b3fd62ea1a | 890 | } |
NYX | 0:85b3fd62ea1a | 891 | |
NYX | 0:85b3fd62ea1a | 892 | /** |
NYX | 0:85b3fd62ea1a | 893 | * @brief stop the audio stream receive from the Media. |
NYX | 0:85b3fd62ea1a | 894 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 895 | * @retval None |
NYX | 0:85b3fd62ea1a | 896 | */ |
NYX | 0:85b3fd62ea1a | 897 | HAL_StatusTypeDef HAL_SPDIFRX_DMAStop(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 898 | { |
NYX | 0:85b3fd62ea1a | 899 | /* Process Locked */ |
NYX | 0:85b3fd62ea1a | 900 | __HAL_LOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 901 | |
NYX | 0:85b3fd62ea1a | 902 | /* Disable the SPDIFRX DMA requests */ |
NYX | 0:85b3fd62ea1a | 903 | hspdif->Instance->CR &= (uint16_t)(~SPDIFRX_CR_RXDMAEN); |
NYX | 0:85b3fd62ea1a | 904 | hspdif->Instance->CR &= (uint16_t)(~SPDIFRX_CR_CBDMAEN); |
NYX | 0:85b3fd62ea1a | 905 | |
NYX | 0:85b3fd62ea1a | 906 | /* Disable the SPDIFRX DMA channel */ |
NYX | 0:85b3fd62ea1a | 907 | __HAL_DMA_DISABLE(hspdif->hdmaDrRx); |
NYX | 0:85b3fd62ea1a | 908 | __HAL_DMA_DISABLE(hspdif->hdmaCsRx); |
NYX | 0:85b3fd62ea1a | 909 | |
NYX | 0:85b3fd62ea1a | 910 | /* Disable SPDIFRX peripheral */ |
NYX | 0:85b3fd62ea1a | 911 | __HAL_SPDIFRX_IDLE(hspdif); |
NYX | 0:85b3fd62ea1a | 912 | |
NYX | 0:85b3fd62ea1a | 913 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 914 | |
NYX | 0:85b3fd62ea1a | 915 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 916 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 917 | |
NYX | 0:85b3fd62ea1a | 918 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 919 | } |
NYX | 0:85b3fd62ea1a | 920 | |
NYX | 0:85b3fd62ea1a | 921 | /** |
NYX | 0:85b3fd62ea1a | 922 | * @brief This function handles SPDIFRX interrupt request. |
NYX | 0:85b3fd62ea1a | 923 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 924 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 925 | */ |
NYX | 0:85b3fd62ea1a | 926 | void HAL_SPDIFRX_IRQHandler(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 927 | { |
NYX | 0:85b3fd62ea1a | 928 | /* SPDIFRX in mode Data Flow Reception ------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 929 | if((__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_RXNE) != RESET) && (__HAL_SPDIFRX_GET_IT_SOURCE(hspdif, SPDIFRX_IT_RXNE) != RESET)) |
NYX | 0:85b3fd62ea1a | 930 | { |
NYX | 0:85b3fd62ea1a | 931 | __HAL_SPDIFRX_CLEAR_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 932 | SPDIFRX_ReceiveDataFlow_IT(hspdif); |
NYX | 0:85b3fd62ea1a | 933 | } |
NYX | 0:85b3fd62ea1a | 934 | |
NYX | 0:85b3fd62ea1a | 935 | /* SPDIFRX in mode Control Flow Reception ------------------------------------------------*/ |
NYX | 0:85b3fd62ea1a | 936 | if((__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_CSRNE) != RESET) && (__HAL_SPDIFRX_GET_IT_SOURCE(hspdif, SPDIFRX_IT_CSRNE) != RESET)) |
NYX | 0:85b3fd62ea1a | 937 | { |
NYX | 0:85b3fd62ea1a | 938 | __HAL_SPDIFRX_CLEAR_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 939 | SPDIFRX_ReceiveControlFlow_IT(hspdif); |
NYX | 0:85b3fd62ea1a | 940 | } |
NYX | 0:85b3fd62ea1a | 941 | |
NYX | 0:85b3fd62ea1a | 942 | /* SPDIFRX Overrun error interrupt occurred ---------------------------------*/ |
NYX | 0:85b3fd62ea1a | 943 | if((__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_OVR) != RESET) && (__HAL_SPDIFRX_GET_IT_SOURCE(hspdif, SPDIFRX_IT_OVRIE) != RESET)) |
NYX | 0:85b3fd62ea1a | 944 | { |
NYX | 0:85b3fd62ea1a | 945 | __HAL_SPDIFRX_CLEAR_IT(hspdif, SPDIFRX_FLAG_OVR); |
NYX | 0:85b3fd62ea1a | 946 | |
NYX | 0:85b3fd62ea1a | 947 | /* Change the SPDIFRX error code */ |
NYX | 0:85b3fd62ea1a | 948 | hspdif->ErrorCode |= HAL_SPDIFRX_ERROR_OVR; |
NYX | 0:85b3fd62ea1a | 949 | |
NYX | 0:85b3fd62ea1a | 950 | /* the transfer is not stopped */ |
NYX | 0:85b3fd62ea1a | 951 | HAL_SPDIFRX_ErrorCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 952 | } |
NYX | 0:85b3fd62ea1a | 953 | |
NYX | 0:85b3fd62ea1a | 954 | /* SPDIFRX Parity error interrupt occurred ---------------------------------*/ |
NYX | 0:85b3fd62ea1a | 955 | if((__HAL_SPDIFRX_GET_FLAG(hspdif, SPDIFRX_FLAG_PERR) != RESET) && (__HAL_SPDIFRX_GET_IT_SOURCE(hspdif, SPDIFRX_IT_PERRIE) != RESET)) |
NYX | 0:85b3fd62ea1a | 956 | { |
NYX | 0:85b3fd62ea1a | 957 | __HAL_SPDIFRX_CLEAR_IT(hspdif, SPDIFRX_FLAG_PERR); |
NYX | 0:85b3fd62ea1a | 958 | |
NYX | 0:85b3fd62ea1a | 959 | /* Change the SPDIFRX error code */ |
NYX | 0:85b3fd62ea1a | 960 | hspdif->ErrorCode |= HAL_SPDIFRX_ERROR_PE; |
NYX | 0:85b3fd62ea1a | 961 | |
NYX | 0:85b3fd62ea1a | 962 | /* the transfer is not stopped */ |
NYX | 0:85b3fd62ea1a | 963 | HAL_SPDIFRX_ErrorCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 964 | } |
NYX | 0:85b3fd62ea1a | 965 | } |
NYX | 0:85b3fd62ea1a | 966 | |
NYX | 0:85b3fd62ea1a | 967 | /** |
NYX | 0:85b3fd62ea1a | 968 | * @brief Rx Transfer (Data flow) half completed callbacks |
NYX | 0:85b3fd62ea1a | 969 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 970 | * @retval None |
NYX | 0:85b3fd62ea1a | 971 | */ |
NYX | 0:85b3fd62ea1a | 972 | __weak void HAL_SPDIFRX_RxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 973 | { |
NYX | 0:85b3fd62ea1a | 974 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 975 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 976 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 977 | the HAL_SPDIFRX_RxCpltCallback could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 978 | */ |
NYX | 0:85b3fd62ea1a | 979 | } |
NYX | 0:85b3fd62ea1a | 980 | |
NYX | 0:85b3fd62ea1a | 981 | /** |
NYX | 0:85b3fd62ea1a | 982 | * @brief Rx Transfer (Data flow) completed callbacks |
NYX | 0:85b3fd62ea1a | 983 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 984 | * @retval None |
NYX | 0:85b3fd62ea1a | 985 | */ |
NYX | 0:85b3fd62ea1a | 986 | __weak void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 987 | { |
NYX | 0:85b3fd62ea1a | 988 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 989 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 990 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 991 | the HAL_SPDIFRX_RxCpltCallback could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 992 | */ |
NYX | 0:85b3fd62ea1a | 993 | } |
NYX | 0:85b3fd62ea1a | 994 | |
NYX | 0:85b3fd62ea1a | 995 | /** |
NYX | 0:85b3fd62ea1a | 996 | * @brief Rx (Control flow) Transfer half completed callbacks |
NYX | 0:85b3fd62ea1a | 997 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 998 | * @retval None |
NYX | 0:85b3fd62ea1a | 999 | */ |
NYX | 0:85b3fd62ea1a | 1000 | __weak void HAL_SPDIFRX_CxHalfCpltCallback(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1001 | { |
NYX | 0:85b3fd62ea1a | 1002 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 1003 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 1004 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 1005 | the HAL_SPDIFRX_RxCpltCallback could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 1006 | */ |
NYX | 0:85b3fd62ea1a | 1007 | } |
NYX | 0:85b3fd62ea1a | 1008 | |
NYX | 0:85b3fd62ea1a | 1009 | /** |
NYX | 0:85b3fd62ea1a | 1010 | * @brief Rx Transfer (Control flow) completed callbacks |
NYX | 0:85b3fd62ea1a | 1011 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1012 | * @retval None |
NYX | 0:85b3fd62ea1a | 1013 | */ |
NYX | 0:85b3fd62ea1a | 1014 | __weak void HAL_SPDIFRX_CxCpltCallback(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1015 | { |
NYX | 0:85b3fd62ea1a | 1016 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 1017 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 1018 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 1019 | the HAL_SPDIFRX_RxCpltCallback could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 1020 | */ |
NYX | 0:85b3fd62ea1a | 1021 | } |
NYX | 0:85b3fd62ea1a | 1022 | |
NYX | 0:85b3fd62ea1a | 1023 | /** |
NYX | 0:85b3fd62ea1a | 1024 | * @brief SPDIFRX error callbacks |
NYX | 0:85b3fd62ea1a | 1025 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1026 | * @retval None |
NYX | 0:85b3fd62ea1a | 1027 | */ |
NYX | 0:85b3fd62ea1a | 1028 | __weak void HAL_SPDIFRX_ErrorCallback(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1029 | { |
NYX | 0:85b3fd62ea1a | 1030 | /* Prevent unused argument(s) compilation warning */ |
NYX | 0:85b3fd62ea1a | 1031 | UNUSED(hspdif); |
NYX | 0:85b3fd62ea1a | 1032 | /* NOTE : This function Should not be modified, when the callback is needed, |
NYX | 0:85b3fd62ea1a | 1033 | the HAL_SPDIFRX_ErrorCallback could be implemented in the user file |
NYX | 0:85b3fd62ea1a | 1034 | */ |
NYX | 0:85b3fd62ea1a | 1035 | } |
NYX | 0:85b3fd62ea1a | 1036 | |
NYX | 0:85b3fd62ea1a | 1037 | /** |
NYX | 0:85b3fd62ea1a | 1038 | * @} |
NYX | 0:85b3fd62ea1a | 1039 | */ |
NYX | 0:85b3fd62ea1a | 1040 | |
NYX | 0:85b3fd62ea1a | 1041 | /** @defgroup SPDIFRX_Exported_Functions_Group3 Peripheral State and Errors functions |
NYX | 0:85b3fd62ea1a | 1042 | * @brief Peripheral State functions |
NYX | 0:85b3fd62ea1a | 1043 | * |
NYX | 0:85b3fd62ea1a | 1044 | @verbatim |
NYX | 0:85b3fd62ea1a | 1045 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 1046 | ##### Peripheral State and Errors functions ##### |
NYX | 0:85b3fd62ea1a | 1047 | =============================================================================== |
NYX | 0:85b3fd62ea1a | 1048 | [..] |
NYX | 0:85b3fd62ea1a | 1049 | This subsection permit to get in run-time the status of the peripheral |
NYX | 0:85b3fd62ea1a | 1050 | and the data flow. |
NYX | 0:85b3fd62ea1a | 1051 | |
NYX | 0:85b3fd62ea1a | 1052 | @endverbatim |
NYX | 0:85b3fd62ea1a | 1053 | * @{ |
NYX | 0:85b3fd62ea1a | 1054 | */ |
NYX | 0:85b3fd62ea1a | 1055 | |
NYX | 0:85b3fd62ea1a | 1056 | /** |
NYX | 0:85b3fd62ea1a | 1057 | * @brief Return the SPDIFRX state |
NYX | 0:85b3fd62ea1a | 1058 | * @param hspdif : SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1059 | * @retval HAL state |
NYX | 0:85b3fd62ea1a | 1060 | */ |
NYX | 0:85b3fd62ea1a | 1061 | HAL_SPDIFRX_StateTypeDef HAL_SPDIFRX_GetState(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1062 | { |
NYX | 0:85b3fd62ea1a | 1063 | return hspdif->State; |
NYX | 0:85b3fd62ea1a | 1064 | } |
NYX | 0:85b3fd62ea1a | 1065 | |
NYX | 0:85b3fd62ea1a | 1066 | /** |
NYX | 0:85b3fd62ea1a | 1067 | * @brief Return the SPDIFRX error code |
NYX | 0:85b3fd62ea1a | 1068 | * @param hspdif : SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1069 | * @retval SPDIFRX Error Code |
NYX | 0:85b3fd62ea1a | 1070 | */ |
NYX | 0:85b3fd62ea1a | 1071 | uint32_t HAL_SPDIFRX_GetError(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1072 | { |
NYX | 0:85b3fd62ea1a | 1073 | return hspdif->ErrorCode; |
NYX | 0:85b3fd62ea1a | 1074 | } |
NYX | 0:85b3fd62ea1a | 1075 | |
NYX | 0:85b3fd62ea1a | 1076 | /** |
NYX | 0:85b3fd62ea1a | 1077 | * @} |
NYX | 0:85b3fd62ea1a | 1078 | */ |
NYX | 0:85b3fd62ea1a | 1079 | |
NYX | 0:85b3fd62ea1a | 1080 | /** |
NYX | 0:85b3fd62ea1a | 1081 | * @brief DMA SPDIFRX receive process (Data flow) complete callback |
NYX | 0:85b3fd62ea1a | 1082 | * @param hdma : DMA handle |
NYX | 0:85b3fd62ea1a | 1083 | * @retval None |
NYX | 0:85b3fd62ea1a | 1084 | */ |
NYX | 0:85b3fd62ea1a | 1085 | static void SPDIFRX_DMARxCplt(DMA_HandleTypeDef *hdma) |
NYX | 0:85b3fd62ea1a | 1086 | { |
NYX | 0:85b3fd62ea1a | 1087 | SPDIFRX_HandleTypeDef* hspdif = ( SPDIFRX_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
NYX | 0:85b3fd62ea1a | 1088 | |
NYX | 0:85b3fd62ea1a | 1089 | /* Disable Rx DMA Request */ |
NYX | 0:85b3fd62ea1a | 1090 | hspdif->Instance->CR &= (uint16_t)(~SPDIFRX_CR_RXDMAEN); |
NYX | 0:85b3fd62ea1a | 1091 | hspdif->RxXferCount = 0U; |
NYX | 0:85b3fd62ea1a | 1092 | |
NYX | 0:85b3fd62ea1a | 1093 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1094 | HAL_SPDIFRX_RxCpltCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1095 | } |
NYX | 0:85b3fd62ea1a | 1096 | |
NYX | 0:85b3fd62ea1a | 1097 | /** |
NYX | 0:85b3fd62ea1a | 1098 | * @brief DMA SPDIFRX receive process (Data flow) half complete callback |
NYX | 0:85b3fd62ea1a | 1099 | * @param hdma : DMA handle |
NYX | 0:85b3fd62ea1a | 1100 | * @retval None |
NYX | 0:85b3fd62ea1a | 1101 | */ |
NYX | 0:85b3fd62ea1a | 1102 | static void SPDIFRX_DMARxHalfCplt(DMA_HandleTypeDef *hdma) |
NYX | 0:85b3fd62ea1a | 1103 | { |
NYX | 0:85b3fd62ea1a | 1104 | SPDIFRX_HandleTypeDef* hspdif = (SPDIFRX_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
NYX | 0:85b3fd62ea1a | 1105 | |
NYX | 0:85b3fd62ea1a | 1106 | HAL_SPDIFRX_RxHalfCpltCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1107 | } |
NYX | 0:85b3fd62ea1a | 1108 | |
NYX | 0:85b3fd62ea1a | 1109 | /** |
NYX | 0:85b3fd62ea1a | 1110 | * @brief DMA SPDIFRX receive process (Control flow) complete callback |
NYX | 0:85b3fd62ea1a | 1111 | * @param hdma : DMA handle |
NYX | 0:85b3fd62ea1a | 1112 | * @retval None |
NYX | 0:85b3fd62ea1a | 1113 | */ |
NYX | 0:85b3fd62ea1a | 1114 | static void SPDIFRX_DMACxCplt(DMA_HandleTypeDef *hdma) |
NYX | 0:85b3fd62ea1a | 1115 | { |
NYX | 0:85b3fd62ea1a | 1116 | SPDIFRX_HandleTypeDef* hspdif = ( SPDIFRX_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
NYX | 0:85b3fd62ea1a | 1117 | |
NYX | 0:85b3fd62ea1a | 1118 | /* Disable Cb DMA Request */ |
NYX | 0:85b3fd62ea1a | 1119 | hspdif->Instance->CR &= (uint16_t)(~SPDIFRX_CR_CBDMAEN); |
NYX | 0:85b3fd62ea1a | 1120 | hspdif->CsXferCount = 0U; |
NYX | 0:85b3fd62ea1a | 1121 | |
NYX | 0:85b3fd62ea1a | 1122 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1123 | HAL_SPDIFRX_CxCpltCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1124 | } |
NYX | 0:85b3fd62ea1a | 1125 | |
NYX | 0:85b3fd62ea1a | 1126 | /** |
NYX | 0:85b3fd62ea1a | 1127 | * @brief DMA SPDIFRX receive process (Control flow) half complete callback |
NYX | 0:85b3fd62ea1a | 1128 | * @param hdma : DMA handle |
NYX | 0:85b3fd62ea1a | 1129 | * @retval None |
NYX | 0:85b3fd62ea1a | 1130 | */ |
NYX | 0:85b3fd62ea1a | 1131 | static void SPDIFRX_DMACxHalfCplt(DMA_HandleTypeDef *hdma) |
NYX | 0:85b3fd62ea1a | 1132 | { |
NYX | 0:85b3fd62ea1a | 1133 | SPDIFRX_HandleTypeDef* hspdif = (SPDIFRX_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
NYX | 0:85b3fd62ea1a | 1134 | |
NYX | 0:85b3fd62ea1a | 1135 | HAL_SPDIFRX_CxHalfCpltCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1136 | } |
NYX | 0:85b3fd62ea1a | 1137 | |
NYX | 0:85b3fd62ea1a | 1138 | /** |
NYX | 0:85b3fd62ea1a | 1139 | * @brief DMA SPDIFRX communication error callback |
NYX | 0:85b3fd62ea1a | 1140 | * @param hdma : DMA handle |
NYX | 0:85b3fd62ea1a | 1141 | * @retval None |
NYX | 0:85b3fd62ea1a | 1142 | */ |
NYX | 0:85b3fd62ea1a | 1143 | static void SPDIFRX_DMAError(DMA_HandleTypeDef *hdma) |
NYX | 0:85b3fd62ea1a | 1144 | { |
NYX | 0:85b3fd62ea1a | 1145 | SPDIFRX_HandleTypeDef* hspdif = ( SPDIFRX_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
NYX | 0:85b3fd62ea1a | 1146 | |
NYX | 0:85b3fd62ea1a | 1147 | /* Disable Rx and Cb DMA Request */ |
NYX | 0:85b3fd62ea1a | 1148 | hspdif->Instance->CR &= (uint16_t)(~(SPDIFRX_CR_RXDMAEN | SPDIFRX_CR_CBDMAEN)); |
NYX | 0:85b3fd62ea1a | 1149 | hspdif->RxXferCount = 0U; |
NYX | 0:85b3fd62ea1a | 1150 | |
NYX | 0:85b3fd62ea1a | 1151 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1152 | |
NYX | 0:85b3fd62ea1a | 1153 | /* Set the error code and execute error callback*/ |
NYX | 0:85b3fd62ea1a | 1154 | hspdif->ErrorCode |= HAL_SPDIFRX_ERROR_DMA; |
NYX | 0:85b3fd62ea1a | 1155 | HAL_SPDIFRX_ErrorCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1156 | } |
NYX | 0:85b3fd62ea1a | 1157 | |
NYX | 0:85b3fd62ea1a | 1158 | /** |
NYX | 0:85b3fd62ea1a | 1159 | * @brief Receive an amount of data (Data Flow) with Interrupt |
NYX | 0:85b3fd62ea1a | 1160 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1161 | * @retval None |
NYX | 0:85b3fd62ea1a | 1162 | */ |
NYX | 0:85b3fd62ea1a | 1163 | static void SPDIFRX_ReceiveDataFlow_IT(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1164 | { |
NYX | 0:85b3fd62ea1a | 1165 | /* Receive data */ |
NYX | 0:85b3fd62ea1a | 1166 | (*hspdif->pRxBuffPtr++) = hspdif->Instance->DR; |
NYX | 0:85b3fd62ea1a | 1167 | hspdif->RxXferCount--; |
NYX | 0:85b3fd62ea1a | 1168 | |
NYX | 0:85b3fd62ea1a | 1169 | if(hspdif->RxXferCount == 0U) |
NYX | 0:85b3fd62ea1a | 1170 | { |
NYX | 0:85b3fd62ea1a | 1171 | /* Disable RXNE/PE and OVR interrupts */ |
NYX | 0:85b3fd62ea1a | 1172 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE | SPDIFRX_IT_PERRIE | SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 1173 | |
NYX | 0:85b3fd62ea1a | 1174 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1175 | |
NYX | 0:85b3fd62ea1a | 1176 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 1177 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 1178 | |
NYX | 0:85b3fd62ea1a | 1179 | HAL_SPDIFRX_RxCpltCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1180 | } |
NYX | 0:85b3fd62ea1a | 1181 | } |
NYX | 0:85b3fd62ea1a | 1182 | |
NYX | 0:85b3fd62ea1a | 1183 | /** |
NYX | 0:85b3fd62ea1a | 1184 | * @brief Receive an amount of data (Control Flow) with Interrupt |
NYX | 0:85b3fd62ea1a | 1185 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1186 | * @retval None |
NYX | 0:85b3fd62ea1a | 1187 | */ |
NYX | 0:85b3fd62ea1a | 1188 | static void SPDIFRX_ReceiveControlFlow_IT(SPDIFRX_HandleTypeDef *hspdif) |
NYX | 0:85b3fd62ea1a | 1189 | { |
NYX | 0:85b3fd62ea1a | 1190 | /* Receive data */ |
NYX | 0:85b3fd62ea1a | 1191 | (*hspdif->pCsBuffPtr++) = hspdif->Instance->CSR; |
NYX | 0:85b3fd62ea1a | 1192 | hspdif->CsXferCount--; |
NYX | 0:85b3fd62ea1a | 1193 | |
NYX | 0:85b3fd62ea1a | 1194 | if(hspdif->CsXferCount == 0U) |
NYX | 0:85b3fd62ea1a | 1195 | { |
NYX | 0:85b3fd62ea1a | 1196 | /* Disable CSRNE interrupt */ |
NYX | 0:85b3fd62ea1a | 1197 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 1198 | |
NYX | 0:85b3fd62ea1a | 1199 | hspdif->State = HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1200 | |
NYX | 0:85b3fd62ea1a | 1201 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 1202 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 1203 | |
NYX | 0:85b3fd62ea1a | 1204 | HAL_SPDIFRX_CxCpltCallback(hspdif); |
NYX | 0:85b3fd62ea1a | 1205 | } |
NYX | 0:85b3fd62ea1a | 1206 | } |
NYX | 0:85b3fd62ea1a | 1207 | |
NYX | 0:85b3fd62ea1a | 1208 | /** |
NYX | 0:85b3fd62ea1a | 1209 | * @brief This function handles SPDIFRX Communication Timeout. |
NYX | 0:85b3fd62ea1a | 1210 | * @param hspdif: SPDIFRX handle |
NYX | 0:85b3fd62ea1a | 1211 | * @param Flag: Flag checked |
NYX | 0:85b3fd62ea1a | 1212 | * @param Status: Value of the flag expected |
NYX | 0:85b3fd62ea1a | 1213 | * @param Timeout: Duration of the timeout |
NYX | 0:85b3fd62ea1a | 1214 | * @retval HAL status |
NYX | 0:85b3fd62ea1a | 1215 | */ |
NYX | 0:85b3fd62ea1a | 1216 | static HAL_StatusTypeDef SPDIFRX_WaitOnFlagUntilTimeout(SPDIFRX_HandleTypeDef *hspdif, uint32_t Flag, FlagStatus Status, uint32_t Timeout) |
NYX | 0:85b3fd62ea1a | 1217 | { |
NYX | 0:85b3fd62ea1a | 1218 | uint32_t tickstart = 0U; |
NYX | 0:85b3fd62ea1a | 1219 | |
NYX | 0:85b3fd62ea1a | 1220 | /* Get tick */ |
NYX | 0:85b3fd62ea1a | 1221 | tickstart = HAL_GetTick(); |
NYX | 0:85b3fd62ea1a | 1222 | |
NYX | 0:85b3fd62ea1a | 1223 | /* Wait until flag is set */ |
NYX | 0:85b3fd62ea1a | 1224 | if(Status == RESET) |
NYX | 0:85b3fd62ea1a | 1225 | { |
NYX | 0:85b3fd62ea1a | 1226 | while(__HAL_SPDIFRX_GET_FLAG(hspdif, Flag) == RESET) |
NYX | 0:85b3fd62ea1a | 1227 | { |
NYX | 0:85b3fd62ea1a | 1228 | /* Check for the Timeout */ |
NYX | 0:85b3fd62ea1a | 1229 | if(Timeout != HAL_MAX_DELAY) |
NYX | 0:85b3fd62ea1a | 1230 | { |
NYX | 0:85b3fd62ea1a | 1231 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
NYX | 0:85b3fd62ea1a | 1232 | { |
NYX | 0:85b3fd62ea1a | 1233 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
NYX | 0:85b3fd62ea1a | 1234 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 1235 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 1236 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 1237 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 1238 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SBLKIE); |
NYX | 0:85b3fd62ea1a | 1239 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SYNCDIE); |
NYX | 0:85b3fd62ea1a | 1240 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_IFEIE); |
NYX | 0:85b3fd62ea1a | 1241 | |
NYX | 0:85b3fd62ea1a | 1242 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1243 | |
NYX | 0:85b3fd62ea1a | 1244 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 1245 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 1246 | |
NYX | 0:85b3fd62ea1a | 1247 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 1248 | } |
NYX | 0:85b3fd62ea1a | 1249 | } |
NYX | 0:85b3fd62ea1a | 1250 | } |
NYX | 0:85b3fd62ea1a | 1251 | } |
NYX | 0:85b3fd62ea1a | 1252 | else |
NYX | 0:85b3fd62ea1a | 1253 | { |
NYX | 0:85b3fd62ea1a | 1254 | while(__HAL_SPDIFRX_GET_FLAG(hspdif, Flag) != RESET) |
NYX | 0:85b3fd62ea1a | 1255 | { |
NYX | 0:85b3fd62ea1a | 1256 | /* Check for the Timeout */ |
NYX | 0:85b3fd62ea1a | 1257 | if(Timeout != HAL_MAX_DELAY) |
NYX | 0:85b3fd62ea1a | 1258 | { |
NYX | 0:85b3fd62ea1a | 1259 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
NYX | 0:85b3fd62ea1a | 1260 | { |
NYX | 0:85b3fd62ea1a | 1261 | /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */ |
NYX | 0:85b3fd62ea1a | 1262 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_RXNE); |
NYX | 0:85b3fd62ea1a | 1263 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_CSRNE); |
NYX | 0:85b3fd62ea1a | 1264 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_PERRIE); |
NYX | 0:85b3fd62ea1a | 1265 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_OVRIE); |
NYX | 0:85b3fd62ea1a | 1266 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SBLKIE); |
NYX | 0:85b3fd62ea1a | 1267 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_SYNCDIE); |
NYX | 0:85b3fd62ea1a | 1268 | __HAL_SPDIFRX_DISABLE_IT(hspdif, SPDIFRX_IT_IFEIE); |
NYX | 0:85b3fd62ea1a | 1269 | |
NYX | 0:85b3fd62ea1a | 1270 | hspdif->State= HAL_SPDIFRX_STATE_READY; |
NYX | 0:85b3fd62ea1a | 1271 | |
NYX | 0:85b3fd62ea1a | 1272 | /* Process Unlocked */ |
NYX | 0:85b3fd62ea1a | 1273 | __HAL_UNLOCK(hspdif); |
NYX | 0:85b3fd62ea1a | 1274 | |
NYX | 0:85b3fd62ea1a | 1275 | return HAL_TIMEOUT; |
NYX | 0:85b3fd62ea1a | 1276 | } |
NYX | 0:85b3fd62ea1a | 1277 | } |
NYX | 0:85b3fd62ea1a | 1278 | } |
NYX | 0:85b3fd62ea1a | 1279 | } |
NYX | 0:85b3fd62ea1a | 1280 | return HAL_OK; |
NYX | 0:85b3fd62ea1a | 1281 | } |
NYX | 0:85b3fd62ea1a | 1282 | |
NYX | 0:85b3fd62ea1a | 1283 | /** |
NYX | 0:85b3fd62ea1a | 1284 | * @} |
NYX | 0:85b3fd62ea1a | 1285 | */ |
NYX | 0:85b3fd62ea1a | 1286 | #endif /* STM32F446xx */ |
NYX | 0:85b3fd62ea1a | 1287 | |
NYX | 0:85b3fd62ea1a | 1288 | #endif /* HAL_SPDIFRX_MODULE_ENABLED */ |
NYX | 0:85b3fd62ea1a | 1289 | /** |
NYX | 0:85b3fd62ea1a | 1290 | * @} |
NYX | 0:85b3fd62ea1a | 1291 | */ |
NYX | 0:85b3fd62ea1a | 1292 | |
NYX | 0:85b3fd62ea1a | 1293 | /** |
NYX | 0:85b3fd62ea1a | 1294 | * @} |
NYX | 0:85b3fd62ea1a | 1295 | */ |
NYX | 0:85b3fd62ea1a | 1296 | |
NYX | 0:85b3fd62ea1a | 1297 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
NYX | 0:85b3fd62ea1a | 1298 |