Go to the documentation of this file.
21 #ifndef STM32H7xx_HAL_I2S_H
22 #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;
187 #define HAL_I2S_ERROR_NONE (0x00000000UL)
188 #define HAL_I2S_ERROR_TIMEOUT (0x00000001UL)
189 #define HAL_I2S_ERROR_OVR (0x00000002UL)
190 #define HAL_I2S_ERROR_UDR (0x00000004UL)
191 #define HAL_I2S_ERROR_DMA (0x00000008UL)
192 #define HAL_I2S_ERROR_PRESCALER (0x00000010UL)
193 #define HAL_I2S_ERROR_FRE (0x00000020UL)
194 #define HAL_I2S_ERROR_NO_OGT (0x00000040UL)
195 #define HAL_I2S_ERROR_NOT_SUPPORTED (0x00000080UL)
196 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
197 #define HAL_I2S_ERROR_INVALID_CALLBACK (0x00000100UL)
206 #define I2S_MODE_SLAVE_TX (0x00000000UL)
207 #define I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0)
208 #define I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1)
209 #define I2S_MODE_MASTER_RX (SPI_I2SCFGR_I2SCFG_0 | SPI_I2SCFGR_I2SCFG_1)
210 #define I2S_MODE_SLAVE_FULLDUPLEX (SPI_I2SCFGR_I2SCFG_2)
211 #define I2S_MODE_MASTER_FULLDUPLEX (SPI_I2SCFGR_I2SCFG_2 | SPI_I2SCFGR_I2SCFG_0)
219 #define I2S_STANDARD_PHILIPS (0x00000000UL)
220 #define I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0)
221 #define I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1)
222 #define I2S_STANDARD_PCM_SHORT (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1)
223 #define I2S_STANDARD_PCM_LONG (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC)
231 #define I2S_DATAFORMAT_16B (0x00000000UL)
232 #define I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN)
233 #define I2S_DATAFORMAT_24B (SPI_I2SCFGR_DATLEN_0)
234 #define I2S_DATAFORMAT_32B (SPI_I2SCFGR_DATLEN_1)
242 #define I2S_MCLKOUTPUT_ENABLE (SPI_I2SCFGR_MCKOE)
243 #define I2S_MCLKOUTPUT_DISABLE (0x00000000UL)
251 #define I2S_AUDIOFREQ_192K (192000UL)
252 #define I2S_AUDIOFREQ_96K (96000UL)
253 #define I2S_AUDIOFREQ_48K (48000UL)
254 #define I2S_AUDIOFREQ_44K (44100UL)
255 #define I2S_AUDIOFREQ_32K (32000UL)
256 #define I2S_AUDIOFREQ_22K (22050UL)
257 #define I2S_AUDIOFREQ_16K (16000UL)
258 #define I2S_AUDIOFREQ_11K (11025UL)
259 #define I2S_AUDIOFREQ_8K (8000UL)
260 #define I2S_AUDIOFREQ_DEFAULT (2UL)
268 #define I2S_CPOL_LOW (0x00000000UL)
269 #define I2S_CPOL_HIGH (SPI_I2SCFGR_CKPOL)
277 #define I2S_FIRSTBIT_MSB (0x00000000UL)
278 #define I2S_FIRSTBIT_LSB SPI_CFG2_LSBFRST
286 #define I2S_WS_INVERSION_DISABLE (0x00000000UL)
287 #define I2S_WS_INVERSION_ENABLE SPI_I2SCFGR_WSINV
295 #define I2S_DATA_24BIT_ALIGNMENT_RIGHT (0x00000000UL)
296 #define I2S_DATA_24BIT_ALIGNMENT_LEFT SPI_I2SCFGR_DATFMT
304 #define I2S_MASTER_KEEP_IO_STATE_DISABLE (0x00000000U)
305 #define I2S_MASTER_KEEP_IO_STATE_ENABLE SPI_CFG2_AFCNTR
313 #define I2S_IT_RXP SPI_IER_RXPIE
314 #define I2S_IT_TXP SPI_IER_TXPIE
315 #define I2S_IT_DXP SPI_IER_DXPIE
316 #define I2S_IT_UDR SPI_IER_UDRIE
317 #define I2S_IT_OVR SPI_IER_OVRIE
318 #define I2S_IT_FRE SPI_IER_TIFREIE
319 #define I2S_IT_ERR (SPI_IER_UDRIE | SPI_IER_OVRIE | SPI_IER_TIFREIE)
327 #define I2S_FLAG_RXP SPI_SR_RXP
328 #define I2S_FLAG_TXP SPI_SR_TXP
329 #define I2S_FLAG_DXP SPI_SR_DXP
330 #define I2S_FLAG_UDR SPI_SR_UDR
331 #define I2S_FLAG_OVR SPI_SR_OVR
332 #define I2S_FLAG_FRE SPI_SR_TIFRE
334 #define I2S_FLAG_MASK (SPI_SR_RXP | SPI_SR_TXP | SPI_SR_DXP |SPI_SR_UDR | SPI_SR_OVR | SPI_SR_TIFRE)
352 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
353 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) do{ \
354 (__HANDLE__)->State = HAL_I2S_STATE_RESET; \
355 (__HANDLE__)->MspInitCallback = NULL; \
356 (__HANDLE__)->MspDeInitCallback = NULL; \
359 #define __HAL_I2S_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2S_STATE_RESET)
366 #define __HAL_I2S_ENABLE(__HANDLE__) (SET_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE))
372 #define __HAL_I2S_DISABLE(__HANDLE__) (CLEAR_BIT((__HANDLE__)->Instance->CR1, SPI_CR1_SPE))
387 #define __HAL_I2S_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER |= (__INTERRUPT__))
402 #define __HAL_I2S_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->IER &= (~(__INTERRUPT__)))
418 #define __HAL_I2S_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
432 #define __HAL_I2S_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
438 #define __HAL_I2S_CLEAR_OVRFLAG(__HANDLE__) SET_BIT((__HANDLE__)->Instance->IFCR , SPI_IFCR_OVRC)
444 #define __HAL_I2S_CLEAR_UDRFLAG(__HANDLE__) SET_BIT((__HANDLE__)->Instance->IFCR , SPI_IFCR_UDRC)
450 #define __HAL_I2S_CLEAR_TIFREFLAG(__HANDLE__) SET_BIT((__HANDLE__)->Instance->IFCR , SPI_IFCR_TIFREC)
471 #if (USE_HAL_I2S_REGISTER_CALLBACKS == 1UL)
487 uint16_t Size, uint32_t Timeout);
560 #define I2S_CHECK_FLAG(__SR__, __FLAG__) ((((__SR__) & ((__FLAG__) & I2S_FLAG_MASK)) == ((__FLAG__) & I2S_FLAG_MASK)) ? SET : RESET)
574 #define I2S_CHECK_IT_SOURCE(__IER__, __INTERRUPT__) ((((__IER__) & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
581 #define IS_I2S_MODE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \
582 ((__MODE__) == I2S_MODE_SLAVE_RX) || \
583 ((__MODE__) == I2S_MODE_MASTER_TX) || \
584 ((__MODE__) == I2S_MODE_MASTER_RX) || \
585 ((__MODE__) == I2S_MODE_SLAVE_FULLDUPLEX) || \
586 ((__MODE__) == I2S_MODE_MASTER_FULLDUPLEX))
588 #define IS_I2S_MASTER(__MODE__) (((__MODE__) == I2S_MODE_MASTER_TX) || \
589 ((__MODE__) == I2S_MODE_MASTER_RX) || \
590 ((__MODE__) == I2S_MODE_MASTER_FULLDUPLEX))
592 #define IS_I2S_SLAVE(__MODE__) (((__MODE__) == I2S_MODE_SLAVE_TX) || \
593 ((__MODE__) == I2S_MODE_SLAVE_RX) || \
594 ((__MODE__) == I2S_MODE_SLAVE_FULLDUPLEX))
596 #define IS_I2S_FULLDUPLEX(__MODE__) (((__MODE__) == I2S_MODE_MASTER_FULLDUPLEX) || \
597 ((__MODE__) == I2S_MODE_SLAVE_FULLDUPLEX))
599 #define IS_I2S_STANDARD(__STANDARD__) (((__STANDARD__) == I2S_STANDARD_PHILIPS) || \
600 ((__STANDARD__) == I2S_STANDARD_MSB) || \
601 ((__STANDARD__) == I2S_STANDARD_LSB) || \
602 ((__STANDARD__) == I2S_STANDARD_PCM_SHORT) || \
603 ((__STANDARD__) == I2S_STANDARD_PCM_LONG))
605 #define IS_I2S_DATA_FORMAT(__FORMAT__) (((__FORMAT__) == I2S_DATAFORMAT_16B) || \
606 ((__FORMAT__) == I2S_DATAFORMAT_16B_EXTENDED) || \
607 ((__FORMAT__) == I2S_DATAFORMAT_24B) || \
608 ((__FORMAT__) == I2S_DATAFORMAT_32B))
610 #define IS_I2S_MCLK_OUTPUT(__OUTPUT__) (((__OUTPUT__) == I2S_MCLKOUTPUT_ENABLE) || \
611 ((__OUTPUT__) == I2S_MCLKOUTPUT_DISABLE))
613 #define IS_I2S_AUDIO_FREQ(__FREQ__) ((((__FREQ__) >= I2S_AUDIOFREQ_8K) && \
614 ((__FREQ__) <= I2S_AUDIOFREQ_192K)) || \
615 ((__FREQ__) == I2S_AUDIOFREQ_DEFAULT))
617 #define IS_I2S_CPOL(__CPOL__) (((__CPOL__) == I2S_CPOL_LOW) || \
618 ((__CPOL__) == I2S_CPOL_HIGH))
620 #define IS_I2S_FIRST_BIT(__BIT__) (((__BIT__) == I2S_FIRSTBIT_MSB) || \
621 ((__BIT__) == I2S_FIRSTBIT_LSB))
623 #define IS_I2S_WS_INVERSION(__WSINV__) (((__WSINV__) == I2S_WS_INVERSION_DISABLE) || \
624 ((__WSINV__) == I2S_WS_INVERSION_ENABLE))
626 #define IS_I2S_DATA_24BIT_ALIGNMENT(__ALIGNMENT__) (((__ALIGNMENT__) == I2S_DATA_24BIT_ALIGNMENT_RIGHT) || \
627 ((__ALIGNMENT__) == I2S_DATA_24BIT_ALIGNMENT_LEFT))
629 #define IS_I2S_MASTER_KEEP_IO_STATE(__AFCNTR__) (((__AFCNTR__) == I2S_MASTER_KEEP_IO_STATE_DISABLE) || \
630 ((__AFCNTR__) == I2S_MASTER_KEEP_IO_STATE_ENABLE))
void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s)
Serial Peripheral Interface.
void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Half Transfer completed callbacks.
HAL_StatusTypeDef
HAL Status structures definition
DMA handle Structure definition.
uint32_t MasterKeepIOState
@ HAL_I2S_STATE_BUSY_TX_RX
HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
Tx Transfer completed callbacks.
void(* RxISR)(struct __I2S_HandleTypeDef *hi2s)
void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Transfer completed callbacks.
I2S handle Structure definition.
void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
HAL_LockTypeDef
HAL Lock structures definition
HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s)
uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s)
struct __I2S_HandleTypeDef I2S_HandleTypeDef
I2S handle Structure definition.
I2S handle Structure definition.
HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
Rx Half Transfer completed callbacks.
HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s)
__IO uint16_t TxXferCount
HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s)
HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s)
__IO uint16_t RxXferCount
void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
I2S error callbacks.
void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s)
uint32_t Data24BitAlignment
__IO HAL_LockTypeDef Lock
void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s)
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size, uint32_t Timeout)
DMA_HandleTypeDef * hdmatx
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size)
This file contains HAL common defines, enumeration, macros and structures definitions.
__IO HAL_I2S_StateTypeDef State
HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s)
I2S Init structure definition.
HAL_I2S_StateTypeDef
HAL State structures definition.
void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s)
DMA_HandleTypeDef * hdmarx
__IO HAL_I2C_ModeTypeDef Mode
HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s)
HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
void(* TxISR)(struct __I2S_HandleTypeDef *hi2s)
HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size)