py32f0xx_hal_exti.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_hal_exti.h
  4. * @author MCU Application Team
  5. * @brief Header file of EXTI HAL 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_EXTI_H
  32. #define __PY32F0xx_HAL_EXTI_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 EXTI EXTI
  42. * @brief EXTI HAL module driver
  43. * @{
  44. */
  45. /* Exported types ------------------------------------------------------------*/
  46. /** @defgroup EXTI_Exported_Types EXTI Exported Types
  47. * @{
  48. */
  49. typedef enum
  50. {
  51. HAL_EXTI_COMMON_CB_ID = 0x00U,
  52. } EXTI_CallbackIDTypeDef;
  53. /**
  54. * @brief EXTI Handle structure definition
  55. */
  56. typedef struct
  57. {
  58. uint32_t Line; /*!< Exti line number */
  59. void (* PendingCallback)(void); /*!< Exti pending callback */
  60. } EXTI_HandleTypeDef;
  61. /**
  62. * @brief EXTI Configuration structure definition
  63. */
  64. typedef struct
  65. {
  66. uint32_t Line; /*!< The Exti line to be configured. This parameter
  67. can be a value of @ref EXTI_Line */
  68. uint32_t Mode; /*!< The Exit Mode to be configured for a core.
  69. This parameter can be a combination of @ref EXTI_Mode */
  70. uint32_t Trigger; /*!< The Exti Trigger to be configured. This parameter
  71. can be a value of @ref EXTI_Trigger */
  72. uint32_t GPIOSel; /*!< The Exti GPIO multiplexer selection to be configured.
  73. This parameter is only possible for line 0 to 15. It
  74. can be a value of @ref EXTI_GPIOSel */
  75. } EXTI_ConfigTypeDef;
  76. /**
  77. * @}
  78. */
  79. /* Exported constants --------------------------------------------------------*/
  80. /** @defgroup EXTI_Exported_Constants EXTI Exported Constants
  81. * @{
  82. */
  83. /** @defgroup EXTI_Line EXTI Line
  84. * @{
  85. */
  86. #define EXTI_LINE_0 (EXTI_GPIO | EXTI_REG1 | 0x00u)
  87. #define EXTI_LINE_1 (EXTI_GPIO | EXTI_REG1 | 0x01u)
  88. #define EXTI_LINE_2 (EXTI_GPIO | EXTI_REG1 | 0x02u)
  89. #define EXTI_LINE_3 (EXTI_GPIO | EXTI_REG1 | 0x03u)
  90. #define EXTI_LINE_4 (EXTI_GPIO | EXTI_REG1 | 0x04u)
  91. #define EXTI_LINE_5 (EXTI_GPIO | EXTI_REG1 | 0x05u)
  92. #define EXTI_LINE_6 (EXTI_GPIO | EXTI_REG1 | 0x06u)
  93. #define EXTI_LINE_7 (EXTI_GPIO | EXTI_REG1 | 0x07u)
  94. #define EXTI_LINE_8 (EXTI_GPIO | EXTI_REG1 | 0x08u)
  95. #define EXTI_LINE_9 (EXTI_GPIO | EXTI_REG1 | 0x09u)
  96. #define EXTI_LINE_10 (EXTI_GPIO | EXTI_REG1 | 0x0Au)
  97. #define EXTI_LINE_11 (EXTI_GPIO | EXTI_REG1 | 0x0Bu)
  98. #define EXTI_LINE_12 (EXTI_GPIO | EXTI_REG1 | 0x0Cu)
  99. #define EXTI_LINE_13 (EXTI_GPIO | EXTI_REG1 | 0x0Du)
  100. #define EXTI_LINE_14 (EXTI_GPIO | EXTI_REG1 | 0x0Eu)
  101. #define EXTI_LINE_15 (EXTI_GPIO | EXTI_REG1 | 0x0Fu)
  102. #define EXTI_LINE_16 (EXTI_CONFIG | EXTI_REG1 | 0x10u)
  103. #if defined(COMP1)
  104. #define EXTI_LINE_17 (EXTI_CONFIG | EXTI_REG1 | 0x11u)
  105. #else
  106. #define EXTI_LINE_17 (EXTI_RESERVED | EXTI_REG1 | 0x11u)
  107. #endif
  108. #if defined(COMP2)
  109. #define EXTI_LINE_18 (EXTI_CONFIG | EXTI_REG1 | 0x12u)
  110. #else
  111. #define EXTI_LINE_18 (EXTI_RESERVED | EXTI_REG1 | 0x12u)
  112. #endif
  113. #if defined(RTC)
  114. #define EXTI_LINE_19 (EXTI_DIRECT | EXTI_REG1 | 0x13u)
  115. #else
  116. #define EXTI_LINE_19 (EXTI_RESERVED | EXTI_REG1 | 0x13u)
  117. #endif
  118. #define EXTI_LINE_20 (EXTI_RESERVED | EXTI_REG1 | 0x14u)
  119. #define EXTI_LINE_21 (EXTI_RESERVED | EXTI_REG1 | 0x15u)
  120. #define EXTI_LINE_22 (EXTI_RESERVED | EXTI_REG1 | 0x16u)
  121. #define EXTI_LINE_23 (EXTI_RESERVED | EXTI_REG1 | 0x17u)
  122. #define EXTI_LINE_24 (EXTI_RESERVED | EXTI_REG1 | 0x18u)
  123. #define EXTI_LINE_25 (EXTI_RESERVED | EXTI_REG1 | 0x19u)
  124. #define EXTI_LINE_26 (EXTI_RESERVED | EXTI_REG1 | 0x1Au)
  125. #define EXTI_LINE_27 (EXTI_RESERVED | EXTI_REG1 | 0x1Bu)
  126. #define EXTI_LINE_28 (EXTI_RESERVED | EXTI_REG1 | 0x1Cu)
  127. #if defined(LPTIM)
  128. #define EXTI_LINE_29 (EXTI_DIRECT | EXTI_REG1 | 0x1Du)
  129. #else
  130. #define EXTI_LINE_29 (EXTI_RESERVED | EXTI_REG1 | 0x1Du)
  131. #endif
  132. #define EXTI_LINE_30 (EXTI_RESERVED | EXTI_REG1 | 0x1Eu)
  133. #define EXTI_LINE_31 (EXTI_RESERVED | EXTI_REG1 | 0x1Fu)
  134. /**
  135. * @}
  136. */
  137. /** @defgroup EXTI_Mode EXTI Mode
  138. * @{
  139. */
  140. #define EXTI_MODE_NONE 0x00000000u
  141. #define EXTI_MODE_INTERRUPT 0x00000001u
  142. #define EXTI_MODE_EVENT 0x00000002u
  143. /**
  144. * @}
  145. */
  146. /** @defgroup EXTI_Trigger EXTI Trigger
  147. * @{
  148. */
  149. #define EXTI_TRIGGER_NONE 0x00000000u
  150. #define EXTI_TRIGGER_RISING 0x00000001u
  151. #define EXTI_TRIGGER_FALLING 0x00000002u
  152. #define EXTI_TRIGGER_RISING_FALLING (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
  153. /**
  154. * @}
  155. */
  156. /** @defgroup EXTI_GPIOSel EXTI GPIOSel
  157. * @brief
  158. * @{
  159. */
  160. #define EXTI_GPIOA 0x00000000u
  161. #define EXTI_GPIOB 0x00000001u
  162. #define EXTI_GPIOF 0x00000002u
  163. /**
  164. * @}
  165. */
  166. /**
  167. * @}
  168. */
  169. /* Exported macro ------------------------------------------------------------*/
  170. /** @defgroup EXTI_Exported_Macros EXTI Exported Macros
  171. * @{
  172. */
  173. /**
  174. * @}
  175. */
  176. /* Private constants --------------------------------------------------------*/
  177. /** @defgroup EXTI_Private_Constants EXTI Private Constants
  178. * @{
  179. */
  180. /**
  181. * @brief EXTI Line property definition
  182. */
  183. #define EXTI_PROPERTY_SHIFT 24u
  184. #define EXTI_DIRECT (0x01uL << EXTI_PROPERTY_SHIFT)
  185. #define EXTI_CONFIG (0x02uL << EXTI_PROPERTY_SHIFT)
  186. #define EXTI_GPIO ((0x04uL << EXTI_PROPERTY_SHIFT) | EXTI_CONFIG)
  187. #define EXTI_RESERVED (0x08uL << EXTI_PROPERTY_SHIFT)
  188. #define EXTI_PROPERTY_MASK (EXTI_DIRECT | EXTI_CONFIG | EXTI_GPIO)
  189. /**
  190. * @brief EXTI Register and bit usage
  191. */
  192. #define EXTI_REG_SHIFT 16u
  193. #define EXTI_REG1 (0x00uL << EXTI_REG_SHIFT)
  194. #define EXTI_REG2 (0x01uL << EXTI_REG_SHIFT)
  195. #define EXTI_REG_MASK (EXTI_REG1 | EXTI_REG2)
  196. #define EXTI_PIN_MASK 0x0000001Fu
  197. /**
  198. * @brief EXTI Mask for interrupt & event mode
  199. */
  200. #define EXTI_MODE_MASK (EXTI_MODE_EVENT | EXTI_MODE_INTERRUPT)
  201. /**
  202. * @brief EXTI Mask for trigger possibilities
  203. */
  204. #define EXTI_TRIGGER_MASK (EXTI_TRIGGER_RISING | EXTI_TRIGGER_FALLING)
  205. /**
  206. * @brief EXTI Line number
  207. */
  208. #if defined(EXTI_IMR2_IM33)
  209. #define EXTI_LINE_NB 34uL
  210. #else
  211. #define EXTI_LINE_NB 32uL
  212. #endif
  213. /**
  214. * @}
  215. */
  216. /* Private macros ------------------------------------------------------------*/
  217. /** @defgroup EXTI_Private_Macros EXTI Private Macros
  218. * @{
  219. */
  220. #define IS_EXTI_LINE(__LINE__) ((((__LINE__) & ~(EXTI_PROPERTY_MASK | EXTI_REG_MASK | EXTI_PIN_MASK)) == 0x00u) && \
  221. ((((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_DIRECT) || \
  222. (((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_CONFIG) || \
  223. (((__LINE__) & EXTI_PROPERTY_MASK) == EXTI_GPIO)) && \
  224. (((__LINE__) & (EXTI_REG_MASK | EXTI_PIN_MASK)) < \
  225. (((EXTI_LINE_NB / 32u) << EXTI_REG_SHIFT) | (EXTI_LINE_NB % 32u))))
  226. #define IS_EXTI_MODE(__LINE__) ((((__LINE__) & EXTI_MODE_MASK) != 0x00u) && \
  227. (((__LINE__) & ~EXTI_MODE_MASK) == 0x00u))
  228. #define IS_EXTI_TRIGGER(__LINE__) (((__LINE__) & ~EXTI_TRIGGER_MASK) == 0x00u)
  229. #define IS_EXTI_PENDING_EDGE(__LINE__) (((__LINE__) == EXTI_TRIGGER_RISING) || \
  230. ((__LINE__) == EXTI_TRIGGER_FALLING))
  231. #define IS_EXTI_CONFIG_LINE(__LINE__) (((__LINE__) & EXTI_CONFIG) != 0x00u)
  232. #define IS_EXTI_GPIO_PORT(__PORT__) (((__PORT__) == EXTI_GPIOA) || \
  233. ((__PORT__) == EXTI_GPIOB) || \
  234. ((__PORT__) == EXTI_GPIOF))
  235. #define IS_EXTI_GPIO_PIN(__PIN__) ((__PIN__) < 16u)
  236. /**
  237. * @}
  238. */
  239. /* Exported functions --------------------------------------------------------*/
  240. /** @defgroup EXTI_Exported_Functions EXTI Exported Functions
  241. * @brief EXTI Exported Functions
  242. * @{
  243. */
  244. /** @defgroup EXTI_Exported_Functions_Group1 Configuration functions
  245. * @brief Configuration functions
  246. * @{
  247. */
  248. /* Configuration functions ****************************************************/
  249. HAL_StatusTypeDef HAL_EXTI_SetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  250. HAL_StatusTypeDef HAL_EXTI_GetConfigLine(EXTI_HandleTypeDef *hexti, EXTI_ConfigTypeDef *pExtiConfig);
  251. HAL_StatusTypeDef HAL_EXTI_ClearConfigLine(EXTI_HandleTypeDef *hexti);
  252. HAL_StatusTypeDef HAL_EXTI_RegisterCallback(EXTI_HandleTypeDef *hexti, EXTI_CallbackIDTypeDef CallbackID, void (*pPendingCbfn)(void));
  253. HAL_StatusTypeDef HAL_EXTI_GetHandle(EXTI_HandleTypeDef *hexti, uint32_t ExtiLine);
  254. /**
  255. * @}
  256. */
  257. /** @defgroup EXTI_Exported_Functions_Group2 IO operation functions
  258. * @brief IO operation functions
  259. * @{
  260. */
  261. /* IO operation functions *****************************************************/
  262. void HAL_EXTI_IRQHandler(EXTI_HandleTypeDef *hexti);
  263. uint32_t HAL_EXTI_GetPending(EXTI_HandleTypeDef *hexti, uint32_t Edge);
  264. void HAL_EXTI_ClearPending(EXTI_HandleTypeDef *hexti);
  265. void HAL_EXTI_GenerateSWI(EXTI_HandleTypeDef *hexti);
  266. /**
  267. * @}
  268. */
  269. /**
  270. * @}
  271. */
  272. /**
  273. * @}
  274. */
  275. /**
  276. * @}
  277. */
  278. #ifdef __cplusplus
  279. }
  280. #endif
  281. #endif /* __PY32F0xx_HAL_EXTI_H */
  282. /************************ (C) COPYRIGHT Puya *****END OF FILE****/