stm32f4xx_hal_sai.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_sai.h
  4. * @author MCD Application Team
  5. * @brief Header file of SAI HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef __STM32F4xx_HAL_SAI_H
  21. #define __STM32F4xx_HAL_SAI_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx_hal_def.h"
  27. /** @addtogroup STM32F4xx_HAL_Driver
  28. * @{
  29. */
  30. #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  31. defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F413xx) || \
  32. defined(STM32F423xx)
  33. /** @addtogroup SAI
  34. * @{
  35. */
  36. /* Exported types ------------------------------------------------------------*/
  37. /** @defgroup SAI_Exported_Types SAI Exported Types
  38. * @{
  39. */
  40. /**
  41. * @brief HAL State structures definition
  42. */
  43. typedef enum
  44. {
  45. HAL_SAI_STATE_RESET = 0x00U, /*!< SAI not yet initialized or disabled */
  46. HAL_SAI_STATE_READY = 0x01U, /*!< SAI initialized and ready for use */
  47. HAL_SAI_STATE_BUSY = 0x02U, /*!< SAI internal process is ongoing */
  48. HAL_SAI_STATE_BUSY_TX = 0x12U, /*!< Data transmission process is ongoing */
  49. HAL_SAI_STATE_BUSY_RX = 0x22U, /*!< Data reception process is ongoing */
  50. HAL_SAI_STATE_TIMEOUT = 0x03U, /*!< SAI timeout state */
  51. HAL_SAI_STATE_ERROR = 0x04U /*!< SAI error state */
  52. }HAL_SAI_StateTypeDef;
  53. /**
  54. * @brief SAI Callback prototype
  55. */
  56. typedef void (*SAIcallback)(void);
  57. /** @defgroup SAI_Init_Structure_definition SAI Init Structure definition
  58. * @brief SAI Init Structure definition
  59. * @{
  60. */
  61. typedef struct
  62. {
  63. uint32_t AudioMode; /*!< Specifies the SAI Block audio Mode.
  64. This parameter can be a value of @ref SAI_Block_Mode */
  65. uint32_t Synchro; /*!< Specifies SAI Block synchronization
  66. This parameter can be a value of @ref SAI_Block_Synchronization */
  67. uint32_t SynchroExt; /*!< Specifies SAI external output synchronization, this setup is common
  68. for BlockA and BlockB
  69. This parameter can be a value of @ref SAI_Block_SyncExt
  70. @note: If both audio blocks of same SAI are used, this parameter has
  71. to be set to the same value for each audio block */
  72. uint32_t OutputDrive; /*!< Specifies when SAI Block outputs are driven.
  73. This parameter can be a value of @ref SAI_Block_Output_Drive
  74. @note this value has to be set before enabling the audio block
  75. but after the audio block configuration. */
  76. uint32_t NoDivider; /*!< Specifies whether master clock will be divided or not.
  77. This parameter can be a value of @ref SAI_Block_NoDivider
  78. @note If bit NODIV in the SAI_xCR1 register is cleared, the frame length
  79. should be aligned to a number equal to a power of 2, from 8 to 256.
  80. If bit NODIV in the SAI_xCR1 register is set, the frame length can
  81. take any of the values without constraint since the input clock of
  82. the audio block should be equal to the bit clock.
  83. There is no MCLK_x clock which can be output. */
  84. uint32_t FIFOThreshold; /*!< Specifies SAI Block FIFO threshold.
  85. This parameter can be a value of @ref SAI_Block_Fifo_Threshold */
  86. uint32_t ClockSource; /*!< Specifies the SAI Block x Clock source.
  87. This parameter is not used for STM32F446xx devices. */
  88. uint32_t AudioFrequency; /*!< Specifies the audio frequency sampling.
  89. This parameter can be a value of @ref SAI_Audio_Frequency */
  90. uint32_t Mckdiv; /*!< Specifies the master clock divider.
  91. This parameter must be a number between Min_Data = 0 and Max_Data = 15.
  92. @note This parameter is used only if AudioFrequency is set to
  93. SAI_AUDIO_FREQUENCY_MCKDIV otherwise it is internally computed. */
  94. uint32_t MonoStereoMode; /*!< Specifies if the mono or stereo mode is selected.
  95. This parameter can be a value of @ref SAI_Mono_Stereo_Mode */
  96. uint32_t CompandingMode; /*!< Specifies the companding mode type.
  97. This parameter can be a value of @ref SAI_Block_Companding_Mode */
  98. uint32_t TriState; /*!< Specifies the companding mode type.
  99. This parameter can be a value of @ref SAI_TRIState_Management */
  100. /* This part of the structure is automatically filled if your are using the high level intialisation
  101. function HAL_SAI_InitProtocol */
  102. uint32_t Protocol; /*!< Specifies the SAI Block protocol.
  103. This parameter can be a value of @ref SAI_Block_Protocol */
  104. uint32_t DataSize; /*!< Specifies the SAI Block data size.
  105. This parameter can be a value of @ref SAI_Block_Data_Size */
  106. uint32_t FirstBit; /*!< Specifies whether data transfers start from MSB or LSB bit.
  107. This parameter can be a value of @ref SAI_Block_MSB_LSB_transmission */
  108. uint32_t ClockStrobing; /*!< Specifies the SAI Block clock strobing edge sensitivity.
  109. This parameter can be a value of @ref SAI_Block_Clock_Strobing */
  110. }SAI_InitTypeDef;
  111. /**
  112. * @}
  113. */
  114. /** @defgroup SAI_Frame_Structure_definition SAI Frame Structure definition
  115. * @brief SAI Frame Init structure definition
  116. * @{
  117. */
  118. typedef struct
  119. {
  120. uint32_t FrameLength; /*!< Specifies the Frame length, the number of SCK clocks for each audio frame.
  121. This parameter must be a number between Min_Data = 8 and Max_Data = 256.
  122. @note If master clock MCLK_x pin is declared as an output, the frame length
  123. should be aligned to a number equal to power of 2 in order to keep
  124. in an audio frame, an integer number of MCLK pulses by bit Clock. */
  125. uint32_t ActiveFrameLength; /*!< Specifies the Frame synchronization active level length.
  126. This Parameter specifies the length in number of bit clock (SCK + 1)
  127. of the active level of FS signal in audio frame.
  128. This parameter must be a number between Min_Data = 1 and Max_Data = 128 */
  129. uint32_t FSDefinition; /*!< Specifies the Frame synchronization definition.
  130. This parameter can be a value of @ref SAI_Block_FS_Definition */
  131. uint32_t FSPolarity; /*!< Specifies the Frame synchronization Polarity.
  132. This parameter can be a value of @ref SAI_Block_FS_Polarity */
  133. uint32_t FSOffset; /*!< Specifies the Frame synchronization Offset.
  134. This parameter can be a value of @ref SAI_Block_FS_Offset */
  135. }SAI_FrameInitTypeDef;
  136. /**
  137. * @}
  138. */
  139. /** @defgroup SAI_Slot_Structure_definition SAI Slot Structure definition
  140. * @brief SAI Block Slot Init Structure definition
  141. * @{
  142. */
  143. typedef struct
  144. {
  145. uint32_t FirstBitOffset; /*!< Specifies the position of first data transfer bit in the slot.
  146. This parameter must be a number between Min_Data = 0 and Max_Data = 24 */
  147. uint32_t SlotSize; /*!< Specifies the Slot Size.
  148. This parameter can be a value of @ref SAI_Block_Slot_Size */
  149. uint32_t SlotNumber; /*!< Specifies the number of slot in the audio frame.
  150. This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
  151. uint32_t SlotActive; /*!< Specifies the slots in audio frame that will be activated.
  152. This parameter can be a value of @ref SAI_Block_Slot_Active */
  153. }SAI_SlotInitTypeDef;
  154. /**
  155. * @}
  156. */
  157. /** @defgroup SAI_Handle_Structure_definition SAI Handle Structure definition
  158. * @brief SAI handle Structure definition
  159. * @{
  160. */
  161. typedef struct __SAI_HandleTypeDef
  162. {
  163. SAI_Block_TypeDef *Instance; /*!< SAI Blockx registers base address */
  164. SAI_InitTypeDef Init; /*!< SAI communication parameters */
  165. SAI_FrameInitTypeDef FrameInit; /*!< SAI Frame configuration parameters */
  166. SAI_SlotInitTypeDef SlotInit; /*!< SAI Slot configuration parameters */
  167. uint8_t *pBuffPtr; /*!< Pointer to SAI transfer Buffer */
  168. uint16_t XferSize; /*!< SAI transfer size */
  169. uint16_t XferCount; /*!< SAI transfer counter */
  170. DMA_HandleTypeDef *hdmatx; /*!< SAI Tx DMA handle parameters */
  171. DMA_HandleTypeDef *hdmarx; /*!< SAI Rx DMA handle parameters */
  172. SAIcallback mutecallback;/*!< SAI mute callback */
  173. void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */
  174. HAL_LockTypeDef Lock; /*!< SAI locking object */
  175. __IO HAL_SAI_StateTypeDef State; /*!< SAI communication state */
  176. __IO uint32_t ErrorCode; /*!< SAI Error code */
  177. #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
  178. void (*RxCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI receive complete callback */
  179. void (*RxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI receive half complete callback */
  180. void (*TxCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI transmit complete callback */
  181. void (*TxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI transmit half complete callback */
  182. void (*ErrorCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI error callback */
  183. void (*MspInitCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI MSP init callback */
  184. void (*MspDeInitCallback)(struct __SAI_HandleTypeDef *hsai); /*!< SAI MSP de-init callback */
  185. #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
  186. } SAI_HandleTypeDef;
  187. /**
  188. * @}
  189. */
  190. #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
  191. /**
  192. * @brief SAI callback ID enumeration definition
  193. */
  194. typedef enum
  195. {
  196. HAL_SAI_RX_COMPLETE_CB_ID = 0x00U, /*!< SAI receive complete callback ID */
  197. HAL_SAI_RX_HALFCOMPLETE_CB_ID = 0x01U, /*!< SAI receive half complete callback ID */
  198. HAL_SAI_TX_COMPLETE_CB_ID = 0x02U, /*!< SAI transmit complete callback ID */
  199. HAL_SAI_TX_HALFCOMPLETE_CB_ID = 0x03U, /*!< SAI transmit half complete callback ID */
  200. HAL_SAI_ERROR_CB_ID = 0x04U, /*!< SAI error callback ID */
  201. HAL_SAI_MSPINIT_CB_ID = 0x05U, /*!< SAI MSP init callback ID */
  202. HAL_SAI_MSPDEINIT_CB_ID = 0x06U /*!< SAI MSP de-init callback ID */
  203. } HAL_SAI_CallbackIDTypeDef;
  204. /**
  205. * @brief SAI callback pointer definition
  206. */
  207. typedef void (*pSAI_CallbackTypeDef)(SAI_HandleTypeDef *hsai);
  208. #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
  209. /**
  210. * @}
  211. */
  212. /* Exported constants --------------------------------------------------------*/
  213. /** @defgroup SAI_Exported_Constants SAI Exported Constants
  214. * @{
  215. */
  216. /** @defgroup SAI_Error_Code SAI Error Code
  217. * @{
  218. */
  219. #define HAL_SAI_ERROR_NONE 0x00000000U /*!< No error */
  220. #define HAL_SAI_ERROR_OVR 0x00000001U /*!< Overrun Error */
  221. #define HAL_SAI_ERROR_UDR 0x00000002U /*!< Underrun error */
  222. #define HAL_SAI_ERROR_AFSDET 0x00000004U /*!< Anticipated Frame synchronisation detection */
  223. #define HAL_SAI_ERROR_LFSDET 0x00000008U /*!< Late Frame synchronisation detection */
  224. #define HAL_SAI_ERROR_CNREADY 0x00000010U /*!< codec not ready */
  225. #define HAL_SAI_ERROR_WCKCFG 0x00000020U /*!< Wrong clock configuration */
  226. #define HAL_SAI_ERROR_TIMEOUT 0x00000040U /*!< Timeout error */
  227. #define HAL_SAI_ERROR_DMA 0x00000080U /*!< DMA error */
  228. #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
  229. #define HAL_SAI_ERROR_INVALID_CALLBACK 0x00000100U /*!< Invalid callback error */
  230. #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
  231. /**
  232. * @}
  233. */
  234. /** @defgroup SAI_Block_SyncExt SAI External synchronisation
  235. * @{
  236. */
  237. #define SAI_SYNCEXT_DISABLE 0U
  238. #define SAI_SYNCEXT_OUTBLOCKA_ENABLE 1U
  239. #define SAI_SYNCEXT_OUTBLOCKB_ENABLE 2U
  240. /**
  241. * @}
  242. */
  243. /** @defgroup SAI_Protocol SAI Supported protocol
  244. * @{
  245. */
  246. #define SAI_I2S_STANDARD 0U
  247. #define SAI_I2S_MSBJUSTIFIED 1U
  248. #define SAI_I2S_LSBJUSTIFIED 2U
  249. #define SAI_PCM_LONG 3U
  250. #define SAI_PCM_SHORT 4U
  251. /**
  252. * @}
  253. */
  254. /** @defgroup SAI_Protocol_DataSize SAI protocol data size
  255. * @{
  256. */
  257. #define SAI_PROTOCOL_DATASIZE_16BIT 0U
  258. #define SAI_PROTOCOL_DATASIZE_16BITEXTENDED 1U
  259. #define SAI_PROTOCOL_DATASIZE_24BIT 2U
  260. #define SAI_PROTOCOL_DATASIZE_32BIT 3U
  261. /**
  262. * @}
  263. */
  264. /** @defgroup SAI_Audio_Frequency SAI Audio Frequency
  265. * @{
  266. */
  267. #define SAI_AUDIO_FREQUENCY_192K 192000U
  268. #define SAI_AUDIO_FREQUENCY_96K 96000U
  269. #define SAI_AUDIO_FREQUENCY_48K 48000U
  270. #define SAI_AUDIO_FREQUENCY_44K 44100U
  271. #define SAI_AUDIO_FREQUENCY_32K 32000U
  272. #define SAI_AUDIO_FREQUENCY_22K 22050U
  273. #define SAI_AUDIO_FREQUENCY_16K 16000U
  274. #define SAI_AUDIO_FREQUENCY_11K 11025U
  275. #define SAI_AUDIO_FREQUENCY_8K 8000U
  276. #define SAI_AUDIO_FREQUENCY_MCKDIV 0U
  277. /**
  278. * @}
  279. */
  280. /** @defgroup SAI_Block_Mode SAI Block Mode
  281. * @{
  282. */
  283. #define SAI_MODEMASTER_TX 0x00000000U
  284. #define SAI_MODEMASTER_RX ((uint32_t)SAI_xCR1_MODE_0)
  285. #define SAI_MODESLAVE_TX ((uint32_t)SAI_xCR1_MODE_1)
  286. #define SAI_MODESLAVE_RX ((uint32_t)(SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0))
  287. /**
  288. * @}
  289. */
  290. /** @defgroup SAI_Block_Protocol SAI Block Protocol
  291. * @{
  292. */
  293. #define SAI_FREE_PROTOCOL 0x00000000U
  294. #define SAI_SPDIF_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_0)
  295. #define SAI_AC97_PROTOCOL ((uint32_t)SAI_xCR1_PRTCFG_1)
  296. /**
  297. * @}
  298. */
  299. /** @defgroup SAI_Block_Data_Size SAI Block Data Size
  300. * @{
  301. */
  302. #define SAI_DATASIZE_8 ((uint32_t)SAI_xCR1_DS_1)
  303. #define SAI_DATASIZE_10 ((uint32_t)(SAI_xCR1_DS_1 | SAI_xCR1_DS_0))
  304. #define SAI_DATASIZE_16 ((uint32_t)SAI_xCR1_DS_2)
  305. #define SAI_DATASIZE_20 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_0))
  306. #define SAI_DATASIZE_24 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_1))
  307. #define SAI_DATASIZE_32 ((uint32_t)(SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0))
  308. /**
  309. * @}
  310. */
  311. /** @defgroup SAI_Block_MSB_LSB_transmission SAI Block MSB LSB transmission
  312. * @{
  313. */
  314. #define SAI_FIRSTBIT_MSB 0x00000000U
  315. #define SAI_FIRSTBIT_LSB ((uint32_t)SAI_xCR1_LSBFIRST)
  316. /**
  317. * @}
  318. */
  319. /** @defgroup SAI_Block_Clock_Strobing SAI Block Clock Strobing
  320. * @{
  321. */
  322. #define SAI_CLOCKSTROBING_FALLINGEDGE 0U
  323. #define SAI_CLOCKSTROBING_RISINGEDGE 1U
  324. /**
  325. * @}
  326. */
  327. /** @defgroup SAI_Block_Synchronization SAI Block Synchronization
  328. * @{
  329. */
  330. #define SAI_ASYNCHRONOUS 0U /*!< Asynchronous */
  331. #define SAI_SYNCHRONOUS 1U /*!< Synchronous with other block of same SAI */
  332. #define SAI_SYNCHRONOUS_EXT_SAI1 2U /*!< Synchronous with other SAI, SAI1 */
  333. #define SAI_SYNCHRONOUS_EXT_SAI2 3U /*!< Synchronous with other SAI, SAI2 */
  334. /**
  335. * @}
  336. */
  337. /** @defgroup SAI_Block_Output_Drive SAI Block Output Drive
  338. * @{
  339. */
  340. #define SAI_OUTPUTDRIVE_DISABLE 0x00000000U
  341. #define SAI_OUTPUTDRIVE_ENABLE ((uint32_t)SAI_xCR1_OUTDRIV)
  342. /**
  343. * @}
  344. */
  345. /** @defgroup SAI_Block_NoDivider SAI Block NoDivider
  346. * @{
  347. */
  348. #define SAI_MASTERDIVIDER_ENABLE 0x00000000U
  349. #define SAI_MASTERDIVIDER_DISABLE ((uint32_t)SAI_xCR1_NODIV)
  350. /**
  351. * @}
  352. */
  353. /** @defgroup SAI_Block_FS_Definition SAI Block FS Definition
  354. * @{
  355. */
  356. #define SAI_FS_STARTFRAME 0x00000000U
  357. #define SAI_FS_CHANNEL_IDENTIFICATION ((uint32_t)SAI_xFRCR_FSDEF)
  358. /**
  359. * @}
  360. */
  361. /** @defgroup SAI_Block_FS_Polarity SAI Block FS Polarity
  362. * @{
  363. */
  364. #define SAI_FS_ACTIVE_LOW 0x00000000U
  365. #define SAI_FS_ACTIVE_HIGH ((uint32_t)SAI_xFRCR_FSPOL)
  366. /**
  367. * @}
  368. */
  369. /** @defgroup SAI_Block_FS_Offset SAI Block FS Offset
  370. * @{
  371. */
  372. #define SAI_FS_FIRSTBIT 0x00000000U
  373. #define SAI_FS_BEFOREFIRSTBIT ((uint32_t)SAI_xFRCR_FSOFF)
  374. /**
  375. * @}
  376. */
  377. /** @defgroup SAI_Block_Slot_Size SAI Block Slot Size
  378. * @{
  379. */
  380. #define SAI_SLOTSIZE_DATASIZE 0x00000000U
  381. #define SAI_SLOTSIZE_16B ((uint32_t)SAI_xSLOTR_SLOTSZ_0)
  382. #define SAI_SLOTSIZE_32B ((uint32_t)SAI_xSLOTR_SLOTSZ_1)
  383. /**
  384. * @}
  385. */
  386. /** @defgroup SAI_Block_Slot_Active SAI Block Slot Active
  387. * @{
  388. */
  389. #define SAI_SLOT_NOTACTIVE 0x00000000U
  390. #define SAI_SLOTACTIVE_0 0x00000001U
  391. #define SAI_SLOTACTIVE_1 0x00000002U
  392. #define SAI_SLOTACTIVE_2 0x00000004U
  393. #define SAI_SLOTACTIVE_3 0x00000008U
  394. #define SAI_SLOTACTIVE_4 0x00000010U
  395. #define SAI_SLOTACTIVE_5 0x00000020U
  396. #define SAI_SLOTACTIVE_6 0x00000040U
  397. #define SAI_SLOTACTIVE_7 0x00000080U
  398. #define SAI_SLOTACTIVE_8 0x00000100U
  399. #define SAI_SLOTACTIVE_9 0x00000200U
  400. #define SAI_SLOTACTIVE_10 0x00000400U
  401. #define SAI_SLOTACTIVE_11 0x00000800U
  402. #define SAI_SLOTACTIVE_12 0x00001000U
  403. #define SAI_SLOTACTIVE_13 0x00002000U
  404. #define SAI_SLOTACTIVE_14 0x00004000U
  405. #define SAI_SLOTACTIVE_15 0x00008000U
  406. #define SAI_SLOTACTIVE_ALL 0x0000FFFFU
  407. /**
  408. * @}
  409. */
  410. /** @defgroup SAI_Mono_Stereo_Mode SAI Mono Stereo Mode
  411. * @{
  412. */
  413. #define SAI_STEREOMODE 0x00000000U
  414. #define SAI_MONOMODE ((uint32_t)SAI_xCR1_MONO)
  415. /**
  416. * @}
  417. */
  418. /** @defgroup SAI_TRIState_Management SAI TRIState Management
  419. * @{
  420. */
  421. #define SAI_OUTPUT_NOTRELEASED 0x00000000U
  422. #define SAI_OUTPUT_RELEASED ((uint32_t)SAI_xCR2_TRIS)
  423. /**
  424. * @}
  425. */
  426. /** @defgroup SAI_Block_Fifo_Threshold SAI Block Fifo Threshold
  427. * @{
  428. */
  429. #define SAI_FIFOTHRESHOLD_EMPTY 0x00000000U
  430. #define SAI_FIFOTHRESHOLD_1QF ((uint32_t)(SAI_xCR2_FTH_0))
  431. #define SAI_FIFOTHRESHOLD_HF ((uint32_t)(SAI_xCR2_FTH_1))
  432. #define SAI_FIFOTHRESHOLD_3QF ((uint32_t)(SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0))
  433. #define SAI_FIFOTHRESHOLD_FULL ((uint32_t)(SAI_xCR2_FTH_2))
  434. /**
  435. * @}
  436. */
  437. /** @defgroup SAI_Block_Companding_Mode SAI Block Companding Mode
  438. * @{
  439. */
  440. #define SAI_NOCOMPANDING 0x00000000U
  441. #define SAI_ULAW_1CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1))
  442. #define SAI_ALAW_1CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0))
  443. #define SAI_ULAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_CPL))
  444. #define SAI_ALAW_2CPL_COMPANDING ((uint32_t)(SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL))
  445. /**
  446. * @}
  447. */
  448. /** @defgroup SAI_Block_Mute_Value SAI Block Mute Value
  449. * @{
  450. */
  451. #define SAI_ZERO_VALUE 0x00000000U
  452. #define SAI_LAST_SENT_VALUE ((uint32_t)SAI_xCR2_MUTEVAL)
  453. /**
  454. * @}
  455. */
  456. /** @defgroup SAI_Block_Interrupts_Definition SAI Block Interrupts Definition
  457. * @{
  458. */
  459. #define SAI_IT_OVRUDR ((uint32_t)SAI_xIMR_OVRUDRIE)
  460. #define SAI_IT_MUTEDET ((uint32_t)SAI_xIMR_MUTEDETIE)
  461. #define SAI_IT_WCKCFG ((uint32_t)SAI_xIMR_WCKCFGIE)
  462. #define SAI_IT_FREQ ((uint32_t)SAI_xIMR_FREQIE)
  463. #define SAI_IT_CNRDY ((uint32_t)SAI_xIMR_CNRDYIE)
  464. #define SAI_IT_AFSDET ((uint32_t)SAI_xIMR_AFSDETIE)
  465. #define SAI_IT_LFSDET ((uint32_t)SAI_xIMR_LFSDETIE)
  466. /**
  467. * @}
  468. */
  469. /** @defgroup SAI_Block_Flags_Definition SAI Block Flags Definition
  470. * @{
  471. */
  472. #define SAI_FLAG_OVRUDR ((uint32_t)SAI_xSR_OVRUDR)
  473. #define SAI_FLAG_MUTEDET ((uint32_t)SAI_xSR_MUTEDET)
  474. #define SAI_FLAG_WCKCFG ((uint32_t)SAI_xSR_WCKCFG)
  475. #define SAI_FLAG_FREQ ((uint32_t)SAI_xSR_FREQ)
  476. #define SAI_FLAG_CNRDY ((uint32_t)SAI_xSR_CNRDY)
  477. #define SAI_FLAG_AFSDET ((uint32_t)SAI_xSR_AFSDET)
  478. #define SAI_FLAG_LFSDET ((uint32_t)SAI_xSR_LFSDET)
  479. /**
  480. * @}
  481. */
  482. /** @defgroup SAI_Block_Fifo_Status_Level SAI Block Fifo Status Level
  483. * @{
  484. */
  485. #define SAI_FIFOSTATUS_EMPTY 0x00000000U
  486. #define SAI_FIFOSTATUS_LESS1QUARTERFULL 0x00010000U
  487. #define SAI_FIFOSTATUS_1QUARTERFULL 0x00020000U
  488. #define SAI_FIFOSTATUS_HALFFULL 0x00030000U
  489. #define SAI_FIFOSTATUS_3QUARTERFULL 0x00040000U
  490. #define SAI_FIFOSTATUS_FULL 0x00050000U
  491. /**
  492. * @}
  493. */
  494. /**
  495. * @}
  496. */
  497. /* Exported macro ------------------------------------------------------------*/
  498. /** @defgroup SAI_Exported_Macros SAI Exported Macros
  499. * @brief macros to handle interrupts and specific configurations
  500. * @{
  501. */
  502. /** @brief Reset SAI handle state
  503. * @param __HANDLE__ specifies the SAI Handle.
  504. * @retval None
  505. */
  506. #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
  507. #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) do{ \
  508. (__HANDLE__)->State = HAL_SAI_STATE_RESET; \
  509. (__HANDLE__)->MspInitCallback = NULL; \
  510. (__HANDLE__)->MspDeInitCallback = NULL; \
  511. } while(0U)
  512. #else
  513. #define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET)
  514. #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
  515. /** @brief Enable or disable the specified SAI interrupts.
  516. * @param __HANDLE__ specifies the SAI Handle.
  517. * @param __INTERRUPT__ specifies the interrupt source to enable or disable.
  518. * This parameter can be one of the following values:
  519. * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
  520. * @arg SAI_IT_MUTEDET: Mute detection interrupt enable
  521. * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
  522. * @arg SAI_IT_FREQ: FIFO request interrupt enable
  523. * @arg SAI_IT_CNRDY: Codec not ready interrupt enable
  524. * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
  525. * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
  526. * @retval None
  527. */
  528. #define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
  529. #define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__)))
  530. /** @brief Check if the specified SAI interrupt source is enabled or disabled.
  531. * @param __HANDLE__ specifies the SAI Handle.
  532. * This parameter can be SAI where x: 1, 2, or 3 to select the SAI peripheral.
  533. * @param __INTERRUPT__ specifies the SAI interrupt source to check.
  534. * This parameter can be one of the following values:
  535. * @arg SAI_IT_OVRUDR: Overrun underrun interrupt enable
  536. * @arg SAI_IT_MUTEDET: Mute detection interrupt enable
  537. * @arg SAI_IT_WCKCFG: Wrong Clock Configuration interrupt enable
  538. * @arg SAI_IT_FREQ: FIFO request interrupt enable
  539. * @arg SAI_IT_CNRDY: Codec not ready interrupt enable
  540. * @arg SAI_IT_AFSDET: Anticipated frame synchronization detection interrupt enable
  541. * @arg SAI_IT_LFSDET: Late frame synchronization detection interrupt enable
  542. * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
  543. */
  544. #define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  545. /** @brief Check whether the specified SAI flag is set or not.
  546. * @param __HANDLE__ specifies the SAI Handle.
  547. * @param __FLAG__ specifies the flag to check.
  548. * This parameter can be one of the following values:
  549. * @arg SAI_FLAG_OVRUDR: Overrun underrun flag.
  550. * @arg SAI_FLAG_MUTEDET: Mute detection flag.
  551. * @arg SAI_FLAG_WCKCFG: Wrong Clock Configuration flag.
  552. * @arg SAI_FLAG_FREQ: FIFO request flag.
  553. * @arg SAI_FLAG_CNRDY: Codec not ready flag.
  554. * @arg SAI_FLAG_AFSDET: Anticipated frame synchronization detection flag.
  555. * @arg SAI_FLAG_LFSDET: Late frame synchronization detection flag.
  556. * @retval The new state of __FLAG__ (TRUE or FALSE).
  557. */
  558. #define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
  559. /** @brief Clear the specified SAI pending flag.
  560. * @param __HANDLE__ specifies the SAI Handle.
  561. * @param __FLAG__ specifies the flag to check.
  562. * This parameter can be any combination of the following values:
  563. * @arg SAI_FLAG_OVRUDR: Clear Overrun underrun
  564. * @arg SAI_FLAG_MUTEDET: Clear Mute detection
  565. * @arg SAI_FLAG_WCKCFG: Clear Wrong Clock Configuration
  566. * @arg SAI_FLAG_FREQ: Clear FIFO request
  567. * @arg SAI_FLAG_CNRDY: Clear Codec not ready
  568. * @arg SAI_FLAG_AFSDET: Clear Anticipated frame synchronization detection
  569. * @arg SAI_FLAG_LFSDET: Clear Late frame synchronization detection
  570. * @retval None
  571. */
  572. #define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__))
  573. /** @brief Enable SAI
  574. * @param __HANDLE__ specifies the SAI Handle.
  575. * @retval None
  576. */
  577. #define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN)
  578. /** @brief Disable SAI
  579. * @param __HANDLE__ specifies the SAI Handle.
  580. * @retval None
  581. */
  582. #define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN)
  583. /**
  584. * @}
  585. */
  586. /* Include HAL SAI Extension module */
  587. #include "stm32f4xx_hal_sai_ex.h"
  588. /* Exported functions --------------------------------------------------------*/
  589. /** @addtogroup SAI_Exported_Functions
  590. * @{
  591. */
  592. /* Initialization/de-initialization functions **********************************/
  593. /** @addtogroup SAI_Exported_Functions_Group1
  594. * @{
  595. */
  596. HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot);
  597. HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai);
  598. HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai);
  599. void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai);
  600. void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai);
  601. #if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
  602. /* SAI callbacks register/unregister functions ********************************/
  603. HAL_StatusTypeDef HAL_SAI_RegisterCallback(SAI_HandleTypeDef *hsai,
  604. HAL_SAI_CallbackIDTypeDef CallbackID,
  605. pSAI_CallbackTypeDef pCallback);
  606. HAL_StatusTypeDef HAL_SAI_UnRegisterCallback(SAI_HandleTypeDef *hsai,
  607. HAL_SAI_CallbackIDTypeDef CallbackID);
  608. #endif /* USE_HAL_SAI_REGISTER_CALLBACKS */
  609. /**
  610. * @}
  611. */
  612. /* I/O operation functions *****************************************************/
  613. /** @addtogroup SAI_Exported_Functions_Group2
  614. * @{
  615. */
  616. /* Blocking mode: Polling */
  617. HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  618. HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
  619. /* Non-Blocking mode: Interrupt */
  620. HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
  621. HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
  622. /* Non-Blocking mode: DMA */
  623. HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
  624. HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
  625. HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai);
  626. HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai);
  627. HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai);
  628. /* Abort function */
  629. HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai);
  630. /* Mute management */
  631. HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val);
  632. HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai);
  633. HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter);
  634. HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai);
  635. /* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
  636. void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai);
  637. void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
  638. void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
  639. void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
  640. void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
  641. void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
  642. /**
  643. * @}
  644. */
  645. /** @addtogroup SAI_Exported_Functions_Group3
  646. * @{
  647. */
  648. /* Peripheral State functions ************************************************/
  649. HAL_SAI_StateTypeDef HAL_SAI_GetState(SAI_HandleTypeDef *hsai);
  650. uint32_t HAL_SAI_GetError(SAI_HandleTypeDef *hsai);
  651. /**
  652. * @}
  653. */
  654. /**
  655. * @}
  656. */
  657. /* Private macros ------------------------------------------------------------*/
  658. /** @addtogroup SAI_Private_Macros
  659. * @{
  660. */
  661. #define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\
  662. ((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\
  663. ((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE))
  664. #define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_I2S_STANDARD) ||\
  665. ((PROTOCOL) == SAI_I2S_MSBJUSTIFIED) ||\
  666. ((PROTOCOL) == SAI_I2S_LSBJUSTIFIED) ||\
  667. ((PROTOCOL) == SAI_PCM_LONG) ||\
  668. ((PROTOCOL) == SAI_PCM_SHORT))
  669. #define IS_SAI_PROTOCOL_DATASIZE(DATASIZE) (((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BIT) ||\
  670. ((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BITEXTENDED) ||\
  671. ((DATASIZE) == SAI_PROTOCOL_DATASIZE_24BIT) ||\
  672. ((DATASIZE) == SAI_PROTOCOL_DATASIZE_32BIT))
  673. #define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \
  674. ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \
  675. ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \
  676. ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \
  677. ((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV))
  678. #define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \
  679. ((MODE) == SAI_MODEMASTER_RX) || \
  680. ((MODE) == SAI_MODESLAVE_TX) || \
  681. ((MODE) == SAI_MODESLAVE_RX))
  682. #define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \
  683. ((PROTOCOL) == SAI_AC97_PROTOCOL) || \
  684. ((PROTOCOL) == SAI_SPDIF_PROTOCOL))
  685. #define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \
  686. ((DATASIZE) == SAI_DATASIZE_10) || \
  687. ((DATASIZE) == SAI_DATASIZE_16) || \
  688. ((DATASIZE) == SAI_DATASIZE_20) || \
  689. ((DATASIZE) == SAI_DATASIZE_24) || \
  690. ((DATASIZE) == SAI_DATASIZE_32))
  691. #define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \
  692. ((BIT) == SAI_FIRSTBIT_LSB))
  693. #define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \
  694. ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE))
  695. #define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \
  696. ((SYNCHRO) == SAI_SYNCHRONOUS) || \
  697. ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1) ||\
  698. ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2))
  699. #define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \
  700. ((DRIVE) == SAI_OUTPUTDRIVE_ENABLE))
  701. #define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \
  702. ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE))
  703. #define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63U)
  704. #define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \
  705. ((VALUE) == SAI_LAST_SENT_VALUE))
  706. #define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \
  707. ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \
  708. ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \
  709. ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \
  710. ((MODE) == SAI_ALAW_2CPL_COMPANDING))
  711. #define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \
  712. ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \
  713. ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \
  714. ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \
  715. ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL))
  716. #define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\
  717. ((STATE) == SAI_OUTPUT_RELEASED))
  718. #define IS_SAI_MONO_STEREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\
  719. ((MODE) == SAI_STEREOMODE))
  720. #define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) <= SAI_SLOTACTIVE_ALL)
  721. #define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1U <= (NUMBER)) && ((NUMBER) <= 16U))
  722. #define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \
  723. ((SIZE) == SAI_SLOTSIZE_16B) || \
  724. ((SIZE) == SAI_SLOTSIZE_32B))
  725. #define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24U)
  726. #define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \
  727. ((OFFSET) == SAI_FS_BEFOREFIRSTBIT))
  728. #define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \
  729. ((POLARITY) == SAI_FS_ACTIVE_HIGH))
  730. #define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \
  731. ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION))
  732. #define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 15U)
  733. #define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8U <= (LENGTH)) && ((LENGTH) <= 256U))
  734. #define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1U <= (LENGTH)) && ((LENGTH) <= 128U))
  735. /**
  736. * @}
  737. */
  738. /* Private functions ---------------------------------------------------------*/
  739. /** @defgroup SAI_Private_Functions SAI Private Functions
  740. * @{
  741. */
  742. /**
  743. * @}
  744. */
  745. /**
  746. * @}
  747. */
  748. #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx || STM32F413xx || STM32F423xx */
  749. /**
  750. * @}
  751. */
  752. #ifdef __cplusplus
  753. }
  754. #endif
  755. #endif /* __STM32F4xx_HAL_SAI_H */
  756. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/