stm32f4xx_hal_i2s_ex.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32F4xx_HAL_I2S_EX_H
  37. #define __STM32F4xx_HAL_I2S_EX_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32f4xx_hal_def.h"
  43. /** @addtogroup STM32F4xx_HAL_Driver
  44. * @{
  45. */
  46. #if defined(SPI_I2S_FULLDUPLEX_SUPPORT)
  47. /** @addtogroup I2SEx I2SEx
  48. * @{
  49. */
  50. /* Exported types ------------------------------------------------------------*/
  51. /* Exported constants --------------------------------------------------------*/
  52. /* Exported macros -----------------------------------------------------------*/
  53. /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros
  54. * @{
  55. */
  56. #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
  57. /** @brief Enable or disable the specified I2SExt peripheral.
  58. * @param __HANDLE__ specifies the I2S Handle.
  59. * @retval None
  60. */
  61. #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
  62. #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
  63. /** @brief Enable or disable the specified I2SExt interrupts.
  64. * @param __HANDLE__ specifies the I2S Handle.
  65. * @param __INTERRUPT__ specifies the interrupt source to enable or disable.
  66. * This parameter can be one of the following values:
  67. * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
  68. * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
  69. * @arg I2S_IT_ERR: Error interrupt enable
  70. * @retval None
  71. */
  72. #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__))
  73. #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__))
  74. /** @brief Checks if the specified I2SExt interrupt source is enabled or disabled.
  75. * @param __HANDLE__ specifies the I2S Handle.
  76. * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
  77. * @param __INTERRUPT__ specifies the I2S interrupt source to check.
  78. * This parameter can be one of the following values:
  79. * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
  80. * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
  81. * @arg I2S_IT_ERR: Error interrupt enable
  82. * @retval The new state of __IT__ (TRUE or FALSE).
  83. */
  84. #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  85. /** @brief Checks whether the specified I2SExt flag is set or not.
  86. * @param __HANDLE__ specifies the I2S Handle.
  87. * @param __FLAG__ specifies the flag to check.
  88. * This parameter can be one of the following values:
  89. * @arg I2S_FLAG_RXNE: Receive buffer not empty flag
  90. * @arg I2S_FLAG_TXE: Transmit buffer empty flag
  91. * @arg I2S_FLAG_UDR: Underrun flag
  92. * @arg I2S_FLAG_OVR: Overrun flag
  93. * @arg I2S_FLAG_FRE: Frame error flag
  94. * @arg I2S_FLAG_CHSIDE: Channel Side flag
  95. * @arg I2S_FLAG_BSY: Busy flag
  96. * @retval The new state of __FLAG__ (TRUE or FALSE).
  97. */
  98. #define __HAL_I2SEXT_GET_FLAG(__HANDLE__, __FLAG__) (((I2SxEXT((__HANDLE__)->Instance)->SR) & (__FLAG__)) == (__FLAG__))
  99. /** @brief Clears the I2SExt OVR pending flag.
  100. * @param __HANDLE__ specifies the I2S Handle.
  101. * @retval None
  102. */
  103. #define __HAL_I2SEXT_CLEAR_OVRFLAG(__HANDLE__) do{ \
  104. __IO uint32_t tmpreg_ovr = 0x00U; \
  105. tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->DR;\
  106. tmpreg_ovr = I2SxEXT((__HANDLE__)->Instance)->SR;\
  107. UNUSED(tmpreg_ovr); \
  108. }while(0U)
  109. /** @brief Clears the I2SExt UDR pending flag.
  110. * @param __HANDLE__ specifies the I2S Handle.
  111. * @retval None
  112. */
  113. #define __HAL_I2SEXT_CLEAR_UDRFLAG(__HANDLE__) do{ \
  114. __IO uint32_t tmpreg_udr = 0x00U; \
  115. tmpreg_udr = I2SxEXT((__HANDLE__)->Instance)->SR;\
  116. UNUSED(tmpreg_udr); \
  117. }while(0U)
  118. /**
  119. * @}
  120. */
  121. /* Exported functions --------------------------------------------------------*/
  122. /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
  123. * @{
  124. */
  125. /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
  126. * @{
  127. */
  128. /* Extended features functions *************************************************/
  129. /* Blocking mode: Polling */
  130. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  131. uint16_t Size, uint32_t Timeout);
  132. /* Non-Blocking mode: Interrupt */
  133. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  134. uint16_t Size);
  135. /* Non-Blocking mode: DMA */
  136. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  137. uint16_t Size);
  138. /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
  139. void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
  140. void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
  141. void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
  142. /**
  143. * @}
  144. */
  145. /**
  146. * @}
  147. */
  148. /* Private types -------------------------------------------------------------*/
  149. /* Private variables ---------------------------------------------------------*/
  150. /* Private constants ---------------------------------------------------------*/
  151. /* Private macros ------------------------------------------------------------*/
  152. /**
  153. * @}
  154. */
  155. /* Private functions ---------------------------------------------------------*/
  156. /**
  157. * @}
  158. */
  159. #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
  160. /**
  161. * @}
  162. */
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif /* __STM32F4xx_HAL_I2S_EX_H */
  167. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/