1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_sai.h 4 * @author MCD Application Team 5 * @version V1.4.0 6 * @date 04-August-2014 7 * @brief This file contains all the functions prototypes for the SAI 8 * firmware library. 9 ****************************************************************************** 10 * @attention 11 * 12 * <h2><center>© COPYRIGHT 2014 STMicroelectronics</center></h2> 13 * 14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); 15 * You may not use this file except in compliance with the License. 16 * You may obtain a copy of the License at: 17 * 18 * http://www.st.com/software_license_agreement_liberty_v2 19 * 20 * Unless required by applicable law or agreed to in writing, software 21 * distributed under the License is distributed on an "AS IS" BASIS, 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the License for the specific language governing permissions and 24 * limitations under the License. 25 * 26 ****************************************************************************** 27 */ 28 29 /* Define to prevent recursive inclusion -------------------------------------*/ 30 #ifndef __STM32F4xx_SAI_H 31 #define __STM32F4xx_SAI_H 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* Includes ------------------------------------------------------------------*/ 38 #include "stm32f4xx.h" 39 40 /** @addtogroup STM32F4xx_StdPeriph_Driver 41 * @{ 42 */ 43 44 /** @addtogroup SAI 45 * @{ 46 */ 47 48 /* Exported types ------------------------------------------------------------*/ 49 50 /** 51 * @brief SAI Block Init structure definition 52 */ 53 54 typedef struct 55 { 56 uint32_t SAI_AudioMode; /*!< Specifies the SAI Block Audio Mode. 57 This parameter can be a value of @ref SAI_Block_Mode */ 58 59 uint32_t SAI_Protocol; /*!< Specifies the SAI Block Protocol. 60 This parameter can be a value of @ref SAI_Block_Protocol */ 61 62 uint32_t SAI_DataSize; /*!< Specifies the SAI Block data size. 63 This parameter can be a value of @ref SAI_Block_Data_Size 64 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 65 66 uint32_t SAI_FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit. 67 This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission 68 @note this value has no meaning when AC'97 or SPDIF protocols are selected.*/ 69 70 uint32_t SAI_ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity. 71 This parameter can be a value of @ref SAI_Block_Clock_Strobing */ 72 73 uint32_t SAI_Synchro; /*!< Specifies SAI Block synchronization 74 This parameter can be a value of @ref SAI_Block_Synchronization */ 75 76 uint32_t SAI_OUTDRIV; /*!< Specifies when SAI Block outputs are driven. 77 This parameter can be a value of @ref SAI_Block_Output_Drive 78 @note this value has to be set before enabling the audio block 79 but after the audio block configuration. */ 80 81 uint32_t SAI_NoDivider; /*!< Specifies whether Master Clock will be divided or not. 82 This parameter can be a value of @ref SAI_Block_NoDivider */ 83 84 uint32_t SAI_MasterDivider; /*!< Specifies SAI Block Master Clock Divider. 85 @note the Master Clock Frequency is calculated accordingly to the 86 following formula : MCLK_x = SAI_CK_x/(MCKDIV[3:0]*2)*/ 87 88 uint32_t SAI_FIFOThreshold; /*!< Specifies SAI Block FIFO Threshold. 89 This parameter can be a value of @ref SAI_Block_Fifo_Threshold */ 90 }SAI_InitTypeDef; 91 92 /** 93 * @brief SAI Block Frame Init structure definition 94 */ 95 96 typedef struct 97 { 98 99 uint32_t SAI_FrameLength; /*!< Specifies the Frame Length, the number of SCK clocks 100 for each audio frame. 101 This parameter must be a number between 8 and 256. 102 @note If master Clock MCLK_x pin is declared as an output, the frame length 103 should be Aligned to a number equal to power of 2 in order to keep 104 in an audio frame, an integer number of MCLK pulses by bit Clock. 105 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 106 107 uint32_t SAI_ActiveFrameLength; /*!< Specifies the Frame synchronization active level length. 108 This Parameter specifies the length in number of bit clock (SCK + 1) 109 of the active level of FS signal in audio frame. 110 This parameter must be a number between 1 and 128. 111 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 112 113 uint32_t SAI_FSDefinition; /*!< Specifies the Frame Synchronization definition. 114 This parameter can be a value of @ref SAI_Block_FS_Definition 115 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 116 117 uint32_t SAI_FSPolarity; /*!< Specifies the Frame Synchronization Polarity. 118 This parameter can be a value of @ref SAI_Block_FS_Polarity 119 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 120 121 uint32_t SAI_FSOffset; /*!< Specifies the Frame Synchronization Offset. 122 This parameter can be a value of @ref SAI_Block_FS_Offset 123 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 124 125 }SAI_FrameInitTypeDef; 126 127 /** 128 * @brief SAI Block Slot Init Structure definition 129 */ 130 131 typedef struct 132 { 133 uint32_t SAI_FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot. 134 This parameter must be a number between 0 and 24. 135 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 136 137 uint32_t SAI_SlotSize; /*!< Specifies the Slot Size. 138 This parameter can be a value of @ref SAI_Block_Slot_Size 139 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 140 141 uint32_t SAI_SlotNumber; /*!< Specifies the number of slot in the audio frame. 142 This parameter must be a number between 1 and 16. 143 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 144 145 uint32_t SAI_SlotActive; /*!< Specifies the slots in audio frame that will be activated. 146 This parameter can be a value of @ ref SAI_Block_Slot_Active 147 @note this value is ignored when AC'97 or SPDIF protocols are selected.*/ 148 }SAI_SlotInitTypeDef; 149 150 /* Exported constants --------------------------------------------------------*/ 151 152 /** @defgroup SAI_Exported_Constants 153 * @{ 154 */ 155 156 #define IS_SAI_PERIPH(PERIPH) ((PERIPH) == SAI1) 157 158 #define IS_SAI_BLOCK_PERIPH(PERIPH) (((PERIPH) == SAI1_Block_A) || \ 159 ((PERIPH) == SAI1_Block_B)) 160 161 162 /** @defgroup SAI_Block_Mode 163 * @{ 164 */ 165 #define SAI_Mode_MasterTx ((uint32_t)0x00000000) 166 #define SAI_Mode_MasterRx ((uint32_t)0x00000001) 167 #define SAI_Mode_SlaveTx ((uint32_t)0x00000002) 168 #define SAI_Mode_SlaveRx ((uint32_t)0x00000003) 169 #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_Mode_MasterTx) || \ 170 ((MODE) == SAI_Mode_MasterRx) || \ 171 ((MODE) == SAI_Mode_SlaveTx) || \ 172 ((MODE) == SAI_Mode_SlaveRx)) 173 /** 174 * @} 175 */ 176 177 /** @defgroup SAI_Block_Protocol 178 * @{ 179 */ 180 181 #define SAI_Free_Protocol ((uint32_t)0x00000000) 182 #define SAI_SPDIF_Protocol ((uint32_t)SAI_xCR1_PRTCFG_0) 183 #define SAI_AC97_Protocol ((uint32_t)SAI_xCR1_PRTCFG_1) 184 #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_Free_Protocol) || \ 185 ((PROTOCOL) == SAI_SPDIF_Protocol) || \ 186 ((PROTOCOL) == SAI_AC97_Protocol)) 187 /** 188 * @} 189 */ 190 191 /** @defgroup SAI_Block_Data_Size 192 * @{ 193 */ 194 195 #define SAI_DataSize_8b ((uint32_t)0x00000040) 196 #define SAI_DataSize_10b ((uint32_t)0x00000060) 197 #define SAI_DataSize_16b ((uint32_t)0x00000080) 198 #define SAI_DataSize_20b ((uint32_t)0x000000A0) 199 #define SAI_DataSize_24b ((uint32_t)0x000000C0) 200 #define SAI_DataSize_32b ((uint32_t)0x000000E0) 201 #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DataSize_8b) || \ 202 ((DATASIZE) == SAI_DataSize_10b) || \ 203 ((DATASIZE) == SAI_DataSize_16b) || \ 204 ((DATASIZE) == SAI_DataSize_20b) || \ 205 ((DATASIZE) == SAI_DataSize_24b) || \ 206 ((DATASIZE) == SAI_DataSize_32b)) 207 /** 208 * @} 209 */ 210 211 /** @defgroup SAI_Block_MSB_LSB_transmission 212 * @{ 213 */ 214 215 #define SAI_FirstBit_MSB ((uint32_t)0x00000000) 216 #define SAI_FirstBit_LSB ((uint32_t)SAI_xCR1_LSBFIRST) 217 #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FirstBit_MSB) || \ 218 ((BIT) == SAI_FirstBit_LSB)) 219 /** 220 * @} 221 */ 222 223 /** @defgroup SAI_Block_Clock_Strobing 224 * @{ 225 */ 226 227 #define SAI_ClockStrobing_FallingEdge ((uint32_t)0x00000000) 228 #define SAI_ClockStrobing_RisingEdge ((uint32_t)SAI_xCR1_CKSTR) 229 #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_ClockStrobing_FallingEdge) || \ 230 ((CLOCK) == SAI_ClockStrobing_RisingEdge)) 231 /** 232 * @} 233 */ 234 235 /** @defgroup SAI_Block_Synchronization 236 * @{ 237 */ 238 239 #define SAI_Asynchronous ((uint32_t)0x00000000) 240 #define SAI_Synchronous ((uint32_t)SAI_xCR1_SYNCEN_0) 241 #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_Synchronous) || \ 242 ((SYNCHRO) == SAI_Asynchronous)) 243 /** 244 * @} 245 */ 246 247 /** @defgroup SAI_Block_Output_Drive 248 * @{ 249 */ 250 251 #define SAI_OutputDrive_Disabled ((uint32_t)0x00000000) 252 #define SAI_OutputDrive_Enabled ((uint32_t)SAI_xCR1_OUTDRIV) 253 #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OutputDrive_Disabled) || \ 254 ((DRIVE) == SAI_OutputDrive_Enabled)) 255 /** 256 * @} 257 */ 258 259 260 261 /** @defgroup SAI_Block_NoDivider 262 * @{ 263 */ 264 265 #define SAI_MasterDivider_Enabled ((uint32_t)0x00000000) 266 #define SAI_MasterDivider_Disabled ((uint32_t)SAI_xCR1_NODIV) 267 #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MasterDivider_Enabled) || \ 268 ((NODIVIDER) == SAI_MasterDivider_Disabled)) 269 /** 270 * @} 271 */ 272 273 274 /** @defgroup SAI_Block_Master_Divider 275 * @{ 276 */ 277 #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15) 278 279 /** 280 * @} 281 */ 282 283 /** @defgroup SAI_Block_Frame_Length 284 * @{ 285 */ 286 #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8 <= (LENGTH)) && ((LENGTH) <= 256)) 287 288 /** 289 * @} 290 */ 291 292 /** @defgroup SAI_Block_Active_FrameLength 293 * @{ 294 */ 295 #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1 <= (LENGTH)) && ((LENGTH) <= 128)) 296 297 /** 298 * @} 299 */ 300 301 /** @defgroup SAI_Block_FS_Definition 302 * @{ 303 */ 304 305 #define SAI_FS_StartFrame ((uint32_t)0x00000000) 306 #define I2S_FS_ChannelIdentification ((uint32_t)SAI_xFRCR_FSDEF) 307 #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_StartFrame) || \ 308 ((DEFINITION) == I2S_FS_ChannelIdentification)) 309 /** 310 * @} 311 */ 312 313 /** @defgroup SAI_Block_FS_Polarity 314 * @{ 315 */ 316 317 #define SAI_FS_ActiveLow ((uint32_t)0x00000000) 318 #define SAI_FS_ActiveHigh ((uint32_t)SAI_xFRCR_FSPO) 319 #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ActiveLow) || \ 320 ((POLARITY) == SAI_FS_ActiveHigh)) 321 /** 322 * @} 323 */ 324 325 /** @defgroup SAI_Block_FS_Offset 326 * @{ 327 */ 328 329 #define SAI_FS_FirstBit ((uint32_t)0x00000000) 330 #define SAI_FS_BeforeFirstBit ((uint32_t)SAI_xFRCR_FSOFF) 331 #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FirstBit) || \ 332 ((OFFSET) == SAI_FS_BeforeFirstBit)) 333 /** 334 * @} 335 */ 336 337 /** @defgroup SAI_Block_Slot_FirstBit_Offset 338 * @{ 339 */ 340 #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24) 341 342 /** 343 * @} 344 */ 345 346 /** @defgroup SAI_Block_Slot_Size 347 * @{ 348 */ 349 #define SAI_SlotSize_DataSize ((uint32_t)0x00000000) 350 #define SAI_SlotSize_16b ((uint32_t)SAI_xSLOTR_SLOTSZ_0) 351 #define SAI_SlotSize_32b ((uint32_t)SAI_xSLOTR_SLOTSZ_1) 352 #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SlotSize_DataSize) || \ 353 ((SIZE) == SAI_SlotSize_16b) || \ 354 ((SIZE) == SAI_SlotSize_32b)) 355 356 /** 357 * @} 358 */ 359 360 /** @defgroup SAI_Block_Slot_Number 361 * @{ 362 */ 363 #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1 <= (NUMBER)) && ((NUMBER) <= 16)) 364 365 /** 366 * @} 367 */ 368 369 /** @defgroup SAI_Block_Slot_Active 370 * @{ 371 */ 372 #define SAI_Slot_NotActive ((uint32_t)0x00000000) 373 #define SAI_SlotActive_0 ((uint32_t)0x00010000) 374 #define SAI_SlotActive_1 ((uint32_t)0x00020000) 375 #define SAI_SlotActive_2 ((uint32_t)0x00040000) 376 #define SAI_SlotActive_3 ((uint32_t)0x00080000) 377 #define SAI_SlotActive_4 ((uint32_t)0x00100000) 378 #define SAI_SlotActive_5 ((uint32_t)0x00200000) 379 #define SAI_SlotActive_6 ((uint32_t)0x00400000) 380 #define SAI_SlotActive_7 ((uint32_t)0x00800000) 381 #define SAI_SlotActive_8 ((uint32_t)0x01000000) 382 #define SAI_SlotActive_9 ((uint32_t)0x02000000) 383 #define SAI_SlotActive_10 ((uint32_t)0x04000000) 384 #define SAI_SlotActive_11 ((uint32_t)0x08000000) 385 #define SAI_SlotActive_12 ((uint32_t)0x10000000) 386 #define SAI_SlotActive_13 ((uint32_t)0x20000000) 387 #define SAI_SlotActive_14 ((uint32_t)0x40000000) 388 #define SAI_SlotActive_15 ((uint32_t)0x80000000) 389 #define SAI_SlotActive_ALL ((uint32_t)0xFFFF0000) 390 391 #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) != 0) 392 393 /** 394 * @} 395 */ 396 397 /** @defgroup SAI_Mono_Streo_Mode 398 * @{ 399 */ 400 401 #define SAI_MonoMode ((uint32_t)SAI_xCR1_MONO) 402 #define SAI_StreoMode ((uint32_t)0x00000000) 403 #define IS_SAI_BLOCK_MONO_STREO_MODE(MODE) (((MODE) == SAI_MonoMode) ||\ 404 ((MODE) == SAI_StreoMode)) 405 /** 406 * @} 407 */ 408 409 /** @defgroup SAI_TRIState_Management 410 * @{ 411 */ 412 413 #define SAI_Output_NotReleased ((uint32_t)0x00000000) 414 #define SAI_Output_Released ((uint32_t)SAI_xCR2_TRIS) 415 #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_Output_NotReleased) ||\ 416 ((STATE) == SAI_Output_Released)) 417 /** 418 * @} 419 */ 420 421 /** @defgroup SAI_Block_Fifo_Threshold 422 * @{ 423 */ 424 425 #define SAI_Threshold_FIFOEmpty ((uint32_t)0x00000000) 426 #define SAI_FIFOThreshold_1QuarterFull ((uint32_t)0x00000001) 427 #define SAI_FIFOThreshold_HalfFull ((uint32_t)0x00000002) 428 #define SAI_FIFOThreshold_3QuartersFull ((uint32_t)0x00000003) 429 #define SAI_FIFOThreshold_Full ((uint32_t)0x00000004) 430 #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_Threshold_FIFOEmpty) || \ 431 ((THRESHOLD) == SAI_FIFOThreshold_1QuarterFull) || \ 432 ((THRESHOLD) == SAI_FIFOThreshold_HalfFull) || \ 433 ((THRESHOLD) == SAI_FIFOThreshold_3QuartersFull) || \ 434 ((THRESHOLD) == SAI_FIFOThreshold_Full)) 435 /** 436 * @} 437 */ 438 439 /** @defgroup SAI_Block_Companding_Mode 440 * @{ 441 */ 442 443 #define SAI_NoCompanding ((uint32_t)0x00000000) 444 #define SAI_ULaw_1CPL_Companding ((uint32_t)0x00008000) 445 #define SAI_ALaw_1CPL_Companding ((uint32_t)0x0000C000) 446 #define SAI_ULaw_2CPL_Companding ((uint32_t)0x0000A000) 447 #define SAI_ALaw_2CPL_Companding ((uint32_t)0x0000E000) 448 #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NoCompanding) || \ 449 ((MODE) == SAI_ULaw_1CPL_Companding) || \ 450 ((MODE) == SAI_ALaw_1CPL_Companding) || \ 451 ((MODE) == SAI_ULaw_2CPL_Companding) || \ 452 ((MODE) == SAI_ALaw_2CPL_Companding)) 453 /** 454 * @} 455 */ 456 457 /** @defgroup SAI_Block_Mute_Value 458 * @{ 459 */ 460 461 #define SAI_ZeroValue ((uint32_t)0x00000000) 462 #define SAI_LastSentValue ((uint32_t)SAI_xCR2_MUTEVAL) 463 #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZeroValue) || \ 464 ((VALUE) == SAI_LastSentValue)) 465 /** 466 * @} 467 */ 468 469 /** @defgroup SAI_Block_Mute_Frame_Counter 470 * @{ 471 */ 472 473 #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63) 474 475 /** 476 * @} 477 */ 478 479 /** @defgroup SAI_Block_Interrupts_Definition 480 * @{ 481 */ 482 483 #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE) 484 #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE) 485 #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE) 486 #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE) 487 #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE) 488 #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE) 489 #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE) 490 491 #define IS_SAI_BLOCK_CONFIG_IT(IT) (((IT) == SAI_IT_OVRUDR) || \ 492 ((IT) == SAI_IT_MUTEDET) || \ 493 ((IT) == SAI_IT_WCKCFG) || \ 494 ((IT) == SAI_IT_FREQ) || \ 495 ((IT) == SAI_IT_CNRDY) || \ 496 ((IT) == SAI_IT_AFSDET) || \ 497 ((IT) == SAI_IT_LFSDET)) 498 /** 499 * @} 500 */ 501 502 /** @defgroup SAI_Block_Flags_Definition 503 * @{ 504 */ 505 506 #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR) 507 #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET) 508 #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG) 509 #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ) 510 #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY) 511 #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET) 512 #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET) 513 514 #define IS_SAI_BLOCK_GET_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \ 515 ((FLAG) == SAI_FLAG_MUTEDET) || \ 516 ((FLAG) == SAI_FLAG_WCKCFG) || \ 517 ((FLAG) == SAI_FLAG_FREQ) || \ 518 ((FLAG) == SAI_FLAG_CNRDY) || \ 519 ((FLAG) == SAI_FLAG_AFSDET) || \ 520 ((FLAG) == SAI_FLAG_LFSDET)) 521 522 #define IS_SAI_BLOCK_CLEAR_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \ 523 ((FLAG) == SAI_FLAG_MUTEDET) || \ 524 ((FLAG) == SAI_FLAG_WCKCFG) || \ 525 ((FLAG) == SAI_FLAG_FREQ) || \ 526 ((FLAG) == SAI_FLAG_CNRDY) || \ 527 ((FLAG) == SAI_FLAG_AFSDET) || \ 528 ((FLAG) == SAI_FLAG_LFSDET)) 529 /** 530 * @} 531 */ 532 533 /** @defgroup SAI_Block_Fifo_Status_Level 534 * @{ 535 */ 536 #define SAI_FIFOStatus_Empty ((uint32_t)0x00000000) 537 #define SAI_FIFOStatus_Less1QuarterFull ((uint32_t)0x00010000) 538 #define SAI_FIFOStatus_1QuarterFull ((uint32_t)0x00020000) 539 #define SAI_FIFOStatus_HalfFull ((uint32_t)0x00030000) 540 #define SAI_FIFOStatus_3QuartersFull ((uint32_t)0x00040000) 541 #define SAI_FIFOStatus_Full ((uint32_t)0x00050000) 542 543 #define IS_SAI_BLOCK_FIFO_STATUS(STATUS) (((STATUS) == SAI_FIFOStatus_Less1QuarterFull ) || \ 544 ((STATUS) == SAI_FIFOStatus_HalfFull) || \ 545 ((STATUS) == SAI_FIFOStatus_1QuarterFull) || \ 546 ((STATUS) == SAI_FIFOStatus_3QuartersFull) || \ 547 ((STATUS) == SAI_FIFOStatus_Full) || \ 548 ((STATUS) == SAI_FIFOStatus_Empty)) 549 /** 550 * @} 551 */ 552 553 554 /** 555 * @} 556 */ 557 558 /* Exported macro ------------------------------------------------------------*/ 559 /* Exported functions --------------------------------------------------------*/ 560 561 /* Function used to set the SAI configuration to the default reset state *****/ 562 void SAI_DeInit(SAI_TypeDef* SAIx); 563 564 /* Initialization and Configuration functions *********************************/ 565 void SAI_Init(SAI_Block_TypeDef* SAI_Block_x, SAI_InitTypeDef* SAI_InitStruct); 566 void SAI_FrameInit(SAI_Block_TypeDef* SAI_Block_x, SAI_FrameInitTypeDef* SAI_FrameInitStruct); 567 void SAI_SlotInit(SAI_Block_TypeDef* SAI_Block_x, SAI_SlotInitTypeDef* SAI_SlotInitStruct); 568 void SAI_StructInit(SAI_InitTypeDef* SAI_InitStruct); 569 void SAI_FrameStructInit(SAI_FrameInitTypeDef* SAI_FrameInitStruct); 570 void SAI_SlotStructInit(SAI_SlotInitTypeDef* SAI_SlotInitStruct); 571 572 void SAI_Cmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState); 573 void SAI_MonoModeConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_Mono_StreoMode); 574 void SAI_TRIStateConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_TRIState); 575 void SAI_CompandingModeConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_CompandingMode); 576 void SAI_MuteModeCmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState); 577 void SAI_MuteValueConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_MuteValue); 578 void SAI_MuteFrameCounterConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_MuteCounter); 579 void SAI_FlushFIFO(SAI_Block_TypeDef* SAI_Block_x); 580 581 /* Data transfers functions ***************************************************/ 582 void SAI_SendData(SAI_Block_TypeDef* SAI_Block_x, uint32_t Data); 583 uint32_t SAI_ReceiveData(SAI_Block_TypeDef* SAI_Block_x); 584 585 /* DMA transfers management functions *****************************************/ 586 void SAI_DMACmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState); 587 588 /* Interrupts and flags management functions **********************************/ 589 void SAI_ITConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT, FunctionalState NewState); 590 FlagStatus SAI_GetFlagStatus(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_FLAG); 591 void SAI_ClearFlag(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_FLAG); 592 ITStatus SAI_GetITStatus(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT); 593 void SAI_ClearITPendingBit(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT); 594 FunctionalState SAI_GetCmdStatus(SAI_Block_TypeDef* SAI_Block_x); 595 uint32_t SAI_GetFIFOStatus(SAI_Block_TypeDef* SAI_Block_x); 596 597 #ifdef __cplusplus 598 } 599 #endif 600 601 #endif /*__STM32F4xx_SAI_H */ 602 603 /** 604 * @} 605 */ 606 607 /** 608 * @} 609 */ 610 611 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ 612