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.
 
 
 

290 lines
16 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32h7xx_hal_irda_ex.h
  4. * @author MCD Application Team
  5. * @version V1.2.0
  6. * @date 29-December-2017
  7. * @brief Header file of IRDA HAL Extended 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 __STM32H7xx_HAL_IRDA_EX_H
  39. #define __STM32H7xx_HAL_IRDA_EX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "stm32h7xx_hal_def.h"
  45. /** @addtogroup STM32H7xx_HAL_Driver
  46. * @{
  47. */
  48. /** @addtogroup IRDAEx
  49. * @{
  50. */
  51. /* Exported types ------------------------------------------------------------*/
  52. /* Exported constants --------------------------------------------------------*/
  53. /* Exported macros -----------------------------------------------------------*/
  54. /* Exported functions --------------------------------------------------------*/
  55. /* Private macros ------------------------------------------------------------*/
  56. /** @defgroup IRDAEx_Private_Macros IRDAEx Private Macros
  57. * @{
  58. */
  59. /** @brief Report the IRDA clock source.
  60. * @param __HANDLE__: specifies the IRDA Handle.
  61. * @param __CLOCKSOURCE__: output variable.
  62. * @retval IRDA clocking source, written in __CLOCKSOURCE__.
  63. */
  64. #define IRDA_GETCLOCKSOURCE(__HANDLE__,__CLOCKSOURCE__) \
  65. do { \
  66. if((__HANDLE__)->Instance == USART1) \
  67. { \
  68. switch(__HAL_RCC_GET_USART1_SOURCE()) \
  69. { \
  70. case RCC_USART1CLKSOURCE_D2PCLK2: \
  71. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK2; \
  72. break; \
  73. case RCC_USART1CLKSOURCE_PLL2: \
  74. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  75. break; \
  76. case RCC_USART1CLKSOURCE_PLL3: \
  77. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  78. break; \
  79. case RCC_USART1CLKSOURCE_HSI: \
  80. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  81. break; \
  82. case RCC_USART1CLKSOURCE_CSI: \
  83. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  84. break; \
  85. case RCC_USART1CLKSOURCE_LSE: \
  86. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  87. break; \
  88. } \
  89. } \
  90. else if((__HANDLE__)->Instance == USART2) \
  91. { \
  92. switch(__HAL_RCC_GET_USART2_SOURCE()) \
  93. { \
  94. case RCC_USART2CLKSOURCE_D2PCLK1: \
  95. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK1; \
  96. break; \
  97. case RCC_USART2CLKSOURCE_PLL2: \
  98. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  99. break; \
  100. case RCC_USART2CLKSOURCE_PLL3: \
  101. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  102. break; \
  103. case RCC_USART2CLKSOURCE_HSI: \
  104. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  105. break; \
  106. case RCC_USART2CLKSOURCE_CSI: \
  107. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  108. break; \
  109. case RCC_USART2CLKSOURCE_LSE: \
  110. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  111. break; \
  112. } \
  113. } \
  114. else if((__HANDLE__)->Instance == USART3) \
  115. { \
  116. switch(__HAL_RCC_GET_USART3_SOURCE()) \
  117. { \
  118. case RCC_USART3CLKSOURCE_D2PCLK1: \
  119. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK1; \
  120. break; \
  121. case RCC_USART3CLKSOURCE_PLL2: \
  122. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  123. break; \
  124. case RCC_USART3CLKSOURCE_PLL3: \
  125. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  126. break; \
  127. case RCC_USART3CLKSOURCE_HSI: \
  128. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  129. break; \
  130. case RCC_USART3CLKSOURCE_CSI: \
  131. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  132. break; \
  133. case RCC_USART3CLKSOURCE_LSE: \
  134. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  135. break; \
  136. } \
  137. } \
  138. else if((__HANDLE__)->Instance == UART4) \
  139. { \
  140. switch(__HAL_RCC_GET_UART4_SOURCE()) \
  141. { \
  142. case RCC_UART4CLKSOURCE_D2PCLK1: \
  143. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK1; \
  144. break; \
  145. case RCC_UART4CLKSOURCE_PLL2: \
  146. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  147. break; \
  148. case RCC_UART4CLKSOURCE_PLL3: \
  149. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  150. break; \
  151. case RCC_UART4CLKSOURCE_HSI: \
  152. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  153. break; \
  154. case RCC_UART4CLKSOURCE_CSI: \
  155. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  156. break; \
  157. case RCC_UART4CLKSOURCE_LSE: \
  158. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  159. break; \
  160. } \
  161. } \
  162. else if ((__HANDLE__)->Instance == UART5) \
  163. { \
  164. switch(__HAL_RCC_GET_UART5_SOURCE()) \
  165. { \
  166. case RCC_UART5CLKSOURCE_D2PCLK1: \
  167. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK1; \
  168. break; \
  169. case RCC_UART5CLKSOURCE_PLL2: \
  170. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  171. break; \
  172. case RCC_UART5CLKSOURCE_PLL3: \
  173. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  174. break; \
  175. case RCC_UART5CLKSOURCE_HSI: \
  176. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  177. break; \
  178. case RCC_UART5CLKSOURCE_CSI: \
  179. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  180. break; \
  181. case RCC_UART5CLKSOURCE_LSE: \
  182. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  183. break; \
  184. } \
  185. } \
  186. else if((__HANDLE__)->Instance == USART6) \
  187. { \
  188. switch(__HAL_RCC_GET_USART6_SOURCE()) \
  189. { \
  190. case RCC_USART6CLKSOURCE_D2PCLK2: \
  191. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK2; \
  192. break; \
  193. case RCC_USART6CLKSOURCE_PLL2: \
  194. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  195. break; \
  196. case RCC_USART6CLKSOURCE_PLL3: \
  197. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  198. break; \
  199. case RCC_USART6CLKSOURCE_HSI: \
  200. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  201. break; \
  202. case RCC_USART6CLKSOURCE_CSI: \
  203. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  204. break; \
  205. case RCC_USART6CLKSOURCE_LSE: \
  206. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  207. break; \
  208. } \
  209. } \
  210. else if((__HANDLE__)->Instance == UART7) \
  211. { \
  212. switch(__HAL_RCC_GET_UART7_SOURCE()) \
  213. { \
  214. case RCC_UART7CLKSOURCE_D2PCLK1: \
  215. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK1; \
  216. break; \
  217. case RCC_UART7CLKSOURCE_PLL2: \
  218. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  219. break; \
  220. case RCC_UART7CLKSOURCE_PLL3: \
  221. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  222. break; \
  223. case RCC_UART7CLKSOURCE_HSI: \
  224. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  225. break; \
  226. case RCC_UART7CLKSOURCE_CSI: \
  227. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  228. break; \
  229. case RCC_UART7CLKSOURCE_LSE: \
  230. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  231. break; \
  232. } \
  233. } \
  234. else if((__HANDLE__)->Instance == UART8) \
  235. { \
  236. switch(__HAL_RCC_GET_UART8_SOURCE()) \
  237. { \
  238. case RCC_UART8CLKSOURCE_D2PCLK1: \
  239. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_D2PCLK1; \
  240. break; \
  241. case RCC_UART8CLKSOURCE_PLL2: \
  242. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL2Q; \
  243. break; \
  244. case RCC_UART8CLKSOURCE_PLL3: \
  245. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_PLL3Q; \
  246. break; \
  247. case RCC_UART8CLKSOURCE_HSI: \
  248. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_HSI; \
  249. break; \
  250. case RCC_UART8CLKSOURCE_CSI: \
  251. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_CSI; \
  252. break; \
  253. case RCC_UART8CLKSOURCE_LSE: \
  254. (__CLOCKSOURCE__) = IRDA_CLOCKSOURCE_LSE; \
  255. break; \
  256. } \
  257. } \
  258. } while(0)
  259. /**
  260. * @}
  261. */
  262. /* Exported functions --------------------------------------------------------*/
  263. /**
  264. * @}
  265. */
  266. /**
  267. * @}
  268. */
  269. #ifdef __cplusplus
  270. }
  271. #endif
  272. #endif /* __STM32H7xx_HAL_IRDA_EX_H */
  273. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/