py32f0xx_ll_exti.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  1. /**
  2. ******************************************************************************
  3. * @file py32f0xx_ll_exti.h
  4. * @author MCU Application Team
  5. * @brief Header file of RCC LL 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_LL_EXTI_H
  32. #define PY32F0XX_LL_EXTI_H
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36. /* Includes ------------------------------------------------------------------*/
  37. #include "py32f0xx.h"
  38. /** @addtogroup PY32F0xx_LL_Driver
  39. * @{
  40. */
  41. #if defined (EXTI)
  42. /** @defgroup EXTI_LL EXTI
  43. * @{
  44. */
  45. /* Private types -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /* Private constants ---------------------------------------------------------*/
  48. #define LL_EXTI_REGISTER_PINPOS_SHFT 8U /*!< Define used to shift pin position in EXTICR register */
  49. #define LL_EXTI_REGISTER_PINMASK_SHFT 16U /*!< Define used to shift pin mask in EXTICR register */
  50. /* Private Macros ------------------------------------------------------------*/
  51. #if defined(USE_FULL_LL_DRIVER)
  52. /** @defgroup EXTI_LL_Private_Macros EXTI Private Macros
  53. * @{
  54. */
  55. /**
  56. * @}
  57. */
  58. #endif /*USE_FULL_LL_DRIVER*/
  59. /* Exported types ------------------------------------------------------------*/
  60. #if defined(USE_FULL_LL_DRIVER)
  61. /** @defgroup EXTI_LL_ES_INIT EXTI Exported Init structure
  62. * @{
  63. */
  64. typedef struct
  65. {
  66. uint32_t Line; /*!< Specifies the EXTI lines to be enabled or disabled for Lines
  67. This parameter can be any combination of @ref EXTI_LL_EC_LINE */
  68. FunctionalState LineCommand; /*!< Specifies the new state of the selected EXTI lines.
  69. This parameter can be set either to ENABLE or DISABLE */
  70. uint8_t Mode; /*!< Specifies the mode for the EXTI lines.
  71. This parameter can be a value of @ref EXTI_LL_EC_MODE. */
  72. uint8_t Trigger; /*!< Specifies the trigger signal active edge for the EXTI lines.
  73. This parameter can be a value of @ref EXTI_LL_EC_TRIGGER. */
  74. } LL_EXTI_InitTypeDef;
  75. /**
  76. * @}
  77. */
  78. #endif /*USE_FULL_LL_DRIVER*/
  79. /* Exported constants --------------------------------------------------------*/
  80. /** @defgroup EXTI_LL_Exported_Constants EXTI Exported Constants
  81. * @{
  82. */
  83. /** @defgroup EXTI_LL_EC_LINE LINE
  84. * @{
  85. */
  86. #define LL_EXTI_LINE_0 EXTI_IMR_IM0 /*!< Extended line 0 */
  87. #define LL_EXTI_LINE_1 EXTI_IMR_IM1 /*!< Extended line 1 */
  88. #define LL_EXTI_LINE_2 EXTI_IMR_IM2 /*!< Extended line 2 */
  89. #define LL_EXTI_LINE_3 EXTI_IMR_IM3 /*!< Extended line 3 */
  90. #define LL_EXTI_LINE_4 EXTI_IMR_IM4 /*!< Extended line 4 */
  91. #define LL_EXTI_LINE_5 EXTI_IMR_IM5 /*!< Extended line 5 */
  92. #define LL_EXTI_LINE_6 EXTI_IMR_IM6 /*!< Extended line 6 */
  93. #define LL_EXTI_LINE_7 EXTI_IMR_IM7 /*!< Extended line 7 */
  94. #define LL_EXTI_LINE_8 EXTI_IMR_IM8 /*!< Extended line 8 */
  95. #define LL_EXTI_LINE_9 EXTI_IMR_IM9 /*!< Extended line 9 */
  96. #define LL_EXTI_LINE_10 EXTI_IMR_IM10 /*!< Extended line 10 */
  97. #define LL_EXTI_LINE_11 EXTI_IMR_IM11 /*!< Extended line 11 */
  98. #define LL_EXTI_LINE_12 EXTI_IMR_IM12 /*!< Extended line 12 */
  99. #define LL_EXTI_LINE_13 EXTI_IMR_IM13 /*!< Extended line 13 */
  100. #define LL_EXTI_LINE_14 EXTI_IMR_IM14 /*!< Extended line 14 */
  101. #define LL_EXTI_LINE_15 EXTI_IMR_IM15 /*!< Extended line 15 */
  102. #define LL_EXTI_LINE_16 EXTI_IMR_IM16 /*!< Extended line 16 */
  103. #define LL_EXTI_LINE_17 EXTI_IMR_IM17 /*!< Extended line 17 */
  104. #define LL_EXTI_LINE_18 EXTI_IMR_IM18 /*!< Extended line 18 */
  105. #define LL_EXTI_LINE_19 EXTI_IMR_IM19 /*!< Extended line 19 */
  106. #define LL_EXTI_LINE_29 EXTI_IMR_IM29 /*!< Extended line 29 */
  107. #if defined(USE_FULL_LL_DRIVER)
  108. #define LL_EXTI_LINE_NONE 0x00000000U /*!< None Extended line */
  109. #endif /*USE_FULL_LL_DRIVER*/
  110. /**
  111. * @}
  112. */
  113. #if defined(USE_FULL_LL_DRIVER)
  114. /** @defgroup EXTI_LL_EC_MODE Mode
  115. * @{
  116. */
  117. #define LL_EXTI_MODE_IT ((uint8_t)0x00U) /*!< Interrupt Mode */
  118. #define LL_EXTI_MODE_EVENT ((uint8_t)0x01U) /*!< Event Mode */
  119. #define LL_EXTI_MODE_IT_EVENT ((uint8_t)0x02U) /*!< Interrupt & Event Mode */
  120. /**
  121. * @}
  122. */
  123. /** @defgroup EXTI_LL_EC_TRIGGER Edge Trigger
  124. * @{
  125. */
  126. #define LL_EXTI_TRIGGER_NONE ((uint8_t)0x00U) /*!< No Trigger Mode */
  127. #define LL_EXTI_TRIGGER_RISING ((uint8_t)0x01U) /*!< Trigger Rising Mode */
  128. #define LL_EXTI_TRIGGER_FALLING ((uint8_t)0x02U) /*!< Trigger Falling Mode */
  129. #define LL_EXTI_TRIGGER_RISING_FALLING ((uint8_t)0x03U) /*!< Trigger Rising & Falling Mode */
  130. /**
  131. * @}
  132. */
  133. #endif /*USE_FULL_LL_DRIVER*/
  134. /** @defgroup EXTI_LL_EC_CONFIG_PORT EXTI CONFIG PORT
  135. * @{
  136. */
  137. #define LL_EXTI_CONFIG_PORTA 0x0U /*!< EXTI PORT A */
  138. #define LL_EXTI_CONFIG_PORTB 0x1U /*!< EXTI PORT B */
  139. #define LL_EXTI_CONFIG_PORTF 0x2U /*!< EXTI PORT F */
  140. /**
  141. * @}
  142. */
  143. /** @defgroup EXTI_LL_EC_CONFIG_LINE EXTI CONFIG LINE
  144. * @{
  145. */
  146. #define LL_EXTI_CONFIG_LINE0 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 0U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_0 | EXTICR[0] */
  147. #define LL_EXTI_CONFIG_LINE1 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 8U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_8 | EXTICR[0] */
  148. #define LL_EXTI_CONFIG_LINE2 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | (16U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_16 | EXTICR[0] */
  149. #define LL_EXTI_CONFIG_LINE3 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | (24U << LL_EXTI_REGISTER_PINPOS_SHFT) | 0U) /*!< EXTI_MASK_3 | EXTI_POSITION_24 | EXTICR[0] */
  150. #define LL_EXTI_CONFIG_LINE4 ((0x3U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 0U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_3 | EXTI_POSITION_0 | EXTICR[1] */
  151. #define LL_EXTI_CONFIG_LINE5 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 8U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_1 | EXTI_POSITION_8 | EXTICR[1] */
  152. #define LL_EXTI_CONFIG_LINE6 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | (16U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_1 | EXTI_POSITION_16 | EXTICR[1] */
  153. #define LL_EXTI_CONFIG_LINE7 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | (24U << LL_EXTI_REGISTER_PINPOS_SHFT) | 1U) /*!< EXTI_MASK_1 | EXTI_POSITION_19 | EXTICR[1] */
  154. #define LL_EXTI_CONFIG_LINE8 ((0x1U << LL_EXTI_REGISTER_PINMASK_SHFT) | ( 0U << LL_EXTI_REGISTER_PINPOS_SHFT) | 2U) /*!< EXTI_MASK_1 | EXTI_POSITION_0 | EXTICR[2] */
  155. /**
  156. * @}
  157. */
  158. /**
  159. * @}
  160. */
  161. /* Exported macro ------------------------------------------------------------*/
  162. /** @defgroup EXTI_LL_Exported_Macros EXTI Exported Macros
  163. * @{
  164. */
  165. /** @defgroup EXTI_LL_EM_WRITE_READ Common Write and read registers Macros
  166. * @{
  167. */
  168. /**
  169. * @brief Write a value in EXTI register
  170. * @param __REG__ Register to be written
  171. * @param __VALUE__ Value to be written in the register
  172. * @retval None
  173. */
  174. #define LL_EXTI_WriteReg(__REG__, __VALUE__) WRITE_REG(EXTI->__REG__, (__VALUE__))
  175. /**
  176. * @brief Read a value in EXTI register
  177. * @param __REG__ Register to be read
  178. * @retval Register value
  179. */
  180. #define LL_EXTI_ReadReg(__REG__) READ_REG(EXTI->__REG__)
  181. /**
  182. * @}
  183. */
  184. /**
  185. * @}
  186. */
  187. /* Exported functions --------------------------------------------------------*/
  188. /** @defgroup EXTI_LL_Exported_Functions EXTI Exported Functions
  189. * @{
  190. */
  191. /** @defgroup EXTI_LL_EF_IT_Management IT Management
  192. * @{
  193. */
  194. /**
  195. * @brief Enable ExtiLine Interrupt request for Lines
  196. * @param ExtiLine This parameter can be a combination of the following values:
  197. * @arg @ref LL_EXTI_LINE_0
  198. * @arg @ref LL_EXTI_LINE_1
  199. * @arg @ref LL_EXTI_LINE_2
  200. * @arg @ref LL_EXTI_LINE_3
  201. * @arg @ref LL_EXTI_LINE_4
  202. * @arg @ref LL_EXTI_LINE_5
  203. * @arg @ref LL_EXTI_LINE_6
  204. * @arg @ref LL_EXTI_LINE_7
  205. * @arg @ref LL_EXTI_LINE_8
  206. * @arg @ref LL_EXTI_LINE_9
  207. * @arg @ref LL_EXTI_LINE_10
  208. * @arg @ref LL_EXTI_LINE_11
  209. * @arg @ref LL_EXTI_LINE_12
  210. * @arg @ref LL_EXTI_LINE_13
  211. * @arg @ref LL_EXTI_LINE_14
  212. * @arg @ref LL_EXTI_LINE_15
  213. * @arg @ref LL_EXTI_LINE_16
  214. * @arg @ref LL_EXTI_LINE_17
  215. * @arg @ref LL_EXTI_LINE_18
  216. * @arg @ref LL_EXTI_LINE_19
  217. * @arg @ref LL_EXTI_LINE_29
  218. * @note Please check each device line mapping for EXTI Line availability
  219. * @retval None
  220. */
  221. __STATIC_INLINE void LL_EXTI_EnableIT(uint32_t ExtiLine)
  222. {
  223. SET_BIT(EXTI->IMR, ExtiLine);
  224. }
  225. /**
  226. * @brief Disable ExtiLine Interrupt request for Lines
  227. * @param ExtiLine This parameter can be a combination of the following values:
  228. * @arg @ref LL_EXTI_LINE_0
  229. * @arg @ref LL_EXTI_LINE_1
  230. * @arg @ref LL_EXTI_LINE_2
  231. * @arg @ref LL_EXTI_LINE_3
  232. * @arg @ref LL_EXTI_LINE_4
  233. * @arg @ref LL_EXTI_LINE_5
  234. * @arg @ref LL_EXTI_LINE_6
  235. * @arg @ref LL_EXTI_LINE_7
  236. * @arg @ref LL_EXTI_LINE_8
  237. * @arg @ref LL_EXTI_LINE_9
  238. * @arg @ref LL_EXTI_LINE_10
  239. * @arg @ref LL_EXTI_LINE_11
  240. * @arg @ref LL_EXTI_LINE_12
  241. * @arg @ref LL_EXTI_LINE_13
  242. * @arg @ref LL_EXTI_LINE_14
  243. * @arg @ref LL_EXTI_LINE_15
  244. * @arg @ref LL_EXTI_LINE_16
  245. * @arg @ref LL_EXTI_LINE_17
  246. * @arg @ref LL_EXTI_LINE_18
  247. * @arg @ref LL_EXTI_LINE_19
  248. * @arg @ref LL_EXTI_LINE_29
  249. * @note Please check each device line mapping for EXTI Line availability
  250. * @retval None
  251. */
  252. __STATIC_INLINE void LL_EXTI_DisableIT(uint32_t ExtiLine)
  253. {
  254. CLEAR_BIT(EXTI->IMR, ExtiLine);
  255. }
  256. /**
  257. * @brief Indicate if ExtiLine Interrupt request is enabled for Lines
  258. * Bits are set automatically at Power on.
  259. * @rmtoll IMR1 IMx LL_EXTI_IsEnabledIT_0_31
  260. * @param ExtiLine This parameter can be a combination of the following values:
  261. * @arg @ref LL_EXTI_LINE_0
  262. * @arg @ref LL_EXTI_LINE_1
  263. * @arg @ref LL_EXTI_LINE_2
  264. * @arg @ref LL_EXTI_LINE_3
  265. * @arg @ref LL_EXTI_LINE_4
  266. * @arg @ref LL_EXTI_LINE_5
  267. * @arg @ref LL_EXTI_LINE_6
  268. * @arg @ref LL_EXTI_LINE_7
  269. * @arg @ref LL_EXTI_LINE_8
  270. * @arg @ref LL_EXTI_LINE_9
  271. * @arg @ref LL_EXTI_LINE_10
  272. * @arg @ref LL_EXTI_LINE_11
  273. * @arg @ref LL_EXTI_LINE_12
  274. * @arg @ref LL_EXTI_LINE_13
  275. * @arg @ref LL_EXTI_LINE_14
  276. * @arg @ref LL_EXTI_LINE_15
  277. * @arg @ref LL_EXTI_LINE_16
  278. * @arg @ref LL_EXTI_LINE_17
  279. * @arg @ref LL_EXTI_LINE_18
  280. * @arg @ref LL_EXTI_LINE_19
  281. * @arg @ref LL_EXTI_LINE_29
  282. * @note Please check each device line mapping for EXTI Line availability
  283. * @retval State of bit (1 or 0).
  284. */
  285. __STATIC_INLINE uint32_t LL_EXTI_IsEnabledIT(uint32_t ExtiLine)
  286. {
  287. return (READ_BIT(EXTI->IMR, ExtiLine) == (ExtiLine));
  288. }
  289. /**
  290. * @}
  291. */
  292. /** @defgroup EXTI_LL_EF_Event_Management Event_Management
  293. * @{
  294. */
  295. /**
  296. * @brief Enable ExtiLine Event request for Lines
  297. * @param ExtiLine This parameter can be a combination of the following values:
  298. * @arg @ref LL_EXTI_LINE_0
  299. * @arg @ref LL_EXTI_LINE_1
  300. * @arg @ref LL_EXTI_LINE_2
  301. * @arg @ref LL_EXTI_LINE_3
  302. * @arg @ref LL_EXTI_LINE_4
  303. * @arg @ref LL_EXTI_LINE_5
  304. * @arg @ref LL_EXTI_LINE_6
  305. * @arg @ref LL_EXTI_LINE_7
  306. * @arg @ref LL_EXTI_LINE_8
  307. * @arg @ref LL_EXTI_LINE_9
  308. * @arg @ref LL_EXTI_LINE_10
  309. * @arg @ref LL_EXTI_LINE_11
  310. * @arg @ref LL_EXTI_LINE_12
  311. * @arg @ref LL_EXTI_LINE_13
  312. * @arg @ref LL_EXTI_LINE_14
  313. * @arg @ref LL_EXTI_LINE_15
  314. * @arg @ref LL_EXTI_LINE_16
  315. * @arg @ref LL_EXTI_LINE_17
  316. * @arg @ref LL_EXTI_LINE_18
  317. * @arg @ref LL_EXTI_LINE_19
  318. * @arg @ref LL_EXTI_LINE_29
  319. * @note Please check each device line mapping for EXTI Line availability
  320. * @retval None
  321. */
  322. __STATIC_INLINE void LL_EXTI_EnableEvent(uint32_t ExtiLine)
  323. {
  324. SET_BIT(EXTI->EMR, ExtiLine);
  325. }
  326. /**
  327. * @brief Disable ExtiLine Event request for Lines
  328. * @param ExtiLine This parameter can be a combination of the following values:
  329. * @arg @ref LL_EXTI_LINE_0
  330. * @arg @ref LL_EXTI_LINE_1
  331. * @arg @ref LL_EXTI_LINE_2
  332. * @arg @ref LL_EXTI_LINE_3
  333. * @arg @ref LL_EXTI_LINE_4
  334. * @arg @ref LL_EXTI_LINE_5
  335. * @arg @ref LL_EXTI_LINE_6
  336. * @arg @ref LL_EXTI_LINE_7
  337. * @arg @ref LL_EXTI_LINE_8
  338. * @arg @ref LL_EXTI_LINE_9
  339. * @arg @ref LL_EXTI_LINE_10
  340. * @arg @ref LL_EXTI_LINE_11
  341. * @arg @ref LL_EXTI_LINE_12
  342. * @arg @ref LL_EXTI_LINE_13
  343. * @arg @ref LL_EXTI_LINE_14
  344. * @arg @ref LL_EXTI_LINE_15
  345. * @arg @ref LL_EXTI_LINE_16
  346. * @arg @ref LL_EXTI_LINE_17
  347. * @arg @ref LL_EXTI_LINE_18
  348. * @arg @ref LL_EXTI_LINE_19
  349. * @arg @ref LL_EXTI_LINE_29
  350. * @note Please check each device line mapping for EXTI Line availability
  351. * @retval None
  352. */
  353. __STATIC_INLINE void LL_EXTI_DisableEvent(uint32_t ExtiLine)
  354. {
  355. CLEAR_BIT(EXTI->EMR, ExtiLine);
  356. }
  357. /**
  358. * @brief Indicate if ExtiLine Event request is enabled for Lines
  359. * @param ExtiLine This parameter can be a combination of the following values:
  360. * @arg @ref LL_EXTI_LINE_0
  361. * @arg @ref LL_EXTI_LINE_1
  362. * @arg @ref LL_EXTI_LINE_2
  363. * @arg @ref LL_EXTI_LINE_3
  364. * @arg @ref LL_EXTI_LINE_4
  365. * @arg @ref LL_EXTI_LINE_5
  366. * @arg @ref LL_EXTI_LINE_6
  367. * @arg @ref LL_EXTI_LINE_7
  368. * @arg @ref LL_EXTI_LINE_8
  369. * @arg @ref LL_EXTI_LINE_9
  370. * @arg @ref LL_EXTI_LINE_10
  371. * @arg @ref LL_EXTI_LINE_11
  372. * @arg @ref LL_EXTI_LINE_12
  373. * @arg @ref LL_EXTI_LINE_13
  374. * @arg @ref LL_EXTI_LINE_14
  375. * @arg @ref LL_EXTI_LINE_15
  376. * @arg @ref LL_EXTI_LINE_16
  377. * @arg @ref LL_EXTI_LINE_17
  378. * @arg @ref LL_EXTI_LINE_18
  379. * @arg @ref LL_EXTI_LINE_19
  380. * @arg @ref LL_EXTI_LINE_29
  381. * @note Please check each device line mapping for EXTI Line availability
  382. * @retval State of bit (1 or 0).
  383. */
  384. __STATIC_INLINE uint32_t LL_EXTI_IsEnabledEvent(uint32_t ExtiLine)
  385. {
  386. return (READ_BIT(EXTI->EMR, ExtiLine) == (ExtiLine));
  387. }
  388. /**
  389. * @}
  390. */
  391. /** @defgroup EXTI_LL_EF_Rising_Trigger_Management Rising_Trigger_Management
  392. * @{
  393. */
  394. /**
  395. * @brief Enable ExtiLine Rising Edge Trigger for Lines
  396. * @note The configurable wakeup lines are edge-triggered. No glitch must be
  397. * generated on these lines. If a rising edge on a configurable interrupt
  398. * line occurs during a write operation in the EXTI_RTSR register, the
  399. * pending bit is not set.
  400. * Rising and falling edge triggers can be set for
  401. * the same interrupt line. In this case, both generate a trigger
  402. * condition.
  403. * @param ExtiLine This parameter can be a combination of the following values:
  404. * @arg @ref LL_EXTI_LINE_0
  405. * @arg @ref LL_EXTI_LINE_1
  406. * @arg @ref LL_EXTI_LINE_2
  407. * @arg @ref LL_EXTI_LINE_3
  408. * @arg @ref LL_EXTI_LINE_4
  409. * @arg @ref LL_EXTI_LINE_5
  410. * @arg @ref LL_EXTI_LINE_6
  411. * @arg @ref LL_EXTI_LINE_7
  412. * @arg @ref LL_EXTI_LINE_8
  413. * @arg @ref LL_EXTI_LINE_9
  414. * @arg @ref LL_EXTI_LINE_10
  415. * @arg @ref LL_EXTI_LINE_11
  416. * @arg @ref LL_EXTI_LINE_12
  417. * @arg @ref LL_EXTI_LINE_13
  418. * @arg @ref LL_EXTI_LINE_14
  419. * @arg @ref LL_EXTI_LINE_15
  420. * @arg @ref LL_EXTI_LINE_16
  421. * @arg @ref LL_EXTI_LINE_17
  422. * @arg @ref LL_EXTI_LINE_18
  423. * @note Please check each device line mapping for EXTI Line availability
  424. * @retval None
  425. */
  426. __STATIC_INLINE void LL_EXTI_EnableRisingTrig(uint32_t ExtiLine)
  427. {
  428. SET_BIT(EXTI->RTSR, ExtiLine);
  429. }
  430. /**
  431. * @brief Disable ExtiLine Rising Edge Trigger for Lines
  432. * @note The configurable wakeup lines are edge-triggered. No glitch must be
  433. * generated on these lines. If a rising edge on a configurable interrupt
  434. * line occurs during a write operation in the EXTI_RTSR register, the
  435. * pending bit is not set.
  436. * Rising and falling edge triggers can be set for
  437. * the same interrupt line. In this case, both generate a trigger
  438. * condition.
  439. * @param ExtiLine This parameter can be a combination of the following values:
  440. * @arg @ref LL_EXTI_LINE_0
  441. * @arg @ref LL_EXTI_LINE_1
  442. * @arg @ref LL_EXTI_LINE_2
  443. * @arg @ref LL_EXTI_LINE_3
  444. * @arg @ref LL_EXTI_LINE_4
  445. * @arg @ref LL_EXTI_LINE_5
  446. * @arg @ref LL_EXTI_LINE_6
  447. * @arg @ref LL_EXTI_LINE_7
  448. * @arg @ref LL_EXTI_LINE_8
  449. * @arg @ref LL_EXTI_LINE_9
  450. * @arg @ref LL_EXTI_LINE_10
  451. * @arg @ref LL_EXTI_LINE_11
  452. * @arg @ref LL_EXTI_LINE_12
  453. * @arg @ref LL_EXTI_LINE_13
  454. * @arg @ref LL_EXTI_LINE_14
  455. * @arg @ref LL_EXTI_LINE_15
  456. * @arg @ref LL_EXTI_LINE_16
  457. * @arg @ref LL_EXTI_LINE_17
  458. * @arg @ref LL_EXTI_LINE_18
  459. * @note Please check each device line mapping for EXTI Line availability
  460. * @retval None
  461. */
  462. __STATIC_INLINE void LL_EXTI_DisableRisingTrig(uint32_t ExtiLine)
  463. {
  464. CLEAR_BIT(EXTI->RTSR, ExtiLine);
  465. }
  466. /**
  467. * @brief Check if rising edge trigger is enabled for Lines
  468. * @param ExtiLine This parameter can be a combination of the following values:
  469. * @arg @ref LL_EXTI_LINE_0
  470. * @arg @ref LL_EXTI_LINE_1
  471. * @arg @ref LL_EXTI_LINE_2
  472. * @arg @ref LL_EXTI_LINE_3
  473. * @arg @ref LL_EXTI_LINE_4
  474. * @arg @ref LL_EXTI_LINE_5
  475. * @arg @ref LL_EXTI_LINE_6
  476. * @arg @ref LL_EXTI_LINE_7
  477. * @arg @ref LL_EXTI_LINE_8
  478. * @arg @ref LL_EXTI_LINE_9
  479. * @arg @ref LL_EXTI_LINE_10
  480. * @arg @ref LL_EXTI_LINE_11
  481. * @arg @ref LL_EXTI_LINE_12
  482. * @arg @ref LL_EXTI_LINE_13
  483. * @arg @ref LL_EXTI_LINE_14
  484. * @arg @ref LL_EXTI_LINE_15
  485. * @arg @ref LL_EXTI_LINE_16
  486. * @arg @ref LL_EXTI_LINE_17
  487. * @arg @ref LL_EXTI_LINE_18
  488. * @note Please check each device line mapping for EXTI Line availability
  489. * @retval State of bit (1 or 0).
  490. */
  491. __STATIC_INLINE uint32_t LL_EXTI_IsEnabledRisingTrig(uint32_t ExtiLine)
  492. {
  493. return (READ_BIT(EXTI->RTSR, ExtiLine) == (ExtiLine));
  494. }
  495. /**
  496. * @}
  497. */
  498. /** @defgroup EXTI_LL_EF_Falling_Trigger_Management Falling_Trigger_Management
  499. * @{
  500. */
  501. /**
  502. * @brief Enable ExtiLine Falling Edge Trigger for Lines
  503. * @note The configurable wakeup lines are edge-triggered. No glitch must be
  504. * generated on these lines. If a falling edge on a configurable interrupt
  505. * line occurs during a write operation in the EXTI_FTSR register, the
  506. * pending bit is not set.
  507. * Rising and falling edge triggers can be set for
  508. * the same interrupt line. In this case, both generate a trigger
  509. * condition.
  510. * @param ExtiLine This parameter can be a combination of the following values:
  511. * @arg @ref LL_EXTI_LINE_0
  512. * @arg @ref LL_EXTI_LINE_1
  513. * @arg @ref LL_EXTI_LINE_2
  514. * @arg @ref LL_EXTI_LINE_3
  515. * @arg @ref LL_EXTI_LINE_4
  516. * @arg @ref LL_EXTI_LINE_5
  517. * @arg @ref LL_EXTI_LINE_6
  518. * @arg @ref LL_EXTI_LINE_7
  519. * @arg @ref LL_EXTI_LINE_8
  520. * @arg @ref LL_EXTI_LINE_9
  521. * @arg @ref LL_EXTI_LINE_10
  522. * @arg @ref LL_EXTI_LINE_11
  523. * @arg @ref LL_EXTI_LINE_12
  524. * @arg @ref LL_EXTI_LINE_13
  525. * @arg @ref LL_EXTI_LINE_14
  526. * @arg @ref LL_EXTI_LINE_15
  527. * @arg @ref LL_EXTI_LINE_16
  528. * @arg @ref LL_EXTI_LINE_17
  529. * @arg @ref LL_EXTI_LINE_18
  530. * @note Please check each device line mapping for EXTI Line availability
  531. * @retval None
  532. */
  533. __STATIC_INLINE void LL_EXTI_EnableFallingTrig(uint32_t ExtiLine)
  534. {
  535. SET_BIT(EXTI->FTSR, ExtiLine);
  536. }
  537. /**
  538. * @brief Disable ExtiLine Falling Edge Trigger for Lines
  539. * @note The configurable wakeup lines are edge-triggered. No glitch must be
  540. * generated on these lines. If a Falling edge on a configurable interrupt
  541. * line occurs during a write operation in the EXTI_FTSR register, the
  542. * pending bit is not set.
  543. * Rising and falling edge triggers can be set for the same interrupt line.
  544. * In this case, both generate a trigger condition.
  545. * @param ExtiLine This parameter can be a combination of the following values:
  546. * @arg @ref LL_EXTI_LINE_0
  547. * @arg @ref LL_EXTI_LINE_1
  548. * @arg @ref LL_EXTI_LINE_2
  549. * @arg @ref LL_EXTI_LINE_3
  550. * @arg @ref LL_EXTI_LINE_4
  551. * @arg @ref LL_EXTI_LINE_5
  552. * @arg @ref LL_EXTI_LINE_6
  553. * @arg @ref LL_EXTI_LINE_7
  554. * @arg @ref LL_EXTI_LINE_8
  555. * @arg @ref LL_EXTI_LINE_9
  556. * @arg @ref LL_EXTI_LINE_10
  557. * @arg @ref LL_EXTI_LINE_11
  558. * @arg @ref LL_EXTI_LINE_12
  559. * @arg @ref LL_EXTI_LINE_13
  560. * @arg @ref LL_EXTI_LINE_14
  561. * @arg @ref LL_EXTI_LINE_15
  562. * @arg @ref LL_EXTI_LINE_16
  563. * @arg @ref LL_EXTI_LINE_17
  564. * @arg @ref LL_EXTI_LINE_18
  565. * @note Please check each device line mapping for EXTI Line availability
  566. * @retval None
  567. */
  568. __STATIC_INLINE void LL_EXTI_DisableFallingTrig(uint32_t ExtiLine)
  569. {
  570. CLEAR_BIT(EXTI->FTSR, ExtiLine);
  571. }
  572. /**
  573. * @brief Check if falling edge trigger is enabled for Lines
  574. * @param ExtiLine This parameter can be a combination of the following values:
  575. * @arg @ref LL_EXTI_LINE_0
  576. * @arg @ref LL_EXTI_LINE_1
  577. * @arg @ref LL_EXTI_LINE_2
  578. * @arg @ref LL_EXTI_LINE_3
  579. * @arg @ref LL_EXTI_LINE_4
  580. * @arg @ref LL_EXTI_LINE_5
  581. * @arg @ref LL_EXTI_LINE_6
  582. * @arg @ref LL_EXTI_LINE_7
  583. * @arg @ref LL_EXTI_LINE_8
  584. * @arg @ref LL_EXTI_LINE_9
  585. * @arg @ref LL_EXTI_LINE_10
  586. * @arg @ref LL_EXTI_LINE_11
  587. * @arg @ref LL_EXTI_LINE_12
  588. * @arg @ref LL_EXTI_LINE_13
  589. * @arg @ref LL_EXTI_LINE_14
  590. * @arg @ref LL_EXTI_LINE_15
  591. * @arg @ref LL_EXTI_LINE_16
  592. * @arg @ref LL_EXTI_LINE_17
  593. * @arg @ref LL_EXTI_LINE_18
  594. * @note Please check each device line mapping for EXTI Line availability
  595. * @retval State of bit (1 or 0).
  596. */
  597. __STATIC_INLINE uint32_t LL_EXTI_IsEnabledFallingTrig(uint32_t ExtiLine)
  598. {
  599. return (READ_BIT(EXTI->FTSR, ExtiLine) == (ExtiLine));
  600. }
  601. /**
  602. * @}
  603. */
  604. /** @defgroup EXTI_LL_EF_Software_Interrupt_Management Software_Interrupt_Management
  605. * @{
  606. */
  607. /**
  608. * @brief Generate a software Interrupt Event for Lines
  609. * @note If the interrupt is enabled on this line in the EXTI_IMR, writing a 1 to
  610. * this bit when it is at '0' sets the corresponding pending bit in EXTI_PR
  611. * resulting in an interrupt request generation.
  612. * This bit is cleared by clearing the corresponding bit in the EXTI_PR
  613. * register (by writing a 1 into the bit)
  614. * @param ExtiLine This parameter can be a combination of the following values:
  615. * @arg @ref LL_EXTI_LINE_0
  616. * @arg @ref LL_EXTI_LINE_1
  617. * @arg @ref LL_EXTI_LINE_2
  618. * @arg @ref LL_EXTI_LINE_3
  619. * @arg @ref LL_EXTI_LINE_4
  620. * @arg @ref LL_EXTI_LINE_5
  621. * @arg @ref LL_EXTI_LINE_6
  622. * @arg @ref LL_EXTI_LINE_7
  623. * @arg @ref LL_EXTI_LINE_8
  624. * @arg @ref LL_EXTI_LINE_9
  625. * @arg @ref LL_EXTI_LINE_10
  626. * @arg @ref LL_EXTI_LINE_11
  627. * @arg @ref LL_EXTI_LINE_12
  628. * @arg @ref LL_EXTI_LINE_13
  629. * @arg @ref LL_EXTI_LINE_14
  630. * @arg @ref LL_EXTI_LINE_15
  631. * @arg @ref LL_EXTI_LINE_16
  632. * @arg @ref LL_EXTI_LINE_17
  633. * @arg @ref LL_EXTI_LINE_18
  634. * @note Please check each device line mapping for EXTI Line availability
  635. * @retval None
  636. */
  637. __STATIC_INLINE void LL_EXTI_GenerateSWI(uint32_t ExtiLine)
  638. {
  639. SET_BIT(EXTI->SWIER, ExtiLine);
  640. }
  641. /**
  642. * @}
  643. */
  644. /** @defgroup EXTI_LL_EF_Flag_Management FLAG Management
  645. * @{
  646. */
  647. /**
  648. * @brief Check if the ExtLine Flag is set or not for Lines
  649. * @param ExtiLine This parameter can be a combination of the following values:
  650. * @arg @ref LL_EXTI_LINE_0
  651. * @arg @ref LL_EXTI_LINE_1
  652. * @arg @ref LL_EXTI_LINE_2
  653. * @arg @ref LL_EXTI_LINE_3
  654. * @arg @ref LL_EXTI_LINE_4
  655. * @arg @ref LL_EXTI_LINE_5
  656. * @arg @ref LL_EXTI_LINE_6
  657. * @arg @ref LL_EXTI_LINE_7
  658. * @arg @ref LL_EXTI_LINE_8
  659. * @arg @ref LL_EXTI_LINE_9
  660. * @arg @ref LL_EXTI_LINE_10
  661. * @arg @ref LL_EXTI_LINE_11
  662. * @arg @ref LL_EXTI_LINE_12
  663. * @arg @ref LL_EXTI_LINE_13
  664. * @arg @ref LL_EXTI_LINE_14
  665. * @arg @ref LL_EXTI_LINE_15
  666. * @arg @ref LL_EXTI_LINE_16
  667. * @arg @ref LL_EXTI_LINE_17
  668. * @arg @ref LL_EXTI_LINE_18
  669. * @note Please check each device line mapping for EXTI Line availability
  670. * @retval State of bit (1 or 0).
  671. */
  672. __STATIC_INLINE uint32_t LL_EXTI_IsActiveFlag(uint32_t ExtiLine)
  673. {
  674. return (READ_BIT(EXTI->PR, ExtiLine) == (ExtiLine));
  675. }
  676. /**
  677. * @brief Read ExtLine Combination Flag for Lines
  678. * @param ExtiLine This parameter can be a combination of the following values:
  679. * @arg @ref LL_EXTI_LINE_0
  680. * @arg @ref LL_EXTI_LINE_1
  681. * @arg @ref LL_EXTI_LINE_2
  682. * @arg @ref LL_EXTI_LINE_3
  683. * @arg @ref LL_EXTI_LINE_4
  684. * @arg @ref LL_EXTI_LINE_5
  685. * @arg @ref LL_EXTI_LINE_6
  686. * @arg @ref LL_EXTI_LINE_7
  687. * @arg @ref LL_EXTI_LINE_8
  688. * @arg @ref LL_EXTI_LINE_9
  689. * @arg @ref LL_EXTI_LINE_10
  690. * @arg @ref LL_EXTI_LINE_11
  691. * @arg @ref LL_EXTI_LINE_12
  692. * @arg @ref LL_EXTI_LINE_13
  693. * @arg @ref LL_EXTI_LINE_14
  694. * @arg @ref LL_EXTI_LINE_15
  695. * @arg @ref LL_EXTI_LINE_16
  696. * @arg @ref LL_EXTI_LINE_17
  697. * @arg @ref LL_EXTI_LINE_18
  698. * @note Please check each device line mapping for EXTI Line availability
  699. * @retval @note This bit is set when the selected edge event arrives on the interrupt
  700. */
  701. __STATIC_INLINE uint32_t LL_EXTI_ReadFlag(uint32_t ExtiLine)
  702. {
  703. return (READ_BIT(EXTI->PR, ExtiLine));
  704. }
  705. /**
  706. * @brief Clear ExtLine Flags for Lines
  707. * @param ExtiLine This parameter can be a combination of the following values:
  708. * @arg @ref LL_EXTI_LINE_0
  709. * @arg @ref LL_EXTI_LINE_1
  710. * @arg @ref LL_EXTI_LINE_2
  711. * @arg @ref LL_EXTI_LINE_3
  712. * @arg @ref LL_EXTI_LINE_4
  713. * @arg @ref LL_EXTI_LINE_5
  714. * @arg @ref LL_EXTI_LINE_6
  715. * @arg @ref LL_EXTI_LINE_7
  716. * @arg @ref LL_EXTI_LINE_8
  717. * @arg @ref LL_EXTI_LINE_9
  718. * @arg @ref LL_EXTI_LINE_10
  719. * @arg @ref LL_EXTI_LINE_11
  720. * @arg @ref LL_EXTI_LINE_12
  721. * @arg @ref LL_EXTI_LINE_13
  722. * @arg @ref LL_EXTI_LINE_14
  723. * @arg @ref LL_EXTI_LINE_15
  724. * @arg @ref LL_EXTI_LINE_16
  725. * @arg @ref LL_EXTI_LINE_17
  726. * @arg @ref LL_EXTI_LINE_18
  727. * @note Please check each device line mapping for EXTI Line availability
  728. * @retval None
  729. */
  730. __STATIC_INLINE void LL_EXTI_ClearFlag(uint32_t ExtiLine)
  731. {
  732. WRITE_REG(EXTI->PR, ExtiLine);
  733. }
  734. /**
  735. * @brief Configure source input for the EXTI external interrupt.
  736. * @param Port This parameter can be one of the following values:
  737. * @arg @ref LL_EXTI_CONFIG_PORTA
  738. * @arg @ref LL_EXTI_CONFIG_PORTB
  739. * @arg @ref LL_EXTI_CONFIG_PORTF
  740. * @param Line This parameter can be one of the following values:
  741. * @arg @ref LL_EXTI_CONFIG_LINE0
  742. * @arg @ref LL_EXTI_CONFIG_LINE1
  743. * @arg @ref LL_EXTI_CONFIG_LINE2
  744. * @arg @ref LL_EXTI_CONFIG_LINE3
  745. * @arg @ref LL_EXTI_CONFIG_LINE4
  746. * @arg @ref LL_EXTI_CONFIG_LINE5
  747. * @arg @ref LL_EXTI_CONFIG_LINE6
  748. * @arg @ref LL_EXTI_CONFIG_LINE7
  749. * @arg @ref LL_EXTI_CONFIG_LINE8
  750. * @retval None
  751. */
  752. __STATIC_INLINE void LL_EXTI_SetEXTISource(uint32_t Port, uint32_t Line)
  753. {
  754. uint32_t mask = (Line >> LL_EXTI_REGISTER_PINMASK_SHFT) & 0xFF;
  755. uint32_t pos = (Line >> LL_EXTI_REGISTER_PINPOS_SHFT) & 0xFF;
  756. MODIFY_REG(EXTI->EXTICR[Line & 0x03u], (mask << pos), (Port << pos));
  757. }
  758. /**
  759. * @brief Get the configured defined for specific EXTI Line
  760. * @param Line This parameter can be one of the following values:
  761. * @arg @ref LL_EXTI_CONFIG_LINE0
  762. * @arg @ref LL_EXTI_CONFIG_LINE1
  763. * @arg @ref LL_EXTI_CONFIG_LINE2
  764. * @arg @ref LL_EXTI_CONFIG_LINE3
  765. * @arg @ref LL_EXTI_CONFIG_LINE4
  766. * @arg @ref LL_EXTI_CONFIG_LINE5
  767. * @arg @ref LL_EXTI_CONFIG_LINE6
  768. * @arg @ref LL_EXTI_CONFIG_LINE7
  769. * @arg @ref LL_EXTI_CONFIG_LINE8
  770. * @retval Returned value can be one of the following values:
  771. * @arg @ref LL_EXTI_CONFIG_PORTA
  772. * @arg @ref LL_EXTI_CONFIG_PORTB
  773. * @arg @ref LL_EXTI_CONFIG_PORTF
  774. */
  775. __STATIC_INLINE uint32_t LL_EXTI_GetEXTISource(uint32_t Line)
  776. {
  777. uint32_t mask = (Line >> LL_EXTI_REGISTER_PINMASK_SHFT) & 0xFF;
  778. uint32_t pos = (Line >> LL_EXTI_REGISTER_PINPOS_SHFT) & 0xFF;
  779. return (READ_BIT(EXTI->EXTICR[Line & 0x03u], (mask << pos)) >> pos);
  780. }
  781. /**
  782. * @}
  783. */
  784. /** @defgroup EXTI_LL_EF_Config EF configuration functions
  785. * @{
  786. */
  787. /**
  788. * @}
  789. */
  790. #if defined(USE_FULL_LL_DRIVER)
  791. /** @defgroup EXTI_LL_EF_Init Initialization and de-initialization functions
  792. * @{
  793. */
  794. uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct);
  795. uint32_t LL_EXTI_DeInit(void);
  796. void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct);
  797. /**
  798. * @}
  799. */
  800. #endif /* USE_FULL_LL_DRIVER */
  801. /**
  802. * @}
  803. */
  804. /**
  805. * @}
  806. */
  807. #endif /* EXTI */
  808. /**
  809. * @}
  810. */
  811. #ifdef __cplusplus
  812. }
  813. #endif
  814. #endif /* PY32F0XX_LL_EXTI_H */
  815. /************************ (C) COPYRIGHT Puya *****END OF FILE****/