RTEMS 6.1-rc6
Loading...
Searching...
No Matches
stm32h7xx_hal_sai.h
Go to the documentation of this file.
1
19/* Define to prevent recursive inclusion -------------------------------------*/
20#ifndef STM32H7xx_HAL_SAI_H
21#define STM32H7xx_HAL_SAI_H
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
27/* Includes ------------------------------------------------------------------*/
28#include "stm32h7xx_hal_def.h"
29
38/* Exported types ------------------------------------------------------------*/
47typedef enum
48{
55
59typedef void (*SAIcallback)(void);
60
66typedef struct
67{
68 FunctionalState Activation;
69 uint32_t MicPairsNbr;
71 uint32_t ClockEnable;
83typedef struct
84{
85 uint32_t AudioMode;
88 uint32_t Synchro;
91 uint32_t SynchroExt;
97 uint32_t MckOutput;
101 uint32_t OutputDrive;
106 uint32_t NoDivider;
114 uint32_t FIFOThreshold;
117 uint32_t AudioFrequency;
120 uint32_t Mckdiv;
128 uint32_t MonoStereoMode;
131 uint32_t CompandingMode;
134 uint32_t TriState;
139 /* This part of the structure is automatically filled if your are using the high level initialisation
140 function HAL_SAI_InitProtocol */
141
142 uint32_t Protocol;
145 uint32_t DataSize;
148 uint32_t FirstBit;
151 uint32_t ClockStrobing;
164typedef struct
165{
166
167 uint32_t FrameLength;
178 uint32_t FSDefinition;
181 uint32_t FSPolarity;
184 uint32_t FSOffset;
199typedef struct
200{
201 uint32_t FirstBitOffset;
204 uint32_t SlotSize;
207 uint32_t SlotNumber;
210 uint32_t SlotActive;
223{
232 uint8_t *pBuffPtr;
234 uint16_t XferSize;
236 uint16_t XferCount;
244 void (*InterruptServiceRoutine)(struct __SAI_HandleTypeDef *hsai); /* function pointer for IRQ handler */
245
250 __IO uint32_t ErrorCode;
252#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
253 void (*RxCpltCallback)(struct __SAI_HandleTypeDef *hsai);
254 void (*RxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai);
255 void (*TxCpltCallback)(struct __SAI_HandleTypeDef *hsai);
256 void (*TxHalfCpltCallback)(struct __SAI_HandleTypeDef *hsai);
257 void (*ErrorCallback)(struct __SAI_HandleTypeDef *hsai);
258 void (*MspInitCallback)(struct __SAI_HandleTypeDef *hsai);
259 void (*MspDeInitCallback)(struct __SAI_HandleTypeDef *hsai);
260#endif
266#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
270typedef enum
271{
272 HAL_SAI_RX_COMPLETE_CB_ID = 0x00U,
273 HAL_SAI_RX_HALFCOMPLETE_CB_ID = 0x01U,
274 HAL_SAI_TX_COMPLETE_CB_ID = 0x02U,
275 HAL_SAI_TX_HALFCOMPLETE_CB_ID = 0x03U,
276 HAL_SAI_ERROR_CB_ID = 0x04U,
277 HAL_SAI_MSPINIT_CB_ID = 0x05U,
278 HAL_SAI_MSPDEINIT_CB_ID = 0x06U
279} HAL_SAI_CallbackIDTypeDef;
280
284typedef void (*pSAI_CallbackTypeDef)(SAI_HandleTypeDef *hsai);
285#endif
286
291/* Exported constants --------------------------------------------------------*/
301#define HAL_SAI_ERROR_NONE 0x00000000U
302#define HAL_SAI_ERROR_OVR 0x00000001U
303#define HAL_SAI_ERROR_UDR 0x00000002U
304#define HAL_SAI_ERROR_AFSDET 0x00000004U
305#define HAL_SAI_ERROR_LFSDET 0x00000008U
306#define HAL_SAI_ERROR_CNREADY 0x00000010U
307#define HAL_SAI_ERROR_WCKCFG 0x00000020U
308#define HAL_SAI_ERROR_TIMEOUT 0x00000040U
309#define HAL_SAI_ERROR_DMA 0x00000080U
310#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
311#define HAL_SAI_ERROR_INVALID_CALLBACK 0x00000100U
312#endif
321#define SAI_SYNCEXT_DISABLE 0U
322#define SAI_SYNCEXT_OUTBLOCKA_ENABLE 1U
323#define SAI_SYNCEXT_OUTBLOCKB_ENABLE 2U
332#define SAI_MCK_OUTPUT_DISABLE 0x00000000U
333#define SAI_MCK_OUTPUT_ENABLE SAI_xCR1_MCKEN
342#define SAI_I2S_STANDARD 0U
343#define SAI_I2S_MSBJUSTIFIED 1U
344#define SAI_I2S_LSBJUSTIFIED 2U
345#define SAI_PCM_LONG 3U
346#define SAI_PCM_SHORT 4U
355#define SAI_PROTOCOL_DATASIZE_16BIT 0U
356#define SAI_PROTOCOL_DATASIZE_16BITEXTENDED 1U
357#define SAI_PROTOCOL_DATASIZE_24BIT 2U
358#define SAI_PROTOCOL_DATASIZE_32BIT 3U
367#define SAI_AUDIO_FREQUENCY_192K 192000U
368#define SAI_AUDIO_FREQUENCY_96K 96000U
369#define SAI_AUDIO_FREQUENCY_48K 48000U
370#define SAI_AUDIO_FREQUENCY_44K 44100U
371#define SAI_AUDIO_FREQUENCY_32K 32000U
372#define SAI_AUDIO_FREQUENCY_22K 22050U
373#define SAI_AUDIO_FREQUENCY_16K 16000U
374#define SAI_AUDIO_FREQUENCY_11K 11025U
375#define SAI_AUDIO_FREQUENCY_8K 8000U
376#define SAI_AUDIO_FREQUENCY_MCKDIV 0U
385#define SAI_MCK_OVERSAMPLING_DISABLE 0x00000000U
386#define SAI_MCK_OVERSAMPLING_ENABLE SAI_xCR1_OSR
395#define SAI_PDM_CLOCK1_ENABLE SAI_PDMCR_CKEN1
396#define SAI_PDM_CLOCK2_ENABLE SAI_PDMCR_CKEN2
405#define SAI_MODEMASTER_TX 0x00000000U
406#define SAI_MODEMASTER_RX SAI_xCR1_MODE_0
407#define SAI_MODESLAVE_TX SAI_xCR1_MODE_1
408#define SAI_MODESLAVE_RX (SAI_xCR1_MODE_1 | SAI_xCR1_MODE_0)
409
418#define SAI_FREE_PROTOCOL 0x00000000U
419#define SAI_SPDIF_PROTOCOL SAI_xCR1_PRTCFG_0
420#define SAI_AC97_PROTOCOL SAI_xCR1_PRTCFG_1
429#define SAI_DATASIZE_8 SAI_xCR1_DS_1
430#define SAI_DATASIZE_10 (SAI_xCR1_DS_1 | SAI_xCR1_DS_0)
431#define SAI_DATASIZE_16 SAI_xCR1_DS_2
432#define SAI_DATASIZE_20 (SAI_xCR1_DS_2 | SAI_xCR1_DS_0)
433#define SAI_DATASIZE_24 (SAI_xCR1_DS_2 | SAI_xCR1_DS_1)
434#define SAI_DATASIZE_32 (SAI_xCR1_DS_2 | SAI_xCR1_DS_1 | SAI_xCR1_DS_0)
443#define SAI_FIRSTBIT_MSB 0x00000000U
444#define SAI_FIRSTBIT_LSB SAI_xCR1_LSBFIRST
453#define SAI_CLOCKSTROBING_FALLINGEDGE 0U
454#define SAI_CLOCKSTROBING_RISINGEDGE 1U
463#define SAI_ASYNCHRONOUS 0U
464#define SAI_SYNCHRONOUS 1U
465#define SAI_SYNCHRONOUS_EXT_SAI1 2U
466#if defined(SAI2)
467#define SAI_SYNCHRONOUS_EXT_SAI2 3U
468#endif /* SAI2 */
469#if defined(SAI3)
470#define SAI_SYNCHRONOUS_EXT_SAI3 4U
471#endif /* SAI3 */
472#if defined(SAI4)
473#define SAI_SYNCHRONOUS_EXT_SAI4 5U
474#endif /* SAI4 */
483#define SAI_OUTPUTDRIVE_DISABLE 0x00000000U
484#define SAI_OUTPUTDRIVE_ENABLE SAI_xCR1_OUTDRIV
493#define SAI_MASTERDIVIDER_ENABLE 0x00000000U
494#define SAI_MASTERDIVIDER_DISABLE SAI_xCR1_NODIV
503#define SAI_FS_STARTFRAME 0x00000000U
504#define SAI_FS_CHANNEL_IDENTIFICATION SAI_xFRCR_FSDEF
513#define SAI_FS_ACTIVE_LOW 0x00000000U
514#define SAI_FS_ACTIVE_HIGH SAI_xFRCR_FSPOL
523#define SAI_FS_FIRSTBIT 0x00000000U
524#define SAI_FS_BEFOREFIRSTBIT SAI_xFRCR_FSOFF
533#define SAI_SLOTSIZE_DATASIZE 0x00000000U
534#define SAI_SLOTSIZE_16B SAI_xSLOTR_SLOTSZ_0
535#define SAI_SLOTSIZE_32B SAI_xSLOTR_SLOTSZ_1
544#define SAI_SLOT_NOTACTIVE 0x00000000U
545#define SAI_SLOTACTIVE_0 0x00000001U
546#define SAI_SLOTACTIVE_1 0x00000002U
547#define SAI_SLOTACTIVE_2 0x00000004U
548#define SAI_SLOTACTIVE_3 0x00000008U
549#define SAI_SLOTACTIVE_4 0x00000010U
550#define SAI_SLOTACTIVE_5 0x00000020U
551#define SAI_SLOTACTIVE_6 0x00000040U
552#define SAI_SLOTACTIVE_7 0x00000080U
553#define SAI_SLOTACTIVE_8 0x00000100U
554#define SAI_SLOTACTIVE_9 0x00000200U
555#define SAI_SLOTACTIVE_10 0x00000400U
556#define SAI_SLOTACTIVE_11 0x00000800U
557#define SAI_SLOTACTIVE_12 0x00001000U
558#define SAI_SLOTACTIVE_13 0x00002000U
559#define SAI_SLOTACTIVE_14 0x00004000U
560#define SAI_SLOTACTIVE_15 0x00008000U
561#define SAI_SLOTACTIVE_ALL 0x0000FFFFU
570#define SAI_STEREOMODE 0x00000000U
571#define SAI_MONOMODE SAI_xCR1_MONO
580#define SAI_OUTPUT_NOTRELEASED 0x00000000U
581#define SAI_OUTPUT_RELEASED SAI_xCR2_TRIS
590#define SAI_FIFOTHRESHOLD_EMPTY 0x00000000U
591#define SAI_FIFOTHRESHOLD_1QF SAI_xCR2_FTH_0
592#define SAI_FIFOTHRESHOLD_HF SAI_xCR2_FTH_1
593#define SAI_FIFOTHRESHOLD_3QF (SAI_xCR2_FTH_1 | SAI_xCR2_FTH_0)
594#define SAI_FIFOTHRESHOLD_FULL SAI_xCR2_FTH_2
603#define SAI_NOCOMPANDING 0x00000000U
604#define SAI_ULAW_1CPL_COMPANDING SAI_xCR2_COMP_1
605#define SAI_ALAW_1CPL_COMPANDING (SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0)
606#define SAI_ULAW_2CPL_COMPANDING (SAI_xCR2_COMP_1 | SAI_xCR2_CPL)
607#define SAI_ALAW_2CPL_COMPANDING (SAI_xCR2_COMP_1 | SAI_xCR2_COMP_0 | SAI_xCR2_CPL)
616#define SAI_ZERO_VALUE 0x00000000U
617#define SAI_LAST_SENT_VALUE SAI_xCR2_MUTEVAL
626#define SAI_IT_OVRUDR SAI_xIMR_OVRUDRIE
627#define SAI_IT_MUTEDET SAI_xIMR_MUTEDETIE
628#define SAI_IT_WCKCFG SAI_xIMR_WCKCFGIE
629#define SAI_IT_FREQ SAI_xIMR_FREQIE
630#define SAI_IT_CNRDY SAI_xIMR_CNRDYIE
631#define SAI_IT_AFSDET SAI_xIMR_AFSDETIE
632#define SAI_IT_LFSDET SAI_xIMR_LFSDETIE
641#define SAI_FLAG_OVRUDR SAI_xSR_OVRUDR
642#define SAI_FLAG_MUTEDET SAI_xSR_MUTEDET
643#define SAI_FLAG_WCKCFG SAI_xSR_WCKCFG
644#define SAI_FLAG_FREQ SAI_xSR_FREQ
645#define SAI_FLAG_CNRDY SAI_xSR_CNRDY
646#define SAI_FLAG_AFSDET SAI_xSR_AFSDET
647#define SAI_FLAG_LFSDET SAI_xSR_LFSDET
656#define SAI_FIFOSTATUS_EMPTY 0x00000000U
657#define SAI_FIFOSTATUS_LESS1QUARTERFULL 0x00010000U
658#define SAI_FIFOSTATUS_1QUARTERFULL 0x00020000U
659#define SAI_FIFOSTATUS_HALFFULL 0x00030000U
660#define SAI_FIFOSTATUS_3QUARTERFULL 0x00040000U
661#define SAI_FIFOSTATUS_FULL 0x00050000U
670/* Exported macro ------------------------------------------------------------*/
681#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
682#define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) do{ \
683 (__HANDLE__)->State = HAL_SAI_STATE_RESET; \
684 (__HANDLE__)->MspInitCallback = NULL; \
685 (__HANDLE__)->MspDeInitCallback = NULL; \
686 } while(0U)
687#else
688#define __HAL_SAI_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SAI_STATE_RESET)
689#endif
690
704#define __HAL_SAI_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR |= (__INTERRUPT__))
705
719#define __HAL_SAI_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IMR &= (~(__INTERRUPT__)))
720
734#define __HAL_SAI_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IMR & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
735
749#define __HAL_SAI_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
750
765#define __HAL_SAI_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->CLRFR = (__FLAG__))
766
771#define __HAL_SAI_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= SAI_xCR1_SAIEN)
772
777#define __HAL_SAI_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~SAI_xCR1_SAIEN)
778
783/* Include SAI HAL Extension module */
784#include "stm32h7xx_hal_sai_ex.h"
785
786/* Exported functions --------------------------------------------------------*/
791/* Initialization/de-initialization functions ********************************/
795HAL_StatusTypeDef HAL_SAI_InitProtocol(SAI_HandleTypeDef *hsai, uint32_t protocol, uint32_t datasize, uint32_t nbslot);
796HAL_StatusTypeDef HAL_SAI_Init(SAI_HandleTypeDef *hsai);
797HAL_StatusTypeDef HAL_SAI_DeInit(SAI_HandleTypeDef *hsai);
798void HAL_SAI_MspInit(SAI_HandleTypeDef *hsai);
799void HAL_SAI_MspDeInit(SAI_HandleTypeDef *hsai);
800
801#if (USE_HAL_SAI_REGISTER_CALLBACKS == 1)
802/* SAI callbacks register/unregister functions ********************************/
803HAL_StatusTypeDef HAL_SAI_RegisterCallback(SAI_HandleTypeDef *hsai,
804 HAL_SAI_CallbackIDTypeDef CallbackID,
805 pSAI_CallbackTypeDef pCallback);
806HAL_StatusTypeDef HAL_SAI_UnRegisterCallback(SAI_HandleTypeDef *hsai,
807 HAL_SAI_CallbackIDTypeDef CallbackID);
808#endif
813/* I/O operation functions ***************************************************/
817/* Blocking mode: Polling */
818HAL_StatusTypeDef HAL_SAI_Transmit(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
819HAL_StatusTypeDef HAL_SAI_Receive(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size, uint32_t Timeout);
820
821/* Non-Blocking mode: Interrupt */
822HAL_StatusTypeDef HAL_SAI_Transmit_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
823HAL_StatusTypeDef HAL_SAI_Receive_IT(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
824
825/* Non-Blocking mode: DMA */
826HAL_StatusTypeDef HAL_SAI_Transmit_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
827HAL_StatusTypeDef HAL_SAI_Receive_DMA(SAI_HandleTypeDef *hsai, uint8_t *pData, uint16_t Size);
828HAL_StatusTypeDef HAL_SAI_DMAPause(SAI_HandleTypeDef *hsai);
829HAL_StatusTypeDef HAL_SAI_DMAResume(SAI_HandleTypeDef *hsai);
830HAL_StatusTypeDef HAL_SAI_DMAStop(SAI_HandleTypeDef *hsai);
831
832/* Abort function */
833HAL_StatusTypeDef HAL_SAI_Abort(SAI_HandleTypeDef *hsai);
834
835/* Mute management */
836HAL_StatusTypeDef HAL_SAI_EnableTxMuteMode(SAI_HandleTypeDef *hsai, uint16_t val);
837HAL_StatusTypeDef HAL_SAI_DisableTxMuteMode(SAI_HandleTypeDef *hsai);
838HAL_StatusTypeDef HAL_SAI_EnableRxMuteMode(SAI_HandleTypeDef *hsai, SAIcallback callback, uint16_t counter);
839HAL_StatusTypeDef HAL_SAI_DisableRxMuteMode(SAI_HandleTypeDef *hsai);
840
841/* SAI IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
842void HAL_SAI_IRQHandler(SAI_HandleTypeDef *hsai);
843void HAL_SAI_TxHalfCpltCallback(SAI_HandleTypeDef *hsai);
844void HAL_SAI_TxCpltCallback(SAI_HandleTypeDef *hsai);
845void HAL_SAI_RxHalfCpltCallback(SAI_HandleTypeDef *hsai);
846void HAL_SAI_RxCpltCallback(SAI_HandleTypeDef *hsai);
847void HAL_SAI_ErrorCallback(SAI_HandleTypeDef *hsai);
855/* Peripheral State functions ************************************************/
856HAL_SAI_StateTypeDef HAL_SAI_GetState(const SAI_HandleTypeDef *hsai);
857uint32_t HAL_SAI_GetError(const SAI_HandleTypeDef *hsai);
866/* Private macros ------------------------------------------------------------*/
871#define IS_SAI_BLOCK_SYNCEXT(STATE) (((STATE) == SAI_SYNCEXT_DISABLE) ||\
872 ((STATE) == SAI_SYNCEXT_OUTBLOCKA_ENABLE) ||\
873 ((STATE) == SAI_SYNCEXT_OUTBLOCKB_ENABLE))
874
875#define IS_SAI_SUPPORTED_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_I2S_STANDARD) ||\
876 ((PROTOCOL) == SAI_I2S_MSBJUSTIFIED) ||\
877 ((PROTOCOL) == SAI_I2S_LSBJUSTIFIED) ||\
878 ((PROTOCOL) == SAI_PCM_LONG) ||\
879 ((PROTOCOL) == SAI_PCM_SHORT))
880
881#define IS_SAI_PROTOCOL_DATASIZE(DATASIZE) (((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BIT) ||\
882 ((DATASIZE) == SAI_PROTOCOL_DATASIZE_16BITEXTENDED) ||\
883 ((DATASIZE) == SAI_PROTOCOL_DATASIZE_24BIT) ||\
884 ((DATASIZE) == SAI_PROTOCOL_DATASIZE_32BIT))
885
886#define IS_SAI_AUDIO_FREQUENCY(AUDIO) (((AUDIO) == SAI_AUDIO_FREQUENCY_192K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_96K) || \
887 ((AUDIO) == SAI_AUDIO_FREQUENCY_48K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_44K) || \
888 ((AUDIO) == SAI_AUDIO_FREQUENCY_32K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_22K) || \
889 ((AUDIO) == SAI_AUDIO_FREQUENCY_16K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_11K) || \
890 ((AUDIO) == SAI_AUDIO_FREQUENCY_8K) || ((AUDIO) == SAI_AUDIO_FREQUENCY_MCKDIV))
891
892#define IS_SAI_BLOCK_MCK_OVERSAMPLING(VALUE) (((VALUE) == SAI_MCK_OVERSAMPLING_DISABLE) || \
893 ((VALUE) == SAI_MCK_OVERSAMPLING_ENABLE))
894
895#define IS_SAI_PDM_MIC_PAIRS_NUMBER(VALUE) ((1U <= (VALUE)) && ((VALUE) <= 3U))
896
897#define IS_SAI_PDM_CLOCK_ENABLE(CLOCK) (((CLOCK) != 0U) && \
898 (((CLOCK) & ~(SAI_PDM_CLOCK1_ENABLE | SAI_PDM_CLOCK2_ENABLE)) == 0U))
899
900#define IS_SAI_BLOCK_MODE(MODE) (((MODE) == SAI_MODEMASTER_TX) || \
901 ((MODE) == SAI_MODEMASTER_RX) || \
902 ((MODE) == SAI_MODESLAVE_TX) || \
903 ((MODE) == SAI_MODESLAVE_RX))
904
905#define IS_SAI_BLOCK_PROTOCOL(PROTOCOL) (((PROTOCOL) == SAI_FREE_PROTOCOL) || \
906 ((PROTOCOL) == SAI_AC97_PROTOCOL) || \
907 ((PROTOCOL) == SAI_SPDIF_PROTOCOL))
908
909#define IS_SAI_BLOCK_DATASIZE(DATASIZE) (((DATASIZE) == SAI_DATASIZE_8) || \
910 ((DATASIZE) == SAI_DATASIZE_10) || \
911 ((DATASIZE) == SAI_DATASIZE_16) || \
912 ((DATASIZE) == SAI_DATASIZE_20) || \
913 ((DATASIZE) == SAI_DATASIZE_24) || \
914 ((DATASIZE) == SAI_DATASIZE_32))
915
916#define IS_SAI_BLOCK_FIRST_BIT(BIT) (((BIT) == SAI_FIRSTBIT_MSB) || \
917 ((BIT) == SAI_FIRSTBIT_LSB))
918
919#define IS_SAI_BLOCK_CLOCK_STROBING(CLOCK) (((CLOCK) == SAI_CLOCKSTROBING_FALLINGEDGE) || \
920 ((CLOCK) == SAI_CLOCKSTROBING_RISINGEDGE))
921#if defined(SAI2) && defined(SAI3) && defined(SAI4)
922#define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \
923 ((SYNCHRO) == SAI_SYNCHRONOUS) || \
924 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1) || \
925 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2) || \
926 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI3) || \
927 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI4))
928#elif defined(SAI2)
929#define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \
930 ((SYNCHRO) == SAI_SYNCHRONOUS) || \
931 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1) || \
932 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI2))
933#else
934#define IS_SAI_BLOCK_SYNCHRO(SYNCHRO) (((SYNCHRO) == SAI_ASYNCHRONOUS) || \
935 ((SYNCHRO) == SAI_SYNCHRONOUS) || \
936 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI1) || \
937 ((SYNCHRO) == SAI_SYNCHRONOUS_EXT_SAI4))
938#endif
939
940#define IS_SAI_BLOCK_MCK_OUTPUT(VALUE) (((VALUE) == SAI_MCK_OUTPUT_ENABLE) || \
941 ((VALUE) == SAI_MCK_OUTPUT_DISABLE))
942
943#define IS_SAI_BLOCK_OUTPUT_DRIVE(DRIVE) (((DRIVE) == SAI_OUTPUTDRIVE_DISABLE) || \
944 ((DRIVE) == SAI_OUTPUTDRIVE_ENABLE))
945
946#define IS_SAI_BLOCK_NODIVIDER(NODIVIDER) (((NODIVIDER) == SAI_MASTERDIVIDER_ENABLE) || \
947 ((NODIVIDER) == SAI_MASTERDIVIDER_DISABLE))
948
949#define IS_SAI_BLOCK_MUTE_COUNTER(COUNTER) ((COUNTER) <= 63U)
950
951#define IS_SAI_BLOCK_MUTE_VALUE(VALUE) (((VALUE) == SAI_ZERO_VALUE) || \
952 ((VALUE) == SAI_LAST_SENT_VALUE))
953
954#define IS_SAI_BLOCK_COMPANDING_MODE(MODE) (((MODE) == SAI_NOCOMPANDING) || \
955 ((MODE) == SAI_ULAW_1CPL_COMPANDING) || \
956 ((MODE) == SAI_ALAW_1CPL_COMPANDING) || \
957 ((MODE) == SAI_ULAW_2CPL_COMPANDING) || \
958 ((MODE) == SAI_ALAW_2CPL_COMPANDING))
959
960#define IS_SAI_BLOCK_FIFO_THRESHOLD(THRESHOLD) (((THRESHOLD) == SAI_FIFOTHRESHOLD_EMPTY) || \
961 ((THRESHOLD) == SAI_FIFOTHRESHOLD_1QF) || \
962 ((THRESHOLD) == SAI_FIFOTHRESHOLD_HF) || \
963 ((THRESHOLD) == SAI_FIFOTHRESHOLD_3QF) || \
964 ((THRESHOLD) == SAI_FIFOTHRESHOLD_FULL))
965
966#define IS_SAI_BLOCK_TRISTATE_MANAGEMENT(STATE) (((STATE) == SAI_OUTPUT_NOTRELEASED) ||\
967 ((STATE) == SAI_OUTPUT_RELEASED))
968
969#define IS_SAI_MONO_STEREO_MODE(MODE) (((MODE) == SAI_MONOMODE) ||\
970 ((MODE) == SAI_STEREOMODE))
971
972#define IS_SAI_SLOT_ACTIVE(ACTIVE) ((ACTIVE) <= SAI_SLOTACTIVE_ALL)
973
974#define IS_SAI_BLOCK_SLOT_NUMBER(NUMBER) ((1U <= (NUMBER)) && ((NUMBER) <= 16U))
975
976#define IS_SAI_BLOCK_SLOT_SIZE(SIZE) (((SIZE) == SAI_SLOTSIZE_DATASIZE) || \
977 ((SIZE) == SAI_SLOTSIZE_16B) || \
978 ((SIZE) == SAI_SLOTSIZE_32B))
979
980#define IS_SAI_BLOCK_FIRSTBIT_OFFSET(OFFSET) ((OFFSET) <= 24U)
981
982#define IS_SAI_BLOCK_FS_OFFSET(OFFSET) (((OFFSET) == SAI_FS_FIRSTBIT) || \
983 ((OFFSET) == SAI_FS_BEFOREFIRSTBIT))
984
985#define IS_SAI_BLOCK_FS_POLARITY(POLARITY) (((POLARITY) == SAI_FS_ACTIVE_LOW) || \
986 ((POLARITY) == SAI_FS_ACTIVE_HIGH))
987
988#define IS_SAI_BLOCK_FS_DEFINITION(DEFINITION) (((DEFINITION) == SAI_FS_STARTFRAME) || \
989 ((DEFINITION) == SAI_FS_CHANNEL_IDENTIFICATION))
990
991#define IS_SAI_BLOCK_MASTER_DIVIDER(DIVIDER) ((DIVIDER) <= 63U)
992
993#define IS_SAI_BLOCK_FRAME_LENGTH(LENGTH) ((8U <= (LENGTH)) && ((LENGTH) <= 256U))
994
995#define IS_SAI_BLOCK_ACTIVE_FRAME(LENGTH) ((1U <= (LENGTH)) && ((LENGTH) <= 128U))
996
1001/* Private functions ---------------------------------------------------------*/
1019#ifdef __cplusplus
1020}
1021#endif
1022
1023#endif /* STM32H7xx_HAL_SAI_H */
1024
#define __IO
Definition: core_cm4.h:239
void(* SAIcallback)(void)
SAI Callback prototype.
Definition: stm32h7xx_hal_sai.h:59
HAL_SAI_StateTypeDef
HAL State structures definition.
Definition: stm32h7xx_hal_sai.h:48
@ HAL_SAI_STATE_RESET
Definition: stm32h7xx_hal_sai.h:49
@ HAL_SAI_STATE_BUSY_RX
Definition: stm32h7xx_hal_sai.h:53
@ HAL_SAI_STATE_READY
Definition: stm32h7xx_hal_sai.h:50
@ HAL_SAI_STATE_BUSY
Definition: stm32h7xx_hal_sai.h:51
@ HAL_SAI_STATE_BUSY_TX
Definition: stm32h7xx_hal_sai.h:52
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32h7xx_hal_def.h:47
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32h7xx_hal_def.h:58
Header file of SAI HAL extended module.
Definition: stm32h723xx.h:1375
Definition: stm32h7xx_hal_sai.h:165
uint32_t ActiveFrameLength
Definition: stm32h7xx_hal_sai.h:173
uint32_t FSPolarity
Definition: stm32h7xx_hal_sai.h:181
uint32_t FSDefinition
Definition: stm32h7xx_hal_sai.h:178
uint32_t FrameLength
Definition: stm32h7xx_hal_sai.h:167
uint32_t FSOffset
Definition: stm32h7xx_hal_sai.h:184
Definition: stm32h7xx_hal_sai.h:84
uint32_t Mckdiv
Definition: stm32h7xx_hal_sai.h:120
uint32_t Protocol
Definition: stm32h7xx_hal_sai.h:142
SAI_PdmInitTypeDef PdmInit
Definition: stm32h7xx_hal_sai.h:137
uint32_t NoDivider
Definition: stm32h7xx_hal_sai.h:106
uint32_t ClockStrobing
Definition: stm32h7xx_hal_sai.h:151
uint32_t MckOutput
Definition: stm32h7xx_hal_sai.h:97
uint32_t MonoStereoMode
Definition: stm32h7xx_hal_sai.h:128
uint32_t MckOverSampling
Definition: stm32h7xx_hal_sai.h:125
uint32_t SynchroExt
Definition: stm32h7xx_hal_sai.h:91
uint32_t DataSize
Definition: stm32h7xx_hal_sai.h:145
uint32_t FirstBit
Definition: stm32h7xx_hal_sai.h:148
uint32_t FIFOThreshold
Definition: stm32h7xx_hal_sai.h:114
uint32_t AudioFrequency
Definition: stm32h7xx_hal_sai.h:117
uint32_t AudioMode
Definition: stm32h7xx_hal_sai.h:85
uint32_t OutputDrive
Definition: stm32h7xx_hal_sai.h:101
uint32_t Synchro
Definition: stm32h7xx_hal_sai.h:88
uint32_t TriState
Definition: stm32h7xx_hal_sai.h:134
uint32_t CompandingMode
Definition: stm32h7xx_hal_sai.h:131
Definition: stm32h7xx_hal_sai.h:67
uint32_t MicPairsNbr
Definition: stm32h7xx_hal_sai.h:69
FunctionalState Activation
Definition: stm32h7xx_hal_sai.h:68
uint32_t ClockEnable
Definition: stm32h7xx_hal_sai.h:71
Definition: stm32h7xx_hal_sai.h:200
uint32_t SlotNumber
Definition: stm32h7xx_hal_sai.h:207
uint32_t SlotActive
Definition: stm32h7xx_hal_sai.h:210
uint32_t FirstBitOffset
Definition: stm32h7xx_hal_sai.h:201
uint32_t SlotSize
Definition: stm32h7xx_hal_sai.h:204
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138
Definition: stm32h7xx_hal_sai.h:223
HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_sai.h:246
SAI_InitTypeDef Init
Definition: stm32h7xx_hal_sai.h:226
DMA_HandleTypeDef * hdmatx
Definition: stm32h7xx_hal_sai.h:238
SAI_FrameInitTypeDef FrameInit
Definition: stm32h7xx_hal_sai.h:228
uint8_t * pBuffPtr
Definition: stm32h7xx_hal_sai.h:232
SAI_SlotInitTypeDef SlotInit
Definition: stm32h7xx_hal_sai.h:230
__IO uint32_t ErrorCode
Definition: stm32h7xx_hal_sai.h:250
__IO HAL_SAI_StateTypeDef State
Definition: stm32h7xx_hal_sai.h:248
uint16_t XferSize
Definition: stm32h7xx_hal_sai.h:234
SAI_Block_TypeDef * Instance
Definition: stm32h7xx_hal_sai.h:224
SAIcallback mutecallback
Definition: stm32h7xx_hal_sai.h:242
uint16_t XferCount
Definition: stm32h7xx_hal_sai.h:236
DMA_HandleTypeDef * hdmarx
Definition: stm32h7xx_hal_sai.h:240