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

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

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

Who changed what in which revision?

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