You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

984 lines
39 KiB

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