您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

186 行
8.0 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\
  69. & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  70. /** @brief Checks whether the specified I2SExt flag is set or not.
  71. * @param __HANDLE__ specifies the I2S Handle.
  72. * @param __FLAG__ specifies the flag to check.
  73. * This parameter can be one of the following values:
  74. * @arg I2S_FLAG_RXNE: Receive buffer not empty flag
  75. * @arg I2S_FLAG_TXE: Transmit buffer empty flag
  76. * @arg I2S_FLAG_UDR: Underrun flag
  77. * @arg I2S_FLAG_OVR: Overrun flag
  78. * @arg I2S_FLAG_FRE: Frame error flag
  79. * @arg I2S_FLAG_CHSIDE: Channel Side flag
  80. * @arg I2S_FLAG_BSY: Busy flag
  81. * @retval The new state of __FLAG__ (TRUE or FALSE).
  82. */
  83. #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__))
  84. /** @brief Clears the I2SExt OVR pending flag.
  85. * @param __HANDLE__ specifies the I2S Handle.
  86. * @retval None
  87. */
  88. #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \
  89. __IO uint32_t tmpreg_ovr = 0x00U; \
  90. tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\
  91. tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\
  92. UNUSED(tmpreg_ovr); \
  93. }while(0U)
  94. /** @brief Clears the I2SExt UDR pending flag.
  95. * @param __HANDLE__ specifies the I2S Handle.
  96. * @retval None
  97. */
  98. #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \
  99. __IO uint32_t tmpreg_udr = 0x00U; \
  100. tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\
  101. UNUSED(tmpreg_udr); \
  102. }while(0U)
  103. /** @brief Flush the I2S and I2SExt DR Registers.
  104. * @param __HANDLE__ specifies the I2S Handle.
  105. * @retval None
  106. */
  107. #define __HAL_I2SEXT_FLUSH_RX_DR(__HANDLE__) do{ \
  108. __IO uint32_t tmpreg_dr = 0x00U; \
  109. tmpreg_dr = I2SxEXT((__HANDLE__)->Instance)->DR; \
  110. tmpreg_dr = ((__HANDLE__)->Instance->DR); \
  111. UNUSED(tmpreg_dr); \
  112. }while(0U)
  113. /**
  114. * @}
  115. */
  116. /* Exported functions --------------------------------------------------------*/
  117. /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
  118. * @{
  119. */
  120. /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
  121. * @{
  122. */
  123. /* Extended features functions *************************************************/
  124. /* Blocking mode: Polling */
  125. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  126. uint16_t Size, uint32_t Timeout);
  127. /* Non-Blocking mode: Interrupt */
  128. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  129. uint16_t Size);
  130. /* Non-Blocking mode: DMA */
  131. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  132. uint16_t Size);
  133. /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
  134. void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
  135. void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
  136. void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
  137. /**
  138. * @}
  139. */
  140. /**
  141. * @}
  142. */
  143. /* Private types -------------------------------------------------------------*/
  144. /* Private variables ---------------------------------------------------------*/
  145. /* Private constants ---------------------------------------------------------*/
  146. /* Private macros ------------------------------------------------------------*/
  147. /**
  148. * @}
  149. */
  150. /* Private functions ---------------------------------------------------------*/
  151. /**
  152. * @}
  153. */
  154. #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
  155. /**
  156. * @}
  157. */
  158. #ifdef __cplusplus
  159. }
  160. #endif
  161. #endif /* STM32F4xx_HAL_I2S_EX_H */
  162. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/