stm32f4xx_sai.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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>&copy; 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. /* 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. #define IS_SAI_PERIPH(PERIPH) ((PERIPH) == SAI1)
  124. #define IS_SAI_BLOCK_PERIPH(PERIPH) (((PERIPH) == SAI1_Block_A) || \
  125. ((PERIPH) == SAI1_Block_B))
  126. /** @defgroup SAI_Block_Mode
  127. * @{
  128. */
  129. #define SAI_Mode_MasterTx ((uint32_t)0x00000000)
  130. #define SAI_Mode_MasterRx ((uint32_t)0x00000001)
  131. #define SAI_Mode_SlaveTx ((uint32_t)0x00000002)
  132. #define SAI_Mode_SlaveRx ((uint32_t)0x00000003)
  133. #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_Mode_MasterTx) || \
  134. ((MODE) == SAI_Mode_MasterRx) || \
  135. ((MODE) == SAI_Mode_SlaveTx) || \
  136. ((MODE) == SAI_Mode_SlaveRx))
  137. /**
  138. * @}
  139. */
  140. /** @defgroup SAI_Block_Protocol
  141. * @{
  142. */
  143. #define SAI_Free_Protocol ((uint32_t)0x00000000)
  144. #define SAI_SPDIF_Protocol ((uint32_t)SAI_xCR1_PRTCFG_0)
  145. #define SAI_AC97_Protocol ((uint32_t)SAI_xCR1_PRTCFG_1)
  146. #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_Free_Protocol) || \
  147. ((PROTOCOL) == SAI_SPDIF_Protocol) || \
  148. ((PROTOCOL) == SAI_AC97_Protocol))
  149. /**
  150. * @}
  151. */
  152. /** @defgroup SAI_Block_Data_Size
  153. * @{
  154. */
  155. #define SAI_DataSize_8b ((uint32_t)0x00000040)
  156. #define SAI_DataSize_10b ((uint32_t)0x00000060)
  157. #define SAI_DataSize_16b ((uint32_t)0x00000080)
  158. #define SAI_DataSize_20b ((uint32_t)0x000000A0)
  159. #define SAI_DataSize_24b ((uint32_t)0x000000C0)
  160. #define SAI_DataSize_32b ((uint32_t)0x000000E0)
  161. #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DataSize_8b) || \
  162. ((DATASIZE) == SAI_DataSize_10b) || \
  163. ((DATASIZE) == SAI_DataSize_16b) || \
  164. ((DATASIZE) == SAI_DataSize_20b) || \
  165. ((DATASIZE) == SAI_DataSize_24b) || \
  166. ((DATASIZE) == SAI_DataSize_32b))
  167. /**
  168. * @}
  169. */
  170. /** @defgroup SAI_Block_MSB_LSB_transmission
  171. * @{
  172. */
  173. #define SAI_FirstBit_MSB ((uint32_t)0x00000000)
  174. #define SAI_FirstBit_LSB ((uint32_t)SAI_xCR1_LSBFIRST)
  175. #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FirstBit_MSB) || \
  176. ((BIT) == SAI_FirstBit_LSB))
  177. /**
  178. * @}
  179. */
  180. /** @defgroup SAI_Block_Clock_Strobing
  181. * @{
  182. */
  183. #define SAI_ClockStrobing_FallingEdge ((uint32_t)0x00000000)
  184. #define SAI_ClockStrobing_RisingEdge ((uint32_t)SAI_xCR1_CKSTR)
  185. #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_ClockStrobing_FallingEdge) || \
  186. ((CLOCK) == SAI_ClockStrobing_RisingEdge))
  187. /**
  188. * @}
  189. */
  190. /** @defgroup SAI_Block_Synchronization
  191. * @{
  192. */
  193. #define SAI_Asynchronous ((uint32_t)0x00000000)
  194. #define SAI_Synchronous ((uint32_t)SAI_xCR1_SYNCEN_0)
  195. #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_Synchronous) || \
  196. ((SYNCHRO) == SAI_Asynchronous))
  197. /**
  198. * @}
  199. */
  200. /** @defgroup SAI_Block_Output_Drive
  201. * @{
  202. */
  203. #define SAI_OutputDrive_Disabled ((uint32_t)0x00000000)
  204. #define SAI_OutputDrive_Enabled ((uint32_t)SAI_xCR1_OUTDRIV)
  205. #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OutputDrive_Disabled) || \
  206. ((DRIVE) == SAI_OutputDrive_Enabled))
  207. /**
  208. * @}
  209. */
  210. /** @defgroup SAI_Block_NoDivider
  211. * @{
  212. */
  213. #define SAI_MasterDivider_Enabled ((uint32_t)0x00000000)
  214. #define SAI_MasterDivider_Disabled ((uint32_t)SAI_xCR1_NODIV)
  215. #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MasterDivider_Enabled) || \
  216. ((NODIVIDER) == SAI_MasterDivider_Disabled))
  217. /**
  218. * @}
  219. */
  220. /** @defgroup SAI_Block_Master_Divider
  221. * @{
  222. */
  223. #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15)
  224. /**
  225. * @}
  226. */
  227. /** @defgroup SAI_Block_Frame_Length
  228. * @{
  229. */
  230. #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8 <= (LENGTH)) && ((LENGTH) <= 256))
  231. /**
  232. * @}
  233. */
  234. /** @defgroup SAI_Block_Active_FrameLength
  235. * @{
  236. */
  237. #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1 <= (LENGTH)) && ((LENGTH) <= 128))
  238. /**
  239. * @}
  240. */
  241. /** @defgroup SAI_Block_FS_Definition
  242. * @{
  243. */
  244. #define SAI_FS_StartFrame ((uint32_t)0x00000000)
  245. #define I2S_FS_ChannelIdentification ((uint32_t)SAI_xFRCR_FSDEF)
  246. #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_StartFrame) || \
  247. ((DEFINITION) == I2S_FS_ChannelIdentification))
  248. /**
  249. * @}
  250. */
  251. /** @defgroup SAI_Block_FS_Polarity
  252. * @{
  253. */
  254. #define SAI_FS_ActiveLow ((uint32_t)0x00000000)
  255. #define SAI_FS_ActiveHigh ((uint32_t)SAI_xFRCR_FSPO)
  256. #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ActiveLow) || \
  257. ((POLARITY) == SAI_FS_ActiveHigh))
  258. /**
  259. * @}
  260. */
  261. /** @defgroup SAI_Block_FS_Offset
  262. * @{
  263. */
  264. #define SAI_FS_FirstBit ((uint32_t)0x00000000)
  265. #define SAI_FS_BeforeFirstBit ((uint32_t)SAI_xFRCR_FSOFF)
  266. #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FirstBit) || \
  267. ((OFFSET) == SAI_FS_BeforeFirstBit))
  268. /**
  269. * @}
  270. */
  271. /** @defgroup SAI_Block_Slot_FirstBit_Offset
  272. * @{
  273. */
  274. #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24)
  275. /**
  276. * @}
  277. */
  278. /** @defgroup SAI_Block_Slot_Size
  279. * @{
  280. */
  281. #define SAI_SlotSize_DataSize ((uint32_t)0x00000000)
  282. #define SAI_SlotSize_16b ((uint32_t)SAI_xSLOTR_SLOTSZ_0)
  283. #define SAI_SlotSize_32b ((uint32_t)SAI_xSLOTR_SLOTSZ_1)
  284. #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SlotSize_DataSize) || \
  285. ((SIZE) == SAI_SlotSize_16b) || \
  286. ((SIZE) == SAI_SlotSize_32b))
  287. /**
  288. * @}
  289. */
  290. /** @defgroup SAI_Block_Slot_Number
  291. * @{
  292. */
  293. #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1 <= (NUMBER)) && ((NUMBER) <= 16))
  294. /**
  295. * @}
  296. */
  297. /** @defgroup SAI_Block_Slot_Active
  298. * @{
  299. */
  300. #define SAI_Slot_NotActive ((uint32_t)0x00000000)
  301. #define SAI_SlotActive_0 ((uint32_t)0x00010000)
  302. #define SAI_SlotActive_1 ((uint32_t)0x00020000)
  303. #define SAI_SlotActive_2 ((uint32_t)0x00040000)
  304. #define SAI_SlotActive_3 ((uint32_t)0x00080000)
  305. #define SAI_SlotActive_4 ((uint32_t)0x00100000)
  306. #define SAI_SlotActive_5 ((uint32_t)0x00200000)
  307. #define SAI_SlotActive_6 ((uint32_t)0x00400000)
  308. #define SAI_SlotActive_7 ((uint32_t)0x00800000)
  309. #define SAI_SlotActive_8 ((uint32_t)0x01000000)
  310. #define SAI_SlotActive_9 ((uint32_t)0x02000000)
  311. #define SAI_SlotActive_10 ((uint32_t)0x04000000)
  312. #define SAI_SlotActive_11 ((uint32_t)0x08000000)
  313. #define SAI_SlotActive_12 ((uint32_t)0x10000000)
  314. #define SAI_SlotActive_13 ((uint32_t)0x20000000)
  315. #define SAI_SlotActive_14 ((uint32_t)0x40000000)
  316. #define SAI_SlotActive_15 ((uint32_t)0x80000000)
  317. #define SAI_SlotActive_ALL ((uint32_t)0xFFFF0000)
  318. #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) != 0)
  319. /**
  320. * @}
  321. */
  322. /** @defgroup SAI_Mono_Streo_Mode
  323. * @{
  324. */
  325. #define SAI_MonoMode ((uint32_t)SAI_xCR1_MONO)
  326. #define SAI_StreoMode ((uint32_t)0x00000000)
  327. #define IS_SAI_BLOCK_MONO_STREO_MODE(MODE) (((MODE) == SAI_MonoMode) ||\
  328. ((MODE) == SAI_StreoMode))
  329. /**
  330. * @}
  331. */
  332. /** @defgroup SAI_TRIState_Management
  333. * @{
  334. */
  335. #define SAI_Output_NotReleased ((uint32_t)0x00000000)
  336. #define SAI_Output_Released ((uint32_t)SAI_xCR2_TRIS)
  337. #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_Output_NotReleased) ||\
  338. ((STATE) == SAI_Output_Released))
  339. /**
  340. * @}
  341. */
  342. /** @defgroup SAI_Block_Fifo_Threshold
  343. * @{
  344. */
  345. #define SAI_Threshold_FIFOEmpty ((uint32_t)0x00000000)
  346. #define SAI_FIFOThreshold_1QuarterFull ((uint32_t)0x00000001)
  347. #define SAI_FIFOThreshold_HalfFull ((uint32_t)0x00000002)
  348. #define SAI_FIFOThreshold_3QuartersFull ((uint32_t)0x00000003)
  349. #define SAI_FIFOThreshold_Full ((uint32_t)0x00000004)
  350. #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_Threshold_FIFOEmpty) || \
  351. ((THRESHOLD) == SAI_FIFOThreshold_1QuarterFull) || \
  352. ((THRESHOLD) == SAI_FIFOThreshold_HalfFull) || \
  353. ((THRESHOLD) == SAI_FIFOThreshold_3QuartersFull) || \
  354. ((THRESHOLD) == SAI_FIFOThreshold_Full))
  355. /**
  356. * @}
  357. */
  358. /** @defgroup SAI_Block_Companding_Mode
  359. * @{
  360. */
  361. #define SAI_NoCompanding ((uint32_t)0x00000000)
  362. #define SAI_ULaw_1CPL_Companding ((uint32_t)0x00008000)
  363. #define SAI_ALaw_1CPL_Companding ((uint32_t)0x0000C000)
  364. #define SAI_ULaw_2CPL_Companding ((uint32_t)0x0000A000)
  365. #define SAI_ALaw_2CPL_Companding ((uint32_t)0x0000E000)
  366. #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NoCompanding) || \
  367. ((MODE) == SAI_ULaw_1CPL_Companding) || \
  368. ((MODE) == SAI_ALaw_1CPL_Companding) || \
  369. ((MODE) == SAI_ULaw_2CPL_Companding) || \
  370. ((MODE) == SAI_ALaw_2CPL_Companding))
  371. /**
  372. * @}
  373. */
  374. /** @defgroup SAI_Block_Mute_Value
  375. * @{
  376. */
  377. #define SAI_ZeroValue ((uint32_t)0x00000000)
  378. #define SAI_LastSentValue ((uint32_t)SAI_xCR2_MUTEVAL)
  379. #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZeroValue) || \
  380. ((VALUE) == SAI_LastSentValue))
  381. /**
  382. * @}
  383. */
  384. /** @defgroup SAI_Block_Mute_Frame_Counter
  385. * @{
  386. */
  387. #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63)
  388. /**
  389. * @}
  390. */
  391. /** @defgroup SAI_Block_Interrupts_Definition
  392. * @{
  393. */
  394. #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE)
  395. #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE)
  396. #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE)
  397. #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE)
  398. #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE)
  399. #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE)
  400. #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE)
  401. #define IS_SAI_BLOCK_CONFIG_IT(IT) (((IT) == SAI_IT_OVRUDR) || \
  402. ((IT) == SAI_IT_MUTEDET) || \
  403. ((IT) == SAI_IT_WCKCFG) || \
  404. ((IT) == SAI_IT_FREQ) || \
  405. ((IT) == SAI_IT_CNRDY) || \
  406. ((IT) == SAI_IT_AFSDET) || \
  407. ((IT) == SAI_IT_LFSDET))
  408. /**
  409. * @}
  410. */
  411. /** @defgroup SAI_Block_Flags_Definition
  412. * @{
  413. */
  414. #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR)
  415. #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET)
  416. #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG)
  417. #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ)
  418. #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY)
  419. #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET)
  420. #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET)
  421. #define IS_SAI_BLOCK_GET_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \
  422. ((FLAG) == SAI_FLAG_MUTEDET) || \
  423. ((FLAG) == SAI_FLAG_WCKCFG) || \
  424. ((FLAG) == SAI_FLAG_FREQ) || \
  425. ((FLAG) == SAI_FLAG_CNRDY) || \
  426. ((FLAG) == SAI_FLAG_AFSDET) || \
  427. ((FLAG) == SAI_FLAG_LFSDET))
  428. #define IS_SAI_BLOCK_CLEAR_FLAG(FLAG) (((FLAG) == SAI_FLAG_OVRUDR) || \
  429. ((FLAG) == SAI_FLAG_MUTEDET) || \
  430. ((FLAG) == SAI_FLAG_WCKCFG) || \
  431. ((FLAG) == SAI_FLAG_FREQ) || \
  432. ((FLAG) == SAI_FLAG_CNRDY) || \
  433. ((FLAG) == SAI_FLAG_AFSDET) || \
  434. ((FLAG) == SAI_FLAG_LFSDET))
  435. /**
  436. * @}
  437. */
  438. /** @defgroup SAI_Block_Fifo_Status_Level
  439. * @{
  440. */
  441. #define SAI_FIFOStatus_Empty ((uint32_t)0x00000000)
  442. #define SAI_FIFOStatus_Less1QuarterFull ((uint32_t)0x00010000)
  443. #define SAI_FIFOStatus_1QuarterFull ((uint32_t)0x00020000)
  444. #define SAI_FIFOStatus_HalfFull ((uint32_t)0x00030000)
  445. #define SAI_FIFOStatus_3QuartersFull ((uint32_t)0x00040000)
  446. #define SAI_FIFOStatus_Full ((uint32_t)0x00050000)
  447. #define IS_SAI_BLOCK_FIFO_STATUS(STATUS) (((STATUS) == SAI_FIFOStatus_Less1QuarterFull ) || \
  448. ((STATUS) == SAI_FIFOStatus_HalfFull) || \
  449. ((STATUS) == SAI_FIFOStatus_1QuarterFull) || \
  450. ((STATUS) == SAI_FIFOStatus_3QuartersFull) || \
  451. ((STATUS) == SAI_FIFOStatus_Full) || \
  452. ((STATUS) == SAI_FIFOStatus_Empty))
  453. /**
  454. * @}
  455. */
  456. /**
  457. * @}
  458. */
  459. /* Exported macro ------------------------------------------------------------*/
  460. /* Exported functions --------------------------------------------------------*/
  461. /* Function used to set the SAI configuration to the default reset state *****/
  462. void SAI_DeInit(SAI_TypeDef* SAIx);
  463. /* Initialization and Configuration functions *********************************/
  464. void SAI_Init(SAI_Block_TypeDef* SAI_Block_x, SAI_InitTypeDef* SAI_InitStruct);
  465. void SAI_FrameInit(SAI_Block_TypeDef* SAI_Block_x, SAI_FrameInitTypeDef* SAI_FrameInitStruct);
  466. void SAI_SlotInit(SAI_Block_TypeDef* SAI_Block_x, SAI_SlotInitTypeDef* SAI_SlotInitStruct);
  467. void SAI_StructInit(SAI_InitTypeDef* SAI_InitStruct);
  468. void SAI_FrameStructInit(SAI_FrameInitTypeDef* SAI_FrameInitStruct);
  469. void SAI_SlotStructInit(SAI_SlotInitTypeDef* SAI_SlotInitStruct);
  470. void SAI_Cmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState);
  471. void SAI_MonoModeConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_Mono_StreoMode);
  472. void SAI_TRIStateConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_TRIState);
  473. void SAI_CompandingModeConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_CompandingMode);
  474. void SAI_MuteModeCmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState);
  475. void SAI_MuteValueConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_MuteValue);
  476. void SAI_MuteFrameCounterConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_MuteCounter);
  477. void SAI_FlushFIFO(SAI_Block_TypeDef* SAI_Block_x);
  478. /* Data transfers functions ***************************************************/
  479. void SAI_SendData(SAI_Block_TypeDef* SAI_Block_x, uint32_t Data);
  480. uint32_t SAI_ReceiveData(SAI_Block_TypeDef* SAI_Block_x);
  481. /* DMA transfers management functions *****************************************/
  482. void SAI_DMACmd(SAI_Block_TypeDef* SAI_Block_x, FunctionalState NewState);
  483. /* Interrupts and flags management functions **********************************/
  484. void SAI_ITConfig(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT, FunctionalState NewState);
  485. FlagStatus SAI_GetFlagStatus(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_FLAG);
  486. void SAI_ClearFlag(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_FLAG);
  487. ITStatus SAI_GetITStatus(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT);
  488. void SAI_ClearITPendingBit(SAI_Block_TypeDef* SAI_Block_x, uint32_t SAI_IT);
  489. FunctionalState SAI_GetCmdStatus(SAI_Block_TypeDef* SAI_Block_x);
  490. uint32_t SAI_GetFIFOStatus(SAI_Block_TypeDef* SAI_Block_x);
  491. #ifdef __cplusplus
  492. }
  493. #endif
  494. #endif /*__STM32F4xx_SAI_H */
  495. /**
  496. * @}
  497. */
  498. /**
  499. * @}
  500. */
  501. /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/