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.
 
 
 

969 lines
38 KiB

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