mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F411RE/stm32f4xx_hal_sai.c@235:685d5f11838f, 2014-06-23 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Jun 23 14:00:09 2014 +0100
- Revision:
- 235:685d5f11838f
Synchronized with git revision 9728c76667962b289ee9c4c687ef9f115db48cd3
Full URL: https://github.com/mbedmicro/mbed/commit/9728c76667962b289ee9c4c687ef9f115db48cd3/
[NUCLEO_F411RE] Add all target files
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 235:685d5f11838f | 1 | /** |
mbed_official | 235:685d5f11838f | 2 | ****************************************************************************** |
mbed_official | 235:685d5f11838f | 3 | * @file stm32f4xx_hal_sai.c |
mbed_official | 235:685d5f11838f | 4 | * @author MCD Application Team |
mbed_official | 235:685d5f11838f | 5 | * @version V1.1.0 |
mbed_official | 235:685d5f11838f | 6 | * @date 19-June-2014 |
mbed_official | 235:685d5f11838f | 7 | * @brief SAI HAL module driver. |
mbed_official | 235:685d5f11838f | 8 | * This file provides firmware functions to manage the following |
mbed_official | 235:685d5f11838f | 9 | * functionalities of the Serial Audio Interface (SAI) peripheral: |
mbed_official | 235:685d5f11838f | 10 | * + Initialization/de-initialization functions |
mbed_official | 235:685d5f11838f | 11 | * + I/O operation functions |
mbed_official | 235:685d5f11838f | 12 | * + Peripheral Control functions |
mbed_official | 235:685d5f11838f | 13 | * + Peripheral State functions |
mbed_official | 235:685d5f11838f | 14 | * |
mbed_official | 235:685d5f11838f | 15 | @verbatim |
mbed_official | 235:685d5f11838f | 16 | ============================================================================== |
mbed_official | 235:685d5f11838f | 17 | ##### How to use this driver ##### |
mbed_official | 235:685d5f11838f | 18 | ============================================================================== |
mbed_official | 235:685d5f11838f | 19 | |
mbed_official | 235:685d5f11838f | 20 | [..] |
mbed_official | 235:685d5f11838f | 21 | The SAI HAL driver can be used as follows: |
mbed_official | 235:685d5f11838f | 22 | |
mbed_official | 235:685d5f11838f | 23 | (#) Declare a SAI_HandleTypeDef handle structure. |
mbed_official | 235:685d5f11838f | 24 | (#) Initialize the SAI low level resources by implementing the HAL_SAI_MspInit() API: |
mbed_official | 235:685d5f11838f | 25 | (##) Enable the SAI interface clock. |
mbed_official | 235:685d5f11838f | 26 | (##) SAI pins configuration: |
mbed_official | 235:685d5f11838f | 27 | (+++) Enable the clock for the SAI GPIOs. |
mbed_official | 235:685d5f11838f | 28 | (+++) Configure these SAI pins as alternate function pull-up. |
mbed_official | 235:685d5f11838f | 29 | (##) NVIC configuration if you need to use interrupt process (HAL_SAI_Transmit_IT() |
mbed_official | 235:685d5f11838f | 30 | and HAL_SAI_Receive_IT() APIs): |
mbed_official | 235:685d5f11838f | 31 | (+++) Configure the SAI interrupt priority. |
mbed_official | 235:685d5f11838f | 32 | (+++) Enable the NVIC SAI IRQ handle. |
mbed_official | 235:685d5f11838f | 33 | |
mbed_official | 235:685d5f11838f | 34 | (##) DMA Configuration if you need to use DMA process (HAL_SAI_Transmit_DMA() |
mbed_official | 235:685d5f11838f | 35 | and HAL_SAI_Receive_DMA() APIs): |
mbed_official | 235:685d5f11838f | 36 | (+++) Declare a DMA handle structure for the Tx/Rx stream. |
mbed_official | 235:685d5f11838f | 37 | (+++) Enable the DMAx interface clock. |
mbed_official | 235:685d5f11838f | 38 | (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. |
mbed_official | 235:685d5f11838f | 39 | (+++) Configure the DMA Tx/Rx Stream. |
mbed_official | 235:685d5f11838f | 40 | (+++) Associate the initialized DMA handle to the SAI DMA Tx/Rx handle. |
mbed_official | 235:685d5f11838f | 41 | (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the |
mbed_official | 235:685d5f11838f | 42 | DMA Tx/Rx Stream. |
mbed_official | 235:685d5f11838f | 43 | |
mbed_official | 235:685d5f11838f | 44 | (#) Program the SAI Mode, Standard, Data Format, MCLK Output, Audio frequency and Polarity |
mbed_official | 235:685d5f11838f | 45 | using HAL_SAI_Init() function. |
mbed_official | 235:685d5f11838f | 46 | |
mbed_official | 235:685d5f11838f | 47 | -@- The specific SAI interrupts (FIFO request and Overrun underrun interrupt) |
mbed_official | 235:685d5f11838f | 48 | will be managed using the macros __SAI_ENABLE_IT() and __SAI_DISABLE_IT() |
mbed_official | 235:685d5f11838f | 49 | inside the transmit and receive process. |
mbed_official | 235:685d5f11838f | 50 | |
mbed_official | 235:685d5f11838f | 51 | [..] |
mbed_official | 235:685d5f11838f | 52 | (@) Make sure that either: |
mbed_official | 235:685d5f11838f | 53 | (+@) I2S PLL is configured or |
mbed_official | 235:685d5f11838f | 54 | (+@) SAI PLL is configured or |
mbed_official | 235:685d5f11838f | 55 | (+@) External clock source is configured after setting correctly |
mbed_official | 235:685d5f11838f | 56 | the define constant EXTERNAL_CLOCK_VALUE in the stm32f4xx_hal_conf.h file. |
mbed_official | 235:685d5f11838f | 57 | |
mbed_official | 235:685d5f11838f | 58 | [..] |
mbed_official | 235:685d5f11838f | 59 | (@) In master Tx mode: enabling the audio block immediately generates the bit clock |
mbed_official | 235:685d5f11838f | 60 | for the external slaves even if there is no data in the FIFO, However FS signal |
mbed_official | 235:685d5f11838f | 61 | generation is conditioned by the presence of data in the FIFO. |
mbed_official | 235:685d5f11838f | 62 | |
mbed_official | 235:685d5f11838f | 63 | [..] |
mbed_official | 235:685d5f11838f | 64 | (@) In master Rx mode: enabling the audio block immediately generates the bit clock |
mbed_official | 235:685d5f11838f | 65 | and FS signal for the external slaves. |
mbed_official | 235:685d5f11838f | 66 | |
mbed_official | 235:685d5f11838f | 67 | [..] |
mbed_official | 235:685d5f11838f | 68 | (@) It is mandatory to respect the following conditions in order to avoid bad SAI behavior: |
mbed_official | 235:685d5f11838f | 69 | (+@) First bit Offset <= (SLOT size - Data size) |
mbed_official | 235:685d5f11838f | 70 | (+@) Data size <= SLOT size |
mbed_official | 235:685d5f11838f | 71 | (+@) Number of SLOT x SLOT size = Frame length |
mbed_official | 235:685d5f11838f | 72 | (+@) The number of slots should be even when SAI_FS_CHANNEL_IDENTIFICATION is selected. |
mbed_official | 235:685d5f11838f | 73 | |
mbed_official | 235:685d5f11838f | 74 | [..] |
mbed_official | 235:685d5f11838f | 75 | Three operation modes are available within this driver : |
mbed_official | 235:685d5f11838f | 76 | |
mbed_official | 235:685d5f11838f | 77 | *** Polling mode IO operation *** |
mbed_official | 235:685d5f11838f | 78 | ================================= |
mbed_official | 235:685d5f11838f | 79 | [..] |
mbed_official | 235:685d5f11838f | 80 | (+) Send an amount of data in blocking mode using HAL_SAI_Transmit() |
mbed_official | 235:685d5f11838f | 81 | (+) Receive an amount of data in blocking mode using HAL_SAI_Receive() |
mbed_official | 235:685d5f11838f | 82 | |
mbed_official | 235:685d5f11838f | 83 | *** Interrupt mode IO operation *** |
mbed_official | 235:685d5f11838f | 84 | =================================== |
mbed_official | 235:685d5f11838f | 85 | [..] |
mbed_official | 235:685d5f11838f | 86 | (+) Send an amount of data in non blocking mode using HAL_SAI_Transmit_IT() |
mbed_official | 235:685d5f11838f | 87 | (+) At transmission end of transfer HAL_SAI_TxCpltCallback is executed and user can |
mbed_official | 235:685d5f11838f | 88 | add his own code by customization of function pointer HAL_SAI_TxCpltCallback |
mbed_official | 235:685d5f11838f | 89 | (+) Receive an amount of data in non blocking mode using HAL_SAI_Receive_IT() |
mbed_official | 235:685d5f11838f | 90 | (+) At reception end of transfer HAL_SAI_RxCpltCallback is executed and user can |
mbed_official | 235:685d5f11838f | 91 | add his own code by customization of function pointer HAL_SAI_RxCpltCallback |
mbed_official | 235:685d5f11838f | 92 | (+) In case of transfer Error, HAL_SAI_ErrorCallback() function is executed and user can |
mbed_official | 235:685d5f11838f | 93 | add his own code by customization of function pointer HAL_SAI_ErrorCallback |
mbed_official | 235:685d5f11838f | 94 | |
mbed_official | 235:685d5f11838f | 95 | *** DMA mode IO operation *** |
mbed_official | 235:685d5f11838f | 96 | ============================== |
mbed_official | 235:685d5f11838f | 97 | [..] |
mbed_official | 235:685d5f11838f | 98 | (+) Send an amount of data in non blocking mode (DMA) using HAL_SAI_Transmit_DMA() |
mbed_official | 235:685d5f11838f | 99 | (+) At transmission end of transfer HAL_SAI_TxCpltCallback is executed and user can |
mbed_official | 235:685d5f11838f | 100 | add his own code by customization of function pointer HAL_SAI_TxCpltCallback |
mbed_official | 235:685d5f11838f | 101 | (+) Receive an amount of data in non blocking mode (DMA) using HAL_SAI_Receive_DMA() |
mbed_official | 235:685d5f11838f | 102 | (+) At reception end of transfer HAL_SAI_RxCpltCallback is executed and user can |
mbed_official | 235:685d5f11838f | 103 | add his own code by customization of function pointer HAL_SAI_RxCpltCallback |
mbed_official | 235:685d5f11838f | 104 | (+) In case of transfer Error, HAL_SAI_ErrorCallback() function is executed and user can |
mbed_official | 235:685d5f11838f | 105 | add his own code by customization of function pointer HAL_SAI_ErrorCallback |
mbed_official | 235:685d5f11838f | 106 | (+) Pause the DMA Transfer using HAL_SAI_DMAPause() |
mbed_official | 235:685d5f11838f | 107 | (+) Resume the DMA Transfer using HAL_SAI_DMAResume() |
mbed_official | 235:685d5f11838f | 108 | (+) Stop the DMA Transfer using HAL_SAI_DMAStop() |
mbed_official | 235:685d5f11838f | 109 | |
mbed_official | 235:685d5f11838f | 110 | *** SAI HAL driver macros list *** |
mbed_official | 235:685d5f11838f | 111 | ============================================= |
mbed_official | 235:685d5f11838f | 112 | [..] |
mbed_official | 235:685d5f11838f | 113 | Below the list of most used macros in USART HAL driver : |
mbed_official | 235:685d5f11838f | 114 | |
mbed_official | 235:685d5f11838f | 115 | (+) __HAL_SAI_ENABLE: Enable the SAI peripheral |
mbed_official | 235:685d5f11838f | 116 | (+) __HAL_SAI_DISABLE: Disable the SAI peripheral |
mbed_official | 235:685d5f11838f | 117 | (+) __HAL_SAI_ENABLE_IT : Enable the specified SAI interrupts |
mbed_official | 235:685d5f11838f | 118 | (+) __HAL_SAI_DISABLE_IT : Disable the specified SAI interrupts |
mbed_official | 235:685d5f11838f | 119 | (+) __HAL_SAI_GET_IT_SOURCE: Check if the specified SAI interrupt source is |
mbed_official | 235:685d5f11838f | 120 | enabled or disabled |
mbed_official | 235:685d5f11838f | 121 | (+) __HAL_SAI_GET_FLAG: Check whether the specified SAI flag is set or not |
mbed_official | 235:685d5f11838f | 122 | |
mbed_official | 235:685d5f11838f | 123 | @endverbatim |
mbed_official | 235:685d5f11838f | 124 | ****************************************************************************** |
mbed_official | 235:685d5f11838f | 125 | * @attention |
mbed_official | 235:685d5f11838f | 126 | * |
mbed_official | 235:685d5f11838f | 127 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 235:685d5f11838f | 128 | * |
mbed_official | 235:685d5f11838f | 129 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 235:685d5f11838f | 130 | * are permitted provided that the following conditions are met: |
mbed_official | 235:685d5f11838f | 131 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 235:685d5f11838f | 132 | * this list of conditions and the following disclaimer. |
mbed_official | 235:685d5f11838f | 133 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 235:685d5f11838f | 134 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 235:685d5f11838f | 135 | * and/or other materials provided with the distribution. |
mbed_official | 235:685d5f11838f | 136 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 235:685d5f11838f | 137 | * may be used to endorse or promote products derived from this software |
mbed_official | 235:685d5f11838f | 138 | * without specific prior written permission. |
mbed_official | 235:685d5f11838f | 139 | * |
mbed_official | 235:685d5f11838f | 140 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 235:685d5f11838f | 141 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 235:685d5f11838f | 142 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 235:685d5f11838f | 143 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 235:685d5f11838f | 144 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 235:685d5f11838f | 145 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 235:685d5f11838f | 146 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 235:685d5f11838f | 147 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 235:685d5f11838f | 148 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 235:685d5f11838f | 149 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 235:685d5f11838f | 150 | * |
mbed_official | 235:685d5f11838f | 151 | ****************************************************************************** |
mbed_official | 235:685d5f11838f | 152 | */ |
mbed_official | 235:685d5f11838f | 153 | |
mbed_official | 235:685d5f11838f | 154 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 155 | #include "stm32f4xx_hal.h" |
mbed_official | 235:685d5f11838f | 156 | |
mbed_official | 235:685d5f11838f | 157 | /** @addtogroup STM32F4xx_HAL_Driver |
mbed_official | 235:685d5f11838f | 158 | * @{ |
mbed_official | 235:685d5f11838f | 159 | */ |
mbed_official | 235:685d5f11838f | 160 | |
mbed_official | 235:685d5f11838f | 161 | /** @defgroup SAI |
mbed_official | 235:685d5f11838f | 162 | * @brief SAI HAL module driver |
mbed_official | 235:685d5f11838f | 163 | * @{ |
mbed_official | 235:685d5f11838f | 164 | */ |
mbed_official | 235:685d5f11838f | 165 | |
mbed_official | 235:685d5f11838f | 166 | #ifdef HAL_SAI_MODULE_ENABLED |
mbed_official | 235:685d5f11838f | 167 | |
mbed_official | 235:685d5f11838f | 168 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) |
mbed_official | 235:685d5f11838f | 169 | |
mbed_official | 235:685d5f11838f | 170 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 171 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 172 | /* SAI registers Masks */ |
mbed_official | 235:685d5f11838f | 173 | #define CR1_CLEAR_MASK ((uint32_t)0xFF07C010) |
mbed_official | 235:685d5f11838f | 174 | #define FRCR_CLEAR_MASK ((uint32_t)0xFFF88000) |
mbed_official | 235:685d5f11838f | 175 | #define SLOTR_CLEAR_MASK ((uint32_t)0x0000F020) |
mbed_official | 235:685d5f11838f | 176 | |
mbed_official | 235:685d5f11838f | 177 | #define SAI_TIMEOUT_VALUE 10 |
mbed_official | 235:685d5f11838f | 178 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 179 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 180 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 181 | static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 235:685d5f11838f | 182 | static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 235:685d5f11838f | 183 | static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 235:685d5f11838f | 184 | static void SAI_DMARxHalfCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 235:685d5f11838f | 185 | static void SAI_DMAError(DMA_HandleTypeDef *hdma); |
mbed_official | 235:685d5f11838f | 186 | |
mbed_official | 235:685d5f11838f | 187 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 188 | |
mbed_official | 235:685d5f11838f | 189 | /** @defgroup SAI_Private_Functions |
mbed_official | 235:685d5f11838f | 190 | * @{ |
mbed_official | 235:685d5f11838f | 191 | */ |
mbed_official | 235:685d5f11838f | 192 | |
mbed_official | 235:685d5f11838f | 193 | /** @defgroup SAI_Group1 Initialization and de-initialization functions |
mbed_official | 235:685d5f11838f | 194 | * @brief Initialization and Configuration functions |
mbed_official | 235:685d5f11838f | 195 | * |
mbed_official | 235:685d5f11838f | 196 | @verbatim |
mbed_official | 235:685d5f11838f | 197 | =============================================================================== |
mbed_official | 235:685d5f11838f | 198 | ##### Initialization and de-initialization functions ##### |
mbed_official | 235:685d5f11838f | 199 | =============================================================================== |
mbed_official | 235:685d5f11838f | 200 | [..] This subsection provides a set of functions allowing to initialize and |
mbed_official | 235:685d5f11838f | 201 | de-initialize the SAIx peripheral: |
mbed_official | 235:685d5f11838f | 202 | |
mbed_official | 235:685d5f11838f | 203 | (+) User must implement HAL_SAI_MspInit() function in which he configures |
mbed_official | 235:685d5f11838f | 204 | all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). |
mbed_official | 235:685d5f11838f | 205 | |
mbed_official | 235:685d5f11838f | 206 | (+) Call the function HAL_SAI_Init() to configure the selected device with |
mbed_official | 235:685d5f11838f | 207 | the selected configuration: |
mbed_official | 235:685d5f11838f | 208 | (++) Mode (Master/slave TX/RX) |
mbed_official | 235:685d5f11838f | 209 | (++) Protocol |
mbed_official | 235:685d5f11838f | 210 | (++) Data Size |
mbed_official | 235:685d5f11838f | 211 | (++) MCLK Output |
mbed_official | 235:685d5f11838f | 212 | (++) Audio frequency |
mbed_official | 235:685d5f11838f | 213 | (++) FIFO Threshold |
mbed_official | 235:685d5f11838f | 214 | (++) Frame Config |
mbed_official | 235:685d5f11838f | 215 | (++) Slot Config |
mbed_official | 235:685d5f11838f | 216 | |
mbed_official | 235:685d5f11838f | 217 | (+) Call the function HAL_SAI_DeInit() to restore the default configuration |
mbed_official | 235:685d5f11838f | 218 | of the selected SAI peripheral. |
mbed_official | 235:685d5f11838f | 219 | |
mbed_official | 235:685d5f11838f | 220 | @endverbatim |
mbed_official | 235:685d5f11838f | 221 | * @{ |
mbed_official | 235:685d5f11838f | 222 | */ |
mbed_official | 235:685d5f11838f | 223 | |
mbed_official | 235:685d5f11838f | 224 | /** |
mbed_official | 235:685d5f11838f | 225 | * @brief Initializes the SAI according to the specified parameters |
mbed_official | 235:685d5f11838f | 226 | * in the SAI_InitTypeDef and create the associated handle. |
mbed_official | 235:685d5f11838f | 227 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 228 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 229 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 230 | */ |
mbed_official | 235:685d5f11838f | 231 | HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 232 | { |
mbed_official | 235:685d5f11838f | 233 | uint32_t tmpreg = 0; |
mbed_official | 235:685d5f11838f | 234 | uint32_t tmpclock = 0, tmp2clock = 0; |
mbed_official | 235:685d5f11838f | 235 | /* This variable used to store the VCO Input (value in Hz) */ |
mbed_official | 235:685d5f11838f | 236 | uint32_t vcoinput = 0; |
mbed_official | 235:685d5f11838f | 237 | /* This variable used to store the SAI_CK_x (value in Hz) */ |
mbed_official | 235:685d5f11838f | 238 | uint32_t saiclocksource = 0; |
mbed_official | 235:685d5f11838f | 239 | |
mbed_official | 235:685d5f11838f | 240 | /* Check the SAI handle allocation */ |
mbed_official | 235:685d5f11838f | 241 | if(hsai == NULL) |
mbed_official | 235:685d5f11838f | 242 | { |
mbed_official | 235:685d5f11838f | 243 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 244 | } |
mbed_official | 235:685d5f11838f | 245 | |
mbed_official | 235:685d5f11838f | 246 | /* Check the SAI Block parameters */ |
mbed_official | 235:685d5f11838f | 247 | assert_param(IS_SAI_BLOCK_PROTOCOL(hsai->Init.Protocol)); |
mbed_official | 235:685d5f11838f | 248 | assert_param(IS_SAI_BLOCK_MODE(hsai->Init.AudioMode)); |
mbed_official | 235:685d5f11838f | 249 | assert_param(IS_SAI_BLOCK_DATASIZE(hsai->Init.DataSize)); |
mbed_official | 235:685d5f11838f | 250 | assert_param(IS_SAI_BLOCK_FIRST_BIT(hsai->Init.FirstBit)); |
mbed_official | 235:685d5f11838f | 251 | assert_param(IS_SAI_BLOCK_CLOCK_STROBING(hsai->Init.ClockStrobing)); |
mbed_official | 235:685d5f11838f | 252 | assert_param(IS_SAI_BLOCK_SYNCHRO(hsai->Init.Synchro)); |
mbed_official | 235:685d5f11838f | 253 | assert_param(IS_SAI_BLOCK_OUTPUT_DRIVE(hsai->Init.OutputDrive)); |
mbed_official | 235:685d5f11838f | 254 | assert_param(IS_SAI_BLOCK_NODIVIDER(hsai->Init.NoDivider)); |
mbed_official | 235:685d5f11838f | 255 | assert_param(IS_SAI_BLOCK_FIFO_THRESHOLD(hsai->Init.FIFOThreshold)); |
mbed_official | 235:685d5f11838f | 256 | assert_param(IS_SAI_AUDIO_FREQUENCY(hsai->Init.AudioFrequency)); |
mbed_official | 235:685d5f11838f | 257 | |
mbed_official | 235:685d5f11838f | 258 | /* Check the SAI Block Frame parameters */ |
mbed_official | 235:685d5f11838f | 259 | assert_param(IS_SAI_BLOCK_FRAME_LENGTH(hsai->FrameInit.FrameLength)); |
mbed_official | 235:685d5f11838f | 260 | assert_param(IS_SAI_BLOCK_ACTIVE_FRAME(hsai->FrameInit.ActiveFrameLength)); |
mbed_official | 235:685d5f11838f | 261 | assert_param(IS_SAI_BLOCK_FS_DEFINITION(hsai->FrameInit.FSDefinition)); |
mbed_official | 235:685d5f11838f | 262 | assert_param(IS_SAI_BLOCK_FS_POLARITY(hsai->FrameInit.FSPolarity)); |
mbed_official | 235:685d5f11838f | 263 | assert_param(IS_SAI_BLOCK_FS_OFFSET(hsai->FrameInit.FSOffset)); |
mbed_official | 235:685d5f11838f | 264 | |
mbed_official | 235:685d5f11838f | 265 | /* Check the SAI Block Slot parameters */ |
mbed_official | 235:685d5f11838f | 266 | assert_param(IS_SAI_BLOCK_FIRSTBIT_OFFSET(hsai->SlotInit.FirstBitOffset)); |
mbed_official | 235:685d5f11838f | 267 | assert_param(IS_SAI_BLOCK_SLOT_SIZE(hsai->SlotInit.SlotSize)); |
mbed_official | 235:685d5f11838f | 268 | assert_param(IS_SAI_BLOCK_SLOT_NUMBER(hsai->SlotInit.SlotNumber)); |
mbed_official | 235:685d5f11838f | 269 | assert_param(IS_SAI_SLOT_ACTIVE(hsai->SlotInit.SlotActive)); |
mbed_official | 235:685d5f11838f | 270 | |
mbed_official | 235:685d5f11838f | 271 | if(hsai->State == HAL_SAI_STATE_RESET) |
mbed_official | 235:685d5f11838f | 272 | { |
mbed_official | 235:685d5f11838f | 273 | /* Init the low level hardware : GPIO, CLOCK, NVIC and DMA */ |
mbed_official | 235:685d5f11838f | 274 | HAL_SAI_MspInit(hsai); |
mbed_official | 235:685d5f11838f | 275 | } |
mbed_official | 235:685d5f11838f | 276 | |
mbed_official | 235:685d5f11838f | 277 | hsai->State = HAL_SAI_STATE_BUSY; |
mbed_official | 235:685d5f11838f | 278 | |
mbed_official | 235:685d5f11838f | 279 | /* Disable the selected SAI peripheral */ |
mbed_official | 235:685d5f11838f | 280 | __HAL_SAI_DISABLE(hsai); |
mbed_official | 235:685d5f11838f | 281 | |
mbed_official | 235:685d5f11838f | 282 | /* SAI Block Configuration ------------------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 283 | /* SAI Block_x CR1 Configuration */ |
mbed_official | 235:685d5f11838f | 284 | /* Get the SAI Block_x CR1 value */ |
mbed_official | 235:685d5f11838f | 285 | tmpreg = hsai->Instance->CR1; |
mbed_official | 235:685d5f11838f | 286 | /* Clear MODE, PRTCFG, DS, LSBFIRST, CKSTR, SYNCEN, OUTDRIV, NODIV, and MCKDIV bits */ |
mbed_official | 235:685d5f11838f | 287 | tmpreg &= CR1_CLEAR_MASK; |
mbed_official | 235:685d5f11838f | 288 | /* Configure SAI_Block_x: Audio Protocol, Data Size, first transmitted bit, Clock strobing |
mbed_official | 235:685d5f11838f | 289 | edge, Synchronization mode, Output drive, Master Divider and FIFO level */ |
mbed_official | 235:685d5f11838f | 290 | /* Set PRTCFG bits according to Protocol value */ |
mbed_official | 235:685d5f11838f | 291 | /* Set DS bits according to DataSize value */ |
mbed_official | 235:685d5f11838f | 292 | /* Set LSBFIRST bit according to FirstBit value */ |
mbed_official | 235:685d5f11838f | 293 | /* Set CKSTR bit according to ClockStrobing value */ |
mbed_official | 235:685d5f11838f | 294 | /* Set SYNCEN bit according to Synchro value */ |
mbed_official | 235:685d5f11838f | 295 | /* Set OUTDRIV bit according to OutputDrive value */ |
mbed_official | 235:685d5f11838f | 296 | /* Set NODIV bit according to NoDivider value */ |
mbed_official | 235:685d5f11838f | 297 | tmpreg |= (uint32_t)(hsai->Init.Protocol | |
mbed_official | 235:685d5f11838f | 298 | hsai->Init.AudioMode | |
mbed_official | 235:685d5f11838f | 299 | hsai->Init.DataSize | |
mbed_official | 235:685d5f11838f | 300 | hsai->Init.FirstBit | |
mbed_official | 235:685d5f11838f | 301 | hsai->Init.ClockStrobing | |
mbed_official | 235:685d5f11838f | 302 | hsai->Init.Synchro | |
mbed_official | 235:685d5f11838f | 303 | hsai->Init.OutputDrive | |
mbed_official | 235:685d5f11838f | 304 | hsai->Init.NoDivider); |
mbed_official | 235:685d5f11838f | 305 | /* Write to SAI_Block_x CR1 */ |
mbed_official | 235:685d5f11838f | 306 | hsai->Instance->CR1 = tmpreg; |
mbed_official | 235:685d5f11838f | 307 | |
mbed_official | 235:685d5f11838f | 308 | /* SAI Block_x CR2 Configuration */ |
mbed_official | 235:685d5f11838f | 309 | /* Get the SAIBlock_x CR2 value */ |
mbed_official | 235:685d5f11838f | 310 | tmpreg = hsai->Instance->CR2; |
mbed_official | 235:685d5f11838f | 311 | /* Clear FTH bits */ |
mbed_official | 235:685d5f11838f | 312 | tmpreg &= ~(SAI_xCR2_FTH); |
mbed_official | 235:685d5f11838f | 313 | /* Configure the FIFO Level */ |
mbed_official | 235:685d5f11838f | 314 | /* Set FTH bits according to SAI_FIFOThreshold value */ |
mbed_official | 235:685d5f11838f | 315 | tmpreg |= (uint32_t)(hsai->Init.FIFOThreshold); |
mbed_official | 235:685d5f11838f | 316 | /* Write to SAI_Block_x CR2 */ |
mbed_official | 235:685d5f11838f | 317 | hsai->Instance->CR2 = tmpreg; |
mbed_official | 235:685d5f11838f | 318 | |
mbed_official | 235:685d5f11838f | 319 | /* SAI Block_x Frame Configuration -----------------------------------------*/ |
mbed_official | 235:685d5f11838f | 320 | /* Get the SAI Block_x FRCR value */ |
mbed_official | 235:685d5f11838f | 321 | tmpreg = hsai->Instance->FRCR; |
mbed_official | 235:685d5f11838f | 322 | /* Clear FRL, FSALL, FSDEF, FSPOL, FSOFF bits */ |
mbed_official | 235:685d5f11838f | 323 | tmpreg &= FRCR_CLEAR_MASK; |
mbed_official | 235:685d5f11838f | 324 | /* Configure SAI_Block_x Frame: Frame Length, Active Frame Length, Frame Synchronization |
mbed_official | 235:685d5f11838f | 325 | Definition, Frame Synchronization Polarity and Frame Synchronization Polarity */ |
mbed_official | 235:685d5f11838f | 326 | /* Set FRL bits according to SAI_FrameLength value */ |
mbed_official | 235:685d5f11838f | 327 | /* Set FSALL bits according to SAI_ActiveFrameLength value */ |
mbed_official | 235:685d5f11838f | 328 | /* Set FSDEF bit according to SAI_FSDefinition value */ |
mbed_official | 235:685d5f11838f | 329 | /* Set FSPOL bit according to SAI_FSPolarity value */ |
mbed_official | 235:685d5f11838f | 330 | /* Set FSOFF bit according to SAI_FSOffset value */ |
mbed_official | 235:685d5f11838f | 331 | tmpreg |= (uint32_t)((uint32_t)(hsai->FrameInit.FrameLength - 1) | |
mbed_official | 235:685d5f11838f | 332 | hsai->FrameInit.FSOffset | |
mbed_official | 235:685d5f11838f | 333 | hsai->FrameInit.FSDefinition | |
mbed_official | 235:685d5f11838f | 334 | hsai->FrameInit.FSPolarity | |
mbed_official | 235:685d5f11838f | 335 | (uint32_t)((hsai->FrameInit.ActiveFrameLength - 1) << 8)); |
mbed_official | 235:685d5f11838f | 336 | |
mbed_official | 235:685d5f11838f | 337 | /* Write to SAI_Block_x FRCR */ |
mbed_official | 235:685d5f11838f | 338 | hsai->Instance->FRCR = tmpreg; |
mbed_official | 235:685d5f11838f | 339 | |
mbed_official | 235:685d5f11838f | 340 | /* SAI Block_x SLOT Configuration ------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 341 | /* Get the SAI Block_x SLOTR value */ |
mbed_official | 235:685d5f11838f | 342 | tmpreg = hsai->Instance->SLOTR; |
mbed_official | 235:685d5f11838f | 343 | /* Clear FBOFF, SLOTSZ, NBSLOT, SLOTEN bits */ |
mbed_official | 235:685d5f11838f | 344 | tmpreg &= SLOTR_CLEAR_MASK; |
mbed_official | 235:685d5f11838f | 345 | /* Configure SAI_Block_x Slot: First bit offset, Slot size, Number of Slot in |
mbed_official | 235:685d5f11838f | 346 | audio frame and slots activated in audio frame */ |
mbed_official | 235:685d5f11838f | 347 | /* Set FBOFF bits according to SAI_FirstBitOffset value */ |
mbed_official | 235:685d5f11838f | 348 | /* Set SLOTSZ bits according to SAI_SlotSize value */ |
mbed_official | 235:685d5f11838f | 349 | /* Set NBSLOT bits according to SAI_SlotNumber value */ |
mbed_official | 235:685d5f11838f | 350 | /* Set SLOTEN bits according to SAI_SlotActive value */ |
mbed_official | 235:685d5f11838f | 351 | tmpreg |= (uint32_t)(hsai->SlotInit.FirstBitOffset | |
mbed_official | 235:685d5f11838f | 352 | hsai->SlotInit.SlotSize | |
mbed_official | 235:685d5f11838f | 353 | hsai->SlotInit.SlotActive | |
mbed_official | 235:685d5f11838f | 354 | (uint32_t)((hsai->SlotInit.SlotNumber - 1) << 8)); |
mbed_official | 235:685d5f11838f | 355 | |
mbed_official | 235:685d5f11838f | 356 | /* Write to SAI_Block_x SLOTR */ |
mbed_official | 235:685d5f11838f | 357 | hsai->Instance->SLOTR = tmpreg; |
mbed_official | 235:685d5f11838f | 358 | |
mbed_official | 235:685d5f11838f | 359 | /* SAI Block_x Clock Configuration -----------------------------------------*/ |
mbed_official | 235:685d5f11838f | 360 | /* Check the Clock parameters */ |
mbed_official | 235:685d5f11838f | 361 | assert_param(IS_SAI_CLK_SOURCE(hsai->Init.ClockSource)); |
mbed_official | 235:685d5f11838f | 362 | |
mbed_official | 235:685d5f11838f | 363 | /* SAI Block clock source selection */ |
mbed_official | 235:685d5f11838f | 364 | if(hsai->Instance == SAI1_Block_A) |
mbed_official | 235:685d5f11838f | 365 | { |
mbed_official | 235:685d5f11838f | 366 | __HAL_RCC_SAI_BLOCKACLKSOURCE_CONFIG(hsai->Init.ClockSource); |
mbed_official | 235:685d5f11838f | 367 | } |
mbed_official | 235:685d5f11838f | 368 | else |
mbed_official | 235:685d5f11838f | 369 | { |
mbed_official | 235:685d5f11838f | 370 | __HAL_RCC_SAI_BLOCKBCLKSOURCE_CONFIG((uint32_t)(hsai->Init.ClockSource << 2)); |
mbed_official | 235:685d5f11838f | 371 | } |
mbed_official | 235:685d5f11838f | 372 | |
mbed_official | 235:685d5f11838f | 373 | /* VCO Input Clock value calculation */ |
mbed_official | 235:685d5f11838f | 374 | if((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLSOURCE_HSI) |
mbed_official | 235:685d5f11838f | 375 | { |
mbed_official | 235:685d5f11838f | 376 | /* In Case the PLL Source is HSI (Internal Clock) */ |
mbed_official | 235:685d5f11838f | 377 | vcoinput = (HSI_VALUE / (uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLM)); |
mbed_official | 235:685d5f11838f | 378 | } |
mbed_official | 235:685d5f11838f | 379 | else |
mbed_official | 235:685d5f11838f | 380 | { |
mbed_official | 235:685d5f11838f | 381 | /* In Case the PLL Source is HSE (External Clock) */ |
mbed_official | 235:685d5f11838f | 382 | vcoinput = ((HSE_VALUE / (uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLM))); |
mbed_official | 235:685d5f11838f | 383 | } |
mbed_official | 235:685d5f11838f | 384 | |
mbed_official | 235:685d5f11838f | 385 | /* SAI_CLK_x : SAI Block Clock configuration for different clock sources selected */ |
mbed_official | 235:685d5f11838f | 386 | if(hsai->Init.ClockSource == SAI_CLKSOURCE_PLLSAI) |
mbed_official | 235:685d5f11838f | 387 | { |
mbed_official | 235:685d5f11838f | 388 | /* Configure the PLLI2S division factor */ |
mbed_official | 235:685d5f11838f | 389 | /* PLLSAI_VCO Input = PLL_SOURCE/PLLM */ |
mbed_official | 235:685d5f11838f | 390 | /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN */ |
mbed_official | 235:685d5f11838f | 391 | /* SAI_CLK(first level) = PLLSAI_VCO Output/PLLSAIQ */ |
mbed_official | 235:685d5f11838f | 392 | tmpreg = (RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIQ) >> 24; |
mbed_official | 235:685d5f11838f | 393 | saiclocksource = (vcoinput * ((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIN) >> 6))/(tmpreg); |
mbed_official | 235:685d5f11838f | 394 | |
mbed_official | 235:685d5f11838f | 395 | /* SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ */ |
mbed_official | 235:685d5f11838f | 396 | tmpreg = (((RCC->DCKCFGR & RCC_DCKCFGR_PLLSAIDIVQ) >> 8) + 1); |
mbed_official | 235:685d5f11838f | 397 | saiclocksource = saiclocksource/(tmpreg); |
mbed_official | 235:685d5f11838f | 398 | |
mbed_official | 235:685d5f11838f | 399 | } |
mbed_official | 235:685d5f11838f | 400 | else if(hsai->Init.ClockSource == SAI_CLKSOURCE_PLLI2S) |
mbed_official | 235:685d5f11838f | 401 | { |
mbed_official | 235:685d5f11838f | 402 | /* Configure the PLLI2S division factor */ |
mbed_official | 235:685d5f11838f | 403 | /* PLLI2S_VCO Input = PLL_SOURCE/PLLM */ |
mbed_official | 235:685d5f11838f | 404 | /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN */ |
mbed_official | 235:685d5f11838f | 405 | /* SAI_CLK(first level) = PLLI2S_VCO Output/PLLI2SQ */ |
mbed_official | 235:685d5f11838f | 406 | tmpreg = (RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SQ) >> 24; |
mbed_official | 235:685d5f11838f | 407 | saiclocksource = (vcoinput * ((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SN) >> 6))/(tmpreg); |
mbed_official | 235:685d5f11838f | 408 | |
mbed_official | 235:685d5f11838f | 409 | /* SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ */ |
mbed_official | 235:685d5f11838f | 410 | tmpreg = ((RCC->DCKCFGR & RCC_DCKCFGR_PLLI2SDIVQ) + 1); |
mbed_official | 235:685d5f11838f | 411 | saiclocksource = saiclocksource/(tmpreg); |
mbed_official | 235:685d5f11838f | 412 | } |
mbed_official | 235:685d5f11838f | 413 | else /* sConfig->ClockSource == SAI_CLKSource_Ext */ |
mbed_official | 235:685d5f11838f | 414 | { |
mbed_official | 235:685d5f11838f | 415 | /* Enable the External Clock selection */ |
mbed_official | 235:685d5f11838f | 416 | __HAL_RCC_I2SCLK(RCC_I2SCLKSOURCE_EXT); |
mbed_official | 235:685d5f11838f | 417 | |
mbed_official | 235:685d5f11838f | 418 | saiclocksource = EXTERNAL_CLOCK_VALUE; |
mbed_official | 235:685d5f11838f | 419 | } |
mbed_official | 235:685d5f11838f | 420 | |
mbed_official | 235:685d5f11838f | 421 | /* Configure Master Clock using the following formula : |
mbed_official | 235:685d5f11838f | 422 | MCLK_x = SAI_CK_x / (MCKDIV[3:0] * 2) with MCLK_x = 256 * FS |
mbed_official | 235:685d5f11838f | 423 | FS = SAI_CK_x / (MCKDIV[3:0] * 2) * 256 |
mbed_official | 235:685d5f11838f | 424 | MCKDIV[3:0] = SAI_CK_x / FS * 512 */ |
mbed_official | 235:685d5f11838f | 425 | if(hsai->Init.NoDivider == SAI_MASTERDIVIDER_ENABLED) |
mbed_official | 235:685d5f11838f | 426 | { |
mbed_official | 235:685d5f11838f | 427 | /* (saiclocksource x 10) to keep Significant digits */ |
mbed_official | 235:685d5f11838f | 428 | tmpclock = (((saiclocksource * 10) / ((hsai->Init.AudioFrequency) * 512))); |
mbed_official | 235:685d5f11838f | 429 | |
mbed_official | 235:685d5f11838f | 430 | /* Get the result of modulo division */ |
mbed_official | 235:685d5f11838f | 431 | tmp2clock = (tmpclock % 10); |
mbed_official | 235:685d5f11838f | 432 | |
mbed_official | 235:685d5f11838f | 433 | /* Round result to the nearest integer*/ |
mbed_official | 235:685d5f11838f | 434 | if (tmp2clock > 8) |
mbed_official | 235:685d5f11838f | 435 | { |
mbed_official | 235:685d5f11838f | 436 | tmpclock = ((tmpclock / 10) + 1); |
mbed_official | 235:685d5f11838f | 437 | } |
mbed_official | 235:685d5f11838f | 438 | else |
mbed_official | 235:685d5f11838f | 439 | { |
mbed_official | 235:685d5f11838f | 440 | tmpclock = (tmpclock / 10); |
mbed_official | 235:685d5f11838f | 441 | } |
mbed_official | 235:685d5f11838f | 442 | /*Set MCKDIV value in CR1 register*/ |
mbed_official | 235:685d5f11838f | 443 | hsai->Instance->CR1 |= (tmpclock << 20); |
mbed_official | 235:685d5f11838f | 444 | |
mbed_official | 235:685d5f11838f | 445 | } |
mbed_official | 235:685d5f11838f | 446 | |
mbed_official | 235:685d5f11838f | 447 | /* Initialise the error code */ |
mbed_official | 235:685d5f11838f | 448 | hsai->ErrorCode = HAL_SAI_ERROR_NONE; |
mbed_official | 235:685d5f11838f | 449 | |
mbed_official | 235:685d5f11838f | 450 | /* Initialize the SAI state */ |
mbed_official | 235:685d5f11838f | 451 | hsai->State= HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 452 | |
mbed_official | 235:685d5f11838f | 453 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 454 | } |
mbed_official | 235:685d5f11838f | 455 | |
mbed_official | 235:685d5f11838f | 456 | /** |
mbed_official | 235:685d5f11838f | 457 | * @brief DeInitializes the SAI peripheral. |
mbed_official | 235:685d5f11838f | 458 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 459 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 460 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 461 | */ |
mbed_official | 235:685d5f11838f | 462 | HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 463 | { |
mbed_official | 235:685d5f11838f | 464 | /* Check the SAI handle allocation */ |
mbed_official | 235:685d5f11838f | 465 | if(hsai == NULL) |
mbed_official | 235:685d5f11838f | 466 | { |
mbed_official | 235:685d5f11838f | 467 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 468 | } |
mbed_official | 235:685d5f11838f | 469 | |
mbed_official | 235:685d5f11838f | 470 | hsai->State = HAL_SAI_STATE_BUSY; |
mbed_official | 235:685d5f11838f | 471 | |
mbed_official | 235:685d5f11838f | 472 | /* DeInit the low level hardware: GPIO, CLOCK, NVIC and DMA */ |
mbed_official | 235:685d5f11838f | 473 | HAL_SAI_MspDeInit(hsai); |
mbed_official | 235:685d5f11838f | 474 | |
mbed_official | 235:685d5f11838f | 475 | /* Initialize the error code */ |
mbed_official | 235:685d5f11838f | 476 | hsai->ErrorCode = HAL_SAI_ERROR_NONE; |
mbed_official | 235:685d5f11838f | 477 | |
mbed_official | 235:685d5f11838f | 478 | /* Initialize the SAI state */ |
mbed_official | 235:685d5f11838f | 479 | hsai->State = HAL_SAI_STATE_RESET; |
mbed_official | 235:685d5f11838f | 480 | |
mbed_official | 235:685d5f11838f | 481 | /* Release Lock */ |
mbed_official | 235:685d5f11838f | 482 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 483 | |
mbed_official | 235:685d5f11838f | 484 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 485 | } |
mbed_official | 235:685d5f11838f | 486 | |
mbed_official | 235:685d5f11838f | 487 | /** |
mbed_official | 235:685d5f11838f | 488 | * @brief SAI MSP Init. |
mbed_official | 235:685d5f11838f | 489 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 490 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 491 | * @retval None |
mbed_official | 235:685d5f11838f | 492 | */ |
mbed_official | 235:685d5f11838f | 493 | __weak void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 494 | { |
mbed_official | 235:685d5f11838f | 495 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 496 | the HAL_SAI_MspInit could be implemented in the user file |
mbed_official | 235:685d5f11838f | 497 | */ |
mbed_official | 235:685d5f11838f | 498 | } |
mbed_official | 235:685d5f11838f | 499 | |
mbed_official | 235:685d5f11838f | 500 | /** |
mbed_official | 235:685d5f11838f | 501 | * @brief SAI MSP DeInit. |
mbed_official | 235:685d5f11838f | 502 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 503 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 504 | * @retval None |
mbed_official | 235:685d5f11838f | 505 | */ |
mbed_official | 235:685d5f11838f | 506 | __weak void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 507 | { |
mbed_official | 235:685d5f11838f | 508 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 509 | the HAL_SAI_MspDeInit could be implemented in the user file |
mbed_official | 235:685d5f11838f | 510 | */ |
mbed_official | 235:685d5f11838f | 511 | } |
mbed_official | 235:685d5f11838f | 512 | |
mbed_official | 235:685d5f11838f | 513 | /** |
mbed_official | 235:685d5f11838f | 514 | * @} |
mbed_official | 235:685d5f11838f | 515 | */ |
mbed_official | 235:685d5f11838f | 516 | |
mbed_official | 235:685d5f11838f | 517 | /** @defgroup SAI_Group2 IO operation functions |
mbed_official | 235:685d5f11838f | 518 | * @brief Data transfers functions |
mbed_official | 235:685d5f11838f | 519 | * |
mbed_official | 235:685d5f11838f | 520 | @verbatim |
mbed_official | 235:685d5f11838f | 521 | =============================================================================== |
mbed_official | 235:685d5f11838f | 522 | ##### IO operation functions ##### |
mbed_official | 235:685d5f11838f | 523 | =============================================================================== |
mbed_official | 235:685d5f11838f | 524 | [..] |
mbed_official | 235:685d5f11838f | 525 | This subsection provides a set of functions allowing to manage the SAI data |
mbed_official | 235:685d5f11838f | 526 | transfers. |
mbed_official | 235:685d5f11838f | 527 | |
mbed_official | 235:685d5f11838f | 528 | (+) There are two modes of transfer: |
mbed_official | 235:685d5f11838f | 529 | (++) Blocking mode : The communication is performed in the polling mode. |
mbed_official | 235:685d5f11838f | 530 | The status of all data processing is returned by the same function |
mbed_official | 235:685d5f11838f | 531 | after finishing transfer. |
mbed_official | 235:685d5f11838f | 532 | (++) No-Blocking mode : The communication is performed using Interrupts |
mbed_official | 235:685d5f11838f | 533 | or DMA. These functions return the status of the transfer startup. |
mbed_official | 235:685d5f11838f | 534 | The end of the data processing will be indicated through the |
mbed_official | 235:685d5f11838f | 535 | dedicated SAI IRQ when using Interrupt mode or the DMA IRQ when |
mbed_official | 235:685d5f11838f | 536 | using DMA mode. |
mbed_official | 235:685d5f11838f | 537 | |
mbed_official | 235:685d5f11838f | 538 | (+) Blocking mode functions are : |
mbed_official | 235:685d5f11838f | 539 | (++) HAL_SAI_Transmit() |
mbed_official | 235:685d5f11838f | 540 | (++) HAL_SAI_Receive() |
mbed_official | 235:685d5f11838f | 541 | (++) HAL_SAI_TransmitReceive() |
mbed_official | 235:685d5f11838f | 542 | |
mbed_official | 235:685d5f11838f | 543 | (+) Non Blocking mode functions with Interrupt are : |
mbed_official | 235:685d5f11838f | 544 | (++) HAL_SAI_Transmit_IT() |
mbed_official | 235:685d5f11838f | 545 | (++) HAL_SAI_Receive_IT() |
mbed_official | 235:685d5f11838f | 546 | (++) HAL_SAI_TransmitReceive_IT() |
mbed_official | 235:685d5f11838f | 547 | |
mbed_official | 235:685d5f11838f | 548 | (+) Non Blocking mode functions with DMA are : |
mbed_official | 235:685d5f11838f | 549 | (++) HAL_SAI_Transmit_DMA() |
mbed_official | 235:685d5f11838f | 550 | (++) HAL_SAI_Receive_DMA() |
mbed_official | 235:685d5f11838f | 551 | (++) HAL_SAI_TransmitReceive_DMA() |
mbed_official | 235:685d5f11838f | 552 | |
mbed_official | 235:685d5f11838f | 553 | (+) A set of Transfer Complete Callbacks are provided in non Blocking mode: |
mbed_official | 235:685d5f11838f | 554 | (++) HAL_SAI_TxCpltCallback() |
mbed_official | 235:685d5f11838f | 555 | (++) HAL_SAI_RxCpltCallback() |
mbed_official | 235:685d5f11838f | 556 | (++) HAL_SAI_ErrorCallback() |
mbed_official | 235:685d5f11838f | 557 | |
mbed_official | 235:685d5f11838f | 558 | @endverbatim |
mbed_official | 235:685d5f11838f | 559 | * @{ |
mbed_official | 235:685d5f11838f | 560 | */ |
mbed_official | 235:685d5f11838f | 561 | |
mbed_official | 235:685d5f11838f | 562 | /** |
mbed_official | 235:685d5f11838f | 563 | * @brief Transmits an amount of data in blocking mode. |
mbed_official | 235:685d5f11838f | 564 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 565 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 566 | * @param pData: Pointer to data buffer |
mbed_official | 235:685d5f11838f | 567 | * @param Size: Amount of data to be sent |
mbed_official | 235:685d5f11838f | 568 | * @param Timeout: Timeout duration |
mbed_official | 235:685d5f11838f | 569 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 570 | */ |
mbed_official | 235:685d5f11838f | 571 | HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint16_t* pData, uint16_t Size, uint32_t Timeout) |
mbed_official | 235:685d5f11838f | 572 | { |
mbed_official | 235:685d5f11838f | 573 | uint32_t tickstart = 0; |
mbed_official | 235:685d5f11838f | 574 | |
mbed_official | 235:685d5f11838f | 575 | if((pData == NULL ) || (Size == 0)) |
mbed_official | 235:685d5f11838f | 576 | { |
mbed_official | 235:685d5f11838f | 577 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 578 | } |
mbed_official | 235:685d5f11838f | 579 | |
mbed_official | 235:685d5f11838f | 580 | if(hsai->State == HAL_SAI_STATE_READY) |
mbed_official | 235:685d5f11838f | 581 | { |
mbed_official | 235:685d5f11838f | 582 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 583 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 584 | |
mbed_official | 235:685d5f11838f | 585 | hsai->State = HAL_SAI_STATE_BUSY_TX; |
mbed_official | 235:685d5f11838f | 586 | |
mbed_official | 235:685d5f11838f | 587 | /* Check if the SAI is already enabled */ |
mbed_official | 235:685d5f11838f | 588 | if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != SAI_xCR1_SAIEN) |
mbed_official | 235:685d5f11838f | 589 | { |
mbed_official | 235:685d5f11838f | 590 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 591 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 592 | } |
mbed_official | 235:685d5f11838f | 593 | |
mbed_official | 235:685d5f11838f | 594 | while(Size > 0) |
mbed_official | 235:685d5f11838f | 595 | { |
mbed_official | 235:685d5f11838f | 596 | /* Get tick */ |
mbed_official | 235:685d5f11838f | 597 | tickstart = HAL_GetTick(); |
mbed_official | 235:685d5f11838f | 598 | |
mbed_official | 235:685d5f11838f | 599 | /* Wait the FIFO to be empty */ |
mbed_official | 235:685d5f11838f | 600 | while(__HAL_SAI_GET_FLAG(hsai, SAI_xSR_FREQ) == RESET) |
mbed_official | 235:685d5f11838f | 601 | { |
mbed_official | 235:685d5f11838f | 602 | /* Check for the Timeout */ |
mbed_official | 235:685d5f11838f | 603 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 235:685d5f11838f | 604 | { |
mbed_official | 235:685d5f11838f | 605 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 235:685d5f11838f | 606 | { |
mbed_official | 235:685d5f11838f | 607 | /* Update error code */ |
mbed_official | 235:685d5f11838f | 608 | hsai->ErrorCode |= HAL_SAI_ERROR_TIMEOUT; |
mbed_official | 235:685d5f11838f | 609 | |
mbed_official | 235:685d5f11838f | 610 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 611 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 612 | |
mbed_official | 235:685d5f11838f | 613 | /* Change the SAI state */ |
mbed_official | 235:685d5f11838f | 614 | hsai->State = HAL_SAI_STATE_TIMEOUT; |
mbed_official | 235:685d5f11838f | 615 | |
mbed_official | 235:685d5f11838f | 616 | return HAL_TIMEOUT; |
mbed_official | 235:685d5f11838f | 617 | } |
mbed_official | 235:685d5f11838f | 618 | } |
mbed_official | 235:685d5f11838f | 619 | } |
mbed_official | 235:685d5f11838f | 620 | hsai->Instance->DR = (*pData++); |
mbed_official | 235:685d5f11838f | 621 | Size--; |
mbed_official | 235:685d5f11838f | 622 | } |
mbed_official | 235:685d5f11838f | 623 | |
mbed_official | 235:685d5f11838f | 624 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 625 | |
mbed_official | 235:685d5f11838f | 626 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 627 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 628 | |
mbed_official | 235:685d5f11838f | 629 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 630 | } |
mbed_official | 235:685d5f11838f | 631 | else |
mbed_official | 235:685d5f11838f | 632 | { |
mbed_official | 235:685d5f11838f | 633 | return HAL_BUSY; |
mbed_official | 235:685d5f11838f | 634 | } |
mbed_official | 235:685d5f11838f | 635 | } |
mbed_official | 235:685d5f11838f | 636 | |
mbed_official | 235:685d5f11838f | 637 | /** |
mbed_official | 235:685d5f11838f | 638 | * @brief Receives an amount of data in blocking mode. |
mbed_official | 235:685d5f11838f | 639 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 640 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 641 | * @param pData: Pointer to data buffer |
mbed_official | 235:685d5f11838f | 642 | * @param Size: Amount of data to be received |
mbed_official | 235:685d5f11838f | 643 | * @param Timeout: Timeout duration |
mbed_official | 235:685d5f11838f | 644 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 645 | */ |
mbed_official | 235:685d5f11838f | 646 | HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size, uint32_t Timeout) |
mbed_official | 235:685d5f11838f | 647 | { |
mbed_official | 235:685d5f11838f | 648 | uint32_t tickstart = 0; |
mbed_official | 235:685d5f11838f | 649 | |
mbed_official | 235:685d5f11838f | 650 | if((pData == NULL ) || (Size == 0)) |
mbed_official | 235:685d5f11838f | 651 | { |
mbed_official | 235:685d5f11838f | 652 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 653 | } |
mbed_official | 235:685d5f11838f | 654 | |
mbed_official | 235:685d5f11838f | 655 | if(hsai->State == HAL_SAI_STATE_READY) |
mbed_official | 235:685d5f11838f | 656 | { |
mbed_official | 235:685d5f11838f | 657 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 658 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 659 | |
mbed_official | 235:685d5f11838f | 660 | hsai->State = HAL_SAI_STATE_BUSY_RX; |
mbed_official | 235:685d5f11838f | 661 | |
mbed_official | 235:685d5f11838f | 662 | /* Check if the SAI is already enabled */ |
mbed_official | 235:685d5f11838f | 663 | if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != SAI_xCR1_SAIEN) |
mbed_official | 235:685d5f11838f | 664 | { |
mbed_official | 235:685d5f11838f | 665 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 666 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 667 | } |
mbed_official | 235:685d5f11838f | 668 | |
mbed_official | 235:685d5f11838f | 669 | /* Receive data */ |
mbed_official | 235:685d5f11838f | 670 | while(Size > 0) |
mbed_official | 235:685d5f11838f | 671 | { |
mbed_official | 235:685d5f11838f | 672 | /* Get tick */ |
mbed_official | 235:685d5f11838f | 673 | tickstart = HAL_GetTick(); |
mbed_official | 235:685d5f11838f | 674 | |
mbed_official | 235:685d5f11838f | 675 | /* Wait until RXNE flag is set */ |
mbed_official | 235:685d5f11838f | 676 | while(__HAL_SAI_GET_FLAG(hsai, SAI_xSR_FREQ) == RESET) |
mbed_official | 235:685d5f11838f | 677 | { |
mbed_official | 235:685d5f11838f | 678 | /* Check for the Timeout */ |
mbed_official | 235:685d5f11838f | 679 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 235:685d5f11838f | 680 | { |
mbed_official | 235:685d5f11838f | 681 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 235:685d5f11838f | 682 | { |
mbed_official | 235:685d5f11838f | 683 | /* Update error code */ |
mbed_official | 235:685d5f11838f | 684 | hsai->ErrorCode |= HAL_SAI_ERROR_TIMEOUT; |
mbed_official | 235:685d5f11838f | 685 | |
mbed_official | 235:685d5f11838f | 686 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 687 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 688 | |
mbed_official | 235:685d5f11838f | 689 | /* Change the SAI state */ |
mbed_official | 235:685d5f11838f | 690 | hsai->State = HAL_SAI_STATE_TIMEOUT; |
mbed_official | 235:685d5f11838f | 691 | |
mbed_official | 235:685d5f11838f | 692 | return HAL_TIMEOUT; |
mbed_official | 235:685d5f11838f | 693 | } |
mbed_official | 235:685d5f11838f | 694 | } |
mbed_official | 235:685d5f11838f | 695 | } |
mbed_official | 235:685d5f11838f | 696 | |
mbed_official | 235:685d5f11838f | 697 | (*pData++) = hsai->Instance->DR; |
mbed_official | 235:685d5f11838f | 698 | Size--; |
mbed_official | 235:685d5f11838f | 699 | } |
mbed_official | 235:685d5f11838f | 700 | |
mbed_official | 235:685d5f11838f | 701 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 702 | |
mbed_official | 235:685d5f11838f | 703 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 704 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 705 | |
mbed_official | 235:685d5f11838f | 706 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 707 | } |
mbed_official | 235:685d5f11838f | 708 | else |
mbed_official | 235:685d5f11838f | 709 | { |
mbed_official | 235:685d5f11838f | 710 | return HAL_BUSY; |
mbed_official | 235:685d5f11838f | 711 | } |
mbed_official | 235:685d5f11838f | 712 | } |
mbed_official | 235:685d5f11838f | 713 | |
mbed_official | 235:685d5f11838f | 714 | /** |
mbed_official | 235:685d5f11838f | 715 | * @brief Transmits an amount of data in no-blocking mode with Interrupt. |
mbed_official | 235:685d5f11838f | 716 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 717 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 718 | * @param pData: Pointer to data buffer |
mbed_official | 235:685d5f11838f | 719 | * @param Size: Amount of data to be sent |
mbed_official | 235:685d5f11838f | 720 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 721 | */ |
mbed_official | 235:685d5f11838f | 722 | HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size) |
mbed_official | 235:685d5f11838f | 723 | { |
mbed_official | 235:685d5f11838f | 724 | if(hsai->State == HAL_SAI_STATE_READY) |
mbed_official | 235:685d5f11838f | 725 | { |
mbed_official | 235:685d5f11838f | 726 | if((pData == NULL) || (Size == 0)) |
mbed_official | 235:685d5f11838f | 727 | { |
mbed_official | 235:685d5f11838f | 728 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 729 | } |
mbed_official | 235:685d5f11838f | 730 | |
mbed_official | 235:685d5f11838f | 731 | hsai->pTxBuffPtr = pData; |
mbed_official | 235:685d5f11838f | 732 | hsai->TxXferSize = Size; |
mbed_official | 235:685d5f11838f | 733 | hsai->TxXferCount = Size; |
mbed_official | 235:685d5f11838f | 734 | |
mbed_official | 235:685d5f11838f | 735 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 736 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 737 | |
mbed_official | 235:685d5f11838f | 738 | hsai->State = HAL_SAI_STATE_BUSY_TX; |
mbed_official | 235:685d5f11838f | 739 | |
mbed_official | 235:685d5f11838f | 740 | /* Transmit data */ |
mbed_official | 235:685d5f11838f | 741 | hsai->Instance->DR = (*hsai->pTxBuffPtr++); |
mbed_official | 235:685d5f11838f | 742 | hsai->TxXferCount--; |
mbed_official | 235:685d5f11838f | 743 | |
mbed_official | 235:685d5f11838f | 744 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 745 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 746 | |
mbed_official | 235:685d5f11838f | 747 | /* Enable FRQ and OVRUDR interrupts */ |
mbed_official | 235:685d5f11838f | 748 | __HAL_SAI_ENABLE_IT(hsai, (SAI_IT_FREQ | SAI_IT_OVRUDR)); |
mbed_official | 235:685d5f11838f | 749 | |
mbed_official | 235:685d5f11838f | 750 | /* Check if the SAI is already enabled */ |
mbed_official | 235:685d5f11838f | 751 | if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != SAI_xCR1_SAIEN) |
mbed_official | 235:685d5f11838f | 752 | { |
mbed_official | 235:685d5f11838f | 753 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 754 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 755 | } |
mbed_official | 235:685d5f11838f | 756 | |
mbed_official | 235:685d5f11838f | 757 | |
mbed_official | 235:685d5f11838f | 758 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 759 | } |
mbed_official | 235:685d5f11838f | 760 | else if(hsai->State == HAL_SAI_STATE_BUSY_TX) |
mbed_official | 235:685d5f11838f | 761 | { |
mbed_official | 235:685d5f11838f | 762 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 763 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 764 | |
mbed_official | 235:685d5f11838f | 765 | /* Transmit data */ |
mbed_official | 235:685d5f11838f | 766 | hsai->Instance->DR = (*hsai->pTxBuffPtr++); |
mbed_official | 235:685d5f11838f | 767 | |
mbed_official | 235:685d5f11838f | 768 | hsai->TxXferCount--; |
mbed_official | 235:685d5f11838f | 769 | |
mbed_official | 235:685d5f11838f | 770 | if(hsai->TxXferCount == 0) |
mbed_official | 235:685d5f11838f | 771 | { |
mbed_official | 235:685d5f11838f | 772 | /* Disable FREQ and OVRUDR interrupts */ |
mbed_official | 235:685d5f11838f | 773 | __HAL_SAI_DISABLE_IT(hsai, (SAI_IT_FREQ | SAI_IT_OVRUDR)); |
mbed_official | 235:685d5f11838f | 774 | |
mbed_official | 235:685d5f11838f | 775 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 776 | |
mbed_official | 235:685d5f11838f | 777 | HAL_SAI_TxCpltCallback(hsai); |
mbed_official | 235:685d5f11838f | 778 | } |
mbed_official | 235:685d5f11838f | 779 | |
mbed_official | 235:685d5f11838f | 780 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 781 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 782 | |
mbed_official | 235:685d5f11838f | 783 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 784 | } |
mbed_official | 235:685d5f11838f | 785 | |
mbed_official | 235:685d5f11838f | 786 | else |
mbed_official | 235:685d5f11838f | 787 | { |
mbed_official | 235:685d5f11838f | 788 | return HAL_BUSY; |
mbed_official | 235:685d5f11838f | 789 | } |
mbed_official | 235:685d5f11838f | 790 | } |
mbed_official | 235:685d5f11838f | 791 | |
mbed_official | 235:685d5f11838f | 792 | /** |
mbed_official | 235:685d5f11838f | 793 | * @brief Receives an amount of data in no-blocking mode with Interrupt. |
mbed_official | 235:685d5f11838f | 794 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 795 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 796 | * @param pData: Pointer to data buffer |
mbed_official | 235:685d5f11838f | 797 | * @param Size: Amount of data to be received |
mbed_official | 235:685d5f11838f | 798 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 799 | */ |
mbed_official | 235:685d5f11838f | 800 | HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size) |
mbed_official | 235:685d5f11838f | 801 | { |
mbed_official | 235:685d5f11838f | 802 | if(hsai->State == HAL_SAI_STATE_READY) |
mbed_official | 235:685d5f11838f | 803 | { |
mbed_official | 235:685d5f11838f | 804 | if((pData == NULL) || (Size == 0)) |
mbed_official | 235:685d5f11838f | 805 | { |
mbed_official | 235:685d5f11838f | 806 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 807 | } |
mbed_official | 235:685d5f11838f | 808 | |
mbed_official | 235:685d5f11838f | 809 | hsai->pRxBuffPtr = pData; |
mbed_official | 235:685d5f11838f | 810 | hsai->RxXferSize = Size; |
mbed_official | 235:685d5f11838f | 811 | hsai->RxXferCount = Size; |
mbed_official | 235:685d5f11838f | 812 | |
mbed_official | 235:685d5f11838f | 813 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 814 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 815 | |
mbed_official | 235:685d5f11838f | 816 | hsai->State = HAL_SAI_STATE_BUSY_RX; |
mbed_official | 235:685d5f11838f | 817 | |
mbed_official | 235:685d5f11838f | 818 | /* Enable TXE and OVRUDR interrupts */ |
mbed_official | 235:685d5f11838f | 819 | __HAL_SAI_ENABLE_IT(hsai, (SAI_IT_FREQ | SAI_IT_OVRUDR)); |
mbed_official | 235:685d5f11838f | 820 | |
mbed_official | 235:685d5f11838f | 821 | /* Check if the SAI is already enabled */ |
mbed_official | 235:685d5f11838f | 822 | if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != SAI_xCR1_SAIEN) |
mbed_official | 235:685d5f11838f | 823 | { |
mbed_official | 235:685d5f11838f | 824 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 825 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 826 | } |
mbed_official | 235:685d5f11838f | 827 | |
mbed_official | 235:685d5f11838f | 828 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 829 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 830 | |
mbed_official | 235:685d5f11838f | 831 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 832 | } |
mbed_official | 235:685d5f11838f | 833 | else if(hsai->State == HAL_SAI_STATE_BUSY_RX) |
mbed_official | 235:685d5f11838f | 834 | { |
mbed_official | 235:685d5f11838f | 835 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 836 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 837 | |
mbed_official | 235:685d5f11838f | 838 | /* Receive data */ |
mbed_official | 235:685d5f11838f | 839 | (*hsai->pRxBuffPtr++) = hsai->Instance->DR; |
mbed_official | 235:685d5f11838f | 840 | |
mbed_official | 235:685d5f11838f | 841 | hsai->RxXferCount--; |
mbed_official | 235:685d5f11838f | 842 | |
mbed_official | 235:685d5f11838f | 843 | if(hsai->RxXferCount == 0) |
mbed_official | 235:685d5f11838f | 844 | { |
mbed_official | 235:685d5f11838f | 845 | /* Disable TXE and OVRUDR interrupts */ |
mbed_official | 235:685d5f11838f | 846 | __HAL_SAI_DISABLE_IT(hsai, (SAI_IT_FREQ | SAI_IT_OVRUDR)); |
mbed_official | 235:685d5f11838f | 847 | |
mbed_official | 235:685d5f11838f | 848 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 849 | HAL_SAI_RxCpltCallback(hsai); |
mbed_official | 235:685d5f11838f | 850 | } |
mbed_official | 235:685d5f11838f | 851 | |
mbed_official | 235:685d5f11838f | 852 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 853 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 854 | |
mbed_official | 235:685d5f11838f | 855 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 856 | } |
mbed_official | 235:685d5f11838f | 857 | |
mbed_official | 235:685d5f11838f | 858 | else |
mbed_official | 235:685d5f11838f | 859 | { |
mbed_official | 235:685d5f11838f | 860 | return HAL_BUSY; |
mbed_official | 235:685d5f11838f | 861 | } |
mbed_official | 235:685d5f11838f | 862 | } |
mbed_official | 235:685d5f11838f | 863 | |
mbed_official | 235:685d5f11838f | 864 | /** |
mbed_official | 235:685d5f11838f | 865 | * @brief Pauses the audio stream playing from the Media. |
mbed_official | 235:685d5f11838f | 866 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 867 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 868 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 869 | */ |
mbed_official | 235:685d5f11838f | 870 | HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 871 | { |
mbed_official | 235:685d5f11838f | 872 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 873 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 874 | |
mbed_official | 235:685d5f11838f | 875 | /* Pause the audio file playing by disabling the SAI DMA requests */ |
mbed_official | 235:685d5f11838f | 876 | hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN; |
mbed_official | 235:685d5f11838f | 877 | |
mbed_official | 235:685d5f11838f | 878 | |
mbed_official | 235:685d5f11838f | 879 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 880 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 881 | |
mbed_official | 235:685d5f11838f | 882 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 883 | } |
mbed_official | 235:685d5f11838f | 884 | |
mbed_official | 235:685d5f11838f | 885 | /** |
mbed_official | 235:685d5f11838f | 886 | * @brief Resumes the audio stream playing from the Media. |
mbed_official | 235:685d5f11838f | 887 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 888 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 889 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 890 | */ |
mbed_official | 235:685d5f11838f | 891 | HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 892 | { |
mbed_official | 235:685d5f11838f | 893 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 894 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 895 | |
mbed_official | 235:685d5f11838f | 896 | /* Enable the SAI DMA requests */ |
mbed_official | 235:685d5f11838f | 897 | hsai->Instance->CR1 |= SAI_xCR1_DMAEN; |
mbed_official | 235:685d5f11838f | 898 | |
mbed_official | 235:685d5f11838f | 899 | |
mbed_official | 235:685d5f11838f | 900 | /* If the SAI peripheral is still not enabled, enable it */ |
mbed_official | 235:685d5f11838f | 901 | if ((hsai->Instance->CR1 & SAI_xCR1_SAIEN) == 0) |
mbed_official | 235:685d5f11838f | 902 | { |
mbed_official | 235:685d5f11838f | 903 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 904 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 905 | } |
mbed_official | 235:685d5f11838f | 906 | |
mbed_official | 235:685d5f11838f | 907 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 908 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 909 | |
mbed_official | 235:685d5f11838f | 910 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 911 | } |
mbed_official | 235:685d5f11838f | 912 | |
mbed_official | 235:685d5f11838f | 913 | /** |
mbed_official | 235:685d5f11838f | 914 | * @brief Stops the audio stream playing from the Media. |
mbed_official | 235:685d5f11838f | 915 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 916 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 917 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 918 | */ |
mbed_official | 235:685d5f11838f | 919 | HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 920 | { |
mbed_official | 235:685d5f11838f | 921 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 922 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 923 | |
mbed_official | 235:685d5f11838f | 924 | /* Disable the SAI DMA request */ |
mbed_official | 235:685d5f11838f | 925 | hsai->Instance->CR1 &= ~SAI_xCR1_DMAEN; |
mbed_official | 235:685d5f11838f | 926 | |
mbed_official | 235:685d5f11838f | 927 | /* Abort the SAI DMA Tx Stream */ |
mbed_official | 235:685d5f11838f | 928 | if(hsai->hdmatx != NULL) |
mbed_official | 235:685d5f11838f | 929 | { |
mbed_official | 235:685d5f11838f | 930 | HAL_DMA_Abort(hsai->hdmatx); |
mbed_official | 235:685d5f11838f | 931 | } |
mbed_official | 235:685d5f11838f | 932 | /* Abort the SAI DMA Rx Stream */ |
mbed_official | 235:685d5f11838f | 933 | if(hsai->hdmarx != NULL) |
mbed_official | 235:685d5f11838f | 934 | { |
mbed_official | 235:685d5f11838f | 935 | HAL_DMA_Abort(hsai->hdmarx); |
mbed_official | 235:685d5f11838f | 936 | } |
mbed_official | 235:685d5f11838f | 937 | |
mbed_official | 235:685d5f11838f | 938 | /* Disable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 939 | __HAL_SAI_DISABLE(hsai); |
mbed_official | 235:685d5f11838f | 940 | |
mbed_official | 235:685d5f11838f | 941 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 942 | |
mbed_official | 235:685d5f11838f | 943 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 944 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 945 | |
mbed_official | 235:685d5f11838f | 946 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 947 | } |
mbed_official | 235:685d5f11838f | 948 | /** |
mbed_official | 235:685d5f11838f | 949 | * @brief Transmits an amount of data in no-blocking mode with DMA. |
mbed_official | 235:685d5f11838f | 950 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 951 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 952 | * @param pData: Pointer to data buffer |
mbed_official | 235:685d5f11838f | 953 | * @param Size: Amount of data to be sent |
mbed_official | 235:685d5f11838f | 954 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 955 | */ |
mbed_official | 235:685d5f11838f | 956 | HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size) |
mbed_official | 235:685d5f11838f | 957 | { |
mbed_official | 235:685d5f11838f | 958 | uint32_t *tmp; |
mbed_official | 235:685d5f11838f | 959 | |
mbed_official | 235:685d5f11838f | 960 | if((pData == NULL) || (Size == 0)) |
mbed_official | 235:685d5f11838f | 961 | { |
mbed_official | 235:685d5f11838f | 962 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 963 | } |
mbed_official | 235:685d5f11838f | 964 | |
mbed_official | 235:685d5f11838f | 965 | if(hsai->State == HAL_SAI_STATE_READY) |
mbed_official | 235:685d5f11838f | 966 | { |
mbed_official | 235:685d5f11838f | 967 | hsai->pTxBuffPtr = pData; |
mbed_official | 235:685d5f11838f | 968 | hsai->TxXferSize = Size; |
mbed_official | 235:685d5f11838f | 969 | hsai->TxXferCount = Size; |
mbed_official | 235:685d5f11838f | 970 | |
mbed_official | 235:685d5f11838f | 971 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 972 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 973 | |
mbed_official | 235:685d5f11838f | 974 | hsai->State = HAL_SAI_STATE_BUSY_TX; |
mbed_official | 235:685d5f11838f | 975 | |
mbed_official | 235:685d5f11838f | 976 | /* Set the SAI Tx DMA Half transfert complete callback */ |
mbed_official | 235:685d5f11838f | 977 | hsai->hdmatx->XferHalfCpltCallback = SAI_DMATxHalfCplt; |
mbed_official | 235:685d5f11838f | 978 | |
mbed_official | 235:685d5f11838f | 979 | /* Set the SAI TxDMA transfer complete callback */ |
mbed_official | 235:685d5f11838f | 980 | hsai->hdmatx->XferCpltCallback = SAI_DMATxCplt; |
mbed_official | 235:685d5f11838f | 981 | |
mbed_official | 235:685d5f11838f | 982 | /* Set the DMA error callback */ |
mbed_official | 235:685d5f11838f | 983 | hsai->hdmatx->XferErrorCallback = SAI_DMAError; |
mbed_official | 235:685d5f11838f | 984 | |
mbed_official | 235:685d5f11838f | 985 | /* Enable the Tx DMA Stream */ |
mbed_official | 235:685d5f11838f | 986 | tmp = (uint32_t*)&pData; |
mbed_official | 235:685d5f11838f | 987 | HAL_DMA_Start_IT(hsai->hdmatx, *(uint32_t*)tmp, (uint32_t)&hsai->Instance->DR, hsai->TxXferSize); |
mbed_official | 235:685d5f11838f | 988 | |
mbed_official | 235:685d5f11838f | 989 | /* Check if the SAI is already enabled */ |
mbed_official | 235:685d5f11838f | 990 | if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != SAI_xCR1_SAIEN) |
mbed_official | 235:685d5f11838f | 991 | { |
mbed_official | 235:685d5f11838f | 992 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 993 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 994 | } |
mbed_official | 235:685d5f11838f | 995 | |
mbed_official | 235:685d5f11838f | 996 | /* Enable SAI Tx DMA Request */ |
mbed_official | 235:685d5f11838f | 997 | hsai->Instance->CR1 |= SAI_xCR1_DMAEN; |
mbed_official | 235:685d5f11838f | 998 | |
mbed_official | 235:685d5f11838f | 999 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 1000 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 1001 | |
mbed_official | 235:685d5f11838f | 1002 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 1003 | } |
mbed_official | 235:685d5f11838f | 1004 | else |
mbed_official | 235:685d5f11838f | 1005 | { |
mbed_official | 235:685d5f11838f | 1006 | return HAL_BUSY; |
mbed_official | 235:685d5f11838f | 1007 | } |
mbed_official | 235:685d5f11838f | 1008 | } |
mbed_official | 235:685d5f11838f | 1009 | |
mbed_official | 235:685d5f11838f | 1010 | /** |
mbed_official | 235:685d5f11838f | 1011 | * @brief Receives an amount of data in no-blocking mode with DMA. |
mbed_official | 235:685d5f11838f | 1012 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1013 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1014 | * @param pData: Pointer to data buffer |
mbed_official | 235:685d5f11838f | 1015 | * @param Size: Amount of data to be received |
mbed_official | 235:685d5f11838f | 1016 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 1017 | */ |
mbed_official | 235:685d5f11838f | 1018 | HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint16_t *pData, uint16_t Size) |
mbed_official | 235:685d5f11838f | 1019 | { |
mbed_official | 235:685d5f11838f | 1020 | uint32_t *tmp; |
mbed_official | 235:685d5f11838f | 1021 | |
mbed_official | 235:685d5f11838f | 1022 | if((pData == NULL) || (Size == 0)) |
mbed_official | 235:685d5f11838f | 1023 | { |
mbed_official | 235:685d5f11838f | 1024 | return HAL_ERROR; |
mbed_official | 235:685d5f11838f | 1025 | } |
mbed_official | 235:685d5f11838f | 1026 | |
mbed_official | 235:685d5f11838f | 1027 | if(hsai->State == HAL_SAI_STATE_READY) |
mbed_official | 235:685d5f11838f | 1028 | { |
mbed_official | 235:685d5f11838f | 1029 | hsai->pRxBuffPtr = pData; |
mbed_official | 235:685d5f11838f | 1030 | hsai->RxXferSize = Size; |
mbed_official | 235:685d5f11838f | 1031 | hsai->RxXferCount = Size; |
mbed_official | 235:685d5f11838f | 1032 | |
mbed_official | 235:685d5f11838f | 1033 | /* Process Locked */ |
mbed_official | 235:685d5f11838f | 1034 | __HAL_LOCK(hsai); |
mbed_official | 235:685d5f11838f | 1035 | |
mbed_official | 235:685d5f11838f | 1036 | hsai->State = HAL_SAI_STATE_BUSY_RX; |
mbed_official | 235:685d5f11838f | 1037 | |
mbed_official | 235:685d5f11838f | 1038 | /* Set the SAI Rx DMA Half transfert complete callback */ |
mbed_official | 235:685d5f11838f | 1039 | hsai->hdmarx->XferHalfCpltCallback = SAI_DMARxHalfCplt; |
mbed_official | 235:685d5f11838f | 1040 | |
mbed_official | 235:685d5f11838f | 1041 | /* Set the SAI Rx DMA transfert complete callback */ |
mbed_official | 235:685d5f11838f | 1042 | hsai->hdmarx->XferCpltCallback = SAI_DMARxCplt; |
mbed_official | 235:685d5f11838f | 1043 | |
mbed_official | 235:685d5f11838f | 1044 | /* Set the DMA error callback */ |
mbed_official | 235:685d5f11838f | 1045 | hsai->hdmarx->XferErrorCallback = SAI_DMAError; |
mbed_official | 235:685d5f11838f | 1046 | |
mbed_official | 235:685d5f11838f | 1047 | /* Enable the Rx DMA Stream */ |
mbed_official | 235:685d5f11838f | 1048 | tmp = (uint32_t*)&pData; |
mbed_official | 235:685d5f11838f | 1049 | HAL_DMA_Start_IT(hsai->hdmarx, (uint32_t)&hsai->Instance->DR, *(uint32_t*)tmp, hsai->RxXferSize); |
mbed_official | 235:685d5f11838f | 1050 | |
mbed_official | 235:685d5f11838f | 1051 | /* Check if the SAI is already enabled */ |
mbed_official | 235:685d5f11838f | 1052 | if((hsai->Instance->CR1 & SAI_xCR1_SAIEN) != SAI_xCR1_SAIEN) |
mbed_official | 235:685d5f11838f | 1053 | { |
mbed_official | 235:685d5f11838f | 1054 | /* Enable SAI peripheral */ |
mbed_official | 235:685d5f11838f | 1055 | __HAL_SAI_ENABLE(hsai); |
mbed_official | 235:685d5f11838f | 1056 | } |
mbed_official | 235:685d5f11838f | 1057 | |
mbed_official | 235:685d5f11838f | 1058 | /* Enable SAI Rx DMA Request */ |
mbed_official | 235:685d5f11838f | 1059 | hsai->Instance->CR1 |= SAI_xCR1_DMAEN; |
mbed_official | 235:685d5f11838f | 1060 | |
mbed_official | 235:685d5f11838f | 1061 | /* Process Unlocked */ |
mbed_official | 235:685d5f11838f | 1062 | __HAL_UNLOCK(hsai); |
mbed_official | 235:685d5f11838f | 1063 | |
mbed_official | 235:685d5f11838f | 1064 | return HAL_OK; |
mbed_official | 235:685d5f11838f | 1065 | } |
mbed_official | 235:685d5f11838f | 1066 | else |
mbed_official | 235:685d5f11838f | 1067 | { |
mbed_official | 235:685d5f11838f | 1068 | return HAL_BUSY; |
mbed_official | 235:685d5f11838f | 1069 | } |
mbed_official | 235:685d5f11838f | 1070 | } |
mbed_official | 235:685d5f11838f | 1071 | |
mbed_official | 235:685d5f11838f | 1072 | /** |
mbed_official | 235:685d5f11838f | 1073 | * @brief This function handles SAI interrupt request. |
mbed_official | 235:685d5f11838f | 1074 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1075 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1076 | * @retval HAL status |
mbed_official | 235:685d5f11838f | 1077 | */ |
mbed_official | 235:685d5f11838f | 1078 | void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1079 | { |
mbed_official | 235:685d5f11838f | 1080 | uint32_t tmp1 = 0, tmp2 = 0; |
mbed_official | 235:685d5f11838f | 1081 | |
mbed_official | 235:685d5f11838f | 1082 | if(hsai->State == HAL_SAI_STATE_BUSY_RX) |
mbed_official | 235:685d5f11838f | 1083 | { |
mbed_official | 235:685d5f11838f | 1084 | tmp1 = __HAL_SAI_GET_FLAG(hsai, SAI_xSR_FREQ); |
mbed_official | 235:685d5f11838f | 1085 | tmp2 = __HAL_SAI_GET_IT_SOURCE(hsai, SAI_IT_FREQ); |
mbed_official | 235:685d5f11838f | 1086 | /* SAI in mode Receiver --------------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 1087 | if((tmp1 != RESET) && (tmp2 != RESET)) |
mbed_official | 235:685d5f11838f | 1088 | { |
mbed_official | 235:685d5f11838f | 1089 | HAL_SAI_Receive_IT(hsai, NULL, 0); |
mbed_official | 235:685d5f11838f | 1090 | } |
mbed_official | 235:685d5f11838f | 1091 | |
mbed_official | 235:685d5f11838f | 1092 | tmp1 = __HAL_SAI_GET_FLAG(hsai, SAI_FLAG_OVRUDR); |
mbed_official | 235:685d5f11838f | 1093 | tmp2 = __HAL_SAI_GET_IT_SOURCE(hsai, SAI_IT_OVRUDR); |
mbed_official | 235:685d5f11838f | 1094 | /* SAI Overrun error interrupt occurred ----------------------------------*/ |
mbed_official | 235:685d5f11838f | 1095 | if((tmp1 != RESET) && (tmp2 != RESET)) |
mbed_official | 235:685d5f11838f | 1096 | { |
mbed_official | 235:685d5f11838f | 1097 | /* Change the SAI error code */ |
mbed_official | 235:685d5f11838f | 1098 | hsai->ErrorCode = HAL_SAI_ERROR_OVR; |
mbed_official | 235:685d5f11838f | 1099 | |
mbed_official | 235:685d5f11838f | 1100 | /* Clear the SAI Overrun flag */ |
mbed_official | 235:685d5f11838f | 1101 | __HAL_SAI_CLEAR_FLAG(hsai, SAI_FLAG_OVRUDR); |
mbed_official | 235:685d5f11838f | 1102 | /* Set the SAI state ready to be able to start again the process */ |
mbed_official | 235:685d5f11838f | 1103 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 1104 | HAL_SAI_ErrorCallback(hsai); |
mbed_official | 235:685d5f11838f | 1105 | } |
mbed_official | 235:685d5f11838f | 1106 | } |
mbed_official | 235:685d5f11838f | 1107 | |
mbed_official | 235:685d5f11838f | 1108 | if(hsai->State == HAL_SAI_STATE_BUSY_TX) |
mbed_official | 235:685d5f11838f | 1109 | { |
mbed_official | 235:685d5f11838f | 1110 | tmp1 = __HAL_SAI_GET_FLAG(hsai, SAI_xSR_FREQ); |
mbed_official | 235:685d5f11838f | 1111 | tmp2 = __HAL_SAI_GET_IT_SOURCE(hsai, SAI_IT_FREQ); |
mbed_official | 235:685d5f11838f | 1112 | /* SAI in mode Transmitter -----------------------------------------------*/ |
mbed_official | 235:685d5f11838f | 1113 | if((tmp1 != RESET) && (tmp2 != RESET)) |
mbed_official | 235:685d5f11838f | 1114 | { |
mbed_official | 235:685d5f11838f | 1115 | HAL_SAI_Transmit_IT(hsai, NULL, 0); |
mbed_official | 235:685d5f11838f | 1116 | } |
mbed_official | 235:685d5f11838f | 1117 | |
mbed_official | 235:685d5f11838f | 1118 | tmp1 = __HAL_SAI_GET_FLAG(hsai, SAI_FLAG_OVRUDR); |
mbed_official | 235:685d5f11838f | 1119 | tmp2 = __HAL_SAI_GET_IT_SOURCE(hsai, SAI_IT_OVRUDR); |
mbed_official | 235:685d5f11838f | 1120 | /* SAI Underrun error interrupt occurred ---------------------------------*/ |
mbed_official | 235:685d5f11838f | 1121 | if((tmp1 != RESET) && (tmp2 != RESET)) |
mbed_official | 235:685d5f11838f | 1122 | { |
mbed_official | 235:685d5f11838f | 1123 | /* Change the SAI error code */ |
mbed_official | 235:685d5f11838f | 1124 | hsai->ErrorCode = HAL_SAI_ERROR_UDR; |
mbed_official | 235:685d5f11838f | 1125 | |
mbed_official | 235:685d5f11838f | 1126 | /* Clear the SAI Underrun flag */ |
mbed_official | 235:685d5f11838f | 1127 | __HAL_SAI_CLEAR_FLAG(hsai, SAI_FLAG_OVRUDR); |
mbed_official | 235:685d5f11838f | 1128 | /* Set the SAI state ready to be able to start again the process */ |
mbed_official | 235:685d5f11838f | 1129 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 1130 | HAL_SAI_ErrorCallback(hsai); |
mbed_official | 235:685d5f11838f | 1131 | } |
mbed_official | 235:685d5f11838f | 1132 | } |
mbed_official | 235:685d5f11838f | 1133 | } |
mbed_official | 235:685d5f11838f | 1134 | |
mbed_official | 235:685d5f11838f | 1135 | /** |
mbed_official | 235:685d5f11838f | 1136 | * @brief Tx Transfer completed callbacks. |
mbed_official | 235:685d5f11838f | 1137 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1138 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1139 | * @retval None |
mbed_official | 235:685d5f11838f | 1140 | */ |
mbed_official | 235:685d5f11838f | 1141 | __weak void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1142 | { |
mbed_official | 235:685d5f11838f | 1143 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 1144 | the HAL_SAI_TxCpltCallback could be implemented in the user file |
mbed_official | 235:685d5f11838f | 1145 | */ |
mbed_official | 235:685d5f11838f | 1146 | } |
mbed_official | 235:685d5f11838f | 1147 | |
mbed_official | 235:685d5f11838f | 1148 | /** |
mbed_official | 235:685d5f11838f | 1149 | * @brief Tx Transfer Half completed callbacks |
mbed_official | 235:685d5f11838f | 1150 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1151 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1152 | * @retval None |
mbed_official | 235:685d5f11838f | 1153 | */ |
mbed_official | 235:685d5f11838f | 1154 | __weak void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1155 | { |
mbed_official | 235:685d5f11838f | 1156 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 1157 | the HAL_SAI_TxHalfCpltCallback could be implenetd in the user file |
mbed_official | 235:685d5f11838f | 1158 | */ |
mbed_official | 235:685d5f11838f | 1159 | } |
mbed_official | 235:685d5f11838f | 1160 | |
mbed_official | 235:685d5f11838f | 1161 | /** |
mbed_official | 235:685d5f11838f | 1162 | * @brief Rx Transfer completed callbacks. |
mbed_official | 235:685d5f11838f | 1163 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1164 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1165 | * @retval None |
mbed_official | 235:685d5f11838f | 1166 | */ |
mbed_official | 235:685d5f11838f | 1167 | __weak void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1168 | { |
mbed_official | 235:685d5f11838f | 1169 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 1170 | the HAL_SAI_RxCpltCallback could be implemented in the user file |
mbed_official | 235:685d5f11838f | 1171 | */ |
mbed_official | 235:685d5f11838f | 1172 | } |
mbed_official | 235:685d5f11838f | 1173 | |
mbed_official | 235:685d5f11838f | 1174 | /** |
mbed_official | 235:685d5f11838f | 1175 | * @brief Rx Transfer half completed callbacks |
mbed_official | 235:685d5f11838f | 1176 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1177 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1178 | * @retval None |
mbed_official | 235:685d5f11838f | 1179 | */ |
mbed_official | 235:685d5f11838f | 1180 | __weak void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1181 | { |
mbed_official | 235:685d5f11838f | 1182 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 1183 | the HAL_SAI_RxCpltCallback could be implenetd in the user file |
mbed_official | 235:685d5f11838f | 1184 | */ |
mbed_official | 235:685d5f11838f | 1185 | } |
mbed_official | 235:685d5f11838f | 1186 | |
mbed_official | 235:685d5f11838f | 1187 | /** |
mbed_official | 235:685d5f11838f | 1188 | * @brief SAI error callbacks. |
mbed_official | 235:685d5f11838f | 1189 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1190 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1191 | * @retval None |
mbed_official | 235:685d5f11838f | 1192 | */ |
mbed_official | 235:685d5f11838f | 1193 | __weak void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1194 | { |
mbed_official | 235:685d5f11838f | 1195 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 235:685d5f11838f | 1196 | the HAL_SAI_ErrorCallback could be implemented in the user file |
mbed_official | 235:685d5f11838f | 1197 | */ |
mbed_official | 235:685d5f11838f | 1198 | } |
mbed_official | 235:685d5f11838f | 1199 | |
mbed_official | 235:685d5f11838f | 1200 | /** |
mbed_official | 235:685d5f11838f | 1201 | * @} |
mbed_official | 235:685d5f11838f | 1202 | */ |
mbed_official | 235:685d5f11838f | 1203 | |
mbed_official | 235:685d5f11838f | 1204 | |
mbed_official | 235:685d5f11838f | 1205 | /** @defgroup SAI_Group3 Peripheral State functions |
mbed_official | 235:685d5f11838f | 1206 | * @brief Peripheral State functions |
mbed_official | 235:685d5f11838f | 1207 | * |
mbed_official | 235:685d5f11838f | 1208 | @verbatim |
mbed_official | 235:685d5f11838f | 1209 | =============================================================================== |
mbed_official | 235:685d5f11838f | 1210 | ##### Peripheral State and Errors functions ##### |
mbed_official | 235:685d5f11838f | 1211 | =============================================================================== |
mbed_official | 235:685d5f11838f | 1212 | [..] |
mbed_official | 235:685d5f11838f | 1213 | This subsection permits to get in run-time the status of the peripheral |
mbed_official | 235:685d5f11838f | 1214 | and the data flow. |
mbed_official | 235:685d5f11838f | 1215 | |
mbed_official | 235:685d5f11838f | 1216 | @endverbatim |
mbed_official | 235:685d5f11838f | 1217 | * @{ |
mbed_official | 235:685d5f11838f | 1218 | */ |
mbed_official | 235:685d5f11838f | 1219 | |
mbed_official | 235:685d5f11838f | 1220 | /** |
mbed_official | 235:685d5f11838f | 1221 | * @brief Returns the SAI state. |
mbed_official | 235:685d5f11838f | 1222 | * @param hsai: pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1223 | * the configuration information for SAI module. |
mbed_official | 235:685d5f11838f | 1224 | * @retval HAL state |
mbed_official | 235:685d5f11838f | 1225 | */ |
mbed_official | 235:685d5f11838f | 1226 | HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1227 | { |
mbed_official | 235:685d5f11838f | 1228 | return hsai->State; |
mbed_official | 235:685d5f11838f | 1229 | } |
mbed_official | 235:685d5f11838f | 1230 | |
mbed_official | 235:685d5f11838f | 1231 | /** |
mbed_official | 235:685d5f11838f | 1232 | * @brief Return the SAI error code |
mbed_official | 235:685d5f11838f | 1233 | * @param hsai : pointer to a SAI_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1234 | * the configuration information for the specified SAI Block. |
mbed_official | 235:685d5f11838f | 1235 | * @retval SAI Error Code |
mbed_official | 235:685d5f11838f | 1236 | */ |
mbed_official | 235:685d5f11838f | 1237 | uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai) |
mbed_official | 235:685d5f11838f | 1238 | { |
mbed_official | 235:685d5f11838f | 1239 | return hsai->ErrorCode; |
mbed_official | 235:685d5f11838f | 1240 | } |
mbed_official | 235:685d5f11838f | 1241 | /** |
mbed_official | 235:685d5f11838f | 1242 | * @} |
mbed_official | 235:685d5f11838f | 1243 | */ |
mbed_official | 235:685d5f11838f | 1244 | |
mbed_official | 235:685d5f11838f | 1245 | /** |
mbed_official | 235:685d5f11838f | 1246 | * @brief DMA SAI transmit process complete callback. |
mbed_official | 235:685d5f11838f | 1247 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1248 | * the configuration information for the specified DMA module. |
mbed_official | 235:685d5f11838f | 1249 | * @retval None |
mbed_official | 235:685d5f11838f | 1250 | */ |
mbed_official | 235:685d5f11838f | 1251 | static void SAI_DMATxCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 235:685d5f11838f | 1252 | { |
mbed_official | 235:685d5f11838f | 1253 | uint32_t tickstart = 0; |
mbed_official | 235:685d5f11838f | 1254 | |
mbed_official | 235:685d5f11838f | 1255 | SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 235:685d5f11838f | 1256 | |
mbed_official | 235:685d5f11838f | 1257 | if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) |
mbed_official | 235:685d5f11838f | 1258 | { |
mbed_official | 235:685d5f11838f | 1259 | hsai->TxXferCount = 0; |
mbed_official | 235:685d5f11838f | 1260 | hsai->RxXferCount = 0; |
mbed_official | 235:685d5f11838f | 1261 | |
mbed_official | 235:685d5f11838f | 1262 | /* Disable SAI Tx DMA Request */ |
mbed_official | 235:685d5f11838f | 1263 | hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN); |
mbed_official | 235:685d5f11838f | 1264 | |
mbed_official | 235:685d5f11838f | 1265 | /* Get tick */ |
mbed_official | 235:685d5f11838f | 1266 | tickstart = HAL_GetTick(); |
mbed_official | 235:685d5f11838f | 1267 | |
mbed_official | 235:685d5f11838f | 1268 | /* Set timeout: 10 is the max delay to send the remaining data in the SAI FIFO */ |
mbed_official | 235:685d5f11838f | 1269 | /* Wait until FIFO is empty */ |
mbed_official | 235:685d5f11838f | 1270 | while(__HAL_SAI_GET_FLAG(hsai, SAI_xSR_FLVL) != RESET) |
mbed_official | 235:685d5f11838f | 1271 | { |
mbed_official | 235:685d5f11838f | 1272 | /* Check for the Timeout */ |
mbed_official | 235:685d5f11838f | 1273 | if((HAL_GetTick() - tickstart ) > SAI_TIMEOUT_VALUE) |
mbed_official | 235:685d5f11838f | 1274 | { |
mbed_official | 235:685d5f11838f | 1275 | /* Update error code */ |
mbed_official | 235:685d5f11838f | 1276 | hsai->ErrorCode |= HAL_SAI_ERROR_TIMEOUT; |
mbed_official | 235:685d5f11838f | 1277 | |
mbed_official | 235:685d5f11838f | 1278 | /* Change the SAI state */ |
mbed_official | 235:685d5f11838f | 1279 | HAL_SAI_ErrorCallback(hsai); |
mbed_official | 235:685d5f11838f | 1280 | } |
mbed_official | 235:685d5f11838f | 1281 | } |
mbed_official | 235:685d5f11838f | 1282 | |
mbed_official | 235:685d5f11838f | 1283 | hsai->State= HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 1284 | } |
mbed_official | 235:685d5f11838f | 1285 | HAL_SAI_TxCpltCallback(hsai); |
mbed_official | 235:685d5f11838f | 1286 | } |
mbed_official | 235:685d5f11838f | 1287 | |
mbed_official | 235:685d5f11838f | 1288 | /** |
mbed_official | 235:685d5f11838f | 1289 | * @brief DMA SAI transmit process half complete callback |
mbed_official | 235:685d5f11838f | 1290 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1291 | * the configuration information for the specified DMA module. |
mbed_official | 235:685d5f11838f | 1292 | * @retval None |
mbed_official | 235:685d5f11838f | 1293 | */ |
mbed_official | 235:685d5f11838f | 1294 | static void SAI_DMATxHalfCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 235:685d5f11838f | 1295 | { |
mbed_official | 235:685d5f11838f | 1296 | SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
mbed_official | 235:685d5f11838f | 1297 | |
mbed_official | 235:685d5f11838f | 1298 | HAL_SAI_TxHalfCpltCallback(hsai); |
mbed_official | 235:685d5f11838f | 1299 | } |
mbed_official | 235:685d5f11838f | 1300 | |
mbed_official | 235:685d5f11838f | 1301 | /** |
mbed_official | 235:685d5f11838f | 1302 | * @brief DMA SAI receive process complete callback. |
mbed_official | 235:685d5f11838f | 1303 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1304 | * the configuration information for the specified DMA module. |
mbed_official | 235:685d5f11838f | 1305 | * @retval None |
mbed_official | 235:685d5f11838f | 1306 | */ |
mbed_official | 235:685d5f11838f | 1307 | static void SAI_DMARxCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 235:685d5f11838f | 1308 | { |
mbed_official | 235:685d5f11838f | 1309 | SAI_HandleTypeDef* hsai = ( SAI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 235:685d5f11838f | 1310 | if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) |
mbed_official | 235:685d5f11838f | 1311 | { |
mbed_official | 235:685d5f11838f | 1312 | /* Disable Rx DMA Request */ |
mbed_official | 235:685d5f11838f | 1313 | hsai->Instance->CR1 &= (uint32_t)(~SAI_xCR1_DMAEN); |
mbed_official | 235:685d5f11838f | 1314 | hsai->RxXferCount = 0; |
mbed_official | 235:685d5f11838f | 1315 | |
mbed_official | 235:685d5f11838f | 1316 | hsai->State = HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 1317 | } |
mbed_official | 235:685d5f11838f | 1318 | HAL_SAI_RxCpltCallback(hsai); |
mbed_official | 235:685d5f11838f | 1319 | } |
mbed_official | 235:685d5f11838f | 1320 | |
mbed_official | 235:685d5f11838f | 1321 | /** |
mbed_official | 235:685d5f11838f | 1322 | * @brief DMA SAI receive process half complete callback |
mbed_official | 235:685d5f11838f | 1323 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1324 | * the configuration information for the specified DMA module. |
mbed_official | 235:685d5f11838f | 1325 | * @retval None |
mbed_official | 235:685d5f11838f | 1326 | */ |
mbed_official | 235:685d5f11838f | 1327 | static void SAI_DMARxHalfCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 235:685d5f11838f | 1328 | { |
mbed_official | 235:685d5f11838f | 1329 | SAI_HandleTypeDef* hsai = (SAI_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
mbed_official | 235:685d5f11838f | 1330 | |
mbed_official | 235:685d5f11838f | 1331 | HAL_SAI_RxHalfCpltCallback(hsai); |
mbed_official | 235:685d5f11838f | 1332 | } |
mbed_official | 235:685d5f11838f | 1333 | /** |
mbed_official | 235:685d5f11838f | 1334 | * @brief DMA SAI communication error callback. |
mbed_official | 235:685d5f11838f | 1335 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 235:685d5f11838f | 1336 | * the configuration information for the specified DMA module. |
mbed_official | 235:685d5f11838f | 1337 | * @retval None |
mbed_official | 235:685d5f11838f | 1338 | */ |
mbed_official | 235:685d5f11838f | 1339 | static void SAI_DMAError(DMA_HandleTypeDef *hdma) |
mbed_official | 235:685d5f11838f | 1340 | { |
mbed_official | 235:685d5f11838f | 1341 | SAI_HandleTypeDef* hsai = ( SAI_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 235:685d5f11838f | 1342 | /* Set the SAI state ready to be able to start again the process */ |
mbed_official | 235:685d5f11838f | 1343 | hsai->State= HAL_SAI_STATE_READY; |
mbed_official | 235:685d5f11838f | 1344 | HAL_SAI_ErrorCallback(hsai); |
mbed_official | 235:685d5f11838f | 1345 | |
mbed_official | 235:685d5f11838f | 1346 | hsai->TxXferCount = 0; |
mbed_official | 235:685d5f11838f | 1347 | hsai->RxXferCount = 0; |
mbed_official | 235:685d5f11838f | 1348 | } |
mbed_official | 235:685d5f11838f | 1349 | |
mbed_official | 235:685d5f11838f | 1350 | /** |
mbed_official | 235:685d5f11838f | 1351 | * @} |
mbed_official | 235:685d5f11838f | 1352 | */ |
mbed_official | 235:685d5f11838f | 1353 | |
mbed_official | 235:685d5f11838f | 1354 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ |
mbed_official | 235:685d5f11838f | 1355 | #endif /* HAL_SAI_MODULE_ENABLED */ |
mbed_official | 235:685d5f11838f | 1356 | /** |
mbed_official | 235:685d5f11838f | 1357 | * @} |
mbed_official | 235:685d5f11838f | 1358 | */ |
mbed_official | 235:685d5f11838f | 1359 | |
mbed_official | 235:685d5f11838f | 1360 | /** |
mbed_official | 235:685d5f11838f | 1361 | * @} |
mbed_official | 235:685d5f11838f | 1362 | */ |
mbed_official | 235:685d5f11838f | 1363 | |
mbed_official | 235:685d5f11838f | 1364 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |