20#ifndef STM32H7xx_HAL_I2S_H
21#define STM32H7xx_HAL_I2S_H
137#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
151#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
158 HAL_I2S_TX_COMPLETE_CB_ID = 0x00UL,
159 HAL_I2S_RX_COMPLETE_CB_ID = 0x01UL,
160 HAL_I2S_TX_RX_COMPLETE_CB_ID = 0x02UL,
161 HAL_I2S_TX_HALF_COMPLETE_CB_ID = 0x03UL,
162 HAL_I2S_RX_HALF_COMPLETE_CB_ID = 0x04UL,
163 HAL_I2S_TX_RX_HALF_COMPLETE_CB_ID = 0x05UL,
164 HAL_I2S_ERROR_CB_ID = 0x06UL,
165 HAL_I2S_MSPINIT_CB_ID = 0x07UL,
166 HAL_I2S_MSPDEINIT_CB_ID = 0x08UL
168} HAL_I2S_CallbackIDTypeDef;
189#define HAL_I2S_ERROR_NONE (0x00000000UL)
190#define HAL_I2S_ERROR_TIMEOUT (0x00000001UL)
191#define HAL_I2S_ERROR_OVR (0x00000002UL)
192#define HAL_I2S_ERROR_UDR (0x00000004UL)
193#define HAL_I2S_ERROR_DMA (0x00000008UL)
194#define HAL_I2S_ERROR_PRESCALER (0x00000010UL)
195#define HAL_I2S_ERROR_FRE (0x00000020UL)
196#define HAL_I2S_ERROR_NO_OGT (0x00000040UL)
197#define HAL_I2S_ERROR_NOT_SUPPORTED (0x00000080UL)
198#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
199#define HAL_I2S_ERROR_INVALID_CALLBACK (0x00000100UL)
209#define I2S_MODE_SLAVE_TX (0x00000000UL)
210#define I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0)
211#define I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1)
212#define I2S_MODE_MASTER_RX (SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1)
213#define I2S_MODE_SLAVE_FULLDUPLEX (SPI_I2SCFGR_I2SCFG_2)
214#define I2S_MODE_MASTER_FULLDUPLEX (SPI_I2SCFGR_I2SCFG_2 | SPI_I2SCFGR_I2SCFG_0)
223#define I2S_STANDARD_PHILIPS (0x00000000UL)
224#define I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0)
225#define I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1)
226#define I2S_STANDARD_PCM_SHORT (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1)
227#define I2S_STANDARD_PCM_LONG (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC)
236#define I2S_DATAFORMAT_16B (0x00000000UL)
237#define I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN)
238#define I2S_DATAFORMAT_24B (SPI_I2SCFGR_DATLEN_0)
239#define I2S_DATAFORMAT_32B (SPI_I2SCFGR_DATLEN_1)
248#define I2S_MCLKOUTPUT_ENABLE (SPI_I2SCFGR_MCKOE)
249#define I2S_MCLKOUTPUT_DISABLE (0x00000000UL)
258#define I2S_AUDIOFREQ_192K (192000UL)
259#define I2S_AUDIOFREQ_96K (96000UL)
260#define I2S_AUDIOFREQ_48K (48000UL)
261#define I2S_AUDIOFREQ_44K (44100UL)
262#define I2S_AUDIOFREQ_32K (32000UL)
263#define I2S_AUDIOFREQ_22K (22050UL)
264#define I2S_AUDIOFREQ_16K (16000UL)
265#define I2S_AUDIOFREQ_11K (11025UL)
266#define I2S_AUDIOFREQ_8K (8000UL)
267#define I2S_AUDIOFREQ_DEFAULT (2UL)
276#define I2S_CPOL_LOW (0x00000000UL)
277#define I2S_CPOL_HIGH (SPI_I2SCFGR_CKPOL)
286#define I2S_FIRSTBIT_MSB (0x00000000UL)
287#define I2S_FIRSTBIT_LSB SPI_CFG2_LSBFRST
296#define I2S_WS_INVERSION_DISABLE (0x00000000UL)
297#define I2S_WS_INVERSION_ENABLE SPI_I2SCFGR_WSINV
306#define I2S_DATA_24BIT_ALIGNMENT_RIGHT (0x00000000UL)
307#define I2S_DATA_24BIT_ALIGNMENT_LEFT SPI_I2SCFGR_DATFMT
316#define I2S_MASTER_KEEP_IO_STATE_DISABLE (0x00000000U)
317#define I2S_MASTER_KEEP_IO_STATE_ENABLE SPI_CFG2_AFCNTR
326#define I2S_IT_RXP SPI_IER_RXPIE
327#define I2S_IT_TXP SPI_IER_TXPIE
328#define I2S_IT_DXP SPI_IER_DXPIE
329#define I2S_IT_UDR SPI_IER_UDRIE
330#define I2S_IT_OVR SPI_IER_OVRIE
331#define I2S_IT_FRE SPI_IER_TIFREIE
332#define I2S_IT_ERR (SPI_IER_UDRIE | SPI_IER_OVRIE | SPI_IER_TIFREIE)
341#define I2S_FLAG_RXP SPI_SR_RXP
342#define I2S_FLAG_TXP SPI_SR_TXP
343#define I2S_FLAG_DXP SPI_SR_DXP
344#define I2S_FLAG_UDR SPI_SR_UDR
345#define I2S_FLAG_OVR SPI_SR_OVR
346#define I2S_FLAG_FRE SPI_SR_TIFRE
348#define I2S_FLAG_MASK (SPI_SR_RXP | SPI_SR_TXP | SPI_SR_DXP |SPI_SR_UDR | SPI_SR_OVR | SPI_SR_TIFRE)
367#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
368#define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) do{ \
369 (__HANDLE__)->State = HAL_I2S_STATE_RESET; \
370 (__HANDLE__)->MspInitCallback = NULL; \
371 (__HANDLE__)->MspDeInitCallback = NULL; \
374#define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET)
381#define __HAL_I2S_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE))
387#define __HAL_I2S_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE))
402#define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
417#define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
433#define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER\
434 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
448#define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
454#define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) SET_BIT((__HANDLE__)->Instance->IFCR , SPI_IFCR_OVRC)
460#define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) SET_BIT((__HANDLE__)->Instance->IFCR , SPI_IFCR_UDRC)
466#define __HAL_I2S_CLEAR_TIFREFLAG(__HANDLE__) SET_BIT((__HANDLE__)->Instance->IFCR , SPI_IFCR_TIFREC)
487#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
489 pI2S_CallbackTypeDef pCallback);
504 uint16_t Size, uint32_t Timeout);
589#define I2S_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__)\
590 & ((__FLAG__) & I2S_FLAG_MASK)) == ((__FLAG__) & I2S_FLAG_MASK))\
605#define I2S_CHECK_IT_SOURCE(__IER__, __INTERRUPT__) ((((__IER__)\
606 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
613#define IS_I2S_MODE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \
614 ((__MODE__) == I2S_MODE_SLAVE_RX) || \
615 ((__MODE__) == I2S_MODE_MASTER_TX) || \
616 ((__MODE__) == I2S_MODE_MASTER_RX) || \
617 ((__MODE__) == I2S_MODE_SLAVE_FULLDUPLEX) || \
618 ((__MODE__) == I2S_MODE_MASTER_FULLDUPLEX))
620#define IS_I2S_MASTER(__MODE__) (((__MODE__) == I2S_MODE_MASTER_TX) || \
621 ((__MODE__) == I2S_MODE_MASTER_RX) || \
622 ((__MODE__) == I2S_MODE_MASTER_FULLDUPLEX))
624#define IS_I2S_SLAVE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \
625 ((__MODE__) == I2S_MODE_SLAVE_RX) || \
626 ((__MODE__) == I2S_MODE_SLAVE_FULLDUPLEX))
628#define IS_I2S_FULLDUPLEX(__MODE__) (((__MODE__) == I2S_MODE_MASTER_FULLDUPLEX) || \
629 ((__MODE__) == I2S_MODE_SLAVE_FULLDUPLEX))
631#define IS_I2S_STANDARD(__STANDARD__) (((__STANDARD__) == I2S_STANDARD_PHILIPS) || \
632 ((__STANDARD__) == I2S_STANDARD_MSB) || \
633 ((__STANDARD__) == I2S_STANDARD_LSB) || \
634 ((__STANDARD__) == I2S_STANDARD_PCM_SHORT) || \
635 ((__STANDARD__) == I2S_STANDARD_PCM_LONG))
637#define IS_I2S_DATA_FORMAT(__FORMAT__) (((__FORMAT__) == I2S_DATAFORMAT_16B) || \
638 ((__FORMAT__) == I2S_DATAFORMAT_16B_EXTENDED) || \
639 ((__FORMAT__) == I2S_DATAFORMAT_24B) || \
640 ((__FORMAT__) == I2S_DATAFORMAT_32B))
642#define IS_I2S_MCLK_OUTPUT(__OUTPUT__) (((__OUTPUT__) == I2S_MCLKOUTPUT_ENABLE) || \
643 ((__OUTPUT__) == I2S_MCLKOUTPUT_DISABLE))
645#define IS_I2S_AUDIO_FREQ(__FREQ__) ((((__FREQ__) >= I2S_AUDIOFREQ_8K) && \
646 ((__FREQ__) <= I2S_AUDIOFREQ_192K)) || \
647 ((__FREQ__) == I2S_AUDIOFREQ_DEFAULT))
649#define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_CPOL_LOW) || \
650 ((__CPOL__) == I2S_CPOL_HIGH))
652#define IS_I2S_FIRST_BIT(__BIT__) (((__BIT__) == I2S_FIRSTBIT_MSB) || \
653 ((__BIT__) == I2S_FIRSTBIT_LSB))
655#define IS_I2S_WS_INVERSION(__WSINV__) (((__WSINV__) == I2S_WS_INVERSION_DISABLE) || \
656 ((__WSINV__) == I2S_WS_INVERSION_ENABLE))
658#define IS_I2S_DATA_24BIT_ALIGNMENT(__ALIGNMENT__) (((__ALIGNMENT__) == I2S_DATA_24BIT_ALIGNMENT_RIGHT) || \
659 ((__ALIGNMENT__) == I2S_DATA_24BIT_ALIGNMENT_LEFT))
661#define IS_I2S_MASTER_KEEP_IO_STATE(__AFCNTR__) (((__AFCNTR__) == I2S_MASTER_KEEP_IO_STATE_DISABLE) || \
662 ((__AFCNTR__) == I2S_MASTER_KEEP_IO_STATE_ENABLE))
#define __IO
Definition: core_cm4.h:239
HAL_I2S_StateTypeDef
HAL State structures definition.
Definition: stm32h7xx_hal_i2s.h:85
struct __I2S_HandleTypeDef I2S_HandleTypeDef
I2S handle Structure definition.
@ HAL_I2S_STATE_ERROR
Definition: stm32h7xx_hal_i2s.h:93
@ HAL_I2S_STATE_BUSY
Definition: stm32h7xx_hal_i2s.h:88
@ HAL_I2S_STATE_RESET
Definition: stm32h7xx_hal_i2s.h:86
@ HAL_I2S_STATE_BUSY_TX_RX
Definition: stm32h7xx_hal_i2s.h:91
@ HAL_I2S_STATE_BUSY_RX
Definition: stm32h7xx_hal_i2s.h:90
@ HAL_I2S_STATE_TIMEOUT
Definition: stm32h7xx_hal_i2s.h:92
@ HAL_I2S_STATE_BUSY_TX
Definition: stm32h7xx_hal_i2s.h:89
@ HAL_I2S_STATE_READY
Definition: stm32h7xx_hal_i2s.h:87
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
I2S Init structure definition.
Definition: stm32h7xx_hal_i2s.h:48
uint32_t MasterKeepIOState
Definition: stm32h7xx_hal_i2s.h:76
uint32_t WSInversion
Definition: stm32h7xx_hal_i2s.h:70
uint32_t AudioFreq
Definition: stm32h7xx_hal_i2s.h:61
uint32_t FirstBit
Definition: stm32h7xx_hal_i2s.h:67
uint32_t Standard
Definition: stm32h7xx_hal_i2s.h:52
uint32_t DataFormat
Definition: stm32h7xx_hal_i2s.h:55
uint32_t Data24BitAlignment
Definition: stm32h7xx_hal_i2s.h:73
uint32_t Mode
Definition: stm32h7xx_hal_i2s.h:49
uint32_t MCLKOutput
Definition: stm32h7xx_hal_i2s.h:58
uint32_t CPOL
Definition: stm32h7xx_hal_i2s.h:64
Serial Peripheral Interface.
Definition: stm32h723xx.h:1479
DMA handle Structure definition.
Definition: stm32h7xx_hal_dma.h:138
I2S handle Structure definition.
Definition: stm32h7xx_hal_i2s.h:100
void(* TxISR)(struct __I2S_HandleTypeDef *hi2s)
Definition: stm32h7xx_hal_i2s.h:124
__IO uint16_t RxXferCount
Definition: stm32h7xx_hal_i2s.h:115
DMA_HandleTypeDef * hdmarx
Definition: stm32h7xx_hal_i2s.h:128
__IO uint16_t TxXferCount
Definition: stm32h7xx_hal_i2s.h:109
__IO uint16_t RxXferSize
Definition: stm32h7xx_hal_i2s.h:113
I2S_InitTypeDef Init
Definition: stm32h7xx_hal_i2s.h:103
__IO uint32_t ErrorCode
Definition: stm32h7xx_hal_i2s.h:134
SPI_TypeDef * Instance
Definition: stm32h7xx_hal_i2s.h:101
void(* RxISR)(struct __I2S_HandleTypeDef *hi2s)
Definition: stm32h7xx_hal_i2s.h:122
DMA_HandleTypeDef * hdmatx
Definition: stm32h7xx_hal_i2s.h:126
__IO HAL_LockTypeDef Lock
Definition: stm32h7xx_hal_i2s.h:130
uint16_t * pRxBuffPtr
Definition: stm32h7xx_hal_i2s.h:111
__IO HAL_I2S_StateTypeDef State
Definition: stm32h7xx_hal_i2s.h:132
const uint16_t * pTxBuffPtr
Definition: stm32h7xx_hal_i2s.h:105
__IO uint16_t TxXferSize
Definition: stm32h7xx_hal_i2s.h:107