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.
 
 

175 lines
7.2 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_i2s_ex.h
  4. * @author MCD Application Team
  5. * @brief Header file of I2S HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2016 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 STM32F4xx_HAL_I2S_EX_H
  21. #define STM32F4xx_HAL_I2S_EX_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32f4xx_hal_def.h"
  27. /** @addtogroup STM32F4xx_HAL_Driver
  28. * @{
  29. */
  30. #if defined(SPI_I2S_FULLDUPLEX_SUPPORT)
  31. /** @addtogroup I2SEx I2SEx
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /* Exported constants --------------------------------------------------------*/
  36. /* Exported macros -----------------------------------------------------------*/
  37. /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros
  38. * @{
  39. */
  40. #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
  41. /** @brief Enable or disable the specified I2SExt peripheral.
  42. * @param __HANDLE__ specifies the I2S Handle.
  43. * @retval None
  44. */
  45. #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
  46. #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
  47. /** @brief Enable or disable the specified I2SExt interrupts.
  48. * @param __HANDLE__ specifies the I2S Handle.
  49. * @param __INTERRUPT__ specifies the interrupt source to enable or disable.
  50. * This parameter can be one of the following values:
  51. * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
  52. * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
  53. * @arg I2S_IT_ERR: Error interrupt enable
  54. * @retval None
  55. */
  56. #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__))
  57. #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__))
  58. /** @brief Checks if the specified I2SExt interrupt source is enabled or disabled.
  59. * @param __HANDLE__ specifies the I2S Handle.
  60. * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
  61. * @param __INTERRUPT__ specifies the I2S interrupt source to check.
  62. * This parameter can be one of the following values:
  63. * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
  64. * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
  65. * @arg I2S_IT_ERR: Error interrupt enable
  66. * @retval The new state of __IT__ (TRUE or FALSE).
  67. */
  68. #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  69. /** @brief Checks whether the specified I2SExt flag is set or not.
  70. * @param __HANDLE__ specifies the I2S Handle.
  71. * @param __FLAG__ specifies the flag to check.
  72. * This parameter can be one of the following values:
  73. * @arg I2S_FLAG_RXNE: Receive buffer not empty flag
  74. * @arg I2S_FLAG_TXE: Transmit buffer empty flag
  75. * @arg I2S_FLAG_UDR: Underrun flag
  76. * @arg I2S_FLAG_OVR: Overrun flag
  77. * @arg I2S_FLAG_FRE: Frame error flag
  78. * @arg I2S_FLAG_CHSIDE: Channel Side flag
  79. * @arg I2S_FLAG_BSY: Busy flag
  80. * @retval The new state of __FLAG__ (TRUE or FALSE).
  81. */
  82. #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__))
  83. /** @brief Clears the I2SExt OVR pending flag.
  84. * @param __HANDLE__ specifies the I2S Handle.
  85. * @retval None
  86. */
  87. #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \
  88. __IO uint32_t tmpreg_ovr = 0x00U; \
  89. tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\
  90. tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\
  91. UNUSED(tmpreg_ovr); \
  92. }while(0U)
  93. /** @brief Clears the I2SExt UDR pending flag.
  94. * @param __HANDLE__ specifies the I2S Handle.
  95. * @retval None
  96. */
  97. #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \
  98. __IO uint32_t tmpreg_udr = 0x00U; \
  99. tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\
  100. UNUSED(tmpreg_udr); \
  101. }while(0U)
  102. /**
  103. * @}
  104. */
  105. /* Exported functions --------------------------------------------------------*/
  106. /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
  107. * @{
  108. */
  109. /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
  110. * @{
  111. */
  112. /* Extended features functions *************************************************/
  113. /* Blocking mode: Polling */
  114. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  115. uint16_t Size, uint32_t Timeout);
  116. /* Non-Blocking mode: Interrupt */
  117. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  118. uint16_t Size);
  119. /* Non-Blocking mode: DMA */
  120. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  121. uint16_t Size);
  122. /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
  123. void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
  124. void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
  125. void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
  126. /**
  127. * @}
  128. */
  129. /**
  130. * @}
  131. */
  132. /* Private types -------------------------------------------------------------*/
  133. /* Private variables ---------------------------------------------------------*/
  134. /* Private constants ---------------------------------------------------------*/
  135. /* Private macros ------------------------------------------------------------*/
  136. /**
  137. * @}
  138. */
  139. /* Private functions ---------------------------------------------------------*/
  140. /**
  141. * @}
  142. */
  143. #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
  144. /**
  145. * @}
  146. */
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150. #endif /* STM32F4xx_HAL_I2S_EX_H */
  151. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/