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.
 
 
 

192 lines
8.5 KiB

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