训练营PLSR题目
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.
 
 
 
 
 
 

184 line
7.8 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. * Copyright (c) 2016 STMicroelectronics.
  10. * All rights reserved.
  11. *
  12. * This software is licensed under terms that can be found in the LICENSE file
  13. * in the root directory of this software component.
  14. * If no LICENSE file comes with this software, it is provided AS-IS.
  15. *
  16. ******************************************************************************
  17. */
  18. /* Define to prevent recursive inclusion -------------------------------------*/
  19. #ifndef STM32F4xx_HAL_I2S_EX_H
  20. #define STM32F4xx_HAL_I2S_EX_H
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Includes ------------------------------------------------------------------*/
  25. #include "stm32f4xx_hal_def.h"
  26. /** @addtogroup STM32F4xx_HAL_Driver
  27. * @{
  28. */
  29. #if defined(SPI_I2S_FULLDUPLEX_SUPPORT)
  30. /** @addtogroup I2SEx I2SEx
  31. * @{
  32. */
  33. /* Exported types ------------------------------------------------------------*/
  34. /* Exported constants --------------------------------------------------------*/
  35. /* Exported macros -----------------------------------------------------------*/
  36. /** @defgroup I2SEx_Exported_Macros I2S Extended Exported Macros
  37. * @{
  38. */
  39. #define I2SxEXT(__INSTANCE__) ((__INSTANCE__) == (SPI2)? (SPI_TypeDef *)(I2S2ext_BASE): (SPI_TypeDef *)(I2S3ext_BASE))
  40. /** @brief Enable or disable the specified I2SExt peripheral.
  41. * @param __HANDLE__ specifies the I2S Handle.
  42. * @retval None
  43. */
  44. #define __HAL_I2SEXT_ENABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR |= SPI_I2SCFGR_I2SE)
  45. #define __HAL_I2SEXT_DISABLE(__HANDLE__) (I2SxEXT((__HANDLE__)->Instance)->I2SCFGR &= ~SPI_I2SCFGR_I2SE)
  46. /** @brief Enable or disable the specified I2SExt interrupts.
  47. * @param __HANDLE__ specifies the I2S Handle.
  48. * @param __INTERRUPT__ specifies the interrupt source to enable or disable.
  49. * This parameter can be one of the following values:
  50. * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
  51. * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
  52. * @arg I2S_IT_ERR: Error interrupt enable
  53. * @retval None
  54. */
  55. #define __HAL_I2SEXT_ENABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 |= (__INTERRUPT__))
  56. #define __HAL_I2SEXT_DISABLE_IT(__HANDLE__, __INTERRUPT__) (I2SxEXT((__HANDLE__)->Instance)->CR2 &= ~(__INTERRUPT__))
  57. /** @brief Checks if the specified I2SExt interrupt source is enabled or disabled.
  58. * @param __HANDLE__ specifies the I2S Handle.
  59. * This parameter can be I2S where x: 1, 2, or 3 to select the I2S peripheral.
  60. * @param __INTERRUPT__ specifies the I2S interrupt source to check.
  61. * This parameter can be one of the following values:
  62. * @arg I2S_IT_TXE: Tx buffer empty interrupt enable
  63. * @arg I2S_IT_RXNE: RX buffer not empty interrupt enable
  64. * @arg I2S_IT_ERR: Error interrupt enable
  65. * @retval The new state of __IT__ (TRUE or FALSE).
  66. */
  67. #define __HAL_I2SEXT_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((I2SxEXT((__HANDLE__)->Instance)->CR2\
  68. & (__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. /** @brief Flush the I2S and I2SExt DR Registers.
  103. * @param __HANDLE__ specifies the I2S Handle.
  104. * @retval None
  105. */
  106. #define __HAL_I2SEXT_FLUSH_RX_DR(__HANDLE__) do{ \
  107. __IO uint32_t tmpreg_dr = 0x00U; \
  108. tmpreg_dr = I2SxEXT((__HANDLE__)->Instance)->DR; \
  109. tmpreg_dr = ((__HANDLE__)->Instance->DR); \
  110. UNUSED(tmpreg_dr); \
  111. }while(0U)
  112. /**
  113. * @}
  114. */
  115. /* Exported functions --------------------------------------------------------*/
  116. /** @addtogroup I2SEx_Exported_Functions I2S Extended Exported Functions
  117. * @{
  118. */
  119. /** @addtogroup I2SEx_Exported_Functions_Group1 I2S Extended IO operation functions
  120. * @{
  121. */
  122. /* Extended features functions *************************************************/
  123. /* Blocking mode: Polling */
  124. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  125. uint16_t Size, uint32_t Timeout);
  126. /* Non-Blocking mode: Interrupt */
  127. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  128. uint16_t Size);
  129. /* Non-Blocking mode: DMA */
  130. HAL_StatusTypeDef HAL_I2SEx_TransmitReceive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pTxData, uint16_t *pRxData,
  131. uint16_t Size);
  132. /* I2S IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
  133. void HAL_I2SEx_FullDuplex_IRQHandler(I2S_HandleTypeDef *hi2s);
  134. void HAL_I2SEx_TxRxHalfCpltCallback(I2S_HandleTypeDef *hi2s);
  135. void HAL_I2SEx_TxRxCpltCallback(I2S_HandleTypeDef *hi2s);
  136. /**
  137. * @}
  138. */
  139. /**
  140. * @}
  141. */
  142. /* Private types -------------------------------------------------------------*/
  143. /* Private variables ---------------------------------------------------------*/
  144. /* Private constants ---------------------------------------------------------*/
  145. /* Private macros ------------------------------------------------------------*/
  146. /**
  147. * @}
  148. */
  149. /* Private functions ---------------------------------------------------------*/
  150. /**
  151. * @}
  152. */
  153. #endif /* SPI_I2S_FULLDUPLEX_SUPPORT */
  154. /**
  155. * @}
  156. */
  157. #ifdef __cplusplus
  158. }
  159. #endif
  160. #endif /* STM32F4xx_HAL_I2S_EX_H */