stm32f4xx_sai.h 25 KB

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