py32f0xx_hal_gpio_ex.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_hal_gpio_ex.h
  4. * @author MCU Application Team
  5. * @brief Header file of GPIO HAL Extended module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2023 Puya Semiconductor Co.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by Puya under BSD 3-Clause license,
  13. * the "License"; You may not use this file except in compliance with the
  14. * License. You may obtain a copy of the License at:
  15. * opensource.org/licenses/BSD-3-Clause
  16. *
  17. ******************************************************************************
  18. * @attention
  19. *
  20. * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
  21. * All rights reserved.</center></h2>
  22. *
  23. * This software component is licensed by ST under BSD 3-Clause license,
  24. * the "License"; You may not use this file except in compliance with the
  25. * License. You may obtain a copy of the License at:
  26. * opensource.org/licenses/BSD-3-Clause
  27. *
  28. ******************************************************************************
  29. */
  30. /* Define to prevent recursive inclusion -------------------------------------*/
  31. #ifndef __PY32F0xx_HAL_GPIO_EX_H
  32. #define __PY32F0xx_HAL_GPIO_EX_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx_hal_def.h"
  38. /** @addtogroup PY32F0xx_HAL_Driver
  39. * @{
  40. */
  41. /** @defgroup GPIOEx GPIOEx
  42. * @brief GPIO Extended HAL module driver
  43. * @{
  44. */
  45. /* Exported types ------------------------------------------------------------*/
  46. /* Exported constants --------------------------------------------------------*/
  47. /** @defgroup GPIOEx_Exported_Constants GPIOEx Exported Constants
  48. * @{
  49. */
  50. /** @defgroup GPIOEx_Alternate_function_selection GPIOEx Alternate function selection
  51. * @{
  52. */
  53. /*------------------------- PY32F0xx ------------------------*/
  54. #if (defined(PY32F003PRE)|| defined(PY32F030PRE))
  55. /**
  56. * @brief AF 0 selection
  57. */
  58. #define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD) Alternate Function mapping */
  59. #define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */
  60. #define GPIO_AF0_SPI2 ((uint8_t)0x00) /*!< SPI2 Alternate Function mapping */
  61. #define GPIO_AF0_TIM14 ((uint8_t)0x00) /*!< TIM14 Alternate Function mapping */
  62. #define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */
  63. /**
  64. * @brief AF 1 selection
  65. */
  66. #define GPIO_AF1_IR ((uint8_t)0x01) /*!< IR Alternate Function mapping */
  67. #define GPIO_AF1_SPI2 ((uint8_t)0x01) /*!< SPI2 Alternate Function mapping */
  68. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */
  69. #define GPIO_AF1_TIM3 ((uint8_t)0x01) /*!< TIM3 Alternate Function mapping */
  70. #define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */
  71. /**
  72. * @brief AF 2 selection
  73. */
  74. #define GPIO_AF2_SPI2 ((uint8_t)0x02) /*!< SPI2 Alternate Function mapping */
  75. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */
  76. #define GPIO_AF2_TIM14 ((uint8_t)0x02) /*!< TIM14 Alternate Function mapping */
  77. #define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */
  78. #define GPIO_AF2_TIM17 ((uint8_t)0x02) /*!< TIM17 Alternate Function mapping */
  79. /**
  80. * @brief AF 3 selection
  81. */
  82. #define GPIO_AF3_LED ((uint8_t)0x03U) /*!< AF3: LED Alternate Function mapping */
  83. #define GPIO_AF3_USART1 ((uint8_t)0x03U) /*!< AF3: USART1 Alternate Function mapping */
  84. #define GPIO_AF3_USART2 ((uint8_t)0x03U) /*!< AF3: USART2 Alternate Function mapping */
  85. #define GPIO_AF3_SPI2 ((uint8_t)0x03U) /*!< AF3: SPI2 Alternate Function mapping */
  86. /**
  87. * @brief AF 4 selection
  88. */
  89. #define GPIO_AF4_TIM14 ((uint8_t)0x04) /*!< TIM14 Alternate Function mapping */
  90. #define GPIO_AF4_USART2 ((uint8_t)0x04) /*!< USART2 Alternate Function mapping */
  91. /**
  92. * @brief AF 5 selection
  93. */
  94. #define GPIO_AF5_LPTIM ((uint8_t)0x05) /*!< LPTIM1 Alternate Function mapping */
  95. #define GPIO_AF5_USART2 ((uint8_t)0x05) /*!< USART2 Alternate Function mapping */
  96. #define GPIO_AF5_EVENTOUT ((uint8_t)0x05) /*!< EVENTOUT Alternate Function mapping */
  97. #define GPIO_AF5_TIM16 ((uint8_t)0x05) /*!< TIM16 Alternate Function mapping */
  98. #define GPIO_AF5_TIM17 ((uint8_t)0x05) /*!< TIM17 Alternate Function mapping */
  99. #define GPIO_AF5_MCO ((uint8_t)0x05) /*!< MCO Alternate Function mapping */
  100. /**
  101. * @brief AF 6 selection
  102. */
  103. #define GPIO_AF6_I2C ((uint8_t)0x06) /*!< I2C1 Alternate Function mapping */
  104. #define GPIO_AF6_LED ((uint8_t)0x06U) /*!< AF6: LED Alternate Function mapping */
  105. #define GPIO_AF6_MCO ((uint8_t)0x06) /*!< MCO Alternate Function mapping */
  106. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /*!< AF6: EVENTOUT Alternate Function mapping */
  107. /**
  108. * @brief AF 7 selection
  109. */
  110. #define GPIO_AF7_EVENTOUT ((uint8_t)0x07) /*!< EVENTOUT Alternate Function mapping */
  111. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /*!< AF7: COMP1 Alternate Function mapping */
  112. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /*!< AF7: COMP2 Alternate Function mapping */
  113. /**
  114. * @brief AF 8 selection
  115. */
  116. #define GPIO_AF8_USART1 ((uint8_t)0x08U) /*!< AF8: USART1 Alternate Function mapping */
  117. /**
  118. * @brief AF 9 selection
  119. */
  120. #define GPIO_AF9_USART2 ((uint8_t)0x09) /*!< USART2 Alternate Function mapping */
  121. /**
  122. * @brief AF 10 selection
  123. */
  124. #define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI2 Alternate Function mapping */
  125. /**
  126. * @brief AF 11 selection
  127. */
  128. #define GPIO_AF11_SPI2 ((uint8_t)0x0B) /*!< SPI2 Alternate Function mapping */
  129. /**
  130. * @brief AF 12 selection
  131. */
  132. #define GPIO_AF12_I2C ((uint8_t)0x0C) /*!< I2C1 Alternate Function mapping */
  133. /**
  134. * @brief AF 13 selection
  135. */
  136. #define GPIO_AF13_TIM1 ((uint8_t)0x0D) /*!< TIM1 Alternate Function mapping */
  137. #define GPIO_AF13_TIM3 ((uint8_t)0x0D) /*!< TIM3 Alternate Function mapping */
  138. #define GPIO_AF13_TIM14 ((uint8_t)0x0D) /*!< TIM14 Alternate Function mapping */
  139. #define GPIO_AF13_TIM17 ((uint8_t)0x0D) /*!< TIM17 Alternate Function mapping */
  140. /**
  141. * @brief AF 14 selection
  142. */
  143. #define GPIO_AF14_TIM1 ((uint8_t)0x0E) /*!< TIM1 Alternate Function mapping */
  144. /**
  145. * @brief AF 15 selection
  146. */
  147. #define GPIO_AF15_RTCOUT ((uint8_t)0x0fU)
  148. #define GPIO_AF15_MCO ((uint8_t)0x0FU) /*!< MCO Alternate Function mapping */
  149. #define GPIO_AF15_IR ((uint8_t)0x0FU) /*!< IR Alternate Function mapping */
  150. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0f)
  151. #elif defined(PY32F002APRE)
  152. /**
  153. * @brief AF 0 selection
  154. */
  155. #define GPIO_AF0_SWJ ((uint8_t)0x00) /*!< SWJ (SWD) Alternate Function mapping */
  156. #define GPIO_AF0_SPI1 ((uint8_t)0x00) /*!< SPI1 Alternate Function mapping */
  157. #define GPIO_AF0_USART1 ((uint8_t)0x00) /*!< USART1 Alternate Function mapping */
  158. /**
  159. * @brief AF 1 selection
  160. */
  161. #define GPIO_AF1_IR ((uint8_t)0x01) /*!< IR Alternate Function mapping */
  162. #define GPIO_AF1_TIM1 ((uint8_t)0x01) /*!< TIM1 Alternate Function mapping */
  163. #define GPIO_AF1_USART1 ((uint8_t)0x01) /*!< USART1 Alternate Function mapping */
  164. /**
  165. * @brief AF 2 selection
  166. */
  167. #define GPIO_AF2_TIM1 ((uint8_t)0x02) /*!< TIM1 Alternate Function mapping */
  168. #define GPIO_AF2_TIM16 ((uint8_t)0x02) /*!< TIM16 Alternate Function mapping */
  169. /**
  170. * @brief AF 3 selection
  171. */
  172. #define GPIO_AF3_USART1 ((uint8_t)0x03U) /*!< AF3: USART1 Alternate Function mapping */
  173. /**
  174. * @brief AF 4 selection
  175. */
  176. /**
  177. * @brief AF 5 selection
  178. */
  179. #define GPIO_AF5_LPTIM ((uint8_t)0x05) /*!< LPTIM1 Alternate Function mapping */
  180. #define GPIO_AF5_EVENTOUT ((uint8_t)0x05) /*!< EVENTOUT Alternate Function mapping */
  181. #define GPIO_AF5_TIM16 ((uint8_t)0x05) /*!< TIM16 Alternate Function mapping */
  182. #define GPIO_AF5_MCO ((uint8_t)0x05) /*!< MCO Alternate Function mapping */
  183. /**
  184. * @brief AF 6 selection
  185. */
  186. #define GPIO_AF6_I2C ((uint8_t)0x06) /*!< I2C1 Alternate Function mapping */
  187. #define GPIO_AF6_MCO ((uint8_t)0x06) /*!< MCO Alternate Function mapping */
  188. #define GPIO_AF6_EVENTOUT ((uint8_t)0x06U) /*!< AF6: EVENTOUT Alternate Function mapping */
  189. /**
  190. * @brief AF 7 selection
  191. */
  192. #define GPIO_AF7_EVENTOUT ((uint8_t)0x07) /*!< EVENTOUT Alternate Function mapping */
  193. #define GPIO_AF7_COMP1 ((uint8_t)0x07U) /*!< AF7: COMP1 Alternate Function mapping */
  194. #define GPIO_AF7_COMP2 ((uint8_t)0x07U) /*!< AF7: COMP2 Alternate Function mapping */
  195. /**
  196. * @brief AF 8 selection
  197. */
  198. #define GPIO_AF8_USART1 ((uint8_t)0x08U) /*!< AF8: USART1 Alternate Function mapping */
  199. /**
  200. * @brief AF 9 selection
  201. */
  202. /**
  203. * @brief AF 10 selection
  204. */
  205. #define GPIO_AF10_SPI1 ((uint8_t)0x0A) /*!< SPI2 Alternate Function mapping */
  206. /**
  207. * @brief AF 11 selection
  208. */
  209. /**
  210. * @brief AF 12 selection
  211. */
  212. #define GPIO_AF12_I2C ((uint8_t)0x0C) /*!< I2C1 Alternate Function mapping */
  213. /**
  214. * @brief AF 13 selection
  215. */
  216. #define GPIO_AF13_TIM1 ((uint8_t)0x0D) /*!< TIM1 Alternate Function mapping */
  217. /**
  218. * @brief AF 14 selection
  219. */
  220. #define GPIO_AF14_TIM1 ((uint8_t)0x0E) /*!< TIM1 Alternate Function mapping */
  221. /**
  222. * @brief AF 15 selection
  223. */
  224. #define GPIO_AF15_MCO ((uint8_t)0x0FU) /*!< MCO Alternate Function mapping */
  225. #define GPIO_AF15_IR ((uint8_t)0x0FU) /*!< IR Alternate Function mapping */
  226. #define IS_GPIO_AF(AF) ((AF) <= (uint8_t)0x0f)
  227. #endif
  228. /**
  229. * @}
  230. */
  231. /**
  232. * @}
  233. */
  234. /* Exported macro ------------------------------------------------------------*/
  235. /** @defgroup GPIOEx_Exported_Macros GPIOEx Exported Macros
  236. * @{
  237. */
  238. /** @defgroup GPIOEx_Get_Port_Index GPIOEx Get Port Index
  239. * @{
  240. */
  241. #define GPIO_GET_INDEX(__GPIOx__) (((__GPIOx__) == (GPIOA))? 0uL :\
  242. ((__GPIOx__) == (GPIOB))? 1uL : 2uL)
  243. /**
  244. * @}
  245. */
  246. /**
  247. * @}
  248. */
  249. /* Exported functions --------------------------------------------------------*/
  250. /**
  251. * @}
  252. */
  253. /**
  254. * @}
  255. */
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259. #endif /* __PY32F0xx_HAL_GPIO_EX_H */
  260. /************************ (C) COPYRIGHT Puya *****END OF FILE****/