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.
 
 
 

215 lines
8.8 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_hal_i2s_ex.h
  4. * @author MCD Application Team
  5. * @version V1.6.0
  6. * @date 04-November-2016
  7. * @brief Header file of I2S HAL module.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2016 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. /** @addtogroup I2SEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /** @defgroup I2SEx_Exported_Types I2S Exported Types
  53. * @{
  54. */
  55. /**
  56. * @}
  57. */
  58. /* Exported constants --------------------------------------------------------*/
  59. /** @defgroup I2SEx_Exported_Constants I2S Exported Constants
  60. * @{
  61. */
  62. /** @defgroup I2S_Clock_Source I2S Clock Source
  63. * @{
  64. */
  65. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  66. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  67. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || \
  68. defined(STM32F479xx)
  69. #define I2S_CLOCK_PLL ((uint32_t)0x00000000U)
  70. #define I2S_CLOCK_EXTERNAL ((uint32_t)0x00000001U)
  71. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  72. STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
  73. #if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) ||\
  74. defined(STM32F413xx) || defined(STM32F423xx)
  75. #define I2S_CLOCK_PLL ((uint32_t)0x00000000U)
  76. #define I2S_CLOCK_EXTERNAL ((uint32_t)0x00000001U)
  77. #define I2S_CLOCK_PLLR ((uint32_t)0x00000002U)
  78. #define I2S_CLOCK_PLLSRC ((uint32_t)0x00000003U)
  79. #endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  80. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  81. #define I2S_CLOCK_PLLSRC ((uint32_t)0x00000000U)
  82. #define I2S_CLOCK_EXTERNAL ((uint32_t)0x00000001U)
  83. #define I2S_CLOCK_PLLR ((uint32_t)0x00000002U)
  84. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  85. /**
  86. * @}
  87. */
  88. /**
  89. * @}
  90. */
  91. /* Exported macro ------------------------------------------------------------*/
  92. /** @defgroup I2SEx_Exported_Macros I2S Exported Macros
  93. * @{
  94. */
  95. /**
  96. * @}
  97. */
  98. /* Exported functions --------------------------------------------------------*/
  99. /** @addtogroup I2SEx_Exported_Functions
  100. * @{
  101. */
  102. /** @addtogroup I2SEx_Exported_Functions_Group1
  103. * @{
  104. */
  105. /* Extended features functions **************************************************/
  106. /* Blocking mode: Polling */
  107. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size, uint32_t Timeout);
  108. /* Non-Blocking mode: Interrupt */
  109. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size);
  110. /* Non-Blocking mode: DMA */
  111. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData, uint16_t Size);
  112. /**
  113. * @}
  114. */
  115. /**
  116. * @}
  117. */
  118. /* Private types -------------------------------------------------------------*/
  119. /* Private variables ---------------------------------------------------------*/
  120. /* Private constants ---------------------------------------------------------*/
  121. /** @defgroup I2SEx_Private_Constants I2S Private Constants
  122. * @{
  123. */
  124. /**
  125. * @}
  126. */
  127. /* Private macros ------------------------------------------------------------*/
  128. /** @defgroup I2SEx_Private_Macros I2S Private Macros
  129. * @{
  130. */
  131. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  132. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  133. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F469xx) || \
  134. defined(STM32F479xx)
  135. #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
  136. ((CLOCK) == I2S_CLOCK_PLL))
  137. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  138. STM32F401xC || STM32F401xE || STM32F411xE || STM32F469xx || STM32F479xx */
  139. #if defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
  140. defined(STM32F412Rx) || defined(STM32F412Cx) || defined (STM32F413xx) ||\
  141. defined(STM32F423xx)
  142. #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
  143. ((CLOCK) == I2S_CLOCK_PLL) ||\
  144. ((CLOCK) == I2S_CLOCK_PLLSRC) ||\
  145. ((CLOCK) == I2S_CLOCK_PLLR))
  146. #endif /* STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  147. #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
  148. #define IS_I2S_CLOCKSOURCE(CLOCK) (((CLOCK) == I2S_CLOCK_EXTERNAL) ||\
  149. ((CLOCK) == I2S_CLOCK_PLLSRC) ||\
  150. ((CLOCK) == I2S_CLOCK_PLLR))
  151. #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
  152. #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
  153. defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
  154. defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Cx) || defined(STM32F410Rx) || \
  155. defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) || \
  156. defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || \
  157. defined(STM32F413xx) || defined(STM32F423xx)
  158. #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
  159. #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
  160. STM32F401xC || STM32F401xE || STM32F410Cx || STM32F410Rx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx ||
  161. STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
  162. /**
  163. * @}
  164. */
  165. /* Private functions ---------------------------------------------------------*/
  166. /** @defgroup I2SEx_Private_Functions I2S Private Functions
  167. * @{
  168. */
  169. HAL_StatusTypeDef I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s);
  170. uint32_t I2S_GetInputClock(I2S_HandleTypeDef *hi2s);
  171. /**
  172. * @}
  173. */
  174. /**
  175. * @}
  176. */
  177. /**
  178. * @}
  179. */
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183. #endif /* __STM32F4xx_HAL_I2S_EX_H */
  184. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/