py32f002b_ll_exti.h 25 KB

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