mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32F7/stm32f7xx_hal_i2s.c@637:ed69428d4850, 2015-12-22 (annotated)
- Committer:
- jaerts
- Date:
- Tue Dec 22 13:22:16 2015 +0000
- Revision:
- 637:ed69428d4850
- Parent:
- 610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 573:ad23fe03a082 | 1 | /** |
mbed_official | 573:ad23fe03a082 | 2 | ****************************************************************************** |
mbed_official | 573:ad23fe03a082 | 3 | * @file stm32f7xx_hal_i2s.c |
mbed_official | 573:ad23fe03a082 | 4 | * @author MCD Application Team |
mbed_official | 610:813dcc80987e | 5 | * @version V1.0.1 |
mbed_official | 610:813dcc80987e | 6 | * @date 25-June-2015 |
mbed_official | 573:ad23fe03a082 | 7 | * @brief I2S HAL module driver. |
mbed_official | 573:ad23fe03a082 | 8 | * This file provides firmware functions to manage the following |
mbed_official | 573:ad23fe03a082 | 9 | * functionalities of the Integrated Interchip Sound (I2S) peripheral: |
mbed_official | 573:ad23fe03a082 | 10 | * + Initialization and de-initialization functions |
mbed_official | 573:ad23fe03a082 | 11 | * + IO operation functions |
mbed_official | 573:ad23fe03a082 | 12 | * + Peripheral State and Errors functions |
mbed_official | 573:ad23fe03a082 | 13 | @verbatim |
mbed_official | 573:ad23fe03a082 | 14 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 15 | ##### How to use this driver ##### |
mbed_official | 573:ad23fe03a082 | 16 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 17 | [..] |
mbed_official | 573:ad23fe03a082 | 18 | The I2S HAL driver can be used as follows: |
mbed_official | 573:ad23fe03a082 | 19 | |
mbed_official | 573:ad23fe03a082 | 20 | (#) Declare a I2S_HandleTypeDef handle structure. |
mbed_official | 573:ad23fe03a082 | 21 | (#) Initialize the I2S low level resources by implement the HAL_I2S_MspInit() API: |
mbed_official | 573:ad23fe03a082 | 22 | (##) Enable the SPIx interface clock. |
mbed_official | 573:ad23fe03a082 | 23 | (##) I2S pins configuration: |
mbed_official | 573:ad23fe03a082 | 24 | (+++) Enable the clock for the I2S GPIOs. |
mbed_official | 573:ad23fe03a082 | 25 | (+++) Configure these I2S pins as alternate function pull-up. |
mbed_official | 573:ad23fe03a082 | 26 | (##) NVIC configuration if you need to use interrupt process (HAL_I2S_Transmit_IT() |
mbed_official | 573:ad23fe03a082 | 27 | and HAL_I2S_Receive_IT() APIs). |
mbed_official | 573:ad23fe03a082 | 28 | (+++) Configure the I2Sx interrupt priority. |
mbed_official | 573:ad23fe03a082 | 29 | (+++) Enable the NVIC I2S IRQ handle. |
mbed_official | 573:ad23fe03a082 | 30 | (##) DMA Configuration if you need to use DMA process (HAL_I2S_Transmit_DMA() |
mbed_official | 573:ad23fe03a082 | 31 | and HAL_I2S_Receive_DMA() APIs: |
mbed_official | 573:ad23fe03a082 | 32 | (+++) Declare a DMA handle structure for the Tx/Rx channel. |
mbed_official | 573:ad23fe03a082 | 33 | (+++) Enable the DMAx interface clock. |
mbed_official | 573:ad23fe03a082 | 34 | (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters. |
mbed_official | 573:ad23fe03a082 | 35 | (+++) Configure the DMA Tx/Rx Channel. |
mbed_official | 573:ad23fe03a082 | 36 | (+++) Associate the initialized DMA handle to the I2S DMA Tx/Rx handle. |
mbed_official | 573:ad23fe03a082 | 37 | (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the |
mbed_official | 573:ad23fe03a082 | 38 | DMA Tx/Rx Channel. |
mbed_official | 573:ad23fe03a082 | 39 | |
mbed_official | 573:ad23fe03a082 | 40 | (#) Program the Mode, Standard, Data Format, MCLK Output, Audio frequency and Polarity |
mbed_official | 573:ad23fe03a082 | 41 | using HAL_I2S_Init() function. |
mbed_official | 573:ad23fe03a082 | 42 | |
mbed_official | 573:ad23fe03a082 | 43 | -@- The specific I2S interrupts (Transmission complete interrupt, |
mbed_official | 573:ad23fe03a082 | 44 | RXNE interrupt and Error Interrupts) will be managed using the macros |
mbed_official | 573:ad23fe03a082 | 45 | __HAL_I2S_ENABLE_IT() and __HAL_I2S_DISABLE_IT() inside the transmit and receive process. |
mbed_official | 573:ad23fe03a082 | 46 | -@- Make sure that either: |
mbed_official | 573:ad23fe03a082 | 47 | (+@) I2S clock is configured based on SYSCLK or |
mbed_official | 573:ad23fe03a082 | 48 | (+@) External clock source is configured after setting correctly |
mbed_official | 573:ad23fe03a082 | 49 | the define constant EXTERNAL_CLOCK_VALUE in the stm32f3xx_hal_conf.h file. |
mbed_official | 573:ad23fe03a082 | 50 | |
mbed_official | 573:ad23fe03a082 | 51 | (#) Three mode of operations are available within this driver : |
mbed_official | 573:ad23fe03a082 | 52 | |
mbed_official | 573:ad23fe03a082 | 53 | *** Polling mode IO operation *** |
mbed_official | 573:ad23fe03a082 | 54 | ================================= |
mbed_official | 573:ad23fe03a082 | 55 | [..] |
mbed_official | 573:ad23fe03a082 | 56 | (+) Send an amount of data in blocking mode using HAL_I2S_Transmit() |
mbed_official | 573:ad23fe03a082 | 57 | (+) Receive an amount of data in blocking mode using HAL_I2S_Receive() |
mbed_official | 573:ad23fe03a082 | 58 | |
mbed_official | 573:ad23fe03a082 | 59 | *** Interrupt mode IO operation *** |
mbed_official | 573:ad23fe03a082 | 60 | =================================== |
mbed_official | 573:ad23fe03a082 | 61 | [..] |
mbed_official | 573:ad23fe03a082 | 62 | (+) Send an amount of data in non blocking mode using HAL_I2S_Transmit_IT() |
mbed_official | 573:ad23fe03a082 | 63 | (+) At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 64 | add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback |
mbed_official | 573:ad23fe03a082 | 65 | (+) At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 66 | add his own code by customization of function pointer HAL_I2S_TxCpltCallback |
mbed_official | 573:ad23fe03a082 | 67 | (+) Receive an amount of data in non blocking mode using HAL_I2S_Receive_IT() |
mbed_official | 573:ad23fe03a082 | 68 | (+) At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 69 | add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback |
mbed_official | 573:ad23fe03a082 | 70 | (+) At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 71 | add his own code by customization of function pointer HAL_I2S_RxCpltCallback |
mbed_official | 573:ad23fe03a082 | 72 | (+) In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can |
mbed_official | 573:ad23fe03a082 | 73 | add his own code by customization of function pointer HAL_I2S_ErrorCallback |
mbed_official | 573:ad23fe03a082 | 74 | |
mbed_official | 573:ad23fe03a082 | 75 | *** DMA mode IO operation *** |
mbed_official | 573:ad23fe03a082 | 76 | ============================== |
mbed_official | 573:ad23fe03a082 | 77 | [..] |
mbed_official | 573:ad23fe03a082 | 78 | (+) Send an amount of data in non blocking mode (DMA) using HAL_I2S_Transmit_DMA() |
mbed_official | 573:ad23fe03a082 | 79 | (+) At transmission end of half transfer HAL_I2S_TxHalfCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 80 | add his own code by customization of function pointer HAL_I2S_TxHalfCpltCallback |
mbed_official | 573:ad23fe03a082 | 81 | (+) At transmission end of transfer HAL_I2S_TxCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 82 | add his own code by customization of function pointer HAL_I2S_TxCpltCallback |
mbed_official | 573:ad23fe03a082 | 83 | (+) Receive an amount of data in non blocking mode (DMA) using HAL_I2S_Receive_DMA() |
mbed_official | 573:ad23fe03a082 | 84 | (+) At reception end of half transfer HAL_I2S_RxHalfCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 85 | add his own code by customization of function pointer HAL_I2S_RxHalfCpltCallback |
mbed_official | 573:ad23fe03a082 | 86 | (+) At reception end of transfer HAL_I2S_RxCpltCallback is executed and user can |
mbed_official | 573:ad23fe03a082 | 87 | add his own code by customization of function pointer HAL_I2S_RxCpltCallback |
mbed_official | 573:ad23fe03a082 | 88 | (+) In case of transfer Error, HAL_I2S_ErrorCallback() function is executed and user can |
mbed_official | 573:ad23fe03a082 | 89 | add his own code by customization of function pointer HAL_I2S_ErrorCallback |
mbed_official | 573:ad23fe03a082 | 90 | (+) Pause the DMA Transfer using HAL_I2S_DMAPause() |
mbed_official | 573:ad23fe03a082 | 91 | (+) Resume the DMA Transfer using HAL_I2S_DMAResume() |
mbed_official | 573:ad23fe03a082 | 92 | (+) Stop the DMA Transfer using HAL_I2S_DMAStop() |
mbed_official | 573:ad23fe03a082 | 93 | |
mbed_official | 573:ad23fe03a082 | 94 | *** I2S HAL driver macros list *** |
mbed_official | 573:ad23fe03a082 | 95 | ============================================= |
mbed_official | 573:ad23fe03a082 | 96 | [..] |
mbed_official | 573:ad23fe03a082 | 97 | Below the list of most used macros in I2S HAL driver. |
mbed_official | 573:ad23fe03a082 | 98 | |
mbed_official | 573:ad23fe03a082 | 99 | (+) __HAL_I2S_ENABLE: Enable the specified SPI peripheral (in I2S mode) |
mbed_official | 573:ad23fe03a082 | 100 | (+) __HAL_I2S_DISABLE: Disable the specified SPI peripheral (in I2S mode) |
mbed_official | 573:ad23fe03a082 | 101 | (+) __HAL_I2S_ENABLE_IT : Enable the specified I2S interrupts |
mbed_official | 573:ad23fe03a082 | 102 | (+) __HAL_I2S_DISABLE_IT : Disable the specified I2S interrupts |
mbed_official | 573:ad23fe03a082 | 103 | (+) __HAL_I2S_GET_FLAG: Check whether the specified I2S flag is set or not |
mbed_official | 573:ad23fe03a082 | 104 | |
mbed_official | 573:ad23fe03a082 | 105 | [..] |
mbed_official | 573:ad23fe03a082 | 106 | (@) You can refer to the I2S HAL driver header file for more useful macros |
mbed_official | 573:ad23fe03a082 | 107 | |
mbed_official | 573:ad23fe03a082 | 108 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 109 | ****************************************************************************** |
mbed_official | 573:ad23fe03a082 | 110 | * @attention |
mbed_official | 573:ad23fe03a082 | 111 | * |
mbed_official | 573:ad23fe03a082 | 112 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
mbed_official | 573:ad23fe03a082 | 113 | * |
mbed_official | 573:ad23fe03a082 | 114 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 573:ad23fe03a082 | 115 | * are permitted provided that the following conditions are met: |
mbed_official | 573:ad23fe03a082 | 116 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 573:ad23fe03a082 | 117 | * this list of conditions and the following disclaimer. |
mbed_official | 573:ad23fe03a082 | 118 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 573:ad23fe03a082 | 119 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 573:ad23fe03a082 | 120 | * and/or other materials provided with the distribution. |
mbed_official | 573:ad23fe03a082 | 121 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 573:ad23fe03a082 | 122 | * may be used to endorse or promote products derived from this software |
mbed_official | 573:ad23fe03a082 | 123 | * without specific prior written permission. |
mbed_official | 573:ad23fe03a082 | 124 | * |
mbed_official | 573:ad23fe03a082 | 125 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 573:ad23fe03a082 | 126 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 573:ad23fe03a082 | 127 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 573:ad23fe03a082 | 128 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 573:ad23fe03a082 | 129 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 573:ad23fe03a082 | 130 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 573:ad23fe03a082 | 131 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 573:ad23fe03a082 | 132 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 573:ad23fe03a082 | 133 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 573:ad23fe03a082 | 134 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 573:ad23fe03a082 | 135 | * |
mbed_official | 573:ad23fe03a082 | 136 | ****************************************************************************** |
mbed_official | 573:ad23fe03a082 | 137 | */ |
mbed_official | 573:ad23fe03a082 | 138 | |
mbed_official | 573:ad23fe03a082 | 139 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 140 | #include "stm32f7xx_hal.h" |
mbed_official | 573:ad23fe03a082 | 141 | |
mbed_official | 573:ad23fe03a082 | 142 | /** @addtogroup STM32F7xx_HAL_Driver |
mbed_official | 573:ad23fe03a082 | 143 | * @{ |
mbed_official | 573:ad23fe03a082 | 144 | */ |
mbed_official | 573:ad23fe03a082 | 145 | |
mbed_official | 573:ad23fe03a082 | 146 | /** @defgroup I2S I2S |
mbed_official | 573:ad23fe03a082 | 147 | * @brief I2S HAL module driver |
mbed_official | 573:ad23fe03a082 | 148 | * @{ |
mbed_official | 573:ad23fe03a082 | 149 | */ |
mbed_official | 573:ad23fe03a082 | 150 | |
mbed_official | 573:ad23fe03a082 | 151 | #ifdef HAL_I2S_MODULE_ENABLED |
mbed_official | 573:ad23fe03a082 | 152 | |
mbed_official | 573:ad23fe03a082 | 153 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 154 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 155 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 156 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 157 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 158 | /** @defgroup I2S_Private_Functions I2S Private Functions |
mbed_official | 573:ad23fe03a082 | 159 | * @{ |
mbed_official | 573:ad23fe03a082 | 160 | */ |
mbed_official | 573:ad23fe03a082 | 161 | static void I2S_DMATxCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 162 | static void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 163 | static void I2S_DMARxCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 164 | static void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 165 | static void I2S_DMAError(DMA_HandleTypeDef *hdma); |
mbed_official | 573:ad23fe03a082 | 166 | static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s); |
mbed_official | 573:ad23fe03a082 | 167 | static void I2S_Receive_IT(I2S_HandleTypeDef *hi2s); |
mbed_official | 573:ad23fe03a082 | 168 | static uint32_t I2S_GetClockFreq(I2S_HandleTypeDef *hi2s); |
mbed_official | 573:ad23fe03a082 | 169 | static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, uint32_t State, uint32_t Timeout); |
mbed_official | 573:ad23fe03a082 | 170 | /** |
mbed_official | 573:ad23fe03a082 | 171 | * @} |
mbed_official | 573:ad23fe03a082 | 172 | */ |
mbed_official | 573:ad23fe03a082 | 173 | |
mbed_official | 573:ad23fe03a082 | 174 | /* Exported functions ---------------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 175 | |
mbed_official | 573:ad23fe03a082 | 176 | /** @defgroup I2S_Exported_Functions I2S Exported Functions |
mbed_official | 573:ad23fe03a082 | 177 | * @{ |
mbed_official | 573:ad23fe03a082 | 178 | */ |
mbed_official | 573:ad23fe03a082 | 179 | |
mbed_official | 573:ad23fe03a082 | 180 | /** @defgroup I2S_Exported_Functions_Group1 Initialization and de-initialization functions |
mbed_official | 573:ad23fe03a082 | 181 | * @brief Initialization and Configuration functions |
mbed_official | 573:ad23fe03a082 | 182 | * |
mbed_official | 573:ad23fe03a082 | 183 | @verbatim |
mbed_official | 573:ad23fe03a082 | 184 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 185 | ##### Initialization and de-initialization functions ##### |
mbed_official | 573:ad23fe03a082 | 186 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 187 | [..] This subsection provides a set of functions allowing to initialize and |
mbed_official | 573:ad23fe03a082 | 188 | de-initialize the I2Sx peripheral in simplex mode: |
mbed_official | 573:ad23fe03a082 | 189 | |
mbed_official | 573:ad23fe03a082 | 190 | (+) User must Implement HAL_I2S_MspInit() function in which he configures |
mbed_official | 573:ad23fe03a082 | 191 | all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ). |
mbed_official | 573:ad23fe03a082 | 192 | |
mbed_official | 573:ad23fe03a082 | 193 | (+) Call the function HAL_I2S_Init() to configure the selected device with |
mbed_official | 573:ad23fe03a082 | 194 | the selected configuration: |
mbed_official | 573:ad23fe03a082 | 195 | (++) Mode |
mbed_official | 573:ad23fe03a082 | 196 | (++) Standard |
mbed_official | 573:ad23fe03a082 | 197 | (++) Data Format |
mbed_official | 573:ad23fe03a082 | 198 | (++) MCLK Output |
mbed_official | 573:ad23fe03a082 | 199 | (++) Audio frequency |
mbed_official | 573:ad23fe03a082 | 200 | (++) Polarity |
mbed_official | 573:ad23fe03a082 | 201 | (++) Full duplex mode |
mbed_official | 573:ad23fe03a082 | 202 | |
mbed_official | 573:ad23fe03a082 | 203 | (+) Call the function HAL_I2S_DeInit() to restore the default configuration |
mbed_official | 573:ad23fe03a082 | 204 | of the selected I2Sx peripheral. |
mbed_official | 573:ad23fe03a082 | 205 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 206 | * @{ |
mbed_official | 573:ad23fe03a082 | 207 | */ |
mbed_official | 573:ad23fe03a082 | 208 | |
mbed_official | 573:ad23fe03a082 | 209 | /** |
mbed_official | 573:ad23fe03a082 | 210 | * @brief Initializes the I2S according to the specified parameters |
mbed_official | 573:ad23fe03a082 | 211 | * in the I2S_InitTypeDef and create the associated handle. |
mbed_official | 573:ad23fe03a082 | 212 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 213 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 214 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 215 | */ |
mbed_official | 573:ad23fe03a082 | 216 | HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 217 | { |
mbed_official | 573:ad23fe03a082 | 218 | uint16_t tmpreg = 0, i2sdiv = 2, i2sodd = 0, packetlength = 1; |
mbed_official | 573:ad23fe03a082 | 219 | uint32_t tmp = 0, i2sclk = 0; |
mbed_official | 573:ad23fe03a082 | 220 | |
mbed_official | 573:ad23fe03a082 | 221 | /* Check the I2S handle allocation */ |
mbed_official | 573:ad23fe03a082 | 222 | if(hi2s == NULL) |
mbed_official | 573:ad23fe03a082 | 223 | { |
mbed_official | 573:ad23fe03a082 | 224 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 225 | } |
mbed_official | 573:ad23fe03a082 | 226 | |
mbed_official | 573:ad23fe03a082 | 227 | /* Check the parameters */ |
mbed_official | 573:ad23fe03a082 | 228 | assert_param(IS_I2S_ALL_INSTANCE(hi2s->Instance)); |
mbed_official | 573:ad23fe03a082 | 229 | assert_param(IS_I2S_MODE(hi2s->Init.Mode)); |
mbed_official | 573:ad23fe03a082 | 230 | assert_param(IS_I2S_STANDARD(hi2s->Init.Standard)); |
mbed_official | 573:ad23fe03a082 | 231 | assert_param(IS_I2S_DATA_FORMAT(hi2s->Init.DataFormat)); |
mbed_official | 573:ad23fe03a082 | 232 | assert_param(IS_I2S_MCLK_OUTPUT(hi2s->Init.MCLKOutput)); |
mbed_official | 573:ad23fe03a082 | 233 | assert_param(IS_I2S_AUDIO_FREQ(hi2s->Init.AudioFreq)); |
mbed_official | 573:ad23fe03a082 | 234 | assert_param(IS_I2S_CPOL(hi2s->Init.CPOL)); |
mbed_official | 573:ad23fe03a082 | 235 | assert_param(IS_I2S_CLOCKSOURCE(hi2s->Init.ClockSource)); |
mbed_official | 573:ad23fe03a082 | 236 | |
mbed_official | 573:ad23fe03a082 | 237 | if(hi2s->State == HAL_I2S_STATE_RESET) |
mbed_official | 573:ad23fe03a082 | 238 | { |
mbed_official | 573:ad23fe03a082 | 239 | /* Allocate lock resource and initialize it */ |
mbed_official | 573:ad23fe03a082 | 240 | hi2s->Lock = HAL_UNLOCKED; |
mbed_official | 573:ad23fe03a082 | 241 | /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */ |
mbed_official | 573:ad23fe03a082 | 242 | HAL_I2S_MspInit(hi2s); |
mbed_official | 573:ad23fe03a082 | 243 | } |
mbed_official | 573:ad23fe03a082 | 244 | |
mbed_official | 573:ad23fe03a082 | 245 | hi2s->State = HAL_I2S_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 246 | |
mbed_official | 573:ad23fe03a082 | 247 | /*----------------------- SPIx I2SCFGR & I2SPR Configuration -----------------*/ |
mbed_official | 573:ad23fe03a082 | 248 | /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */ |
mbed_official | 573:ad23fe03a082 | 249 | hi2s->Instance->I2SCFGR &= ~(SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CKPOL | \ |
mbed_official | 573:ad23fe03a082 | 250 | SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC | SPI_I2SCFGR_I2SCFG | \ |
mbed_official | 573:ad23fe03a082 | 251 | SPI_I2SCFGR_I2SE | SPI_I2SCFGR_I2SMOD); |
mbed_official | 573:ad23fe03a082 | 252 | hi2s->Instance->I2SPR = 0x0002; |
mbed_official | 573:ad23fe03a082 | 253 | |
mbed_official | 573:ad23fe03a082 | 254 | /* Get the I2SCFGR register value */ |
mbed_official | 573:ad23fe03a082 | 255 | tmpreg = hi2s->Instance->I2SCFGR; |
mbed_official | 573:ad23fe03a082 | 256 | |
mbed_official | 573:ad23fe03a082 | 257 | /* If the default value has to be written, reinitialize i2sdiv and i2sodd*/ |
mbed_official | 573:ad23fe03a082 | 258 | if(hi2s->Init.AudioFreq == I2S_AUDIOFREQ_DEFAULT) |
mbed_official | 573:ad23fe03a082 | 259 | { |
mbed_official | 573:ad23fe03a082 | 260 | i2sodd = (uint16_t)0; |
mbed_official | 573:ad23fe03a082 | 261 | i2sdiv = (uint16_t)2; |
mbed_official | 573:ad23fe03a082 | 262 | } |
mbed_official | 573:ad23fe03a082 | 263 | /* If the requested audio frequency is not the default, compute the prescaler */ |
mbed_official | 573:ad23fe03a082 | 264 | else |
mbed_official | 573:ad23fe03a082 | 265 | { |
mbed_official | 573:ad23fe03a082 | 266 | /* Check the frame length (For the Prescaler computing) *******************/ |
mbed_official | 573:ad23fe03a082 | 267 | if(hi2s->Init.DataFormat == I2S_DATAFORMAT_16B) |
mbed_official | 573:ad23fe03a082 | 268 | { |
mbed_official | 573:ad23fe03a082 | 269 | /* Packet length is 16 bits */ |
mbed_official | 573:ad23fe03a082 | 270 | packetlength = 1; |
mbed_official | 573:ad23fe03a082 | 271 | } |
mbed_official | 573:ad23fe03a082 | 272 | else |
mbed_official | 573:ad23fe03a082 | 273 | { |
mbed_official | 573:ad23fe03a082 | 274 | /* Packet length is 32 bits */ |
mbed_official | 573:ad23fe03a082 | 275 | packetlength = 2; |
mbed_official | 573:ad23fe03a082 | 276 | } |
mbed_official | 573:ad23fe03a082 | 277 | |
mbed_official | 573:ad23fe03a082 | 278 | /* Get I2S source Clock frequency ****************************************/ |
mbed_official | 573:ad23fe03a082 | 279 | |
mbed_official | 573:ad23fe03a082 | 280 | /* If an external I2S clock has to be used, the specific define should be set |
mbed_official | 573:ad23fe03a082 | 281 | in the project configuration or in the stm32f3xx_conf.h file */ |
mbed_official | 573:ad23fe03a082 | 282 | if(hi2s->Init.ClockSource == I2S_CLOCK_EXTERNAL) |
mbed_official | 573:ad23fe03a082 | 283 | { |
mbed_official | 573:ad23fe03a082 | 284 | /* Set the I2S clock to the external clock value */ |
mbed_official | 573:ad23fe03a082 | 285 | i2sclk = EXTERNAL_CLOCK_VALUE; |
mbed_official | 573:ad23fe03a082 | 286 | } |
mbed_official | 573:ad23fe03a082 | 287 | else |
mbed_official | 573:ad23fe03a082 | 288 | { |
mbed_official | 573:ad23fe03a082 | 289 | /* Get the I2S source clock value */ |
mbed_official | 573:ad23fe03a082 | 290 | i2sclk = I2S_GetClockFreq(hi2s); |
mbed_official | 573:ad23fe03a082 | 291 | } |
mbed_official | 573:ad23fe03a082 | 292 | |
mbed_official | 573:ad23fe03a082 | 293 | /* Compute the Real divider depending on the MCLK output state, with a floating point */ |
mbed_official | 573:ad23fe03a082 | 294 | if(hi2s->Init.MCLKOutput == I2S_MCLKOUTPUT_ENABLE) |
mbed_official | 573:ad23fe03a082 | 295 | { |
mbed_official | 573:ad23fe03a082 | 296 | /* MCLK output is enabled */ |
mbed_official | 573:ad23fe03a082 | 297 | tmp = (uint16_t)(((((i2sclk / 256) * 10) / hi2s->Init.AudioFreq)) + 5); |
mbed_official | 573:ad23fe03a082 | 298 | } |
mbed_official | 573:ad23fe03a082 | 299 | else |
mbed_official | 573:ad23fe03a082 | 300 | { |
mbed_official | 573:ad23fe03a082 | 301 | /* MCLK output is disabled */ |
mbed_official | 573:ad23fe03a082 | 302 | tmp = (uint16_t)(((((i2sclk / (32 * packetlength)) *10 ) / hi2s->Init.AudioFreq)) + 5); |
mbed_official | 573:ad23fe03a082 | 303 | } |
mbed_official | 573:ad23fe03a082 | 304 | |
mbed_official | 573:ad23fe03a082 | 305 | /* Remove the flatting point */ |
mbed_official | 573:ad23fe03a082 | 306 | tmp = tmp / 10; |
mbed_official | 573:ad23fe03a082 | 307 | |
mbed_official | 573:ad23fe03a082 | 308 | /* Check the parity of the divider */ |
mbed_official | 573:ad23fe03a082 | 309 | i2sodd = (uint16_t)(tmp & (uint16_t)0x0001); |
mbed_official | 573:ad23fe03a082 | 310 | |
mbed_official | 573:ad23fe03a082 | 311 | /* Compute the i2sdiv prescaler */ |
mbed_official | 573:ad23fe03a082 | 312 | i2sdiv = (uint16_t)((tmp - i2sodd) / 2); |
mbed_official | 573:ad23fe03a082 | 313 | |
mbed_official | 573:ad23fe03a082 | 314 | /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */ |
mbed_official | 573:ad23fe03a082 | 315 | i2sodd = (uint16_t) (i2sodd << 8); |
mbed_official | 573:ad23fe03a082 | 316 | } |
mbed_official | 573:ad23fe03a082 | 317 | |
mbed_official | 573:ad23fe03a082 | 318 | /* Test if the divider is 1 or 0 or greater than 0xFF */ |
mbed_official | 573:ad23fe03a082 | 319 | if((i2sdiv < 2) || (i2sdiv > 0xFF)) |
mbed_official | 573:ad23fe03a082 | 320 | { |
mbed_official | 573:ad23fe03a082 | 321 | /* Set the default values */ |
mbed_official | 573:ad23fe03a082 | 322 | i2sdiv = 2; |
mbed_official | 573:ad23fe03a082 | 323 | i2sodd = 0; |
mbed_official | 573:ad23fe03a082 | 324 | } |
mbed_official | 573:ad23fe03a082 | 325 | |
mbed_official | 573:ad23fe03a082 | 326 | /* Write to SPIx I2SPR register the computed value */ |
mbed_official | 573:ad23fe03a082 | 327 | hi2s->Instance->I2SPR = (uint16_t)((uint16_t)i2sdiv | (uint16_t)(i2sodd | (uint16_t)hi2s->Init.MCLKOutput)); |
mbed_official | 573:ad23fe03a082 | 328 | |
mbed_official | 573:ad23fe03a082 | 329 | /* Configure the I2S with the I2S_InitStruct values */ |
mbed_official | 573:ad23fe03a082 | 330 | tmpreg |= (uint16_t)((uint16_t)SPI_I2SCFGR_I2SMOD | (uint16_t)(hi2s->Init.Mode | \ |
mbed_official | 573:ad23fe03a082 | 331 | (uint16_t)(hi2s->Init.Standard | (uint16_t)(hi2s->Init.DataFormat | \ |
mbed_official | 573:ad23fe03a082 | 332 | (uint16_t)hi2s->Init.CPOL)))); |
mbed_official | 573:ad23fe03a082 | 333 | |
mbed_official | 573:ad23fe03a082 | 334 | /* Write to SPIx I2SCFGR */ |
mbed_official | 573:ad23fe03a082 | 335 | hi2s->Instance->I2SCFGR = tmpreg; |
mbed_official | 573:ad23fe03a082 | 336 | |
mbed_official | 573:ad23fe03a082 | 337 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 338 | hi2s->State= HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 339 | |
mbed_official | 573:ad23fe03a082 | 340 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 341 | } |
mbed_official | 573:ad23fe03a082 | 342 | |
mbed_official | 573:ad23fe03a082 | 343 | /** |
mbed_official | 573:ad23fe03a082 | 344 | * @brief DeInitializes the I2S peripheral |
mbed_official | 573:ad23fe03a082 | 345 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 346 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 347 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 348 | */ |
mbed_official | 573:ad23fe03a082 | 349 | HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 350 | { |
mbed_official | 573:ad23fe03a082 | 351 | /* Check the I2S handle allocation */ |
mbed_official | 573:ad23fe03a082 | 352 | if(hi2s == NULL) |
mbed_official | 573:ad23fe03a082 | 353 | { |
mbed_official | 573:ad23fe03a082 | 354 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 355 | } |
mbed_official | 573:ad23fe03a082 | 356 | |
mbed_official | 573:ad23fe03a082 | 357 | /* Check the parameters */ |
mbed_official | 573:ad23fe03a082 | 358 | assert_param(IS_I2S_ALL_INSTANCE(hi2s->Instance)); |
mbed_official | 573:ad23fe03a082 | 359 | |
mbed_official | 573:ad23fe03a082 | 360 | hi2s->State = HAL_I2S_STATE_BUSY; |
mbed_official | 573:ad23fe03a082 | 361 | |
mbed_official | 573:ad23fe03a082 | 362 | /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */ |
mbed_official | 573:ad23fe03a082 | 363 | HAL_I2S_MspDeInit(hi2s); |
mbed_official | 573:ad23fe03a082 | 364 | |
mbed_official | 573:ad23fe03a082 | 365 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 366 | hi2s->State = HAL_I2S_STATE_RESET; |
mbed_official | 573:ad23fe03a082 | 367 | |
mbed_official | 573:ad23fe03a082 | 368 | /* Release Lock */ |
mbed_official | 573:ad23fe03a082 | 369 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 370 | |
mbed_official | 573:ad23fe03a082 | 371 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 372 | } |
mbed_official | 573:ad23fe03a082 | 373 | |
mbed_official | 573:ad23fe03a082 | 374 | /** |
mbed_official | 573:ad23fe03a082 | 375 | * @brief I2S MSP Init |
mbed_official | 573:ad23fe03a082 | 376 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 377 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 378 | * @retval None |
mbed_official | 573:ad23fe03a082 | 379 | */ |
mbed_official | 573:ad23fe03a082 | 380 | __weak void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 381 | { |
mbed_official | 573:ad23fe03a082 | 382 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 383 | the HAL_I2S_MspInit could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 384 | */ |
mbed_official | 573:ad23fe03a082 | 385 | } |
mbed_official | 573:ad23fe03a082 | 386 | |
mbed_official | 573:ad23fe03a082 | 387 | /** |
mbed_official | 573:ad23fe03a082 | 388 | * @brief I2S MSP DeInit |
mbed_official | 573:ad23fe03a082 | 389 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 390 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 391 | * @retval None |
mbed_official | 573:ad23fe03a082 | 392 | */ |
mbed_official | 573:ad23fe03a082 | 393 | __weak void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 394 | { |
mbed_official | 573:ad23fe03a082 | 395 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 396 | the HAL_I2S_MspDeInit could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 397 | */ |
mbed_official | 573:ad23fe03a082 | 398 | } |
mbed_official | 573:ad23fe03a082 | 399 | |
mbed_official | 573:ad23fe03a082 | 400 | /** |
mbed_official | 573:ad23fe03a082 | 401 | * @} |
mbed_official | 573:ad23fe03a082 | 402 | */ |
mbed_official | 573:ad23fe03a082 | 403 | |
mbed_official | 573:ad23fe03a082 | 404 | /** @defgroup I2S_Exported_Functions_Group2 Input and Output operation functions |
mbed_official | 573:ad23fe03a082 | 405 | * @brief Data transfers functions |
mbed_official | 573:ad23fe03a082 | 406 | * |
mbed_official | 573:ad23fe03a082 | 407 | @verbatim |
mbed_official | 573:ad23fe03a082 | 408 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 409 | ##### IO operation functions ##### |
mbed_official | 573:ad23fe03a082 | 410 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 411 | [..] |
mbed_official | 573:ad23fe03a082 | 412 | This subsection provides a set of functions allowing to manage the I2S data |
mbed_official | 573:ad23fe03a082 | 413 | transfers. |
mbed_official | 573:ad23fe03a082 | 414 | |
mbed_official | 573:ad23fe03a082 | 415 | (#) There are two modes of transfer: |
mbed_official | 573:ad23fe03a082 | 416 | (++) Blocking mode : The communication is performed in the polling mode. |
mbed_official | 573:ad23fe03a082 | 417 | The status of all data processing is returned by the same function |
mbed_official | 573:ad23fe03a082 | 418 | after finishing transfer. |
mbed_official | 573:ad23fe03a082 | 419 | (++) No-Blocking mode : The communication is performed using Interrupts |
mbed_official | 573:ad23fe03a082 | 420 | or DMA. These functions return the status of the transfer startup. |
mbed_official | 573:ad23fe03a082 | 421 | The end of the data processing will be indicated through the |
mbed_official | 573:ad23fe03a082 | 422 | dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when |
mbed_official | 573:ad23fe03a082 | 423 | using DMA mode. |
mbed_official | 573:ad23fe03a082 | 424 | |
mbed_official | 573:ad23fe03a082 | 425 | (#) Blocking mode functions are : |
mbed_official | 573:ad23fe03a082 | 426 | (++) HAL_I2S_Transmit() |
mbed_official | 573:ad23fe03a082 | 427 | (++) HAL_I2S_Receive() |
mbed_official | 573:ad23fe03a082 | 428 | |
mbed_official | 573:ad23fe03a082 | 429 | (#) No-Blocking mode functions with Interrupt are : |
mbed_official | 573:ad23fe03a082 | 430 | (++) HAL_I2S_Transmit_IT() |
mbed_official | 573:ad23fe03a082 | 431 | (++) HAL_I2S_Receive_IT() |
mbed_official | 573:ad23fe03a082 | 432 | |
mbed_official | 573:ad23fe03a082 | 433 | (#) No-Blocking mode functions with DMA are : |
mbed_official | 573:ad23fe03a082 | 434 | (++) HAL_I2S_Transmit_DMA() |
mbed_official | 573:ad23fe03a082 | 435 | (++) HAL_I2S_Receive_DMA() |
mbed_official | 573:ad23fe03a082 | 436 | |
mbed_official | 573:ad23fe03a082 | 437 | (#) A set of Transfer Complete Callbacks are provided in non Blocking mode: |
mbed_official | 573:ad23fe03a082 | 438 | (++) HAL_I2S_TxCpltCallback() |
mbed_official | 573:ad23fe03a082 | 439 | (++) HAL_I2S_RxCpltCallback() |
mbed_official | 573:ad23fe03a082 | 440 | (++) HAL_I2S_ErrorCallback() |
mbed_official | 573:ad23fe03a082 | 441 | |
mbed_official | 573:ad23fe03a082 | 442 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 443 | * @{ |
mbed_official | 573:ad23fe03a082 | 444 | */ |
mbed_official | 573:ad23fe03a082 | 445 | |
mbed_official | 573:ad23fe03a082 | 446 | /** |
mbed_official | 573:ad23fe03a082 | 447 | * @brief Transmit an amount of data in blocking mode |
mbed_official | 573:ad23fe03a082 | 448 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 449 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 450 | * @param pData: a 16-bit pointer to data buffer. |
mbed_official | 573:ad23fe03a082 | 451 | * @param Size: number of data sample to be sent: |
mbed_official | 573:ad23fe03a082 | 452 | * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S |
mbed_official | 573:ad23fe03a082 | 453 | * configuration phase, the Size parameter means the number of 16-bit data length |
mbed_official | 573:ad23fe03a082 | 454 | * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected |
mbed_official | 573:ad23fe03a082 | 455 | * the Size parameter means the number of 16-bit data length. |
mbed_official | 573:ad23fe03a082 | 456 | * @param Timeout: Timeout duration |
mbed_official | 573:ad23fe03a082 | 457 | * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization |
mbed_official | 573:ad23fe03a082 | 458 | * between Master and Slave(example: audio streaming). |
mbed_official | 573:ad23fe03a082 | 459 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 460 | */ |
mbed_official | 573:ad23fe03a082 | 461 | HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 462 | { |
mbed_official | 573:ad23fe03a082 | 463 | if((pData == NULL ) || (Size == 0)) |
mbed_official | 573:ad23fe03a082 | 464 | { |
mbed_official | 573:ad23fe03a082 | 465 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 466 | } |
mbed_official | 573:ad23fe03a082 | 467 | |
mbed_official | 573:ad23fe03a082 | 468 | if(hi2s->State == HAL_I2S_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 469 | { |
mbed_official | 573:ad23fe03a082 | 470 | if(((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_24B)||\ |
mbed_official | 573:ad23fe03a082 | 471 | ((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_32B)) |
mbed_official | 573:ad23fe03a082 | 472 | { |
mbed_official | 573:ad23fe03a082 | 473 | hi2s->TxXferSize = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 474 | hi2s->TxXferCount = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 475 | } |
mbed_official | 573:ad23fe03a082 | 476 | else |
mbed_official | 573:ad23fe03a082 | 477 | { |
mbed_official | 573:ad23fe03a082 | 478 | hi2s->TxXferSize = Size; |
mbed_official | 573:ad23fe03a082 | 479 | hi2s->TxXferCount = Size; |
mbed_official | 573:ad23fe03a082 | 480 | } |
mbed_official | 573:ad23fe03a082 | 481 | |
mbed_official | 573:ad23fe03a082 | 482 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 483 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 484 | |
mbed_official | 573:ad23fe03a082 | 485 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 486 | hi2s->State = HAL_I2S_STATE_BUSY_TX; |
mbed_official | 573:ad23fe03a082 | 487 | |
mbed_official | 573:ad23fe03a082 | 488 | /* Check if the I2S is already enabled */ |
mbed_official | 573:ad23fe03a082 | 489 | if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) |
mbed_official | 573:ad23fe03a082 | 490 | { |
mbed_official | 573:ad23fe03a082 | 491 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 492 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 493 | } |
mbed_official | 573:ad23fe03a082 | 494 | |
mbed_official | 573:ad23fe03a082 | 495 | while(hi2s->TxXferCount > 0) |
mbed_official | 573:ad23fe03a082 | 496 | { |
mbed_official | 573:ad23fe03a082 | 497 | hi2s->Instance->DR = (*pData++); |
mbed_official | 573:ad23fe03a082 | 498 | hi2s->TxXferCount--; |
mbed_official | 573:ad23fe03a082 | 499 | /* Wait until TXE flag is set */ |
mbed_official | 573:ad23fe03a082 | 500 | if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, Timeout) != HAL_OK) |
mbed_official | 573:ad23fe03a082 | 501 | { |
mbed_official | 573:ad23fe03a082 | 502 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 503 | hi2s->ErrorCode |= HAL_I2S_ERROR_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 504 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 505 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 506 | } |
mbed_official | 573:ad23fe03a082 | 507 | |
mbed_official | 573:ad23fe03a082 | 508 | /* Check if an underrun occurs */ |
mbed_official | 573:ad23fe03a082 | 509 | if(__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR) == SET) |
mbed_official | 573:ad23fe03a082 | 510 | { |
mbed_official | 573:ad23fe03a082 | 511 | /* Set the I2S State ready */ |
mbed_official | 573:ad23fe03a082 | 512 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 513 | |
mbed_official | 573:ad23fe03a082 | 514 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 515 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 516 | |
mbed_official | 573:ad23fe03a082 | 517 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 518 | hi2s->ErrorCode |= HAL_I2S_ERROR_UDR; |
mbed_official | 573:ad23fe03a082 | 519 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 520 | |
mbed_official | 573:ad23fe03a082 | 521 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 522 | } |
mbed_official | 573:ad23fe03a082 | 523 | } |
mbed_official | 573:ad23fe03a082 | 524 | |
mbed_official | 610:813dcc80987e | 525 | /* Check if Slave mode is selected */ |
mbed_official | 610:813dcc80987e | 526 | if(((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_TX) || ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_RX)) |
mbed_official | 573:ad23fe03a082 | 527 | { |
mbed_official | 610:813dcc80987e | 528 | /* Wait until Busy flag is reset */ |
mbed_official | 610:813dcc80987e | 529 | if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_BSY, RESET, Timeout) != HAL_OK) |
mbed_official | 610:813dcc80987e | 530 | { |
mbed_official | 610:813dcc80987e | 531 | /* Set the error code and execute error callback*/ |
mbed_official | 610:813dcc80987e | 532 | hi2s->ErrorCode |= HAL_I2S_ERROR_TIMEOUT; |
mbed_official | 610:813dcc80987e | 533 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 610:813dcc80987e | 534 | return HAL_TIMEOUT; |
mbed_official | 610:813dcc80987e | 535 | } |
mbed_official | 573:ad23fe03a082 | 536 | } |
mbed_official | 573:ad23fe03a082 | 537 | |
mbed_official | 573:ad23fe03a082 | 538 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 539 | |
mbed_official | 573:ad23fe03a082 | 540 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 541 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 542 | |
mbed_official | 573:ad23fe03a082 | 543 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 544 | } |
mbed_official | 573:ad23fe03a082 | 545 | else |
mbed_official | 573:ad23fe03a082 | 546 | { |
mbed_official | 573:ad23fe03a082 | 547 | return HAL_BUSY; |
mbed_official | 573:ad23fe03a082 | 548 | } |
mbed_official | 573:ad23fe03a082 | 549 | } |
mbed_official | 573:ad23fe03a082 | 550 | |
mbed_official | 573:ad23fe03a082 | 551 | /** |
mbed_official | 573:ad23fe03a082 | 552 | * @brief Receive an amount of data in blocking mode |
mbed_official | 573:ad23fe03a082 | 553 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 554 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 555 | * @param pData: a 16-bit pointer to data buffer. |
mbed_official | 573:ad23fe03a082 | 556 | * @param Size: number of data sample to be sent: |
mbed_official | 573:ad23fe03a082 | 557 | * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S |
mbed_official | 573:ad23fe03a082 | 558 | * configuration phase, the Size parameter means the number of 16-bit data length |
mbed_official | 573:ad23fe03a082 | 559 | * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected |
mbed_official | 573:ad23fe03a082 | 560 | * the Size parameter means the number of 16-bit data length. |
mbed_official | 573:ad23fe03a082 | 561 | * @param Timeout: Timeout duration |
mbed_official | 573:ad23fe03a082 | 562 | * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization |
mbed_official | 573:ad23fe03a082 | 563 | * between Master and Slave(example: audio streaming). |
mbed_official | 573:ad23fe03a082 | 564 | * @note In I2S Master Receiver mode, just after enabling the peripheral the clock will be generate |
mbed_official | 573:ad23fe03a082 | 565 | * in continuous way and as the I2S is not disabled at the end of the I2S transaction. |
mbed_official | 573:ad23fe03a082 | 566 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 567 | */ |
mbed_official | 573:ad23fe03a082 | 568 | HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 569 | { |
mbed_official | 573:ad23fe03a082 | 570 | if((pData == NULL ) || (Size == 0)) |
mbed_official | 573:ad23fe03a082 | 571 | { |
mbed_official | 573:ad23fe03a082 | 572 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 573 | } |
mbed_official | 573:ad23fe03a082 | 574 | |
mbed_official | 573:ad23fe03a082 | 575 | if(hi2s->State == HAL_I2S_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 576 | { |
mbed_official | 573:ad23fe03a082 | 577 | if(((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_24B)||\ |
mbed_official | 573:ad23fe03a082 | 578 | ((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_32B)) |
mbed_official | 573:ad23fe03a082 | 579 | { |
mbed_official | 573:ad23fe03a082 | 580 | hi2s->RxXferSize = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 581 | hi2s->RxXferCount = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 582 | } |
mbed_official | 573:ad23fe03a082 | 583 | else |
mbed_official | 573:ad23fe03a082 | 584 | { |
mbed_official | 573:ad23fe03a082 | 585 | hi2s->RxXferSize = Size; |
mbed_official | 573:ad23fe03a082 | 586 | hi2s->RxXferCount = Size; |
mbed_official | 573:ad23fe03a082 | 587 | } |
mbed_official | 573:ad23fe03a082 | 588 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 589 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 590 | |
mbed_official | 573:ad23fe03a082 | 591 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 592 | hi2s->State = HAL_I2S_STATE_BUSY_RX; |
mbed_official | 573:ad23fe03a082 | 593 | |
mbed_official | 573:ad23fe03a082 | 594 | /* Check if the I2S is already enabled */ |
mbed_official | 573:ad23fe03a082 | 595 | if((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) |
mbed_official | 573:ad23fe03a082 | 596 | { |
mbed_official | 573:ad23fe03a082 | 597 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 598 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 599 | } |
mbed_official | 573:ad23fe03a082 | 600 | |
mbed_official | 573:ad23fe03a082 | 601 | /* Check if Master Receiver mode is selected */ |
mbed_official | 573:ad23fe03a082 | 602 | if((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX) |
mbed_official | 573:ad23fe03a082 | 603 | { |
mbed_official | 573:ad23fe03a082 | 604 | /* Clear the Overrun Flag by a read operation on the SPI_DR register followed by a read |
mbed_official | 573:ad23fe03a082 | 605 | access to the SPI_SR register. */ |
mbed_official | 573:ad23fe03a082 | 606 | __HAL_I2S_CLEAR_OVRFLAG(hi2s); |
mbed_official | 573:ad23fe03a082 | 607 | } |
mbed_official | 573:ad23fe03a082 | 608 | |
mbed_official | 573:ad23fe03a082 | 609 | /* Receive data */ |
mbed_official | 573:ad23fe03a082 | 610 | while(hi2s->RxXferCount > 0) |
mbed_official | 573:ad23fe03a082 | 611 | { |
mbed_official | 573:ad23fe03a082 | 612 | /* Wait until RXNE flag is set */ |
mbed_official | 573:ad23fe03a082 | 613 | if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_RXNE, SET, Timeout) != HAL_OK) |
mbed_official | 573:ad23fe03a082 | 614 | { |
mbed_official | 573:ad23fe03a082 | 615 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 616 | hi2s->ErrorCode |= HAL_I2S_ERROR_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 617 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 618 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 619 | } |
mbed_official | 573:ad23fe03a082 | 620 | |
mbed_official | 573:ad23fe03a082 | 621 | /* Check if an overrun occurs */ |
mbed_official | 573:ad23fe03a082 | 622 | if(__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR) == SET) |
mbed_official | 573:ad23fe03a082 | 623 | { |
mbed_official | 573:ad23fe03a082 | 624 | /* Set the I2S State ready */ |
mbed_official | 573:ad23fe03a082 | 625 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 626 | |
mbed_official | 573:ad23fe03a082 | 627 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 628 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 629 | |
mbed_official | 573:ad23fe03a082 | 630 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 631 | hi2s->ErrorCode |= HAL_I2S_ERROR_OVR; |
mbed_official | 573:ad23fe03a082 | 632 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 633 | |
mbed_official | 573:ad23fe03a082 | 634 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 635 | } |
mbed_official | 573:ad23fe03a082 | 636 | |
mbed_official | 573:ad23fe03a082 | 637 | (*pData++) = hi2s->Instance->DR; |
mbed_official | 573:ad23fe03a082 | 638 | hi2s->RxXferCount--; |
mbed_official | 573:ad23fe03a082 | 639 | } |
mbed_official | 573:ad23fe03a082 | 640 | |
mbed_official | 573:ad23fe03a082 | 641 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 642 | |
mbed_official | 573:ad23fe03a082 | 643 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 644 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 645 | |
mbed_official | 573:ad23fe03a082 | 646 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 647 | } |
mbed_official | 573:ad23fe03a082 | 648 | else |
mbed_official | 573:ad23fe03a082 | 649 | { |
mbed_official | 573:ad23fe03a082 | 650 | return HAL_BUSY; |
mbed_official | 573:ad23fe03a082 | 651 | } |
mbed_official | 573:ad23fe03a082 | 652 | } |
mbed_official | 573:ad23fe03a082 | 653 | |
mbed_official | 573:ad23fe03a082 | 654 | /** |
mbed_official | 573:ad23fe03a082 | 655 | * @brief Transmit an amount of data in non-blocking mode with Interrupt |
mbed_official | 573:ad23fe03a082 | 656 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 657 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 658 | * @param pData: a 16-bit pointer to data buffer. |
mbed_official | 573:ad23fe03a082 | 659 | * @param Size: number of data sample to be sent: |
mbed_official | 573:ad23fe03a082 | 660 | * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S |
mbed_official | 573:ad23fe03a082 | 661 | * configuration phase, the Size parameter means the number of 16-bit data length |
mbed_official | 573:ad23fe03a082 | 662 | * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected |
mbed_official | 573:ad23fe03a082 | 663 | * the Size parameter means the number of 16-bit data length. |
mbed_official | 573:ad23fe03a082 | 664 | * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization |
mbed_official | 573:ad23fe03a082 | 665 | * between Master and Slave(example: audio streaming). |
mbed_official | 573:ad23fe03a082 | 666 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 667 | */ |
mbed_official | 573:ad23fe03a082 | 668 | HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size) |
mbed_official | 573:ad23fe03a082 | 669 | { |
mbed_official | 573:ad23fe03a082 | 670 | if(hi2s->State == HAL_I2S_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 671 | { |
mbed_official | 573:ad23fe03a082 | 672 | if((pData == NULL) || (Size == 0)) |
mbed_official | 573:ad23fe03a082 | 673 | { |
mbed_official | 573:ad23fe03a082 | 674 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 675 | } |
mbed_official | 573:ad23fe03a082 | 676 | |
mbed_official | 573:ad23fe03a082 | 677 | hi2s->pTxBuffPtr = pData; |
mbed_official | 573:ad23fe03a082 | 678 | if(((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_24B)||\ |
mbed_official | 573:ad23fe03a082 | 679 | ((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_32B)) |
mbed_official | 573:ad23fe03a082 | 680 | { |
mbed_official | 573:ad23fe03a082 | 681 | hi2s->TxXferSize = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 682 | hi2s->TxXferCount = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 683 | } |
mbed_official | 573:ad23fe03a082 | 684 | else |
mbed_official | 573:ad23fe03a082 | 685 | { |
mbed_official | 573:ad23fe03a082 | 686 | hi2s->TxXferSize = Size; |
mbed_official | 573:ad23fe03a082 | 687 | hi2s->TxXferCount = Size; |
mbed_official | 573:ad23fe03a082 | 688 | } |
mbed_official | 573:ad23fe03a082 | 689 | |
mbed_official | 573:ad23fe03a082 | 690 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 691 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 692 | |
mbed_official | 573:ad23fe03a082 | 693 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 694 | hi2s->State = HAL_I2S_STATE_BUSY_TX; |
mbed_official | 573:ad23fe03a082 | 695 | |
mbed_official | 573:ad23fe03a082 | 696 | /* Enable TXE and ERR interrupt */ |
mbed_official | 573:ad23fe03a082 | 697 | __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR)); |
mbed_official | 573:ad23fe03a082 | 698 | |
mbed_official | 573:ad23fe03a082 | 699 | /* Check if the I2S is already enabled */ |
mbed_official | 573:ad23fe03a082 | 700 | if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) |
mbed_official | 573:ad23fe03a082 | 701 | { |
mbed_official | 573:ad23fe03a082 | 702 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 703 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 704 | } |
mbed_official | 573:ad23fe03a082 | 705 | |
mbed_official | 573:ad23fe03a082 | 706 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 707 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 708 | |
mbed_official | 573:ad23fe03a082 | 709 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 710 | } |
mbed_official | 573:ad23fe03a082 | 711 | else |
mbed_official | 573:ad23fe03a082 | 712 | { |
mbed_official | 573:ad23fe03a082 | 713 | return HAL_BUSY; |
mbed_official | 573:ad23fe03a082 | 714 | } |
mbed_official | 573:ad23fe03a082 | 715 | } |
mbed_official | 573:ad23fe03a082 | 716 | |
mbed_official | 573:ad23fe03a082 | 717 | /** |
mbed_official | 573:ad23fe03a082 | 718 | * @brief Receive an amount of data in non-blocking mode with Interrupt |
mbed_official | 573:ad23fe03a082 | 719 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 720 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 721 | * @param pData: a 16-bit pointer to the Receive data buffer. |
mbed_official | 573:ad23fe03a082 | 722 | * @param Size: number of data sample to be sent: |
mbed_official | 573:ad23fe03a082 | 723 | * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S |
mbed_official | 573:ad23fe03a082 | 724 | * configuration phase, the Size parameter means the number of 16-bit data length |
mbed_official | 573:ad23fe03a082 | 725 | * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected |
mbed_official | 573:ad23fe03a082 | 726 | * the Size parameter means the number of 16-bit data length. |
mbed_official | 573:ad23fe03a082 | 727 | * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization |
mbed_official | 573:ad23fe03a082 | 728 | * between Master and Slave(example: audio streaming). |
mbed_official | 573:ad23fe03a082 | 729 | * @note It is recommended to use DMA for the I2S receiver to avoid de-synchronisation |
mbed_official | 573:ad23fe03a082 | 730 | * between Master and Slave otherwise the I2S interrupt should be optimized. |
mbed_official | 573:ad23fe03a082 | 731 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 732 | */ |
mbed_official | 573:ad23fe03a082 | 733 | HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size) |
mbed_official | 573:ad23fe03a082 | 734 | { |
mbed_official | 573:ad23fe03a082 | 735 | if(hi2s->State == HAL_I2S_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 736 | { |
mbed_official | 573:ad23fe03a082 | 737 | if((pData == NULL) || (Size == 0)) |
mbed_official | 573:ad23fe03a082 | 738 | { |
mbed_official | 573:ad23fe03a082 | 739 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 740 | } |
mbed_official | 573:ad23fe03a082 | 741 | |
mbed_official | 573:ad23fe03a082 | 742 | hi2s->pRxBuffPtr = pData; |
mbed_official | 573:ad23fe03a082 | 743 | if(((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_24B)||\ |
mbed_official | 573:ad23fe03a082 | 744 | ((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_32B)) |
mbed_official | 573:ad23fe03a082 | 745 | { |
mbed_official | 573:ad23fe03a082 | 746 | hi2s->RxXferSize = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 747 | hi2s->RxXferCount = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 748 | } |
mbed_official | 573:ad23fe03a082 | 749 | else |
mbed_official | 573:ad23fe03a082 | 750 | { |
mbed_official | 573:ad23fe03a082 | 751 | hi2s->RxXferSize = Size; |
mbed_official | 573:ad23fe03a082 | 752 | hi2s->RxXferCount = Size; |
mbed_official | 573:ad23fe03a082 | 753 | } |
mbed_official | 573:ad23fe03a082 | 754 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 755 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 756 | |
mbed_official | 573:ad23fe03a082 | 757 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 758 | hi2s->State = HAL_I2S_STATE_BUSY_RX; |
mbed_official | 573:ad23fe03a082 | 759 | |
mbed_official | 573:ad23fe03a082 | 760 | /* Enable TXE and ERR interrupt */ |
mbed_official | 573:ad23fe03a082 | 761 | __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR)); |
mbed_official | 573:ad23fe03a082 | 762 | |
mbed_official | 573:ad23fe03a082 | 763 | /* Check if the I2S is already enabled */ |
mbed_official | 573:ad23fe03a082 | 764 | if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) |
mbed_official | 573:ad23fe03a082 | 765 | { |
mbed_official | 573:ad23fe03a082 | 766 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 767 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 768 | } |
mbed_official | 573:ad23fe03a082 | 769 | |
mbed_official | 573:ad23fe03a082 | 770 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 771 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 772 | |
mbed_official | 573:ad23fe03a082 | 773 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 774 | } |
mbed_official | 573:ad23fe03a082 | 775 | else |
mbed_official | 573:ad23fe03a082 | 776 | { |
mbed_official | 573:ad23fe03a082 | 777 | return HAL_BUSY; |
mbed_official | 573:ad23fe03a082 | 778 | } |
mbed_official | 573:ad23fe03a082 | 779 | } |
mbed_official | 573:ad23fe03a082 | 780 | |
mbed_official | 573:ad23fe03a082 | 781 | /** |
mbed_official | 573:ad23fe03a082 | 782 | * @brief Transmit an amount of data in non-blocking mode with DMA |
mbed_official | 573:ad23fe03a082 | 783 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 784 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 785 | * @param pData: a 16-bit pointer to the Transmit data buffer. |
mbed_official | 573:ad23fe03a082 | 786 | * @param Size: number of data sample to be sent: |
mbed_official | 573:ad23fe03a082 | 787 | * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S |
mbed_official | 573:ad23fe03a082 | 788 | * configuration phase, the Size parameter means the number of 16-bit data length |
mbed_official | 573:ad23fe03a082 | 789 | * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected |
mbed_official | 573:ad23fe03a082 | 790 | * the Size parameter means the number of 16-bit data length. |
mbed_official | 573:ad23fe03a082 | 791 | * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization |
mbed_official | 573:ad23fe03a082 | 792 | * between Master and Slave(example: audio streaming). |
mbed_official | 573:ad23fe03a082 | 793 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 794 | */ |
mbed_official | 573:ad23fe03a082 | 795 | HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size) |
mbed_official | 573:ad23fe03a082 | 796 | { |
mbed_official | 573:ad23fe03a082 | 797 | uint32_t *tmp; |
mbed_official | 573:ad23fe03a082 | 798 | |
mbed_official | 573:ad23fe03a082 | 799 | if((pData == NULL) || (Size == 0)) |
mbed_official | 573:ad23fe03a082 | 800 | { |
mbed_official | 573:ad23fe03a082 | 801 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 802 | } |
mbed_official | 573:ad23fe03a082 | 803 | |
mbed_official | 573:ad23fe03a082 | 804 | if(hi2s->State == HAL_I2S_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 805 | { |
mbed_official | 573:ad23fe03a082 | 806 | hi2s->pTxBuffPtr = pData; |
mbed_official | 573:ad23fe03a082 | 807 | if(((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_24B)||\ |
mbed_official | 573:ad23fe03a082 | 808 | ((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_32B)) |
mbed_official | 573:ad23fe03a082 | 809 | { |
mbed_official | 573:ad23fe03a082 | 810 | hi2s->TxXferSize = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 811 | hi2s->TxXferCount = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 812 | } |
mbed_official | 573:ad23fe03a082 | 813 | else |
mbed_official | 573:ad23fe03a082 | 814 | { |
mbed_official | 573:ad23fe03a082 | 815 | hi2s->TxXferSize = Size; |
mbed_official | 573:ad23fe03a082 | 816 | hi2s->TxXferCount = Size; |
mbed_official | 573:ad23fe03a082 | 817 | } |
mbed_official | 573:ad23fe03a082 | 818 | |
mbed_official | 573:ad23fe03a082 | 819 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 820 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 821 | |
mbed_official | 573:ad23fe03a082 | 822 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 823 | hi2s->State = HAL_I2S_STATE_BUSY_TX; |
mbed_official | 573:ad23fe03a082 | 824 | |
mbed_official | 573:ad23fe03a082 | 825 | /* Set the I2S Tx DMA Half transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 826 | hi2s->hdmatx->XferHalfCpltCallback = I2S_DMATxHalfCplt; |
mbed_official | 573:ad23fe03a082 | 827 | |
mbed_official | 573:ad23fe03a082 | 828 | /* Set the I2S TxDMA transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 829 | hi2s->hdmatx->XferCpltCallback = I2S_DMATxCplt; |
mbed_official | 573:ad23fe03a082 | 830 | |
mbed_official | 573:ad23fe03a082 | 831 | /* Set the DMA error callback */ |
mbed_official | 573:ad23fe03a082 | 832 | hi2s->hdmatx->XferErrorCallback = I2S_DMAError; |
mbed_official | 573:ad23fe03a082 | 833 | |
mbed_official | 573:ad23fe03a082 | 834 | /* Enable the Tx DMA Channel */ |
mbed_official | 573:ad23fe03a082 | 835 | tmp = (uint32_t*)&pData; |
mbed_official | 573:ad23fe03a082 | 836 | HAL_DMA_Start_IT(hi2s->hdmatx, *(uint32_t*)tmp, (uint32_t)&hi2s->Instance->DR, hi2s->TxXferSize); |
mbed_official | 573:ad23fe03a082 | 837 | |
mbed_official | 573:ad23fe03a082 | 838 | /* Check if the I2S is already enabled */ |
mbed_official | 573:ad23fe03a082 | 839 | if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) |
mbed_official | 573:ad23fe03a082 | 840 | { |
mbed_official | 573:ad23fe03a082 | 841 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 842 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 843 | } |
mbed_official | 573:ad23fe03a082 | 844 | |
mbed_official | 573:ad23fe03a082 | 845 | /* Enable Tx DMA Request */ |
mbed_official | 573:ad23fe03a082 | 846 | hi2s->Instance->CR2 |= SPI_CR2_TXDMAEN; |
mbed_official | 573:ad23fe03a082 | 847 | |
mbed_official | 573:ad23fe03a082 | 848 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 849 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 850 | |
mbed_official | 573:ad23fe03a082 | 851 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 852 | } |
mbed_official | 573:ad23fe03a082 | 853 | else |
mbed_official | 573:ad23fe03a082 | 854 | { |
mbed_official | 573:ad23fe03a082 | 855 | return HAL_BUSY; |
mbed_official | 573:ad23fe03a082 | 856 | } |
mbed_official | 573:ad23fe03a082 | 857 | } |
mbed_official | 573:ad23fe03a082 | 858 | |
mbed_official | 573:ad23fe03a082 | 859 | /** |
mbed_official | 573:ad23fe03a082 | 860 | * @brief Receive an amount of data in non-blocking mode with DMA |
mbed_official | 573:ad23fe03a082 | 861 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 862 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 863 | * @param pData: a 16-bit pointer to the Receive data buffer. |
mbed_official | 573:ad23fe03a082 | 864 | * @param Size: number of data sample to be sent: |
mbed_official | 573:ad23fe03a082 | 865 | * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S |
mbed_official | 573:ad23fe03a082 | 866 | * configuration phase, the Size parameter means the number of 16-bit data length |
mbed_official | 573:ad23fe03a082 | 867 | * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected |
mbed_official | 573:ad23fe03a082 | 868 | * the Size parameter means the number of 16-bit data length. |
mbed_official | 573:ad23fe03a082 | 869 | * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization |
mbed_official | 573:ad23fe03a082 | 870 | * between Master and Slave(example: audio streaming). |
mbed_official | 573:ad23fe03a082 | 871 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 872 | */ |
mbed_official | 573:ad23fe03a082 | 873 | HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size) |
mbed_official | 573:ad23fe03a082 | 874 | { |
mbed_official | 573:ad23fe03a082 | 875 | uint32_t *tmp; |
mbed_official | 573:ad23fe03a082 | 876 | |
mbed_official | 573:ad23fe03a082 | 877 | if((pData == NULL) || (Size == 0)) |
mbed_official | 573:ad23fe03a082 | 878 | { |
mbed_official | 573:ad23fe03a082 | 879 | return HAL_ERROR; |
mbed_official | 573:ad23fe03a082 | 880 | } |
mbed_official | 573:ad23fe03a082 | 881 | |
mbed_official | 573:ad23fe03a082 | 882 | if(hi2s->State == HAL_I2S_STATE_READY) |
mbed_official | 573:ad23fe03a082 | 883 | { |
mbed_official | 573:ad23fe03a082 | 884 | hi2s->pRxBuffPtr = pData; |
mbed_official | 573:ad23fe03a082 | 885 | if(((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_24B)||\ |
mbed_official | 573:ad23fe03a082 | 886 | ((hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN)) == I2S_DATAFORMAT_32B)) |
mbed_official | 573:ad23fe03a082 | 887 | { |
mbed_official | 573:ad23fe03a082 | 888 | hi2s->RxXferSize = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 889 | hi2s->RxXferCount = (Size << 1); |
mbed_official | 573:ad23fe03a082 | 890 | } |
mbed_official | 573:ad23fe03a082 | 891 | else |
mbed_official | 573:ad23fe03a082 | 892 | { |
mbed_official | 573:ad23fe03a082 | 893 | hi2s->RxXferSize = Size; |
mbed_official | 573:ad23fe03a082 | 894 | hi2s->RxXferCount = Size; |
mbed_official | 573:ad23fe03a082 | 895 | } |
mbed_official | 573:ad23fe03a082 | 896 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 897 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 898 | |
mbed_official | 573:ad23fe03a082 | 899 | hi2s->ErrorCode = HAL_I2S_ERROR_NONE; |
mbed_official | 573:ad23fe03a082 | 900 | hi2s->State = HAL_I2S_STATE_BUSY_RX; |
mbed_official | 573:ad23fe03a082 | 901 | |
mbed_official | 573:ad23fe03a082 | 902 | /* Set the I2S Rx DMA Half transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 903 | hi2s->hdmarx->XferHalfCpltCallback = I2S_DMARxHalfCplt; |
mbed_official | 573:ad23fe03a082 | 904 | |
mbed_official | 573:ad23fe03a082 | 905 | /* Set the I2S Rx DMA transfer complete callback */ |
mbed_official | 573:ad23fe03a082 | 906 | hi2s->hdmarx->XferCpltCallback = I2S_DMARxCplt; |
mbed_official | 573:ad23fe03a082 | 907 | |
mbed_official | 573:ad23fe03a082 | 908 | /* Set the DMA error callback */ |
mbed_official | 573:ad23fe03a082 | 909 | hi2s->hdmarx->XferErrorCallback = I2S_DMAError; |
mbed_official | 573:ad23fe03a082 | 910 | |
mbed_official | 573:ad23fe03a082 | 911 | /* Check if Master Receiver mode is selected */ |
mbed_official | 573:ad23fe03a082 | 912 | if((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX) |
mbed_official | 573:ad23fe03a082 | 913 | { |
mbed_official | 573:ad23fe03a082 | 914 | /* Clear the Overrun Flag by a read operation to the SPI_DR register followed by a read |
mbed_official | 573:ad23fe03a082 | 915 | access to the SPI_SR register. */ |
mbed_official | 573:ad23fe03a082 | 916 | __HAL_I2S_CLEAR_OVRFLAG(hi2s); |
mbed_official | 573:ad23fe03a082 | 917 | } |
mbed_official | 573:ad23fe03a082 | 918 | |
mbed_official | 573:ad23fe03a082 | 919 | /* Enable the Rx DMA Channel */ |
mbed_official | 573:ad23fe03a082 | 920 | tmp = (uint32_t*)&pData; |
mbed_official | 573:ad23fe03a082 | 921 | HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->DR, *(uint32_t*)tmp, hi2s->RxXferSize); |
mbed_official | 573:ad23fe03a082 | 922 | |
mbed_official | 573:ad23fe03a082 | 923 | /* Check if the I2S is already enabled */ |
mbed_official | 573:ad23fe03a082 | 924 | if((hi2s->Instance->I2SCFGR &SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE) |
mbed_official | 573:ad23fe03a082 | 925 | { |
mbed_official | 573:ad23fe03a082 | 926 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 927 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 928 | } |
mbed_official | 573:ad23fe03a082 | 929 | |
mbed_official | 573:ad23fe03a082 | 930 | /* Enable Rx DMA Request */ |
mbed_official | 573:ad23fe03a082 | 931 | hi2s->Instance->CR2 |= SPI_CR2_RXDMAEN; |
mbed_official | 573:ad23fe03a082 | 932 | |
mbed_official | 573:ad23fe03a082 | 933 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 934 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 935 | |
mbed_official | 573:ad23fe03a082 | 936 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 937 | } |
mbed_official | 573:ad23fe03a082 | 938 | else |
mbed_official | 573:ad23fe03a082 | 939 | { |
mbed_official | 573:ad23fe03a082 | 940 | return HAL_BUSY; |
mbed_official | 573:ad23fe03a082 | 941 | } |
mbed_official | 573:ad23fe03a082 | 942 | } |
mbed_official | 573:ad23fe03a082 | 943 | |
mbed_official | 573:ad23fe03a082 | 944 | /** |
mbed_official | 573:ad23fe03a082 | 945 | * @brief Pauses the audio stream playing from the Media. |
mbed_official | 573:ad23fe03a082 | 946 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 947 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 948 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 949 | */ |
mbed_official | 573:ad23fe03a082 | 950 | HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 951 | { |
mbed_official | 573:ad23fe03a082 | 952 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 953 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 954 | |
mbed_official | 573:ad23fe03a082 | 955 | if(hi2s->State == HAL_I2S_STATE_BUSY_TX) |
mbed_official | 573:ad23fe03a082 | 956 | { |
mbed_official | 573:ad23fe03a082 | 957 | /* Disable the I2S DMA Tx request */ |
mbed_official | 573:ad23fe03a082 | 958 | hi2s->Instance->CR2 &= (uint32_t)(~SPI_CR2_TXDMAEN); |
mbed_official | 573:ad23fe03a082 | 959 | } |
mbed_official | 573:ad23fe03a082 | 960 | else if(hi2s->State == HAL_I2S_STATE_BUSY_RX) |
mbed_official | 573:ad23fe03a082 | 961 | { |
mbed_official | 573:ad23fe03a082 | 962 | /* Disable the I2S DMA Rx request */ |
mbed_official | 573:ad23fe03a082 | 963 | hi2s->Instance->CR2 &= (uint32_t)(~SPI_CR2_RXDMAEN); |
mbed_official | 573:ad23fe03a082 | 964 | } |
mbed_official | 573:ad23fe03a082 | 965 | else if(hi2s->State == HAL_I2S_STATE_BUSY_TX_RX) |
mbed_official | 573:ad23fe03a082 | 966 | { |
mbed_official | 573:ad23fe03a082 | 967 | if((hi2s->Init.Mode == I2S_MODE_SLAVE_TX)||(hi2s->Init.Mode == I2S_MODE_MASTER_TX)) |
mbed_official | 573:ad23fe03a082 | 968 | { |
mbed_official | 573:ad23fe03a082 | 969 | /* Disable the I2S DMA Tx request */ |
mbed_official | 573:ad23fe03a082 | 970 | hi2s->Instance->CR2 &= (uint32_t)(~SPI_CR2_TXDMAEN); |
mbed_official | 573:ad23fe03a082 | 971 | } |
mbed_official | 573:ad23fe03a082 | 972 | else |
mbed_official | 573:ad23fe03a082 | 973 | { |
mbed_official | 573:ad23fe03a082 | 974 | /* Disable the I2S DMA Rx request */ |
mbed_official | 573:ad23fe03a082 | 975 | hi2s->Instance->CR2 &= (uint32_t)(~SPI_CR2_RXDMAEN); |
mbed_official | 573:ad23fe03a082 | 976 | } |
mbed_official | 573:ad23fe03a082 | 977 | } |
mbed_official | 573:ad23fe03a082 | 978 | |
mbed_official | 573:ad23fe03a082 | 979 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 980 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 981 | |
mbed_official | 573:ad23fe03a082 | 982 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 983 | } |
mbed_official | 573:ad23fe03a082 | 984 | |
mbed_official | 573:ad23fe03a082 | 985 | /** |
mbed_official | 573:ad23fe03a082 | 986 | * @brief Resumes the audio stream playing from the Media. |
mbed_official | 573:ad23fe03a082 | 987 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 988 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 989 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 990 | */ |
mbed_official | 573:ad23fe03a082 | 991 | HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 992 | { |
mbed_official | 573:ad23fe03a082 | 993 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 994 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 995 | |
mbed_official | 573:ad23fe03a082 | 996 | if(hi2s->State == HAL_I2S_STATE_BUSY_TX) |
mbed_official | 573:ad23fe03a082 | 997 | { |
mbed_official | 573:ad23fe03a082 | 998 | /* Enable the I2S DMA Tx request */ |
mbed_official | 573:ad23fe03a082 | 999 | SET_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN); |
mbed_official | 573:ad23fe03a082 | 1000 | } |
mbed_official | 573:ad23fe03a082 | 1001 | else if(hi2s->State == HAL_I2S_STATE_BUSY_RX) |
mbed_official | 573:ad23fe03a082 | 1002 | { |
mbed_official | 573:ad23fe03a082 | 1003 | /* Enable the I2S DMA Rx request */ |
mbed_official | 573:ad23fe03a082 | 1004 | SET_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN); |
mbed_official | 573:ad23fe03a082 | 1005 | } |
mbed_official | 573:ad23fe03a082 | 1006 | |
mbed_official | 573:ad23fe03a082 | 1007 | /* If the I2S peripheral is still not enabled, enable it */ |
mbed_official | 573:ad23fe03a082 | 1008 | if(HAL_IS_BIT_CLR(hi2s->Instance->I2SCFGR, SPI_I2SCFGR_I2SE)) |
mbed_official | 573:ad23fe03a082 | 1009 | { |
mbed_official | 573:ad23fe03a082 | 1010 | /* Enable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 1011 | __HAL_I2S_ENABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 1012 | } |
mbed_official | 573:ad23fe03a082 | 1013 | |
mbed_official | 573:ad23fe03a082 | 1014 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1015 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 1016 | |
mbed_official | 573:ad23fe03a082 | 1017 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1018 | } |
mbed_official | 573:ad23fe03a082 | 1019 | |
mbed_official | 573:ad23fe03a082 | 1020 | /** |
mbed_official | 573:ad23fe03a082 | 1021 | * @brief Stops the audio stream playing from the Media. |
mbed_official | 573:ad23fe03a082 | 1022 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1023 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1024 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1025 | */ |
mbed_official | 573:ad23fe03a082 | 1026 | HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1027 | { |
mbed_official | 573:ad23fe03a082 | 1028 | /* Process Locked */ |
mbed_official | 573:ad23fe03a082 | 1029 | __HAL_LOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 1030 | |
mbed_official | 573:ad23fe03a082 | 1031 | /* Disable the I2S Tx/Rx DMA requests */ |
mbed_official | 573:ad23fe03a082 | 1032 | CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN); |
mbed_official | 573:ad23fe03a082 | 1033 | CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN); |
mbed_official | 573:ad23fe03a082 | 1034 | |
mbed_official | 573:ad23fe03a082 | 1035 | /* Abort the I2S DMA Channel tx */ |
mbed_official | 573:ad23fe03a082 | 1036 | if(hi2s->hdmatx != NULL) |
mbed_official | 573:ad23fe03a082 | 1037 | { |
mbed_official | 573:ad23fe03a082 | 1038 | /* Disable the I2S DMA channel */ |
mbed_official | 573:ad23fe03a082 | 1039 | __HAL_DMA_DISABLE(hi2s->hdmatx); |
mbed_official | 573:ad23fe03a082 | 1040 | HAL_DMA_Abort(hi2s->hdmatx); |
mbed_official | 573:ad23fe03a082 | 1041 | } |
mbed_official | 573:ad23fe03a082 | 1042 | /* Abort the I2S DMA Channel rx */ |
mbed_official | 573:ad23fe03a082 | 1043 | if(hi2s->hdmarx != NULL) |
mbed_official | 573:ad23fe03a082 | 1044 | { |
mbed_official | 573:ad23fe03a082 | 1045 | /* Disable the I2S DMA channel */ |
mbed_official | 573:ad23fe03a082 | 1046 | __HAL_DMA_DISABLE(hi2s->hdmarx); |
mbed_official | 573:ad23fe03a082 | 1047 | HAL_DMA_Abort(hi2s->hdmarx); |
mbed_official | 573:ad23fe03a082 | 1048 | } |
mbed_official | 573:ad23fe03a082 | 1049 | |
mbed_official | 573:ad23fe03a082 | 1050 | /* Disable I2S peripheral */ |
mbed_official | 573:ad23fe03a082 | 1051 | __HAL_I2S_DISABLE(hi2s); |
mbed_official | 573:ad23fe03a082 | 1052 | |
mbed_official | 573:ad23fe03a082 | 1053 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1054 | |
mbed_official | 573:ad23fe03a082 | 1055 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1056 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 1057 | |
mbed_official | 573:ad23fe03a082 | 1058 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1059 | } |
mbed_official | 573:ad23fe03a082 | 1060 | |
mbed_official | 573:ad23fe03a082 | 1061 | /** |
mbed_official | 573:ad23fe03a082 | 1062 | * @brief This function handles I2S interrupt request. |
mbed_official | 573:ad23fe03a082 | 1063 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1064 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1065 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1066 | */ |
mbed_official | 573:ad23fe03a082 | 1067 | void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1068 | { |
mbed_official | 573:ad23fe03a082 | 1069 | __IO uint32_t i2ssr = hi2s->Instance->SR; |
mbed_official | 573:ad23fe03a082 | 1070 | |
mbed_official | 573:ad23fe03a082 | 1071 | if(hi2s->State == HAL_I2S_STATE_BUSY_RX) |
mbed_official | 573:ad23fe03a082 | 1072 | { |
mbed_official | 573:ad23fe03a082 | 1073 | /* I2S in mode Receiver ----------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 1074 | if(((i2ssr & I2S_FLAG_RXNE) == I2S_FLAG_RXNE) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_RXNE) != RESET)) |
mbed_official | 573:ad23fe03a082 | 1075 | { |
mbed_official | 573:ad23fe03a082 | 1076 | I2S_Receive_IT(hi2s); |
mbed_official | 573:ad23fe03a082 | 1077 | } |
mbed_official | 573:ad23fe03a082 | 1078 | |
mbed_official | 573:ad23fe03a082 | 1079 | /* I2S Overrun error interrupt occurred -------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 1080 | if(((i2ssr & I2S_FLAG_OVR) == I2S_FLAG_OVR) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR) != RESET)) |
mbed_official | 573:ad23fe03a082 | 1081 | { |
mbed_official | 573:ad23fe03a082 | 1082 | /* Disable RXNE and ERR interrupt */ |
mbed_official | 573:ad23fe03a082 | 1083 | __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR)); |
mbed_official | 573:ad23fe03a082 | 1084 | |
mbed_official | 573:ad23fe03a082 | 1085 | /* Set the I2S State ready */ |
mbed_official | 573:ad23fe03a082 | 1086 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1087 | |
mbed_official | 573:ad23fe03a082 | 1088 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 1089 | hi2s->ErrorCode |= HAL_I2S_ERROR_OVR; |
mbed_official | 573:ad23fe03a082 | 1090 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1091 | } |
mbed_official | 573:ad23fe03a082 | 1092 | } |
mbed_official | 573:ad23fe03a082 | 1093 | else if(hi2s->State == HAL_I2S_STATE_BUSY_TX) |
mbed_official | 573:ad23fe03a082 | 1094 | { |
mbed_official | 573:ad23fe03a082 | 1095 | /* I2S in mode Transmitter ---------------------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 1096 | if(((i2ssr & I2S_FLAG_TXE) == I2S_FLAG_TXE) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_TXE) != RESET)) |
mbed_official | 573:ad23fe03a082 | 1097 | { |
mbed_official | 573:ad23fe03a082 | 1098 | I2S_Transmit_IT(hi2s); |
mbed_official | 573:ad23fe03a082 | 1099 | } |
mbed_official | 573:ad23fe03a082 | 1100 | |
mbed_official | 573:ad23fe03a082 | 1101 | /* I2S Underrun error interrupt occurred ------------------------------------*/ |
mbed_official | 573:ad23fe03a082 | 1102 | if(((i2ssr & I2S_FLAG_UDR) == I2S_FLAG_UDR) && (__HAL_I2S_GET_IT_SOURCE(hi2s, I2S_IT_ERR) != RESET)) |
mbed_official | 573:ad23fe03a082 | 1103 | { |
mbed_official | 573:ad23fe03a082 | 1104 | /* Disable TXE and ERR interrupt */ |
mbed_official | 573:ad23fe03a082 | 1105 | __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR)); |
mbed_official | 573:ad23fe03a082 | 1106 | |
mbed_official | 573:ad23fe03a082 | 1107 | /* Set the I2S State ready */ |
mbed_official | 573:ad23fe03a082 | 1108 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1109 | |
mbed_official | 573:ad23fe03a082 | 1110 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 1111 | hi2s->ErrorCode |= HAL_I2S_ERROR_UDR; |
mbed_official | 573:ad23fe03a082 | 1112 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1113 | } |
mbed_official | 573:ad23fe03a082 | 1114 | } |
mbed_official | 573:ad23fe03a082 | 1115 | } |
mbed_official | 573:ad23fe03a082 | 1116 | |
mbed_official | 573:ad23fe03a082 | 1117 | /** |
mbed_official | 573:ad23fe03a082 | 1118 | * @} |
mbed_official | 573:ad23fe03a082 | 1119 | */ |
mbed_official | 573:ad23fe03a082 | 1120 | |
mbed_official | 573:ad23fe03a082 | 1121 | /** |
mbed_official | 573:ad23fe03a082 | 1122 | * @} |
mbed_official | 573:ad23fe03a082 | 1123 | */ |
mbed_official | 573:ad23fe03a082 | 1124 | |
mbed_official | 573:ad23fe03a082 | 1125 | /** @addtogroup I2S_Private_Functions I2S Private Functions |
mbed_official | 573:ad23fe03a082 | 1126 | * @{ |
mbed_official | 573:ad23fe03a082 | 1127 | */ |
mbed_official | 573:ad23fe03a082 | 1128 | /** |
mbed_official | 573:ad23fe03a082 | 1129 | * @brief This function handles I2S Communication Timeout. |
mbed_official | 573:ad23fe03a082 | 1130 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1131 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1132 | * @param Flag: Flag checked |
mbed_official | 573:ad23fe03a082 | 1133 | * @param State: Value of the flag expected |
mbed_official | 573:ad23fe03a082 | 1134 | * @param Timeout: Duration of the timeout |
mbed_official | 573:ad23fe03a082 | 1135 | * @retval HAL status |
mbed_official | 573:ad23fe03a082 | 1136 | */ |
mbed_official | 573:ad23fe03a082 | 1137 | static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, |
mbed_official | 573:ad23fe03a082 | 1138 | uint32_t State, uint32_t Timeout) |
mbed_official | 573:ad23fe03a082 | 1139 | { |
mbed_official | 573:ad23fe03a082 | 1140 | uint32_t tickstart = 0; |
mbed_official | 573:ad23fe03a082 | 1141 | |
mbed_official | 573:ad23fe03a082 | 1142 | /* Get tick */ |
mbed_official | 573:ad23fe03a082 | 1143 | tickstart = HAL_GetTick(); |
mbed_official | 573:ad23fe03a082 | 1144 | |
mbed_official | 573:ad23fe03a082 | 1145 | /* Wait until flag is set */ |
mbed_official | 573:ad23fe03a082 | 1146 | if(State == RESET) |
mbed_official | 573:ad23fe03a082 | 1147 | { |
mbed_official | 573:ad23fe03a082 | 1148 | while(__HAL_I2S_GET_FLAG(hi2s, Flag) == RESET) |
mbed_official | 573:ad23fe03a082 | 1149 | { |
mbed_official | 573:ad23fe03a082 | 1150 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1151 | { |
mbed_official | 573:ad23fe03a082 | 1152 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 1153 | { |
mbed_official | 573:ad23fe03a082 | 1154 | /* Set the I2S State ready */ |
mbed_official | 573:ad23fe03a082 | 1155 | hi2s->State= HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1156 | |
mbed_official | 573:ad23fe03a082 | 1157 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1158 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 1159 | |
mbed_official | 573:ad23fe03a082 | 1160 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1161 | } |
mbed_official | 573:ad23fe03a082 | 1162 | } |
mbed_official | 573:ad23fe03a082 | 1163 | } |
mbed_official | 573:ad23fe03a082 | 1164 | } |
mbed_official | 573:ad23fe03a082 | 1165 | else |
mbed_official | 573:ad23fe03a082 | 1166 | { |
mbed_official | 573:ad23fe03a082 | 1167 | while(__HAL_I2S_GET_FLAG(hi2s, Flag) != RESET) |
mbed_official | 573:ad23fe03a082 | 1168 | { |
mbed_official | 573:ad23fe03a082 | 1169 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 573:ad23fe03a082 | 1170 | { |
mbed_official | 573:ad23fe03a082 | 1171 | if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout)) |
mbed_official | 573:ad23fe03a082 | 1172 | { |
mbed_official | 573:ad23fe03a082 | 1173 | /* Set the I2S State ready */ |
mbed_official | 573:ad23fe03a082 | 1174 | hi2s->State= HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1175 | |
mbed_official | 573:ad23fe03a082 | 1176 | /* Process Unlocked */ |
mbed_official | 573:ad23fe03a082 | 1177 | __HAL_UNLOCK(hi2s); |
mbed_official | 573:ad23fe03a082 | 1178 | |
mbed_official | 573:ad23fe03a082 | 1179 | return HAL_TIMEOUT; |
mbed_official | 573:ad23fe03a082 | 1180 | } |
mbed_official | 573:ad23fe03a082 | 1181 | } |
mbed_official | 573:ad23fe03a082 | 1182 | } |
mbed_official | 573:ad23fe03a082 | 1183 | } |
mbed_official | 573:ad23fe03a082 | 1184 | return HAL_OK; |
mbed_official | 573:ad23fe03a082 | 1185 | } |
mbed_official | 573:ad23fe03a082 | 1186 | /** |
mbed_official | 573:ad23fe03a082 | 1187 | * @} |
mbed_official | 573:ad23fe03a082 | 1188 | */ |
mbed_official | 573:ad23fe03a082 | 1189 | |
mbed_official | 573:ad23fe03a082 | 1190 | /** @addtogroup I2S_Exported_Functions I2S Exported Functions |
mbed_official | 573:ad23fe03a082 | 1191 | * @{ |
mbed_official | 573:ad23fe03a082 | 1192 | */ |
mbed_official | 573:ad23fe03a082 | 1193 | |
mbed_official | 573:ad23fe03a082 | 1194 | /** @addtogroup I2S_Exported_Functions_Group2 Input and Output operation functions |
mbed_official | 573:ad23fe03a082 | 1195 | * @{ |
mbed_official | 573:ad23fe03a082 | 1196 | */ |
mbed_official | 573:ad23fe03a082 | 1197 | /** |
mbed_official | 573:ad23fe03a082 | 1198 | * @brief Tx Transfer Half completed callbacks |
mbed_official | 573:ad23fe03a082 | 1199 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1200 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1201 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1202 | */ |
mbed_official | 573:ad23fe03a082 | 1203 | __weak void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1204 | { |
mbed_official | 573:ad23fe03a082 | 1205 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 1206 | the HAL_I2S_TxHalfCpltCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 1207 | */ |
mbed_official | 573:ad23fe03a082 | 1208 | } |
mbed_official | 573:ad23fe03a082 | 1209 | |
mbed_official | 573:ad23fe03a082 | 1210 | /** |
mbed_official | 573:ad23fe03a082 | 1211 | * @brief Tx Transfer completed callbacks |
mbed_official | 573:ad23fe03a082 | 1212 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1213 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1214 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1215 | */ |
mbed_official | 573:ad23fe03a082 | 1216 | __weak void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1217 | { |
mbed_official | 573:ad23fe03a082 | 1218 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 1219 | the HAL_I2S_TxCpltCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 1220 | */ |
mbed_official | 573:ad23fe03a082 | 1221 | } |
mbed_official | 573:ad23fe03a082 | 1222 | |
mbed_official | 573:ad23fe03a082 | 1223 | /** |
mbed_official | 573:ad23fe03a082 | 1224 | * @brief Rx Transfer half completed callbacks |
mbed_official | 573:ad23fe03a082 | 1225 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1226 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1227 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1228 | */ |
mbed_official | 573:ad23fe03a082 | 1229 | __weak void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1230 | { |
mbed_official | 573:ad23fe03a082 | 1231 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 1232 | the HAL_I2S_RxCpltCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 1233 | */ |
mbed_official | 573:ad23fe03a082 | 1234 | } |
mbed_official | 573:ad23fe03a082 | 1235 | |
mbed_official | 573:ad23fe03a082 | 1236 | /** |
mbed_official | 573:ad23fe03a082 | 1237 | * @brief Rx Transfer completed callbacks |
mbed_official | 573:ad23fe03a082 | 1238 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1239 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1240 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1241 | */ |
mbed_official | 573:ad23fe03a082 | 1242 | __weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1243 | { |
mbed_official | 573:ad23fe03a082 | 1244 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 1245 | the HAL_I2S_RxCpltCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 1246 | */ |
mbed_official | 573:ad23fe03a082 | 1247 | } |
mbed_official | 573:ad23fe03a082 | 1248 | |
mbed_official | 573:ad23fe03a082 | 1249 | /** |
mbed_official | 573:ad23fe03a082 | 1250 | * @brief I2S error callbacks |
mbed_official | 573:ad23fe03a082 | 1251 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1252 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1253 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1254 | */ |
mbed_official | 573:ad23fe03a082 | 1255 | __weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1256 | { |
mbed_official | 573:ad23fe03a082 | 1257 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 573:ad23fe03a082 | 1258 | the HAL_I2S_ErrorCallback could be implemented in the user file |
mbed_official | 573:ad23fe03a082 | 1259 | */ |
mbed_official | 573:ad23fe03a082 | 1260 | } |
mbed_official | 573:ad23fe03a082 | 1261 | |
mbed_official | 573:ad23fe03a082 | 1262 | /** |
mbed_official | 573:ad23fe03a082 | 1263 | * @} |
mbed_official | 573:ad23fe03a082 | 1264 | */ |
mbed_official | 573:ad23fe03a082 | 1265 | |
mbed_official | 573:ad23fe03a082 | 1266 | /** @defgroup I2S_Exported_Functions_Group3 Peripheral State and Errors functions |
mbed_official | 573:ad23fe03a082 | 1267 | * @brief Peripheral State functions |
mbed_official | 573:ad23fe03a082 | 1268 | * |
mbed_official | 573:ad23fe03a082 | 1269 | @verbatim |
mbed_official | 573:ad23fe03a082 | 1270 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1271 | ##### Peripheral State and Errors functions ##### |
mbed_official | 573:ad23fe03a082 | 1272 | =============================================================================== |
mbed_official | 573:ad23fe03a082 | 1273 | [..] |
mbed_official | 573:ad23fe03a082 | 1274 | This subsection permits to get in run-time the status of the peripheral |
mbed_official | 573:ad23fe03a082 | 1275 | and the data flow. |
mbed_official | 573:ad23fe03a082 | 1276 | |
mbed_official | 573:ad23fe03a082 | 1277 | @endverbatim |
mbed_official | 573:ad23fe03a082 | 1278 | * @{ |
mbed_official | 573:ad23fe03a082 | 1279 | */ |
mbed_official | 573:ad23fe03a082 | 1280 | |
mbed_official | 573:ad23fe03a082 | 1281 | /** |
mbed_official | 573:ad23fe03a082 | 1282 | * @brief Return the I2S state |
mbed_official | 573:ad23fe03a082 | 1283 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1284 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1285 | * @retval HAL state |
mbed_official | 573:ad23fe03a082 | 1286 | */ |
mbed_official | 573:ad23fe03a082 | 1287 | HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1288 | { |
mbed_official | 573:ad23fe03a082 | 1289 | return hi2s->State; |
mbed_official | 573:ad23fe03a082 | 1290 | } |
mbed_official | 573:ad23fe03a082 | 1291 | |
mbed_official | 573:ad23fe03a082 | 1292 | /** |
mbed_official | 573:ad23fe03a082 | 1293 | * @brief Return the I2S error code |
mbed_official | 573:ad23fe03a082 | 1294 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1295 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1296 | * @retval I2S Error Code |
mbed_official | 573:ad23fe03a082 | 1297 | */ |
mbed_official | 573:ad23fe03a082 | 1298 | uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1299 | { |
mbed_official | 573:ad23fe03a082 | 1300 | return hi2s->ErrorCode; |
mbed_official | 573:ad23fe03a082 | 1301 | } |
mbed_official | 573:ad23fe03a082 | 1302 | /** |
mbed_official | 573:ad23fe03a082 | 1303 | * @} |
mbed_official | 573:ad23fe03a082 | 1304 | */ |
mbed_official | 573:ad23fe03a082 | 1305 | |
mbed_official | 573:ad23fe03a082 | 1306 | /** |
mbed_official | 573:ad23fe03a082 | 1307 | * @} |
mbed_official | 573:ad23fe03a082 | 1308 | */ |
mbed_official | 573:ad23fe03a082 | 1309 | |
mbed_official | 573:ad23fe03a082 | 1310 | /** |
mbed_official | 573:ad23fe03a082 | 1311 | * @brief Get I2S Input Clock based on I2S source clock selection |
mbed_official | 573:ad23fe03a082 | 1312 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1313 | * the configuration information for I2S module. |
mbed_official | 573:ad23fe03a082 | 1314 | * @retval I2S Clock Input |
mbed_official | 573:ad23fe03a082 | 1315 | */ |
mbed_official | 573:ad23fe03a082 | 1316 | static uint32_t I2S_GetClockFreq(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1317 | { |
mbed_official | 573:ad23fe03a082 | 1318 | uint32_t tmpreg = 0; |
mbed_official | 573:ad23fe03a082 | 1319 | /* This variable used to store the VCO Input (value in Hz) */ |
mbed_official | 573:ad23fe03a082 | 1320 | uint32_t vcoinput = 0; |
mbed_official | 573:ad23fe03a082 | 1321 | /* This variable used to store the I2S_CK_x (value in Hz) */ |
mbed_official | 573:ad23fe03a082 | 1322 | uint32_t i2sclocksource = 0; |
mbed_official | 573:ad23fe03a082 | 1323 | |
mbed_official | 573:ad23fe03a082 | 1324 | /* Configure I2S Clock based on I2S source clock selection */ |
mbed_official | 573:ad23fe03a082 | 1325 | |
mbed_official | 573:ad23fe03a082 | 1326 | /* I2S_CLK_x : I2S Block Clock configuration for different clock sources selected */ |
mbed_official | 573:ad23fe03a082 | 1327 | switch(hi2s->Init.ClockSource) |
mbed_official | 573:ad23fe03a082 | 1328 | { |
mbed_official | 573:ad23fe03a082 | 1329 | case I2S_CLOCK_SYSCLK : |
mbed_official | 573:ad23fe03a082 | 1330 | { |
mbed_official | 573:ad23fe03a082 | 1331 | /* Configure the PLLI2S division factor */ |
mbed_official | 573:ad23fe03a082 | 1332 | /* PLLI2S_VCO Input = PLL_SOURCE/PLLI2SM */ |
mbed_official | 573:ad23fe03a082 | 1333 | if((RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) == RCC_PLLSOURCE_HSI) |
mbed_official | 573:ad23fe03a082 | 1334 | { |
mbed_official | 573:ad23fe03a082 | 1335 | /* In Case the PLL Source is HSI (Internal Clock) */ |
mbed_official | 573:ad23fe03a082 | 1336 | vcoinput = (HSI_VALUE / (uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLM)); |
mbed_official | 573:ad23fe03a082 | 1337 | } |
mbed_official | 573:ad23fe03a082 | 1338 | else |
mbed_official | 573:ad23fe03a082 | 1339 | { |
mbed_official | 573:ad23fe03a082 | 1340 | /* In Case the PLL Source is HSE (External Clock) */ |
mbed_official | 573:ad23fe03a082 | 1341 | vcoinput = ((HSE_VALUE / (uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLM))); |
mbed_official | 573:ad23fe03a082 | 1342 | } |
mbed_official | 573:ad23fe03a082 | 1343 | |
mbed_official | 573:ad23fe03a082 | 1344 | /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN */ |
mbed_official | 573:ad23fe03a082 | 1345 | /* I2S_CLK(first level) = PLLI2S_VCO Output/PLLI2SR */ |
mbed_official | 573:ad23fe03a082 | 1346 | tmpreg = (RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SR) >> 28; |
mbed_official | 573:ad23fe03a082 | 1347 | i2sclocksource = (vcoinput * ((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SN) >> 6))/(tmpreg); |
mbed_official | 573:ad23fe03a082 | 1348 | |
mbed_official | 573:ad23fe03a082 | 1349 | break; |
mbed_official | 573:ad23fe03a082 | 1350 | } |
mbed_official | 573:ad23fe03a082 | 1351 | case I2S_CLOCK_EXTERNAL : |
mbed_official | 573:ad23fe03a082 | 1352 | { |
mbed_official | 573:ad23fe03a082 | 1353 | i2sclocksource = EXTERNAL_CLOCK_VALUE; |
mbed_official | 573:ad23fe03a082 | 1354 | break; |
mbed_official | 573:ad23fe03a082 | 1355 | } |
mbed_official | 573:ad23fe03a082 | 1356 | default : |
mbed_official | 573:ad23fe03a082 | 1357 | { |
mbed_official | 573:ad23fe03a082 | 1358 | break; |
mbed_official | 573:ad23fe03a082 | 1359 | } |
mbed_official | 573:ad23fe03a082 | 1360 | } |
mbed_official | 573:ad23fe03a082 | 1361 | |
mbed_official | 573:ad23fe03a082 | 1362 | /* the return result is the value of I2S clock */ |
mbed_official | 573:ad23fe03a082 | 1363 | return i2sclocksource; |
mbed_official | 573:ad23fe03a082 | 1364 | } |
mbed_official | 573:ad23fe03a082 | 1365 | |
mbed_official | 573:ad23fe03a082 | 1366 | /** @addtogroup I2S_Private_Functions I2S Private Functions |
mbed_official | 573:ad23fe03a082 | 1367 | * @{ |
mbed_official | 573:ad23fe03a082 | 1368 | */ |
mbed_official | 573:ad23fe03a082 | 1369 | /** |
mbed_official | 573:ad23fe03a082 | 1370 | * @brief DMA I2S transmit process complete callback |
mbed_official | 573:ad23fe03a082 | 1371 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1372 | * the configuration information for the specified DMA module. |
mbed_official | 573:ad23fe03a082 | 1373 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1374 | */ |
mbed_official | 573:ad23fe03a082 | 1375 | static void I2S_DMATxCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 1376 | { |
mbed_official | 573:ad23fe03a082 | 1377 | I2S_HandleTypeDef* hi2s = (I2S_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 1378 | |
mbed_official | 573:ad23fe03a082 | 1379 | if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) |
mbed_official | 573:ad23fe03a082 | 1380 | { |
mbed_official | 573:ad23fe03a082 | 1381 | hi2s->TxXferCount = 0; |
mbed_official | 573:ad23fe03a082 | 1382 | |
mbed_official | 573:ad23fe03a082 | 1383 | /* Disable Tx DMA Request */ |
mbed_official | 573:ad23fe03a082 | 1384 | hi2s->Instance->CR2 &= (uint32_t)(~SPI_CR2_TXDMAEN); |
mbed_official | 573:ad23fe03a082 | 1385 | |
mbed_official | 573:ad23fe03a082 | 1386 | if(hi2s->State == HAL_I2S_STATE_BUSY_TX_RX) |
mbed_official | 573:ad23fe03a082 | 1387 | { |
mbed_official | 573:ad23fe03a082 | 1388 | if(hi2s->RxXferCount == 0) |
mbed_official | 573:ad23fe03a082 | 1389 | { |
mbed_official | 573:ad23fe03a082 | 1390 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1391 | } |
mbed_official | 573:ad23fe03a082 | 1392 | } |
mbed_official | 573:ad23fe03a082 | 1393 | else |
mbed_official | 573:ad23fe03a082 | 1394 | { |
mbed_official | 573:ad23fe03a082 | 1395 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1396 | } |
mbed_official | 573:ad23fe03a082 | 1397 | } |
mbed_official | 573:ad23fe03a082 | 1398 | HAL_I2S_TxCpltCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1399 | } |
mbed_official | 573:ad23fe03a082 | 1400 | |
mbed_official | 573:ad23fe03a082 | 1401 | /** |
mbed_official | 573:ad23fe03a082 | 1402 | * @brief DMA I2S transmit process half complete callback |
mbed_official | 573:ad23fe03a082 | 1403 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1404 | * the configuration information for the specified DMA module. |
mbed_official | 573:ad23fe03a082 | 1405 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1406 | */ |
mbed_official | 573:ad23fe03a082 | 1407 | static void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 1408 | { |
mbed_official | 573:ad23fe03a082 | 1409 | I2S_HandleTypeDef* hi2s = (I2S_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 1410 | |
mbed_official | 573:ad23fe03a082 | 1411 | HAL_I2S_TxHalfCpltCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1412 | } |
mbed_official | 573:ad23fe03a082 | 1413 | |
mbed_official | 573:ad23fe03a082 | 1414 | /** |
mbed_official | 573:ad23fe03a082 | 1415 | * @brief DMA I2S receive process complete callback |
mbed_official | 573:ad23fe03a082 | 1416 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1417 | * the configuration information for the specified DMA module. |
mbed_official | 573:ad23fe03a082 | 1418 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1419 | */ |
mbed_official | 573:ad23fe03a082 | 1420 | static void I2S_DMARxCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 1421 | { |
mbed_official | 573:ad23fe03a082 | 1422 | I2S_HandleTypeDef* hi2s = (I2S_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 1423 | |
mbed_official | 573:ad23fe03a082 | 1424 | if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0) |
mbed_official | 573:ad23fe03a082 | 1425 | { |
mbed_official | 573:ad23fe03a082 | 1426 | /* Disable Rx DMA Request */ |
mbed_official | 573:ad23fe03a082 | 1427 | hi2s->Instance->CR2 &= (uint32_t)(~SPI_CR2_RXDMAEN); |
mbed_official | 573:ad23fe03a082 | 1428 | |
mbed_official | 573:ad23fe03a082 | 1429 | hi2s->RxXferCount = 0; |
mbed_official | 573:ad23fe03a082 | 1430 | if(hi2s->State == HAL_I2S_STATE_BUSY_TX_RX) |
mbed_official | 573:ad23fe03a082 | 1431 | { |
mbed_official | 573:ad23fe03a082 | 1432 | if(hi2s->TxXferCount == 0) |
mbed_official | 573:ad23fe03a082 | 1433 | { |
mbed_official | 573:ad23fe03a082 | 1434 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1435 | } |
mbed_official | 573:ad23fe03a082 | 1436 | } |
mbed_official | 573:ad23fe03a082 | 1437 | else |
mbed_official | 573:ad23fe03a082 | 1438 | { |
mbed_official | 573:ad23fe03a082 | 1439 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1440 | } |
mbed_official | 573:ad23fe03a082 | 1441 | } |
mbed_official | 573:ad23fe03a082 | 1442 | HAL_I2S_RxCpltCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1443 | } |
mbed_official | 573:ad23fe03a082 | 1444 | |
mbed_official | 573:ad23fe03a082 | 1445 | /** |
mbed_official | 573:ad23fe03a082 | 1446 | * @brief DMA I2S receive process half complete callback |
mbed_official | 573:ad23fe03a082 | 1447 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1448 | * the configuration information for the specified DMA module. |
mbed_official | 573:ad23fe03a082 | 1449 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1450 | */ |
mbed_official | 573:ad23fe03a082 | 1451 | static void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 1452 | { |
mbed_official | 573:ad23fe03a082 | 1453 | I2S_HandleTypeDef* hi2s = (I2S_HandleTypeDef*)((DMA_HandleTypeDef*)hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 1454 | |
mbed_official | 573:ad23fe03a082 | 1455 | HAL_I2S_RxHalfCpltCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1456 | } |
mbed_official | 573:ad23fe03a082 | 1457 | |
mbed_official | 573:ad23fe03a082 | 1458 | /** |
mbed_official | 573:ad23fe03a082 | 1459 | * @brief DMA I2S communication error callback |
mbed_official | 573:ad23fe03a082 | 1460 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1461 | * the configuration information for the specified DMA module. |
mbed_official | 573:ad23fe03a082 | 1462 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1463 | */ |
mbed_official | 573:ad23fe03a082 | 1464 | static void I2S_DMAError(DMA_HandleTypeDef *hdma) |
mbed_official | 573:ad23fe03a082 | 1465 | { |
mbed_official | 573:ad23fe03a082 | 1466 | I2S_HandleTypeDef* hi2s = ( I2S_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 573:ad23fe03a082 | 1467 | |
mbed_official | 573:ad23fe03a082 | 1468 | /* Disable Rx and Tx DMA Request */ |
mbed_official | 573:ad23fe03a082 | 1469 | hi2s->Instance->CR2 &= (uint32_t)(~(SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN)); |
mbed_official | 573:ad23fe03a082 | 1470 | hi2s->TxXferCount = 0; |
mbed_official | 573:ad23fe03a082 | 1471 | hi2s->RxXferCount = 0; |
mbed_official | 573:ad23fe03a082 | 1472 | |
mbed_official | 573:ad23fe03a082 | 1473 | hi2s->State= HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1474 | |
mbed_official | 573:ad23fe03a082 | 1475 | /* Set the error code and execute error callback*/ |
mbed_official | 573:ad23fe03a082 | 1476 | hi2s->ErrorCode |= HAL_I2S_ERROR_DMA; |
mbed_official | 573:ad23fe03a082 | 1477 | HAL_I2S_ErrorCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1478 | } |
mbed_official | 573:ad23fe03a082 | 1479 | |
mbed_official | 573:ad23fe03a082 | 1480 | /** |
mbed_official | 573:ad23fe03a082 | 1481 | * @brief Transmit an amount of data in non-blocking mode with Interrupt |
mbed_official | 573:ad23fe03a082 | 1482 | * @param hi2s: pointer to a I2S_HandleTypeDef structure that contains |
mbed_official | 573:ad23fe03a082 | 1483 | * the configuration information for I2S module |
mbed_official | 573:ad23fe03a082 | 1484 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1485 | */ |
mbed_official | 573:ad23fe03a082 | 1486 | static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1487 | { |
mbed_official | 573:ad23fe03a082 | 1488 | /* Transmit data */ |
mbed_official | 573:ad23fe03a082 | 1489 | hi2s->Instance->DR = (*hi2s->pTxBuffPtr++); |
mbed_official | 573:ad23fe03a082 | 1490 | hi2s->TxXferCount--; |
mbed_official | 573:ad23fe03a082 | 1491 | |
mbed_official | 573:ad23fe03a082 | 1492 | if(hi2s->TxXferCount == 0) |
mbed_official | 573:ad23fe03a082 | 1493 | { |
mbed_official | 573:ad23fe03a082 | 1494 | /* Disable TXE and ERR interrupt */ |
mbed_official | 573:ad23fe03a082 | 1495 | __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR)); |
mbed_official | 573:ad23fe03a082 | 1496 | |
mbed_official | 573:ad23fe03a082 | 1497 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1498 | HAL_I2S_TxCpltCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1499 | } |
mbed_official | 573:ad23fe03a082 | 1500 | } |
mbed_official | 573:ad23fe03a082 | 1501 | |
mbed_official | 573:ad23fe03a082 | 1502 | /** |
mbed_official | 573:ad23fe03a082 | 1503 | * @brief Receive an amount of data in non-blocking mode with Interrupt |
mbed_official | 573:ad23fe03a082 | 1504 | * @param hi2s: I2S handle |
mbed_official | 573:ad23fe03a082 | 1505 | * @retval None |
mbed_official | 573:ad23fe03a082 | 1506 | */ |
mbed_official | 573:ad23fe03a082 | 1507 | static void I2S_Receive_IT(I2S_HandleTypeDef *hi2s) |
mbed_official | 573:ad23fe03a082 | 1508 | { |
mbed_official | 573:ad23fe03a082 | 1509 | /* Receive data */ |
mbed_official | 573:ad23fe03a082 | 1510 | (*hi2s->pRxBuffPtr++) = hi2s->Instance->DR; |
mbed_official | 573:ad23fe03a082 | 1511 | hi2s->RxXferCount--; |
mbed_official | 573:ad23fe03a082 | 1512 | |
mbed_official | 573:ad23fe03a082 | 1513 | if(hi2s->RxXferCount == 0) |
mbed_official | 573:ad23fe03a082 | 1514 | { |
mbed_official | 573:ad23fe03a082 | 1515 | /* Disable RXNE and ERR interrupt */ |
mbed_official | 573:ad23fe03a082 | 1516 | __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR)); |
mbed_official | 573:ad23fe03a082 | 1517 | |
mbed_official | 573:ad23fe03a082 | 1518 | hi2s->State = HAL_I2S_STATE_READY; |
mbed_official | 573:ad23fe03a082 | 1519 | HAL_I2S_RxCpltCallback(hi2s); |
mbed_official | 573:ad23fe03a082 | 1520 | } |
mbed_official | 573:ad23fe03a082 | 1521 | } |
mbed_official | 573:ad23fe03a082 | 1522 | /** |
mbed_official | 573:ad23fe03a082 | 1523 | * @} |
mbed_official | 573:ad23fe03a082 | 1524 | */ |
mbed_official | 573:ad23fe03a082 | 1525 | |
mbed_official | 573:ad23fe03a082 | 1526 | #endif /* HAL_I2S_MODULE_ENABLED */ |
mbed_official | 573:ad23fe03a082 | 1527 | /** |
mbed_official | 573:ad23fe03a082 | 1528 | * @} |
mbed_official | 573:ad23fe03a082 | 1529 | */ |
mbed_official | 573:ad23fe03a082 | 1530 | |
mbed_official | 573:ad23fe03a082 | 1531 | /** |
mbed_official | 573:ad23fe03a082 | 1532 | * @} |
mbed_official | 573:ad23fe03a082 | 1533 | */ |
mbed_official | 573:ad23fe03a082 | 1534 | |
mbed_official | 573:ad23fe03a082 | 1535 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |