meh
Fork of mbed by
TARGET_MTS_MDOT_F405RG/stm32f4xx_hal_sai.h@99:dbbf35b96557, 2015-05-13 (annotated)
- Committer:
- Kojto
- Date:
- Wed May 13 08:08:21 2015 +0200
- Revision:
- 99:dbbf35b96557
- Parent:
- 92:4fc01daae5a5
- Child:
- 106:ba1f97679dad
Release 99 of the mbed library
Changes:
- new targets - MAXWSNENV, DISCO_L053C8
- STM32F4xx - ST Cube driver
- KSDK mcu - SPI timing fix
- Nordic - update to softdevice s130
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 92:4fc01daae5a5 | 1 | /** |
bogdanm | 92:4fc01daae5a5 | 2 | ****************************************************************************** |
bogdanm | 92:4fc01daae5a5 | 3 | * @file stm32f4xx_hal_sai.h |
bogdanm | 92:4fc01daae5a5 | 4 | * @author MCD Application Team |
Kojto | 99:dbbf35b96557 | 5 | * @version V1.3.0 |
Kojto | 99:dbbf35b96557 | 6 | * @date 09-March-2015 |
bogdanm | 92:4fc01daae5a5 | 7 | * @brief Header file of SAI HAL module. |
bogdanm | 92:4fc01daae5a5 | 8 | ****************************************************************************** |
bogdanm | 92:4fc01daae5a5 | 9 | * @attention |
bogdanm | 92:4fc01daae5a5 | 10 | * |
Kojto | 99:dbbf35b96557 | 11 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
bogdanm | 92:4fc01daae5a5 | 12 | * |
bogdanm | 92:4fc01daae5a5 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 92:4fc01daae5a5 | 14 | * are permitted provided that the following conditions are met: |
bogdanm | 92:4fc01daae5a5 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 92:4fc01daae5a5 | 16 | * this list of conditions and the following disclaimer. |
bogdanm | 92:4fc01daae5a5 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 92:4fc01daae5a5 | 18 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 92:4fc01daae5a5 | 19 | * and/or other materials provided with the distribution. |
bogdanm | 92:4fc01daae5a5 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 92:4fc01daae5a5 | 21 | * may be used to endorse or promote products derived from this software |
bogdanm | 92:4fc01daae5a5 | 22 | * without specific prior written permission. |
bogdanm | 92:4fc01daae5a5 | 23 | * |
bogdanm | 92:4fc01daae5a5 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 92:4fc01daae5a5 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 92:4fc01daae5a5 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 92:4fc01daae5a5 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 92:4fc01daae5a5 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 92:4fc01daae5a5 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 92:4fc01daae5a5 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 92:4fc01daae5a5 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 92:4fc01daae5a5 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 92:4fc01daae5a5 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 92:4fc01daae5a5 | 34 | * |
bogdanm | 92:4fc01daae5a5 | 35 | ****************************************************************************** |
bogdanm | 92:4fc01daae5a5 | 36 | */ |
bogdanm | 92:4fc01daae5a5 | 37 | |
bogdanm | 92:4fc01daae5a5 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 39 | #ifndef __STM32F4xx_HAL_SAI_H |
bogdanm | 92:4fc01daae5a5 | 40 | #define __STM32F4xx_HAL_SAI_H |
bogdanm | 92:4fc01daae5a5 | 41 | |
bogdanm | 92:4fc01daae5a5 | 42 | #ifdef __cplusplus |
bogdanm | 92:4fc01daae5a5 | 43 | extern "C" { |
bogdanm | 92:4fc01daae5a5 | 44 | #endif |
bogdanm | 92:4fc01daae5a5 | 45 | |
bogdanm | 92:4fc01daae5a5 | 46 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 47 | #include "stm32f4xx_hal_def.h" |
bogdanm | 92:4fc01daae5a5 | 48 | |
bogdanm | 92:4fc01daae5a5 | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
bogdanm | 92:4fc01daae5a5 | 50 | * @{ |
bogdanm | 92:4fc01daae5a5 | 51 | */ |
Kojto | 99:dbbf35b96557 | 52 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F446xx) |
bogdanm | 92:4fc01daae5a5 | 53 | |
bogdanm | 92:4fc01daae5a5 | 54 | /** @addtogroup SAI |
bogdanm | 92:4fc01daae5a5 | 55 | * @{ |
bogdanm | 92:4fc01daae5a5 | 56 | */ |
Kojto | 99:dbbf35b96557 | 57 | |
Kojto | 99:dbbf35b96557 | 58 | /* Exported types ------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 59 | /** @defgroup SAI_Exported_Types SAI Exported Types |
Kojto | 99:dbbf35b96557 | 60 | * @{ |
Kojto | 99:dbbf35b96557 | 61 | */ |
Kojto | 99:dbbf35b96557 | 62 | |
Kojto | 99:dbbf35b96557 | 63 | /** |
Kojto | 99:dbbf35b96557 | 64 | * @brief HAL State structures definition |
Kojto | 99:dbbf35b96557 | 65 | */ |
Kojto | 99:dbbf35b96557 | 66 | typedef enum |
Kojto | 99:dbbf35b96557 | 67 | { |
Kojto | 99:dbbf35b96557 | 68 | HAL_SAI_STATE_RESET = 0x00, /*!< SAI not yet initialized or disabled */ |
Kojto | 99:dbbf35b96557 | 69 | HAL_SAI_STATE_READY = 0x01, /*!< SAI initialized and ready for use */ |
Kojto | 99:dbbf35b96557 | 70 | HAL_SAI_STATE_BUSY = 0x02, /*!< SAI internal process is ongoing */ |
Kojto | 99:dbbf35b96557 | 71 | HAL_SAI_STATE_BUSY_TX = 0x12, /*!< Data transmission process is ongoing */ |
Kojto | 99:dbbf35b96557 | 72 | HAL_SAI_STATE_BUSY_RX = 0x22, /*!< Data reception process is ongoing */ |
Kojto | 99:dbbf35b96557 | 73 | HAL_SAI_STATE_TIMEOUT = 0x03, /*!< SAI timeout state */ |
Kojto | 99:dbbf35b96557 | 74 | HAL_SAI_STATE_ERROR = 0x04 /*!< SAI error state */ |
Kojto | 99:dbbf35b96557 | 75 | }HAL_SAI_StateTypeDef; |
bogdanm | 92:4fc01daae5a5 | 76 | |
Kojto | 99:dbbf35b96557 | 77 | /** |
Kojto | 99:dbbf35b96557 | 78 | * @brief SAI Callback prototype |
Kojto | 99:dbbf35b96557 | 79 | */ |
Kojto | 99:dbbf35b96557 | 80 | typedef void (*SAIcallback)(void); |
bogdanm | 92:4fc01daae5a5 | 81 | |
bogdanm | 92:4fc01daae5a5 | 82 | /** |
bogdanm | 92:4fc01daae5a5 | 83 | * @brief SAI Init Structure definition |
bogdanm | 92:4fc01daae5a5 | 84 | */ |
bogdanm | 92:4fc01daae5a5 | 85 | typedef struct |
bogdanm | 92:4fc01daae5a5 | 86 | { |
Kojto | 99:dbbf35b96557 | 87 | uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode. |
Kojto | 99:dbbf35b96557 | 88 | This parameter can be a value of @ref SAI_Block_Mode */ |
Kojto | 99:dbbf35b96557 | 89 | |
Kojto | 99:dbbf35b96557 | 90 | uint32_t Synchro; /*!< Specifies SAI Block synchronization |
Kojto | 99:dbbf35b96557 | 91 | This parameter can be a value of @ref SAI_Block_Synchronization */ |
Kojto | 99:dbbf35b96557 | 92 | |
Kojto | 99:dbbf35b96557 | 93 | uint32_t SynchroExt; /*!< Specifies SAI Block synchronization, this setup is common |
Kojto | 99:dbbf35b96557 | 94 | for BLOCKA and BLOCKB |
Kojto | 99:dbbf35b96557 | 95 | This parameter can be a value of @ref SAI_Block_SyncExt */ |
Kojto | 99:dbbf35b96557 | 96 | |
Kojto | 99:dbbf35b96557 | 97 | uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven. |
Kojto | 99:dbbf35b96557 | 98 | This parameter can be a value of @ref SAI_Block_Output_Drive |
Kojto | 99:dbbf35b96557 | 99 | @note this value has to be set before enabling the audio block |
Kojto | 99:dbbf35b96557 | 100 | but after the audio block configuration. */ |
Kojto | 99:dbbf35b96557 | 101 | |
Kojto | 99:dbbf35b96557 | 102 | uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not. |
Kojto | 99:dbbf35b96557 | 103 | This parameter can be a value of @ref SAI_Block_NoDivider |
Kojto | 99:dbbf35b96557 | 104 | @note: If bit NODIV in the SAI_xCR1 register is cleared, the frame length |
Kojto | 99:dbbf35b96557 | 105 | should be aligned to a number equal to a power of 2, from 8 to 256. |
Kojto | 99:dbbf35b96557 | 106 | If bit NODIV in the SAI_xCR1 register is set, the frame length can |
Kojto | 99:dbbf35b96557 | 107 | take any of the values without constraint since the input clock of |
Kojto | 99:dbbf35b96557 | 108 | the audio block should be equal to the bit clock. |
Kojto | 99:dbbf35b96557 | 109 | There is no MCLK_x clock which can be output. */ |
Kojto | 99:dbbf35b96557 | 110 | |
Kojto | 99:dbbf35b96557 | 111 | uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold. |
Kojto | 99:dbbf35b96557 | 112 | This parameter can be a value of @ref SAI_Block_Fifo_Threshold */ |
Kojto | 99:dbbf35b96557 | 113 | |
Kojto | 99:dbbf35b96557 | 114 | uint32_t ClockSource; /*!< Specifies the SAI Block x Clock source. |
Kojto | 99:dbbf35b96557 | 115 | This parameter is not used for STM32F446xx devices. */ |
Kojto | 99:dbbf35b96557 | 116 | |
Kojto | 99:dbbf35b96557 | 117 | uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling. |
Kojto | 99:dbbf35b96557 | 118 | This parameter can be a value of @ref SAI_Audio_Frequency */ |
Kojto | 99:dbbf35b96557 | 119 | |
Kojto | 99:dbbf35b96557 | 120 | uint32_t Mckdiv; /*!< Specifies the master clock divider, the parameter will be used if for |
Kojto | 99:dbbf35b96557 | 121 | AudioFrequency the user choice |
Kojto | 99:dbbf35b96557 | 122 | This parameter must be a number between Min_Data = 0 and Max_Data = 15 */ |
Kojto | 99:dbbf35b96557 | 123 | |
Kojto | 99:dbbf35b96557 | 124 | uint32_t MonoStereoMode; /*!< Specifies if the mono or stereo mode is selected. |
Kojto | 99:dbbf35b96557 | 125 | This parameter can be a value of @ref SAI_Mono_Stereo_Mode */ |
Kojto | 99:dbbf35b96557 | 126 | |
Kojto | 99:dbbf35b96557 | 127 | uint32_t CompandingMode; /*!< Specifies the companding mode type. |
Kojto | 99:dbbf35b96557 | 128 | This parameter can be a value of @ref SAI_Block_Companding_Mode */ |
Kojto | 99:dbbf35b96557 | 129 | |
Kojto | 99:dbbf35b96557 | 130 | uint32_t TriState; /*!< Specifies the companding mode type. |
Kojto | 99:dbbf35b96557 | 131 | This parameter can be a value of @ref SAI_TRIState_Management */ |
Kojto | 99:dbbf35b96557 | 132 | |
Kojto | 99:dbbf35b96557 | 133 | /* This part of the structure is automatically filled if your are using the high level intialisation |
Kojto | 99:dbbf35b96557 | 134 | function HAL_SAI_InitProtocol */ |
Kojto | 99:dbbf35b96557 | 135 | |
bogdanm | 92:4fc01daae5a5 | 136 | uint32_t Protocol; /*!< Specifies the SAI Block protocol. |
Kojto | 99:dbbf35b96557 | 137 | This parameter can be a value of @ref SAI_Block_Protocol */ |
Kojto | 99:dbbf35b96557 | 138 | |
bogdanm | 92:4fc01daae5a5 | 139 | uint32_t DataSize; /*!< Specifies the SAI Block data size. |
Kojto | 99:dbbf35b96557 | 140 | This parameter can be a value of @ref SAI_Block_Data_Size */ |
bogdanm | 92:4fc01daae5a5 | 141 | |
bogdanm | 92:4fc01daae5a5 | 142 | uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. |
Kojto | 99:dbbf35b96557 | 143 | This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */ |
bogdanm | 92:4fc01daae5a5 | 144 | |
bogdanm | 92:4fc01daae5a5 | 145 | uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity. |
Kojto | 99:dbbf35b96557 | 146 | This parameter can be a value of @ref SAI_Block_Clock_Strobing */ |
bogdanm | 92:4fc01daae5a5 | 147 | }SAI_InitTypeDef; |
bogdanm | 92:4fc01daae5a5 | 148 | |
bogdanm | 92:4fc01daae5a5 | 149 | /** |
bogdanm | 92:4fc01daae5a5 | 150 | * @brief SAI Block Frame Init structure definition |
bogdanm | 92:4fc01daae5a5 | 151 | */ |
bogdanm | 92:4fc01daae5a5 | 152 | |
bogdanm | 92:4fc01daae5a5 | 153 | typedef struct |
bogdanm | 92:4fc01daae5a5 | 154 | { |
bogdanm | 92:4fc01daae5a5 | 155 | |
bogdanm | 92:4fc01daae5a5 | 156 | uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame. |
bogdanm | 92:4fc01daae5a5 | 157 | This parameter must be a number between Min_Data = 8 and Max_Data = 256. |
bogdanm | 92:4fc01daae5a5 | 158 | @note: If master clock MCLK_x pin is declared as an output, the frame length |
bogdanm | 92:4fc01daae5a5 | 159 | should be aligned to a number equal to power of 2 in order to keep |
bogdanm | 92:4fc01daae5a5 | 160 | in an audio frame, an integer number of MCLK pulses by bit Clock. */ |
bogdanm | 92:4fc01daae5a5 | 161 | |
bogdanm | 92:4fc01daae5a5 | 162 | uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length. |
bogdanm | 92:4fc01daae5a5 | 163 | This Parameter specifies the length in number of bit clock (SCK + 1) |
bogdanm | 92:4fc01daae5a5 | 164 | of the active level of FS signal in audio frame. |
bogdanm | 92:4fc01daae5a5 | 165 | This parameter must be a number between Min_Data = 1 and Max_Data = 128 */ |
bogdanm | 92:4fc01daae5a5 | 166 | |
bogdanm | 92:4fc01daae5a5 | 167 | uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition. |
bogdanm | 92:4fc01daae5a5 | 168 | This parameter can be a value of @ref SAI_Block_FS_Definition */ |
bogdanm | 92:4fc01daae5a5 | 169 | |
bogdanm | 92:4fc01daae5a5 | 170 | uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity. |
bogdanm | 92:4fc01daae5a5 | 171 | This parameter can be a value of @ref SAI_Block_FS_Polarity */ |
bogdanm | 92:4fc01daae5a5 | 172 | |
bogdanm | 92:4fc01daae5a5 | 173 | uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset. |
bogdanm | 92:4fc01daae5a5 | 174 | This parameter can be a value of @ref SAI_Block_FS_Offset */ |
bogdanm | 92:4fc01daae5a5 | 175 | |
bogdanm | 92:4fc01daae5a5 | 176 | }SAI_FrameInitTypeDef; |
bogdanm | 92:4fc01daae5a5 | 177 | |
bogdanm | 92:4fc01daae5a5 | 178 | /** |
bogdanm | 92:4fc01daae5a5 | 179 | * @brief SAI Block Slot Init Structure definition |
bogdanm | 92:4fc01daae5a5 | 180 | */ |
bogdanm | 92:4fc01daae5a5 | 181 | |
bogdanm | 92:4fc01daae5a5 | 182 | typedef struct |
bogdanm | 92:4fc01daae5a5 | 183 | { |
bogdanm | 92:4fc01daae5a5 | 184 | uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot. |
bogdanm | 92:4fc01daae5a5 | 185 | This parameter must be a number between Min_Data = 0 and Max_Data = 24 */ |
bogdanm | 92:4fc01daae5a5 | 186 | |
bogdanm | 92:4fc01daae5a5 | 187 | uint32_t SlotSize; /*!< Specifies the Slot Size. |
bogdanm | 92:4fc01daae5a5 | 188 | This parameter can be a value of @ref SAI_Block_Slot_Size */ |
bogdanm | 92:4fc01daae5a5 | 189 | |
bogdanm | 92:4fc01daae5a5 | 190 | uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame. |
bogdanm | 92:4fc01daae5a5 | 191 | This parameter must be a number between Min_Data = 1 and Max_Data = 16 */ |
bogdanm | 92:4fc01daae5a5 | 192 | |
bogdanm | 92:4fc01daae5a5 | 193 | uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated. |
bogdanm | 92:4fc01daae5a5 | 194 | This parameter can be a value of @ref SAI_Block_Slot_Active */ |
bogdanm | 92:4fc01daae5a5 | 195 | }SAI_SlotInitTypeDef; |
bogdanm | 92:4fc01daae5a5 | 196 | |
bogdanm | 92:4fc01daae5a5 | 197 | /** |
bogdanm | 92:4fc01daae5a5 | 198 | * @brief SAI handle Structure definition |
bogdanm | 92:4fc01daae5a5 | 199 | */ |
Kojto | 99:dbbf35b96557 | 200 | typedef struct __SAI_HandleTypeDef |
bogdanm | 92:4fc01daae5a5 | 201 | { |
bogdanm | 92:4fc01daae5a5 | 202 | SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */ |
bogdanm | 92:4fc01daae5a5 | 203 | |
bogdanm | 92:4fc01daae5a5 | 204 | SAI_InitTypeDef Init; /*!< SAI communication parameters */ |
bogdanm | 92:4fc01daae5a5 | 205 | |
bogdanm | 92:4fc01daae5a5 | 206 | SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */ |
bogdanm | 92:4fc01daae5a5 | 207 | |
bogdanm | 92:4fc01daae5a5 | 208 | SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */ |
bogdanm | 92:4fc01daae5a5 | 209 | |
Kojto | 99:dbbf35b96557 | 210 | uint8_t *pBuffPtr; /*!< Pointer to SAI transfer Buffer */ |
bogdanm | 92:4fc01daae5a5 | 211 | |
Kojto | 99:dbbf35b96557 | 212 | uint16_t XferSize; /*!< SAI transfer size */ |
bogdanm | 92:4fc01daae5a5 | 213 | |
Kojto | 99:dbbf35b96557 | 214 | uint16_t XferCount; /*!< SAI transfer counter */ |
bogdanm | 92:4fc01daae5a5 | 215 | |
bogdanm | 92:4fc01daae5a5 | 216 | DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */ |
bogdanm | 92:4fc01daae5a5 | 217 | |
bogdanm | 92:4fc01daae5a5 | 218 | DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */ |
bogdanm | 92:4fc01daae5a5 | 219 | |
Kojto | 99:dbbf35b96557 | 220 | SAIcallback mutecallback;/*!< SAI mute callback */ |
Kojto | 99:dbbf35b96557 | 221 | |
Kojto | 99:dbbf35b96557 | 222 | void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */ |
Kojto | 99:dbbf35b96557 | 223 | |
bogdanm | 92:4fc01daae5a5 | 224 | HAL_LockTypeDef Lock; /*!< SAI locking object */ |
bogdanm | 92:4fc01daae5a5 | 225 | |
bogdanm | 92:4fc01daae5a5 | 226 | __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */ |
bogdanm | 92:4fc01daae5a5 | 227 | |
bogdanm | 92:4fc01daae5a5 | 228 | __IO uint32_t ErrorCode; /*!< SAI Error code */ |
bogdanm | 92:4fc01daae5a5 | 229 | }SAI_HandleTypeDef; |
bogdanm | 92:4fc01daae5a5 | 230 | |
Kojto | 99:dbbf35b96557 | 231 | /** |
Kojto | 99:dbbf35b96557 | 232 | * @} |
Kojto | 99:dbbf35b96557 | 233 | */ |
Kojto | 99:dbbf35b96557 | 234 | |
bogdanm | 92:4fc01daae5a5 | 235 | /* Exported constants --------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 236 | |
Kojto | 99:dbbf35b96557 | 237 | /** @defgroup SAI_Exported_Constants SAI Exported Constants |
Kojto | 99:dbbf35b96557 | 238 | * @{ |
Kojto | 99:dbbf35b96557 | 239 | */ |
Kojto | 99:dbbf35b96557 | 240 | |
Kojto | 99:dbbf35b96557 | 241 | /** @defgroup SAI_Error_Code SAI Error Code |
bogdanm | 92:4fc01daae5a5 | 242 | * @{ |
bogdanm | 92:4fc01daae5a5 | 243 | */ |
Kojto | 99:dbbf35b96557 | 244 | #define HAL_SAI_ERROR_NONE ((uint32_t)0x00000000) /*!< No error */ |
Kojto | 99:dbbf35b96557 | 245 | #define HAL_SAI_ERROR_OVR ((uint32_t)0x00000001) /*!< Overrun Error */ |
Kojto | 99:dbbf35b96557 | 246 | #define HAL_SAI_ERROR_UDR ((uint32_t)0x00000002) /*!< Underrun error */ |
Kojto | 99:dbbf35b96557 | 247 | #define HAL_SAI_ERROR_AFSDET ((uint32_t)0x00000004) /*!< Anticipated Frame synchronisation detection */ |
Kojto | 99:dbbf35b96557 | 248 | #define HAL_SAI_ERROR_LFSDET ((uint32_t)0x00000008) /*!< Late Frame synchronisation detection */ |
Kojto | 99:dbbf35b96557 | 249 | #define HAL_SAI_ERROR_CNREADY ((uint32_t)0x00000010) /*!< codec not ready */ |
Kojto | 99:dbbf35b96557 | 250 | #define HAL_SAI_ERROR_WCKCFG ((uint32_t)0x00000020) /*!< Wrong clock configuration */ |
Kojto | 99:dbbf35b96557 | 251 | #define HAL_SAI_ERROR_TIMEOUT ((uint32_t)0x00000040) /*!< Timeout error */ |
Kojto | 99:dbbf35b96557 | 252 | /** |
Kojto | 99:dbbf35b96557 | 253 | * @} |
Kojto | 99:dbbf35b96557 | 254 | */ |
Kojto | 99:dbbf35b96557 | 255 | |
Kojto | 99:dbbf35b96557 | 256 | /** @defgroup SAI_Block_SyncExt SAI External synchronisation |
bogdanm | 92:4fc01daae5a5 | 257 | * @{ |
Kojto | 99:dbbf35b96557 | 258 | */ |
Kojto | 99:dbbf35b96557 | 259 | #define SAI_SYNCEXT_DISABLE ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 260 | #define SAI_SYNCEXT_IN_ENABLE ((uint32_t)0x00000001) |
Kojto | 99:dbbf35b96557 | 261 | #define SAI_SYNCEXT_OUTBLOCKA_ENABLE ((uint32_t)0x00000002) |
Kojto | 99:dbbf35b96557 | 262 | #define SAI_SYNCEXT_OUTBLOCKB_ENABLE ((uint32_t)0x00000004) |
bogdanm | 92:4fc01daae5a5 | 263 | /** |
bogdanm | 92:4fc01daae5a5 | 264 | * @} |
bogdanm | 92:4fc01daae5a5 | 265 | */ |
bogdanm | 92:4fc01daae5a5 | 266 | |
Kojto | 99:dbbf35b96557 | 267 | /** @defgroup SAI_Protocol SAI Supported protocol |
bogdanm | 92:4fc01daae5a5 | 268 | * @{ |
bogdanm | 92:4fc01daae5a5 | 269 | */ |
Kojto | 99:dbbf35b96557 | 270 | #define SAI_I2S_STANDARD ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 271 | #define SAI_I2S_MSBJUSTIFIED ((uint32_t)0x00000001) |
Kojto | 99:dbbf35b96557 | 272 | #define SAI_I2S_LSBJUSTIFIED ((uint32_t)0x00000002) |
Kojto | 99:dbbf35b96557 | 273 | #define SAI_PCM_LONG ((uint32_t)0x00000004) |
Kojto | 99:dbbf35b96557 | 274 | #define SAI_PCM_SHORT ((uint32_t)0x00000008) |
bogdanm | 92:4fc01daae5a5 | 275 | /** |
bogdanm | 92:4fc01daae5a5 | 276 | * @} |
bogdanm | 92:4fc01daae5a5 | 277 | */ |
bogdanm | 92:4fc01daae5a5 | 278 | |
Kojto | 99:dbbf35b96557 | 279 | /** @defgroup SAI_Protocol_DataSize SAI protocol data size |
Kojto | 99:dbbf35b96557 | 280 | * @{ |
Kojto | 99:dbbf35b96557 | 281 | */ |
Kojto | 99:dbbf35b96557 | 282 | #define SAI_PROTOCOL_DATASIZE_16BIT ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 283 | #define SAI_PROTOCOL_DATASIZE_16BITEXTENDED ((uint32_t)0x00000001) |
Kojto | 99:dbbf35b96557 | 284 | #define SAI_PROTOCOL_DATASIZE_24BIT ((uint32_t)0x00000002) |
Kojto | 99:dbbf35b96557 | 285 | #define SAI_PROTOCOL_DATASIZE_32BIT ((uint32_t)0x00000004) |
Kojto | 99:dbbf35b96557 | 286 | /** |
Kojto | 99:dbbf35b96557 | 287 | * @} |
Kojto | 99:dbbf35b96557 | 288 | */ |
Kojto | 99:dbbf35b96557 | 289 | |
Kojto | 99:dbbf35b96557 | 290 | /** @defgroup SAI_Clock_Source SAI Clock Source |
Kojto | 99:dbbf35b96557 | 291 | * @{ |
Kojto | 99:dbbf35b96557 | 292 | */ |
Kojto | 99:dbbf35b96557 | 293 | #define SAI_CLKSOURCE_PLLSAI ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 294 | #define SAI_CLKSOURCE_PLLI2S ((uint32_t)0x00100000) |
Kojto | 99:dbbf35b96557 | 295 | #define SAI_CLKSOURCE_EXT ((uint32_t)0x00200000) |
Kojto | 99:dbbf35b96557 | 296 | #define SAI_CLKSOURCE_NA ((uint32_t)0x00400000) /*!< No applicable for STM32F446xx */ |
Kojto | 99:dbbf35b96557 | 297 | /** |
Kojto | 99:dbbf35b96557 | 298 | * @} |
Kojto | 99:dbbf35b96557 | 299 | */ |
Kojto | 99:dbbf35b96557 | 300 | |
Kojto | 99:dbbf35b96557 | 301 | /** @defgroup SAI_Audio_Frequency SAI Audio Frequency |
bogdanm | 92:4fc01daae5a5 | 302 | * @{ |
bogdanm | 92:4fc01daae5a5 | 303 | */ |
bogdanm | 92:4fc01daae5a5 | 304 | #define SAI_AUDIO_FREQUENCY_192K ((uint32_t)192000) |
bogdanm | 92:4fc01daae5a5 | 305 | #define SAI_AUDIO_FREQUENCY_96K ((uint32_t)96000) |
bogdanm | 92:4fc01daae5a5 | 306 | #define SAI_AUDIO_FREQUENCY_48K ((uint32_t)48000) |
bogdanm | 92:4fc01daae5a5 | 307 | #define SAI_AUDIO_FREQUENCY_44K ((uint32_t)44100) |
bogdanm | 92:4fc01daae5a5 | 308 | #define SAI_AUDIO_FREQUENCY_32K ((uint32_t)32000) |
bogdanm | 92:4fc01daae5a5 | 309 | #define SAI_AUDIO_FREQUENCY_22K ((uint32_t)22050) |
bogdanm | 92:4fc01daae5a5 | 310 | #define SAI_AUDIO_FREQUENCY_16K ((uint32_t)16000) |
bogdanm | 92:4fc01daae5a5 | 311 | #define SAI_AUDIO_FREQUENCY_11K ((uint32_t)11025) |
Kojto | 99:dbbf35b96557 | 312 | #define SAI_AUDIO_FREQUENCY_8K ((uint32_t)8000) |
Kojto | 99:dbbf35b96557 | 313 | #define SAI_AUDIO_FREQUENCY_MCKDIV ((uint32_t)0) |
bogdanm | 92:4fc01daae5a5 | 314 | |
bogdanm | 92:4fc01daae5a5 | 315 | /** |
bogdanm | 92:4fc01daae5a5 | 316 | * @} |
bogdanm | 92:4fc01daae5a5 | 317 | */ |
bogdanm | 92:4fc01daae5a5 | 318 | |
Kojto | 99:dbbf35b96557 | 319 | /** @defgroup SAI_Block_Mode SAI Block Mode |
bogdanm | 92:4fc01daae5a5 | 320 | * @{ |
bogdanm | 92:4fc01daae5a5 | 321 | */ |
bogdanm | 92:4fc01daae5a5 | 322 | #define SAI_MODEMASTER_TX ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 323 | #define SAI_MODEMASTER_RX ((uint32_t)SAI_xCR1_MODE_0) |
Kojto | 99:dbbf35b96557 | 324 | #define SAI_MODESLAVE_TX ((uint32_t)SAI_xCR1_MODE_1) |
Kojto | 99:dbbf35b96557 | 325 | #define SAI_MODESLAVE_RX ((uint32_t)(SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0)) |
Kojto | 99:dbbf35b96557 | 326 | |
bogdanm | 92:4fc01daae5a5 | 327 | /** |
bogdanm | 92:4fc01daae5a5 | 328 | * @} |
bogdanm | 92:4fc01daae5a5 | 329 | */ |
bogdanm | 92:4fc01daae5a5 | 330 | |
Kojto | 99:dbbf35b96557 | 331 | /** @defgroup SAI_Block_Protocol SAI Block Protocol |
bogdanm | 92:4fc01daae5a5 | 332 | * @{ |
bogdanm | 92:4fc01daae5a5 | 333 | */ |
bogdanm | 92:4fc01daae5a5 | 334 | #define SAI_FREE_PROTOCOL ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 335 | #define SAI_SPDIF_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_0) |
bogdanm | 92:4fc01daae5a5 | 336 | #define SAI_AC97_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_1) |
bogdanm | 92:4fc01daae5a5 | 337 | |
bogdanm | 92:4fc01daae5a5 | 338 | /** |
bogdanm | 92:4fc01daae5a5 | 339 | * @} |
bogdanm | 92:4fc01daae5a5 | 340 | */ |
bogdanm | 92:4fc01daae5a5 | 341 | |
Kojto | 99:dbbf35b96557 | 342 | /** @defgroup SAI_Block_Data_Size SAI Block Data Size |
bogdanm | 92:4fc01daae5a5 | 343 | * @{ |
bogdanm | 92:4fc01daae5a5 | 344 | */ |
Kojto | 99:dbbf35b96557 | 345 | #define SAI_DATASIZE_8 ((uint32_t)SAI_xCR1_DS_1) |
Kojto | 99:dbbf35b96557 | 346 | #define SAI_DATASIZE_10 ((uint32_t)(SAI_xCR1_DS_1 | SAI_xCR1_DS_0)) |
Kojto | 99:dbbf35b96557 | 347 | #define SAI_DATASIZE_16 ((uint32_t)SAI_xCR1_DS_2) |
Kojto | 99:dbbf35b96557 | 348 | #define SAI_DATASIZE_20 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_0)) |
Kojto | 99:dbbf35b96557 | 349 | #define SAI_DATASIZE_24 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_1)) |
Kojto | 99:dbbf35b96557 | 350 | #define SAI_DATASIZE_32 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0)) |
bogdanm | 92:4fc01daae5a5 | 351 | |
bogdanm | 92:4fc01daae5a5 | 352 | /** |
bogdanm | 92:4fc01daae5a5 | 353 | * @} |
bogdanm | 92:4fc01daae5a5 | 354 | */ |
bogdanm | 92:4fc01daae5a5 | 355 | |
Kojto | 99:dbbf35b96557 | 356 | /** @defgroup SAI_Block_MSB_LSB_transmission SAI Block MSB LSB transmission |
bogdanm | 92:4fc01daae5a5 | 357 | * @{ |
bogdanm | 92:4fc01daae5a5 | 358 | */ |
bogdanm | 92:4fc01daae5a5 | 359 | #define SAI_FIRSTBIT_MSB ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 360 | #define SAI_FIRSTBIT_LSB ((uint32_t)SAI_xCR1_LSBFIRST) |
bogdanm | 92:4fc01daae5a5 | 361 | |
bogdanm | 92:4fc01daae5a5 | 362 | /** |
bogdanm | 92:4fc01daae5a5 | 363 | * @} |
bogdanm | 92:4fc01daae5a5 | 364 | */ |
bogdanm | 92:4fc01daae5a5 | 365 | |
Kojto | 99:dbbf35b96557 | 366 | /** @defgroup SAI_Block_Clock_Strobing SAI Block Clock Strobing |
bogdanm | 92:4fc01daae5a5 | 367 | * @{ |
bogdanm | 92:4fc01daae5a5 | 368 | */ |
bogdanm | 92:4fc01daae5a5 | 369 | #define SAI_CLOCKSTROBING_FALLINGEDGE ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 370 | #define SAI_CLOCKSTROBING_RISINGEDGE ((uint32_t)SAI_xCR1_CKSTR) |
bogdanm | 92:4fc01daae5a5 | 371 | |
bogdanm | 92:4fc01daae5a5 | 372 | /** |
bogdanm | 92:4fc01daae5a5 | 373 | * @} |
bogdanm | 92:4fc01daae5a5 | 374 | */ |
bogdanm | 92:4fc01daae5a5 | 375 | |
Kojto | 99:dbbf35b96557 | 376 | /** @defgroup SAI_Block_Synchronization SAI Block Synchronization |
bogdanm | 92:4fc01daae5a5 | 377 | * @{ |
bogdanm | 92:4fc01daae5a5 | 378 | */ |
bogdanm | 92:4fc01daae5a5 | 379 | #define SAI_ASYNCHRONOUS ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 380 | #define SAI_SYNCHRONOUS ((uint32_t)SAI_xCR1_SYNCEN_0) |
Kojto | 99:dbbf35b96557 | 381 | #define SAI_SYNCHRONOUS_EXT ((uint32_t)SAI_xCR1_SYNCEN_1) |
bogdanm | 92:4fc01daae5a5 | 382 | |
bogdanm | 92:4fc01daae5a5 | 383 | /** |
bogdanm | 92:4fc01daae5a5 | 384 | * @} |
bogdanm | 92:4fc01daae5a5 | 385 | */ |
bogdanm | 92:4fc01daae5a5 | 386 | |
Kojto | 99:dbbf35b96557 | 387 | /** @defgroup SAI_Block_Output_Drive SAI Block Output Drive |
bogdanm | 92:4fc01daae5a5 | 388 | * @{ |
bogdanm | 92:4fc01daae5a5 | 389 | */ |
Kojto | 99:dbbf35b96557 | 390 | #define SAI_OUTPUTDRIVE_DISABLE ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 391 | #define SAI_OUTPUTDRIVE_ENABLE ((uint32_t)SAI_xCR1_OUTDRIV) |
Kojto | 99:dbbf35b96557 | 392 | |
Kojto | 99:dbbf35b96557 | 393 | /** |
Kojto | 99:dbbf35b96557 | 394 | * @} |
Kojto | 99:dbbf35b96557 | 395 | */ |
bogdanm | 92:4fc01daae5a5 | 396 | |
Kojto | 99:dbbf35b96557 | 397 | /** @defgroup SAI_Block_NoDivider SAI Block NoDivider |
Kojto | 99:dbbf35b96557 | 398 | * @{ |
Kojto | 99:dbbf35b96557 | 399 | */ |
Kojto | 99:dbbf35b96557 | 400 | #define SAI_MASTERDIVIDER_ENABLE ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 401 | #define SAI_MASTERDIVIDER_DISABLE ((uint32_t)SAI_xCR1_NODIV) |
Kojto | 99:dbbf35b96557 | 402 | |
bogdanm | 92:4fc01daae5a5 | 403 | /** |
bogdanm | 92:4fc01daae5a5 | 404 | * @} |
bogdanm | 92:4fc01daae5a5 | 405 | */ |
bogdanm | 92:4fc01daae5a5 | 406 | |
bogdanm | 92:4fc01daae5a5 | 407 | |
Kojto | 99:dbbf35b96557 | 408 | /** @defgroup SAI_Block_FS_Definition SAI Block FS Definition |
bogdanm | 92:4fc01daae5a5 | 409 | * @{ |
bogdanm | 92:4fc01daae5a5 | 410 | */ |
bogdanm | 92:4fc01daae5a5 | 411 | #define SAI_FS_STARTFRAME ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 412 | #define SAI_FS_CHANNEL_IDENTIFICATION ((uint32_t)SAI_xFRCR_FSDEF) |
bogdanm | 92:4fc01daae5a5 | 413 | |
bogdanm | 92:4fc01daae5a5 | 414 | /** |
bogdanm | 92:4fc01daae5a5 | 415 | * @} |
bogdanm | 92:4fc01daae5a5 | 416 | */ |
bogdanm | 92:4fc01daae5a5 | 417 | |
Kojto | 99:dbbf35b96557 | 418 | /** @defgroup SAI_Block_FS_Polarity SAI Block FS Polarity |
bogdanm | 92:4fc01daae5a5 | 419 | * @{ |
bogdanm | 92:4fc01daae5a5 | 420 | */ |
bogdanm | 92:4fc01daae5a5 | 421 | #define SAI_FS_ACTIVE_LOW ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 422 | #define SAI_FS_ACTIVE_HIGH ((uint32_t)SAI_xFRCR_FSPO) |
bogdanm | 92:4fc01daae5a5 | 423 | |
bogdanm | 92:4fc01daae5a5 | 424 | /** |
bogdanm | 92:4fc01daae5a5 | 425 | * @} |
bogdanm | 92:4fc01daae5a5 | 426 | */ |
bogdanm | 92:4fc01daae5a5 | 427 | |
Kojto | 99:dbbf35b96557 | 428 | /** @defgroup SAI_Block_FS_Offset SAI Block FS Offset |
bogdanm | 92:4fc01daae5a5 | 429 | * @{ |
bogdanm | 92:4fc01daae5a5 | 430 | */ |
bogdanm | 92:4fc01daae5a5 | 431 | #define SAI_FS_FIRSTBIT ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 432 | #define SAI_FS_BEFOREFIRSTBIT ((uint32_t)SAI_xFRCR_FSOFF) |
bogdanm | 92:4fc01daae5a5 | 433 | |
bogdanm | 92:4fc01daae5a5 | 434 | /** |
bogdanm | 92:4fc01daae5a5 | 435 | * @} |
bogdanm | 92:4fc01daae5a5 | 436 | */ |
bogdanm | 92:4fc01daae5a5 | 437 | |
bogdanm | 92:4fc01daae5a5 | 438 | |
Kojto | 99:dbbf35b96557 | 439 | /** @defgroup SAI_Block_Slot_Size SAI Block Slot Size |
bogdanm | 92:4fc01daae5a5 | 440 | * @{ |
bogdanm | 92:4fc01daae5a5 | 441 | */ |
bogdanm | 92:4fc01daae5a5 | 442 | #define SAI_SLOTSIZE_DATASIZE ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 443 | #define SAI_SLOTSIZE_16B ((uint32_t)SAI_xSLOTR_SLOTSZ_0) |
bogdanm | 92:4fc01daae5a5 | 444 | #define SAI_SLOTSIZE_32B ((uint32_t)SAI_xSLOTR_SLOTSZ_1) |
bogdanm | 92:4fc01daae5a5 | 445 | /** |
bogdanm | 92:4fc01daae5a5 | 446 | * @} |
bogdanm | 92:4fc01daae5a5 | 447 | */ |
bogdanm | 92:4fc01daae5a5 | 448 | |
Kojto | 99:dbbf35b96557 | 449 | /** @defgroup SAI_Block_Slot_Active SAI Block Slot Active |
bogdanm | 92:4fc01daae5a5 | 450 | * @{ |
bogdanm | 92:4fc01daae5a5 | 451 | */ |
bogdanm | 92:4fc01daae5a5 | 452 | #define SAI_SLOT_NOTACTIVE ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 453 | #define SAI_SLOTACTIVE_0 ((uint32_t)0x00010000) |
bogdanm | 92:4fc01daae5a5 | 454 | #define SAI_SLOTACTIVE_1 ((uint32_t)0x00020000) |
bogdanm | 92:4fc01daae5a5 | 455 | #define SAI_SLOTACTIVE_2 ((uint32_t)0x00040000) |
bogdanm | 92:4fc01daae5a5 | 456 | #define SAI_SLOTACTIVE_3 ((uint32_t)0x00080000) |
bogdanm | 92:4fc01daae5a5 | 457 | #define SAI_SLOTACTIVE_4 ((uint32_t)0x00100000) |
bogdanm | 92:4fc01daae5a5 | 458 | #define SAI_SLOTACTIVE_5 ((uint32_t)0x00200000) |
bogdanm | 92:4fc01daae5a5 | 459 | #define SAI_SLOTACTIVE_6 ((uint32_t)0x00400000) |
bogdanm | 92:4fc01daae5a5 | 460 | #define SAI_SLOTACTIVE_7 ((uint32_t)0x00800000) |
bogdanm | 92:4fc01daae5a5 | 461 | #define SAI_SLOTACTIVE_8 ((uint32_t)0x01000000) |
bogdanm | 92:4fc01daae5a5 | 462 | #define SAI_SLOTACTIVE_9 ((uint32_t)0x02000000) |
bogdanm | 92:4fc01daae5a5 | 463 | #define SAI_SLOTACTIVE_10 ((uint32_t)0x04000000) |
bogdanm | 92:4fc01daae5a5 | 464 | #define SAI_SLOTACTIVE_11 ((uint32_t)0x08000000) |
bogdanm | 92:4fc01daae5a5 | 465 | #define SAI_SLOTACTIVE_12 ((uint32_t)0x10000000) |
bogdanm | 92:4fc01daae5a5 | 466 | #define SAI_SLOTACTIVE_13 ((uint32_t)0x20000000) |
bogdanm | 92:4fc01daae5a5 | 467 | #define SAI_SLOTACTIVE_14 ((uint32_t)0x40000000) |
bogdanm | 92:4fc01daae5a5 | 468 | #define SAI_SLOTACTIVE_15 ((uint32_t)0x80000000) |
bogdanm | 92:4fc01daae5a5 | 469 | #define SAI_SLOTACTIVE_ALL ((uint32_t)0xFFFF0000) |
bogdanm | 92:4fc01daae5a5 | 470 | |
Kojto | 99:dbbf35b96557 | 471 | /** |
Kojto | 99:dbbf35b96557 | 472 | * @} |
Kojto | 99:dbbf35b96557 | 473 | */ |
Kojto | 99:dbbf35b96557 | 474 | |
Kojto | 99:dbbf35b96557 | 475 | /** @defgroup SAI_Mono_Stereo_Mode SAI Mono Stereo Mode |
Kojto | 99:dbbf35b96557 | 476 | * @{ |
Kojto | 99:dbbf35b96557 | 477 | */ |
Kojto | 99:dbbf35b96557 | 478 | #define SAI_STEREOMODE ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 479 | #define SAI_MONOMODE ((uint32_t)SAI_xCR1_MONO) |
bogdanm | 92:4fc01daae5a5 | 480 | |
bogdanm | 92:4fc01daae5a5 | 481 | /** |
bogdanm | 92:4fc01daae5a5 | 482 | * @} |
bogdanm | 92:4fc01daae5a5 | 483 | */ |
bogdanm | 92:4fc01daae5a5 | 484 | |
Kojto | 99:dbbf35b96557 | 485 | /** @defgroup SAI_TRIState_Management SAI TRIState Management |
bogdanm | 92:4fc01daae5a5 | 486 | * @{ |
bogdanm | 92:4fc01daae5a5 | 487 | */ |
bogdanm | 92:4fc01daae5a5 | 488 | #define SAI_OUTPUT_NOTRELEASED ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 489 | #define SAI_OUTPUT_RELEASED ((uint32_t)SAI_xCR2_TRIS) |
bogdanm | 92:4fc01daae5a5 | 490 | |
bogdanm | 92:4fc01daae5a5 | 491 | /** |
bogdanm | 92:4fc01daae5a5 | 492 | * @} |
bogdanm | 92:4fc01daae5a5 | 493 | */ |
bogdanm | 92:4fc01daae5a5 | 494 | |
Kojto | 99:dbbf35b96557 | 495 | /** @defgroup SAI_Block_Fifo_Threshold SAI Block Fifo Threshold |
bogdanm | 92:4fc01daae5a5 | 496 | * @{ |
bogdanm | 92:4fc01daae5a5 | 497 | */ |
bogdanm | 92:4fc01daae5a5 | 498 | #define SAI_FIFOTHRESHOLD_EMPTY ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 499 | #define SAI_FIFOTHRESHOLD_1QF ((uint32_t)SAI_xCR2_FTH_0) |
Kojto | 99:dbbf35b96557 | 500 | #define SAI_FIFOTHRESHOLD_HF ((uint32_t)SAI_xCR2_FTH_1) |
Kojto | 99:dbbf35b96557 | 501 | #define SAI_FIFOTHRESHOLD_3QF ((uint32_t)(SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0)) |
Kojto | 99:dbbf35b96557 | 502 | #define SAI_FIFOTHRESHOLD_FULL ((uint32_t)SAI_xCR2_FTH_2) |
bogdanm | 92:4fc01daae5a5 | 503 | |
bogdanm | 92:4fc01daae5a5 | 504 | /** |
bogdanm | 92:4fc01daae5a5 | 505 | * @} |
bogdanm | 92:4fc01daae5a5 | 506 | */ |
bogdanm | 92:4fc01daae5a5 | 507 | |
Kojto | 99:dbbf35b96557 | 508 | /** @defgroup SAI_Block_Companding_Mode SAI Block Companding Mode |
bogdanm | 92:4fc01daae5a5 | 509 | * @{ |
bogdanm | 92:4fc01daae5a5 | 510 | */ |
bogdanm | 92:4fc01daae5a5 | 511 | #define SAI_NOCOMPANDING ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 512 | #define SAI_ULAW_1CPL_COMPANDING ((uint32_t)SAI_xCR2_COMP_1) |
Kojto | 99:dbbf35b96557 | 513 | #define SAI_ALAW_1CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0)) |
Kojto | 99:dbbf35b96557 | 514 | #define SAI_ULAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_CPL)) |
Kojto | 99:dbbf35b96557 | 515 | #define SAI_ALAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL)) |
bogdanm | 92:4fc01daae5a5 | 516 | |
bogdanm | 92:4fc01daae5a5 | 517 | /** |
bogdanm | 92:4fc01daae5a5 | 518 | * @} |
bogdanm | 92:4fc01daae5a5 | 519 | */ |
bogdanm | 92:4fc01daae5a5 | 520 | |
Kojto | 99:dbbf35b96557 | 521 | /** @defgroup SAI_Block_Mute_Value SAI Block Mute Value |
bogdanm | 92:4fc01daae5a5 | 522 | * @{ |
bogdanm | 92:4fc01daae5a5 | 523 | */ |
bogdanm | 92:4fc01daae5a5 | 524 | #define SAI_ZERO_VALUE ((uint32_t)0x00000000) |
bogdanm | 92:4fc01daae5a5 | 525 | #define SAI_LAST_SENT_VALUE ((uint32_t)SAI_xCR2_MUTEVAL) |
bogdanm | 92:4fc01daae5a5 | 526 | |
bogdanm | 92:4fc01daae5a5 | 527 | /** |
bogdanm | 92:4fc01daae5a5 | 528 | * @} |
bogdanm | 92:4fc01daae5a5 | 529 | */ |
bogdanm | 92:4fc01daae5a5 | 530 | |
bogdanm | 92:4fc01daae5a5 | 531 | |
Kojto | 99:dbbf35b96557 | 532 | /** @defgroup SAI_Block_Interrupts_Definition SAI Block Interrupts Definition |
bogdanm | 92:4fc01daae5a5 | 533 | * @{ |
bogdanm | 92:4fc01daae5a5 | 534 | */ |
bogdanm | 92:4fc01daae5a5 | 535 | #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE) |
bogdanm | 92:4fc01daae5a5 | 536 | #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE) |
bogdanm | 92:4fc01daae5a5 | 537 | #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE) |
bogdanm | 92:4fc01daae5a5 | 538 | #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE) |
bogdanm | 92:4fc01daae5a5 | 539 | #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE) |
bogdanm | 92:4fc01daae5a5 | 540 | #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE) |
bogdanm | 92:4fc01daae5a5 | 541 | #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE) |
bogdanm | 92:4fc01daae5a5 | 542 | |
bogdanm | 92:4fc01daae5a5 | 543 | /** |
bogdanm | 92:4fc01daae5a5 | 544 | * @} |
bogdanm | 92:4fc01daae5a5 | 545 | */ |
bogdanm | 92:4fc01daae5a5 | 546 | |
Kojto | 99:dbbf35b96557 | 547 | /** @defgroup SAI_Block_Flags_Definition SAI Block Flags Definition |
bogdanm | 92:4fc01daae5a5 | 548 | * @{ |
bogdanm | 92:4fc01daae5a5 | 549 | */ |
bogdanm | 92:4fc01daae5a5 | 550 | #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR) |
bogdanm | 92:4fc01daae5a5 | 551 | #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET) |
bogdanm | 92:4fc01daae5a5 | 552 | #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG) |
bogdanm | 92:4fc01daae5a5 | 553 | #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ) |
bogdanm | 92:4fc01daae5a5 | 554 | #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY) |
bogdanm | 92:4fc01daae5a5 | 555 | #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET) |
bogdanm | 92:4fc01daae5a5 | 556 | #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET) |
bogdanm | 92:4fc01daae5a5 | 557 | |
bogdanm | 92:4fc01daae5a5 | 558 | /** |
bogdanm | 92:4fc01daae5a5 | 559 | * @} |
bogdanm | 92:4fc01daae5a5 | 560 | */ |
bogdanm | 92:4fc01daae5a5 | 561 | |
Kojto | 99:dbbf35b96557 | 562 | /** @defgroup SAI_Block_Fifo_Status_Level SAI Block Fifo Status Level |
bogdanm | 92:4fc01daae5a5 | 563 | * @{ |
bogdanm | 92:4fc01daae5a5 | 564 | */ |
Kojto | 99:dbbf35b96557 | 565 | #define SAI_FIFOSTATUS_EMPTY ((uint32_t)0x00000000) |
Kojto | 99:dbbf35b96557 | 566 | #define SAI_FIFOSTATUS_LESS1QUARTERFULL ((uint32_t)0x00010000) |
Kojto | 99:dbbf35b96557 | 567 | #define SAI_FIFOSTATUS_1QUARTERFULL ((uint32_t)0x00020000) |
Kojto | 99:dbbf35b96557 | 568 | #define SAI_FIFOSTATUS_HALFFULL ((uint32_t)0x00030000) |
Kojto | 99:dbbf35b96557 | 569 | #define SAI_FIFOSTATUS_3QUARTERFULL ((uint32_t)0x00040000) |
Kojto | 99:dbbf35b96557 | 570 | #define SAI_FIFOSTATUS_FULL ((uint32_t)0x00050000) |
bogdanm | 92:4fc01daae5a5 | 571 | |
bogdanm | 92:4fc01daae5a5 | 572 | /** |
bogdanm | 92:4fc01daae5a5 | 573 | * @} |
bogdanm | 92:4fc01daae5a5 | 574 | */ |
bogdanm | 92:4fc01daae5a5 | 575 | |
bogdanm | 92:4fc01daae5a5 | 576 | /** |
bogdanm | 92:4fc01daae5a5 | 577 | * @} |
bogdanm | 92:4fc01daae5a5 | 578 | */ |
bogdanm | 92:4fc01daae5a5 | 579 | |
bogdanm | 92:4fc01daae5a5 | 580 | /* Exported macro ------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 581 | |
Kojto | 99:dbbf35b96557 | 582 | /** @defgroup SAI_Exported_Macros SAI Exported Macros |
Kojto | 99:dbbf35b96557 | 583 | * @brief macros to handle interrupts and specific configurations |
Kojto | 99:dbbf35b96557 | 584 | * @{ |
Kojto | 99:dbbf35b96557 | 585 | */ |
Kojto | 99:dbbf35b96557 | 586 | |
bogdanm | 92:4fc01daae5a5 | 587 | /** @brief Reset SAI handle state |
bogdanm | 92:4fc01daae5a5 | 588 | * @param __HANDLE__: specifies the SAI Handle. |
bogdanm | 92:4fc01daae5a5 | 589 | * @retval None |
bogdanm | 92:4fc01daae5a5 | 590 | */ |
bogdanm | 92:4fc01daae5a5 | 591 | #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET) |
bogdanm | 92:4fc01daae5a5 | 592 | |
bogdanm | 92:4fc01daae5a5 | 593 | /** @brief Enable or disable the specified SAI interrupts. |
bogdanm | 92:4fc01daae5a5 | 594 | * @param __HANDLE__: specifies the SAI Handle. |
bogdanm | 92:4fc01daae5a5 | 595 | * @param __INTERRUPT__: specifies the interrupt source to enable or disable. |
bogdanm | 92:4fc01daae5a5 | 596 | * This parameter can be one of the following values: |
bogdanm | 92:4fc01daae5a5 | 597 | * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable |
bogdanm | 92:4fc01daae5a5 | 598 | * @arg SAI_IT_MUTEDET: Mute detection interrupt enable |
bogdanm | 92:4fc01daae5a5 | 599 | * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable |
bogdanm | 92:4fc01daae5a5 | 600 | * @arg SAI_IT_FREQ: FIFO request interrupt enable |
bogdanm | 92:4fc01daae5a5 | 601 | * @arg SAI_IT_CNRDY: Codec not ready interrupt enable |
bogdanm | 92:4fc01daae5a5 | 602 | * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable |
bogdanm | 92:4fc01daae5a5 | 603 | * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enabl |
bogdanm | 92:4fc01daae5a5 | 604 | * @retval None |
bogdanm | 92:4fc01daae5a5 | 605 | */ |
bogdanm | 92:4fc01daae5a5 | 606 | |
bogdanm | 92:4fc01daae5a5 | 607 | #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__)) |
bogdanm | 92:4fc01daae5a5 | 608 | #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__))) |
bogdanm | 92:4fc01daae5a5 | 609 | |
bogdanm | 92:4fc01daae5a5 | 610 | /** @brief Check if the specified SAI interrupt source is enabled or disabled. |
bogdanm | 92:4fc01daae5a5 | 611 | * @param __HANDLE__: specifies the SAI Handle. |
bogdanm | 92:4fc01daae5a5 | 612 | * This parameter can be SAI where x: 1, 2, or 3 to select the SAI peripheral. |
bogdanm | 92:4fc01daae5a5 | 613 | * @param __INTERRUPT__: specifies the SAI interrupt source to check. |
bogdanm | 92:4fc01daae5a5 | 614 | * This parameter can be one of the following values: |
bogdanm | 92:4fc01daae5a5 | 615 | * @arg SAI_IT_TXE: Tx buffer empty interrupt enable. |
bogdanm | 92:4fc01daae5a5 | 616 | * @arg SAI_IT_RXNE: Rx buffer not empty interrupt enable. |
bogdanm | 92:4fc01daae5a5 | 617 | * @arg SAI_IT_ERR: Error interrupt enable. |
bogdanm | 92:4fc01daae5a5 | 618 | * @retval The new state of __INTERRUPT__ (TRUE or FALSE). |
bogdanm | 92:4fc01daae5a5 | 619 | */ |
bogdanm | 92:4fc01daae5a5 | 620 | #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET) |
bogdanm | 92:4fc01daae5a5 | 621 | |
bogdanm | 92:4fc01daae5a5 | 622 | /** @brief Check whether the specified SAI flag is set or not. |
bogdanm | 92:4fc01daae5a5 | 623 | * @param __HANDLE__: specifies the SAI Handle. |
bogdanm | 92:4fc01daae5a5 | 624 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 92:4fc01daae5a5 | 625 | * This parameter can be one of the following values: |
bogdanm | 92:4fc01daae5a5 | 626 | * @arg SAI_FLAG_OVRUDR: Overrun underrun flag. |
bogdanm | 92:4fc01daae5a5 | 627 | * @arg SAI_FLAG_MUTEDET: Mute detection flag. |
bogdanm | 92:4fc01daae5a5 | 628 | * @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag. |
bogdanm | 92:4fc01daae5a5 | 629 | * @arg SAI_FLAG_FREQ: FIFO request flag. |
bogdanm | 92:4fc01daae5a5 | 630 | * @arg SAI_FLAG_CNRDY: Codec not ready flag. |
bogdanm | 92:4fc01daae5a5 | 631 | * @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag. |
bogdanm | 92:4fc01daae5a5 | 632 | * @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag. |
bogdanm | 92:4fc01daae5a5 | 633 | * @retval The new state of __FLAG__ (TRUE or FALSE). |
bogdanm | 92:4fc01daae5a5 | 634 | */ |
bogdanm | 92:4fc01daae5a5 | 635 | #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__)) |
bogdanm | 92:4fc01daae5a5 | 636 | |
bogdanm | 92:4fc01daae5a5 | 637 | /** @brief Clears the specified SAI pending flag. |
bogdanm | 92:4fc01daae5a5 | 638 | * @param __HANDLE__: specifies the SAI Handle. |
bogdanm | 92:4fc01daae5a5 | 639 | * @param __FLAG__: specifies the flag to check. |
bogdanm | 92:4fc01daae5a5 | 640 | * This parameter can be any combination of the following values: |
bogdanm | 92:4fc01daae5a5 | 641 | * @arg SAI_FLAG_OVRUDR: Clear Overrun underrun |
bogdanm | 92:4fc01daae5a5 | 642 | * @arg SAI_FLAG_MUTEDET: Clear Mute detection |
bogdanm | 92:4fc01daae5a5 | 643 | * @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration |
bogdanm | 92:4fc01daae5a5 | 644 | * @arg SAI_FLAG_FREQ: Clear FIFO request |
bogdanm | 92:4fc01daae5a5 | 645 | * @arg SAI_FLAG_CNRDY: Clear Codec not ready |
bogdanm | 92:4fc01daae5a5 | 646 | * @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection |
bogdanm | 92:4fc01daae5a5 | 647 | * @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection |
bogdanm | 92:4fc01daae5a5 | 648 | * |
bogdanm | 92:4fc01daae5a5 | 649 | * @retval None |
bogdanm | 92:4fc01daae5a5 | 650 | */ |
bogdanm | 92:4fc01daae5a5 | 651 | #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__)) |
bogdanm | 92:4fc01daae5a5 | 652 | |
bogdanm | 92:4fc01daae5a5 | 653 | #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN) |
bogdanm | 92:4fc01daae5a5 | 654 | #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN) |
Kojto | 99:dbbf35b96557 | 655 | |
Kojto | 99:dbbf35b96557 | 656 | /** |
Kojto | 99:dbbf35b96557 | 657 | * @} |
Kojto | 99:dbbf35b96557 | 658 | */ |
Kojto | 99:dbbf35b96557 | 659 | |
Kojto | 99:dbbf35b96557 | 660 | /* Include RCC SAI Extension module */ |
Kojto | 99:dbbf35b96557 | 661 | #include "stm32f4xx_hal_sai_ex.h" |
Kojto | 99:dbbf35b96557 | 662 | |
bogdanm | 92:4fc01daae5a5 | 663 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 92:4fc01daae5a5 | 664 | |
Kojto | 99:dbbf35b96557 | 665 | /** @addtogroup SAI_Exported_Functions |
Kojto | 99:dbbf35b96557 | 666 | * @{ |
Kojto | 99:dbbf35b96557 | 667 | */ |
Kojto | 99:dbbf35b96557 | 668 | |
bogdanm | 92:4fc01daae5a5 | 669 | /* Initialization/de-initialization functions **********************************/ |
Kojto | 99:dbbf35b96557 | 670 | /** @addtogroup SAI_Exported_Functions_Group1 |
Kojto | 99:dbbf35b96557 | 671 | * @{ |
Kojto | 99:dbbf35b96557 | 672 | */ |
Kojto | 99:dbbf35b96557 | 673 | HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot); |
bogdanm | 92:4fc01daae5a5 | 674 | HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 675 | HAL_StatusTypeDef HAL_SAI_DeInit (SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 676 | void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 677 | void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 678 | |
Kojto | 99:dbbf35b96557 | 679 | /** |
Kojto | 99:dbbf35b96557 | 680 | * @} |
Kojto | 99:dbbf35b96557 | 681 | */ |
Kojto | 99:dbbf35b96557 | 682 | |
bogdanm | 92:4fc01daae5a5 | 683 | /* I/O operation functions *****************************************************/ |
Kojto | 99:dbbf35b96557 | 684 | /** @addtogroup SAI_Exported_Functions_Group2 |
Kojto | 99:dbbf35b96557 | 685 | * @{ |
Kojto | 99:dbbf35b96557 | 686 | */ |
bogdanm | 92:4fc01daae5a5 | 687 | /* Blocking mode: Polling */ |
Kojto | 99:dbbf35b96557 | 688 | HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
Kojto | 99:dbbf35b96557 | 689 | HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout); |
bogdanm | 92:4fc01daae5a5 | 690 | |
bogdanm | 92:4fc01daae5a5 | 691 | /* Non-Blocking mode: Interrupt */ |
Kojto | 99:dbbf35b96557 | 692 | HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
Kojto | 99:dbbf35b96557 | 693 | HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
bogdanm | 92:4fc01daae5a5 | 694 | |
bogdanm | 92:4fc01daae5a5 | 695 | /* Non-Blocking mode: DMA */ |
Kojto | 99:dbbf35b96557 | 696 | HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
Kojto | 99:dbbf35b96557 | 697 | HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size); |
bogdanm | 92:4fc01daae5a5 | 698 | HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 699 | HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 700 | HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 701 | |
Kojto | 99:dbbf35b96557 | 702 | /* Abort function */ |
Kojto | 99:dbbf35b96557 | 703 | HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai); |
Kojto | 99:dbbf35b96557 | 704 | |
Kojto | 99:dbbf35b96557 | 705 | /* Mute management */ |
Kojto | 99:dbbf35b96557 | 706 | HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val); |
Kojto | 99:dbbf35b96557 | 707 | HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai); |
Kojto | 99:dbbf35b96557 | 708 | HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter); |
Kojto | 99:dbbf35b96557 | 709 | HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai); |
Kojto | 99:dbbf35b96557 | 710 | |
bogdanm | 92:4fc01daae5a5 | 711 | /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */ |
bogdanm | 92:4fc01daae5a5 | 712 | void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 713 | void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 714 | void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 715 | void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 716 | void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 717 | void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai); |
Kojto | 99:dbbf35b96557 | 718 | /** |
Kojto | 99:dbbf35b96557 | 719 | * @} |
Kojto | 99:dbbf35b96557 | 720 | */ |
bogdanm | 92:4fc01daae5a5 | 721 | |
Kojto | 99:dbbf35b96557 | 722 | /** @addtogroup SAI_Exported_Functions_Group3 |
Kojto | 99:dbbf35b96557 | 723 | * @{ |
Kojto | 99:dbbf35b96557 | 724 | */ |
bogdanm | 92:4fc01daae5a5 | 725 | /* Peripheral State functions **************************************************/ |
bogdanm | 92:4fc01daae5a5 | 726 | HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai); |
bogdanm | 92:4fc01daae5a5 | 727 | uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai); |
Kojto | 99:dbbf35b96557 | 728 | /** |
Kojto | 99:dbbf35b96557 | 729 | * @} |
Kojto | 99:dbbf35b96557 | 730 | */ |
Kojto | 99:dbbf35b96557 | 731 | |
Kojto | 99:dbbf35b96557 | 732 | /** |
Kojto | 99:dbbf35b96557 | 733 | * @} |
Kojto | 99:dbbf35b96557 | 734 | */ |
bogdanm | 92:4fc01daae5a5 | 735 | |
Kojto | 99:dbbf35b96557 | 736 | /* Private types -------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 737 | /** @defgroup SAI_Private_Types SAI Private Types |
Kojto | 99:dbbf35b96557 | 738 | * @{ |
Kojto | 99:dbbf35b96557 | 739 | */ |
Kojto | 99:dbbf35b96557 | 740 | |
Kojto | 99:dbbf35b96557 | 741 | /** |
Kojto | 99:dbbf35b96557 | 742 | * @} |
Kojto | 99:dbbf35b96557 | 743 | */ |
Kojto | 99:dbbf35b96557 | 744 | |
Kojto | 99:dbbf35b96557 | 745 | /* Private variables ---------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 746 | /** @defgroup SAI_Private_Variables SAI Private Variables |
Kojto | 99:dbbf35b96557 | 747 | * @{ |
Kojto | 99:dbbf35b96557 | 748 | */ |
Kojto | 99:dbbf35b96557 | 749 | |
Kojto | 99:dbbf35b96557 | 750 | /** |
Kojto | 99:dbbf35b96557 | 751 | * @} |
Kojto | 99:dbbf35b96557 | 752 | */ |
Kojto | 99:dbbf35b96557 | 753 | |
Kojto | 99:dbbf35b96557 | 754 | /* Private constants ---------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 755 | /** @defgroup SAI_Private_Constants SAI Private Constants |
Kojto | 99:dbbf35b96557 | 756 | * @{ |
Kojto | 99:dbbf35b96557 | 757 | */ |
Kojto | 99:dbbf35b96557 | 758 | |
Kojto | 99:dbbf35b96557 | 759 | /** |
Kojto | 99:dbbf35b96557 | 760 | * @} |
Kojto | 99:dbbf35b96557 | 761 | */ |
Kojto | 99:dbbf35b96557 | 762 | |
Kojto | 99:dbbf35b96557 | 763 | /* Private macros ------------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 764 | /** @addtogroup SAI_Private_Macros |
Kojto | 99:dbbf35b96557 | 765 | * @{ |
Kojto | 99:dbbf35b96557 | 766 | */ |
Kojto | 99:dbbf35b96557 | 767 | #define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\ |
Kojto | 99:dbbf35b96557 | 768 | ((STATE) == SAI_SYNCEXT_IN_ENABLE) ||\ |
Kojto | 99:dbbf35b96557 | 769 | ((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\ |
Kojto | 99:dbbf35b96557 | 770 | ((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE)) |
Kojto | 99:dbbf35b96557 | 771 | |
Kojto | 99:dbbf35b96557 | 772 | #define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_I2S_STANDARD) ||\ |
Kojto | 99:dbbf35b96557 | 773 | ((PROTOCOL) == SAI_I2S_MSBJUSTIFIED) ||\ |
Kojto | 99:dbbf35b96557 | 774 | ((PROTOCOL) == SAI_I2S_LSBJUSTIFIED) ||\ |
Kojto | 99:dbbf35b96557 | 775 | ((PROTOCOL) == SAI_PCM_LONG) ||\ |
Kojto | 99:dbbf35b96557 | 776 | ((PROTOCOL) == SAI_PCM_SHORT)) |
Kojto | 99:dbbf35b96557 | 777 | |
Kojto | 99:dbbf35b96557 | 778 | #define IS_SAI_PROTOCOL_DATASIZE(DATASIZE) (((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BIT) ||\ |
Kojto | 99:dbbf35b96557 | 779 | ((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BITEXTENDED) ||\ |
Kojto | 99:dbbf35b96557 | 780 | ((DATASIZE) == SAI_PROTOCOL_DATASIZE_24BIT) ||\ |
Kojto | 99:dbbf35b96557 | 781 | ((DATASIZE) == SAI_PROTOCOL_DATASIZE_32BIT)) |
Kojto | 99:dbbf35b96557 | 782 | |
Kojto | 99:dbbf35b96557 | 783 | #define IS_SAI_CLK_SOURCE(SOURCE) (((SOURCE) == SAI_CLKSOURCE_PLLSAI) ||\ |
Kojto | 99:dbbf35b96557 | 784 | ((SOURCE) == SAI_CLKSOURCE_PLLI2S) ||\ |
Kojto | 99:dbbf35b96557 | 785 | ((SOURCE) == SAI_CLKSOURCE_EXT)) |
Kojto | 99:dbbf35b96557 | 786 | |
Kojto | 99:dbbf35b96557 | 787 | #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \ |
Kojto | 99:dbbf35b96557 | 788 | ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \ |
Kojto | 99:dbbf35b96557 | 789 | ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \ |
Kojto | 99:dbbf35b96557 | 790 | ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \ |
Kojto | 99:dbbf35b96557 | 791 | ((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV)) |
Kojto | 99:dbbf35b96557 | 792 | |
Kojto | 99:dbbf35b96557 | 793 | #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \ |
Kojto | 99:dbbf35b96557 | 794 | ((MODE) == SAI_MODEMASTER_RX) || \ |
Kojto | 99:dbbf35b96557 | 795 | ((MODE) == SAI_MODESLAVE_TX) || \ |
Kojto | 99:dbbf35b96557 | 796 | ((MODE) == SAI_MODESLAVE_RX)) |
Kojto | 99:dbbf35b96557 | 797 | |
Kojto | 99:dbbf35b96557 | 798 | #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \ |
Kojto | 99:dbbf35b96557 | 799 | ((PROTOCOL) == SAI_AC97_PROTOCOL) || \ |
Kojto | 99:dbbf35b96557 | 800 | ((PROTOCOL) == SAI_SPDIF_PROTOCOL)) |
Kojto | 99:dbbf35b96557 | 801 | |
Kojto | 99:dbbf35b96557 | 802 | #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \ |
Kojto | 99:dbbf35b96557 | 803 | ((DATASIZE) == SAI_DATASIZE_10) || \ |
Kojto | 99:dbbf35b96557 | 804 | ((DATASIZE) == SAI_DATASIZE_16) || \ |
Kojto | 99:dbbf35b96557 | 805 | ((DATASIZE) == SAI_DATASIZE_20) || \ |
Kojto | 99:dbbf35b96557 | 806 | ((DATASIZE) == SAI_DATASIZE_24) || \ |
Kojto | 99:dbbf35b96557 | 807 | ((DATASIZE) == SAI_DATASIZE_32)) |
Kojto | 99:dbbf35b96557 | 808 | |
Kojto | 99:dbbf35b96557 | 809 | #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \ |
Kojto | 99:dbbf35b96557 | 810 | ((BIT) == SAI_FIRSTBIT_LSB)) |
Kojto | 99:dbbf35b96557 | 811 | |
Kojto | 99:dbbf35b96557 | 812 | #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \ |
Kojto | 99:dbbf35b96557 | 813 | ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE)) |
Kojto | 99:dbbf35b96557 | 814 | |
Kojto | 99:dbbf35b96557 | 815 | #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \ |
Kojto | 99:dbbf35b96557 | 816 | ((SYNCHRO) == SAI_SYNCHRONOUS) || \ |
Kojto | 99:dbbf35b96557 | 817 | ((SYNCHRO) == SAI_SYNCHRONOUS_EXT)) |
Kojto | 99:dbbf35b96557 | 818 | |
Kojto | 99:dbbf35b96557 | 819 | #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \ |
Kojto | 99:dbbf35b96557 | 820 | ((DRIVE) == SAI_OUTPUTDRIVE_ENABLE)) |
Kojto | 99:dbbf35b96557 | 821 | |
Kojto | 99:dbbf35b96557 | 822 | #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \ |
Kojto | 99:dbbf35b96557 | 823 | ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE)) |
Kojto | 99:dbbf35b96557 | 824 | |
Kojto | 99:dbbf35b96557 | 825 | #define IS_SAI_BLOCK_FIFO_STATUS(STATUS) (((STATUS) == SAI_FIFOSTATUS_LESS1QUARTERFULL ) || \ |
Kojto | 99:dbbf35b96557 | 826 | ((STATUS) == SAI_FIFOSTATUS_HALFFULL) || \ |
Kojto | 99:dbbf35b96557 | 827 | ((STATUS) == SAI_FIFOSTATUS_1QUARTERFULL) || \ |
Kojto | 99:dbbf35b96557 | 828 | ((STATUS) == SAI_FIFOSTATUS_3QUARTERFULL) || \ |
Kojto | 99:dbbf35b96557 | 829 | ((STATUS) == SAI_FIFOSTATUS_FULL) || \ |
Kojto | 99:dbbf35b96557 | 830 | ((STATUS) == SAI_FIFOSTATUS_EMPTY)) |
Kojto | 99:dbbf35b96557 | 831 | |
Kojto | 99:dbbf35b96557 | 832 | #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63) |
Kojto | 99:dbbf35b96557 | 833 | |
Kojto | 99:dbbf35b96557 | 834 | #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \ |
Kojto | 99:dbbf35b96557 | 835 | ((VALUE) == SAI_LAST_SENT_VALUE)) |
Kojto | 99:dbbf35b96557 | 836 | |
Kojto | 99:dbbf35b96557 | 837 | #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \ |
Kojto | 99:dbbf35b96557 | 838 | ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \ |
Kojto | 99:dbbf35b96557 | 839 | ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \ |
Kojto | 99:dbbf35b96557 | 840 | ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \ |
Kojto | 99:dbbf35b96557 | 841 | ((MODE) == SAI_ALAW_2CPL_COMPANDING)) |
Kojto | 99:dbbf35b96557 | 842 | |
Kojto | 99:dbbf35b96557 | 843 | #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \ |
Kojto | 99:dbbf35b96557 | 844 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \ |
Kojto | 99:dbbf35b96557 | 845 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \ |
Kojto | 99:dbbf35b96557 | 846 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \ |
Kojto | 99:dbbf35b96557 | 847 | ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL)) |
Kojto | 99:dbbf35b96557 | 848 | |
Kojto | 99:dbbf35b96557 | 849 | #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\ |
Kojto | 99:dbbf35b96557 | 850 | ((STATE) == SAI_OUTPUT_RELEASED)) |
Kojto | 99:dbbf35b96557 | 851 | |
Kojto | 99:dbbf35b96557 | 852 | #define IS_SAI_MONO_STEREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\ |
Kojto | 99:dbbf35b96557 | 853 | ((MODE) == SAI_STEREOMODE)) |
Kojto | 99:dbbf35b96557 | 854 | |
Kojto | 99:dbbf35b96557 | 855 | #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((((ACTIVE) >> 16 ) > 0) && (((ACTIVE) >> 16 ) <= (SAI_SLOTACTIVE_ALL >> 16))) |
Kojto | 99:dbbf35b96557 | 856 | |
Kojto | 99:dbbf35b96557 | 857 | #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1 <= (NUMBER)) && ((NUMBER) <= 16)) |
Kojto | 99:dbbf35b96557 | 858 | |
Kojto | 99:dbbf35b96557 | 859 | #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \ |
Kojto | 99:dbbf35b96557 | 860 | ((SIZE) == SAI_SLOTSIZE_16B) || \ |
Kojto | 99:dbbf35b96557 | 861 | ((SIZE) == SAI_SLOTSIZE_32B)) |
Kojto | 99:dbbf35b96557 | 862 | |
Kojto | 99:dbbf35b96557 | 863 | #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24) |
Kojto | 99:dbbf35b96557 | 864 | |
Kojto | 99:dbbf35b96557 | 865 | #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \ |
Kojto | 99:dbbf35b96557 | 866 | ((OFFSET) == SAI_FS_BEFOREFIRSTBIT)) |
Kojto | 99:dbbf35b96557 | 867 | |
Kojto | 99:dbbf35b96557 | 868 | #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \ |
Kojto | 99:dbbf35b96557 | 869 | ((POLARITY) == SAI_FS_ACTIVE_HIGH)) |
Kojto | 99:dbbf35b96557 | 870 | |
Kojto | 99:dbbf35b96557 | 871 | #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \ |
Kojto | 99:dbbf35b96557 | 872 | ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION)) |
Kojto | 99:dbbf35b96557 | 873 | |
Kojto | 99:dbbf35b96557 | 874 | #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15) |
Kojto | 99:dbbf35b96557 | 875 | |
Kojto | 99:dbbf35b96557 | 876 | #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8 <= (LENGTH)) && ((LENGTH) <= 256)) |
Kojto | 99:dbbf35b96557 | 877 | |
Kojto | 99:dbbf35b96557 | 878 | #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1 <= (LENGTH)) && ((LENGTH) <= 128)) |
Kojto | 99:dbbf35b96557 | 879 | |
Kojto | 99:dbbf35b96557 | 880 | /** |
Kojto | 99:dbbf35b96557 | 881 | * @} |
Kojto | 99:dbbf35b96557 | 882 | */ |
Kojto | 99:dbbf35b96557 | 883 | |
Kojto | 99:dbbf35b96557 | 884 | /* Private functions ---------------------------------------------------------*/ |
Kojto | 99:dbbf35b96557 | 885 | /** @defgroup SAI_Private_Functions SAI Private Functions |
Kojto | 99:dbbf35b96557 | 886 | * @{ |
Kojto | 99:dbbf35b96557 | 887 | */ |
Kojto | 99:dbbf35b96557 | 888 | |
Kojto | 99:dbbf35b96557 | 889 | /** |
Kojto | 99:dbbf35b96557 | 890 | * @} |
Kojto | 99:dbbf35b96557 | 891 | */ |
Kojto | 99:dbbf35b96557 | 892 | |
Kojto | 99:dbbf35b96557 | 893 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx */ |
bogdanm | 92:4fc01daae5a5 | 894 | /** |
bogdanm | 92:4fc01daae5a5 | 895 | * @} |
bogdanm | 92:4fc01daae5a5 | 896 | */ |
bogdanm | 92:4fc01daae5a5 | 897 | |
bogdanm | 92:4fc01daae5a5 | 898 | /** |
bogdanm | 92:4fc01daae5a5 | 899 | * @} |
bogdanm | 92:4fc01daae5a5 | 900 | */ |
bogdanm | 92:4fc01daae5a5 | 901 | |
bogdanm | 92:4fc01daae5a5 | 902 | #ifdef __cplusplus |
bogdanm | 92:4fc01daae5a5 | 903 | } |
bogdanm | 92:4fc01daae5a5 | 904 | #endif |
bogdanm | 92:4fc01daae5a5 | 905 | |
bogdanm | 92:4fc01daae5a5 | 906 | #endif /* __STM32F4xx_HAL_SAI_H */ |
bogdanm | 92:4fc01daae5a5 | 907 | |
bogdanm | 92:4fc01daae5a5 | 908 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |