py32f002b_ll_system.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. /**
  2. ******************************************************************************
  3. * @file py32f002b_ll_system.h
  4. * @author MCU Application Team
  5. * @brief Header file of SYSTEM 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_SYSTEM_H
  32. #define __PY32F002B_LL_SYSTEM_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 (FLASH) || defined (SYSCFG) || defined (DBGMCU)
  42. /** @defgroup SYSTEM_LL SYSTEM
  43. * @{
  44. */
  45. /* Private types -------------------------------------------------------------*/
  46. /* Private variables ---------------------------------------------------------*/
  47. /* Private constants ---------------------------------------------------------*/
  48. /** @defgroup SYSTEM_LL_Private_Constants SYSTEM Private Constants
  49. * @{
  50. */
  51. /**
  52. * @}
  53. */
  54. /* Private macros ------------------------------------------------------------*/
  55. /* Exported types ------------------------------------------------------------*/
  56. /* Exported constants --------------------------------------------------------*/
  57. /** @defgroup SYSTEM_LL_Exported_Constants SYSTEM Exported Constants
  58. * @{
  59. */
  60. /** @defgroup SYSTEM_LL_EC_REMAP SYSCFG REMAP
  61. * @{
  62. */
  63. #define LL_SYSCFG_REMAP_FLASH 0x00000000U /*!< Main Flash memory mapped at 0x00000000 */
  64. #define LL_SYSCFG_REMAP_SYSTEMFLASH SYSCFG_CFGR1_MEM_MODE_0 /*!< System Flash memory mapped at 0x00000000 */
  65. #define LL_SYSCFG_REMAP_SRAM (SYSCFG_CFGR1_MEM_MODE_1 | SYSCFG_CFGR1_MEM_MODE_0) /*!< Embedded SRAM mapped at 0x00000000 */
  66. /**
  67. * @}
  68. */
  69. /** @defgroup SYSTEM_LL_EC_I2C_FMP SYSCFG I2C FAST MODE ENABLE CONTORL
  70. * @{
  71. */
  72. #define LL_SYSCFG_I2C_FMP_PA2 SYSCFG_CFGR1_I2C_PA2_FMP
  73. #define LL_SYSCFG_I2C_FMP_PB3 SYSCFG_CFGR1_I2C_PB3_FMP
  74. #define LL_SYSCFG_I2C_FMP_PB4 SYSCFG_CFGR1_I2C_PB4_FMP
  75. #define LL_SYSCFG_I2C_FMP_PB6 SYSCFG_CFGR1_I2C_PB6_FMP
  76. /**
  77. * @}
  78. */
  79. /** @defgroup SYSTEM_LL_EC_OCREF_CLR SYSCFG TIMER OCREF CLEAR INPUT
  80. * @{
  81. */
  82. #define LL_SYSCFG_OCREF_CLR_COMP1_TO_TIM1 SYSCFG_CFGR1_COMP1_OCREF_CLR_TIM1
  83. #define LL_SYSCFG_OCREF_CLR_COMP2_TO_TIM1 SYSCFG_CFGR1_COMP2_OCREF_CLR_TIM1
  84. /**
  85. * @}
  86. */
  87. /** @defgroup SYSTEM_LL_EC_CH1_SRC SYSCFG TIM1 CH1 SRC
  88. * @{
  89. */
  90. #define LL_SYSCFG_CH1_SRC_TIM1_GPIO 0x00000000U
  91. #if defined(COMP1)
  92. #define LL_SYSCFG_CH1_SRC_TIM1_COMP1 SYSCFG_CFGR1_TIM1_IC1_SRC_0
  93. #endif
  94. #if defined(COMP2)
  95. #define LL_SYSCFG_CH1_SRC_TIM1_COMP2 SYSCFG_CFGR1_TIM1_IC1_SRC_1
  96. #endif
  97. /**
  98. * @}
  99. */
  100. /** @defgroup SYSTEM_LL_EC_TIMBREAK SYSCFG TIMER BREAK INPUT
  101. * @{
  102. */
  103. #if defined(SYSCFG_CFGR2_LOCKUP_LOCK)
  104. #define LL_SYSCFG_TIMBREAK_LOCKUP_TO_ALL SYSCFG_CFGR2_LOCKUP_LOCK
  105. #endif
  106. #if defined(SYSCFG_CFGR2_COMP1_BRK_TIM1)
  107. #define LL_SYSCFG_TIMBREAK_COMP1_TO_TIM1 SYSCFG_CFGR2_COMP1_BRK_TIM1
  108. #endif
  109. #if defined(SYSCFG_CFGR2_COMP2_BRK_TIM1)
  110. #define LL_SYSCFG_TIMBREAK_COMP2_TO_TIM1 SYSCFG_CFGR2_COMP2_BRK_TIM1
  111. #endif
  112. /**
  113. * @}
  114. */
  115. /** @defgroup SYSTEM_LL_EC_ETR_SRC SYSCFG TIM1 ETR SOURCE
  116. * @{
  117. */
  118. #define LL_SYSCFG_ETR_SRC_TIM1_GPIO 0x00000000U
  119. #if defined(COMP1)
  120. #define LL_SYSCFG_ETR_SRC_TIM1_COMP1 SYSCFG_CFGR2_ETR_SRC_TIM1_0
  121. #endif
  122. #if defined(COMP2)
  123. #define LL_SYSCFG_ETR_SRC_TIM1_COMP2 SYSCFG_CFGR2_ETR_SRC_TIM1_1
  124. #endif
  125. #if defined(ADC)
  126. #define LL_SYSCFG_ETR_SRC_TIM1_ADC (SYSCFG_CFGR2_ETR_SRC_TIM1_0 | SYSCFG_CFGR2_ETR_SRC_TIM1_1)
  127. #endif
  128. /**
  129. * @}
  130. */
  131. /** @defgroup SYSTEM_LL_EC_GPIO_PORT SYSCFG GPIO PORT
  132. * @{
  133. */
  134. #define LL_SYSCFG_GPIO_PORTA 0x00000000U
  135. #define LL_SYSCFG_GPIO_PORTB 0x00000008U
  136. #define LL_SYSCFG_GPIO_PORTC 0x00000010U
  137. /**
  138. * @}
  139. */
  140. /** @defgroup SYSTEM_LL_EC_GPIO_PIN SYSCFG GPIO PIN
  141. * @{
  142. */
  143. #define LL_SYSCFG_GPIO_PIN_0 0x00000001U
  144. #define LL_SYSCFG_GPIO_PIN_1 0x00000002U
  145. #define LL_SYSCFG_GPIO_PIN_2 0x00000004U
  146. #define LL_SYSCFG_GPIO_PIN_3 0x00000008U
  147. #define LL_SYSCFG_GPIO_PIN_4 0x00000010U
  148. #define LL_SYSCFG_GPIO_PIN_5 0x00000020U
  149. #define LL_SYSCFG_GPIO_PIN_6 0x00000040U
  150. #define LL_SYSCFG_GPIO_PIN_7 0x00000080U
  151. /**
  152. * @}
  153. */
  154. /** @defgroup SYSTEM_LL_EC_LATENCY FLASH LATENCY
  155. * @{
  156. */
  157. #define LL_FLASH_LATENCY_0 0x00000000U /*!< FLASH Zero Latency cycle */
  158. #define LL_FLASH_LATENCY_1 FLASH_ACR_LATENCY /*!< FLASH One Latency cycle */
  159. /**
  160. * @}
  161. */
  162. /** @defgroup SYSTEM_LL_EC_APB1_GRP1_STOP_IP DBGMCU APB1 GRP1 STOP IP
  163. * @{
  164. */
  165. #if defined(DBGMCU_APB_FZ1_DBG_TIM3_STOP)
  166. #define LL_DBGMCU_APB1_GRP1_TIM3_STOP DBGMCU_APB_FZ1_DBG_TIM3_STOP /*!< TIM3 counter stopped when core is halted */
  167. #endif
  168. #if defined(DBGMCU_APB_FZ1_DBG_TIM6_STOP)
  169. #define LL_DBGMCU_APB1_GRP1_TIM6_STOP DBGMCU_APB_FZ1_DBG_TIM6_STOP /*!< TIM6 counter stopped when core is halted */
  170. #endif
  171. #if defined(DBGMCU_APB_FZ1_DBG_IWDG_STOP)
  172. #define LL_DBGMCU_APB1_GRP1_IWDG_STOP DBGMCU_APB_FZ1_DBG_IWDG_STOP /*!< Debug Independent Watchdog stopped when Core is halted */
  173. #endif
  174. #if defined(DBGMCU_APB_FZ1_DBG_I2C1_STOP)
  175. #define LL_DBGMCU_APB1_GRP1_I2C1_STOP DBGMCU_APB_FZ1_DBG_I2C1_STOP /*!< I2C1 stopped when Core is halted */
  176. #endif
  177. #if defined(DBGMCU_APB_FZ1_DBG_LPTIM_STOP)
  178. #define LL_DBGMCU_APB1_GRP1_LPTIM1_STOP DBGMCU_APB_FZ1_DBG_LPTIM_STOP /*!< LPTIM1 counter stopped when Core is halted */
  179. #endif
  180. /**
  181. * @}
  182. */
  183. /** @defgroup SYSTEM_LL_EC_APB1_GRP2_STOP_IP DBGMCU APB1 GRP2 STOP IP
  184. * @{
  185. */
  186. #if defined(DBGMCU_APB_FZ2_DBG_TIM1_STOP)
  187. #define LL_DBGMCU_APB1_GRP2_TIM1_STOP DBGMCU_APB_FZ2_DBG_TIM1_STOP /*!< TIM1 counter stopped when core is halted */
  188. #endif
  189. #if defined(DBGMCU_APB_FZ2_DBG_TIM14_STOP)
  190. #define LL_DBGMCU_APB1_GRP2_TIM14_STOP DBGMCU_APB_FZ2_DBG_TIM14_STOP /*!< TIM14 counter stopped when core is halted */
  191. #endif
  192. #if defined(DBGMCU_APB_FZ2_DBG_TIM16_STOP)
  193. #define LL_DBGMCU_APB1_GRP2_TIM16_STOP DBGMCU_APB_FZ2_DBG_TIM16_STOP /*!< TIM16 counter stopped when core is halted */
  194. #endif
  195. #if defined(DBGMCU_APB_FZ2_DBG_TIM17_STOP)
  196. #define LL_DBGMCU_APB1_GRP2_TIM17_STOP DBGMCU_APB_FZ2_DBG_TIM17_STOP /*!< TIM17 counter stopped when core is halted */
  197. #endif
  198. /**
  199. * @}
  200. */
  201. /**
  202. * @}
  203. */
  204. /* Exported macro ------------------------------------------------------------*/
  205. /* Exported functions --------------------------------------------------------*/
  206. /** @defgroup SYSTEM_LL_Exported_Functions SYSTEM Exported Functions
  207. * @{
  208. */
  209. /** @defgroup SYSTEM_LL_EF_SYSCFG SYSCFG
  210. * @{
  211. */
  212. /**
  213. * @brief Set memory mapping at address 0x00000000
  214. * @rmtoll SYSCFG_CFGR1 MEM_MODE LL_SYSCFG_SetRemapMemory
  215. * @param Memory This parameter can be one of the following values:
  216. * @arg @ref LL_SYSCFG_REMAP_FLASH
  217. * @arg @ref LL_SYSCFG_REMAP_SYSTEMFLASH
  218. * @arg @ref LL_SYSCFG_REMAP_SRAM
  219. * @retval None
  220. */
  221. __STATIC_INLINE void LL_SYSCFG_SetRemapMemory(uint32_t Memory)
  222. {
  223. MODIFY_REG(SYSCFG->CFGR1, SYSCFG_CFGR1_MEM_MODE, Memory);
  224. }
  225. /**
  226. * @brief Get memory mapping at address 0x00000000
  227. * @rmtoll SYSCFG_CFGR1 MEM_MODE LL_SYSCFG_GetRemapMemory
  228. * @retval Returned value can be one of the following values:
  229. * @arg @ref LL_SYSCFG_REMAP_FLASH
  230. * @arg @ref LL_SYSCFG_REMAP_SYSTEMFLASH
  231. * @arg @ref LL_SYSCFG_REMAP_SRAM
  232. */
  233. __STATIC_INLINE uint32_t LL_SYSCFG_GetRemapMemory(void)
  234. {
  235. return (uint32_t)(READ_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_MEM_MODE));
  236. }
  237. /**
  238. * @brief Enable I2C Fast mode plus
  239. * @note Depending on devices and packages, some IOs may not be available.
  240. * Refer to device datasheet for IOs availability.
  241. * @param I2CFastModePlus This parameter can be a combination of the following values:
  242. * @arg @ref LL_SYSCFG_I2C_FMP_PA2
  243. * @arg @ref LL_SYSCFG_I2C_FMP_PB3
  244. * @arg @ref LL_SYSCFG_I2C_FMP_PB4
  245. * @arg @ref LL_SYSCFG_I2C_FMP_PB6
  246. * @retval None
  247. */
  248. __STATIC_INLINE void LL_SYSCFG_EnableI2CFastModePlus(uint32_t I2CFastModePlus)
  249. {
  250. SET_BIT(SYSCFG->CFGR1, I2CFastModePlus);
  251. }
  252. /**
  253. * @brief Disable I2C Fast mode plus
  254. * @note Depending on devices and packages, some IOs may not be available.
  255. * Refer to device datasheet for IOs availability.
  256. * @param I2CFastModePlus This parameter can be a combination of the following values:
  257. * @arg @ref LL_SYSCFG_I2C_FMP_PA2
  258. * @arg @ref LL_SYSCFG_I2C_FMP_PB3
  259. * @arg @ref LL_SYSCFG_I2C_FMP_PB4
  260. * @arg @ref LL_SYSCFG_I2C_FMP_PB6
  261. * @retval None
  262. */
  263. __STATIC_INLINE void LL_SYSCFG_DisableI2CFastModePlus(uint32_t I2CFastModePlus)
  264. {
  265. CLEAR_BIT(SYSCFG->CFGR1, I2CFastModePlus);
  266. }
  267. /**
  268. * @brief Indicate if enable I2C Fast mode plus
  269. * @note Depending on devices and packages, some IOs may not be available.
  270. * Refer to device datasheet for IOs availability.
  271. * @param I2CFastModePlus This parameter can be one of the following values:
  272. * @arg @ref LL_SYSCFG_I2C_FMP_PA2
  273. * @arg @ref LL_SYSCFG_I2C_FMP_PB3
  274. * @arg @ref LL_SYSCFG_I2C_FMP_PB4
  275. * @arg @ref LL_SYSCFG_I2C_FMP_PB6
  276. * @retval State of bit (1 or 0).
  277. */
  278. __STATIC_INLINE uint32_t LL_SYSCFG_IsEnabledI2CFastModePlus(uint32_t I2CFastModePlus)
  279. {
  280. return ((READ_BIT(SYSCFG->CFGR1, I2CFastModePlus) == (I2CFastModePlus)) ? 1UL : 0UL);
  281. }
  282. /**
  283. * @brief Enables COMPx as TIMx break input
  284. * @note Depending on devices and packages, some Peripherals may not be available.
  285. * Refer to device datasheet for Peripherals availability.
  286. * @param TIMBreakInputs This parameter can be a combination of the following values:
  287. * @arg @ref LL_SYSCFG_TIMBREAK_LOCKUP_TO_ALL
  288. * @arg @ref LL_SYSCFG_TIMBREAK_COMP1_TO_TIM1
  289. * @arg @ref LL_SYSCFG_TIMBREAK_COMP2_TO_TIM1
  290. * @retval None
  291. */
  292. __STATIC_INLINE void LL_SYSCFG_EnableTIMBreakInputs(uint32_t TIMBreakInputs)
  293. {
  294. SET_BIT(SYSCFG->CFGR2, TIMBreakInputs);
  295. }
  296. /**
  297. * @brief Disables COMPx as TIMx break input
  298. * @note Depending on devices and packages, some Peripherals may not be available.
  299. * Refer to device datasheet for Peripherals availability.
  300. * @param TIMBreakInputs This parameter can be a combination of the following values:
  301. * @arg @ref LL_SYSCFG_TIMBREAK_LOCKUP_TO_ALL
  302. * @arg @ref LL_SYSCFG_TIMBREAK_COMP1_TO_TIM1
  303. * @arg @ref LL_SYSCFG_TIMBREAK_COMP2_TO_TIM1
  304. * @retval None
  305. */
  306. __STATIC_INLINE void LL_SYSCFG_DisableTIMBreakInputs(uint32_t TIMBreakInputs)
  307. {
  308. CLEAR_BIT(SYSCFG->CFGR2, TIMBreakInputs);
  309. }
  310. /**
  311. * @brief Indicate if COMPx as TIMx break input
  312. * @note Depending on devices and packages, some Peripherals may not be available.
  313. * Refer to device datasheet for Peripherals availability.
  314. * @param TIMBreakInputs This parameter can be one of the following values:
  315. * @arg @ref LL_SYSCFG_TIMBREAK_LOCKUP_TO_ALL
  316. * @arg @ref LL_SYSCFG_TIMBREAK_COMP1_TO_TIM1
  317. * @arg @ref LL_SYSCFG_TIMBREAK_COMP2_TO_TIM1
  318. * @retval State of bit (1 or 0).
  319. */
  320. __STATIC_INLINE uint32_t LL_SYSCFG_IsEnabledTIMBreakInputs(uint32_t TIMBreakInputs)
  321. {
  322. return ((READ_BIT(SYSCFG->CFGR2, TIMBreakInputs) == (TIMBreakInputs)) ? 1UL : 0UL);
  323. }
  324. /**
  325. * @brief Set the TIMER1 ETR input source
  326. * @note Depending on devices and packages, some Peripherals may not be available.
  327. * Refer to device datasheet for Peripherals availability.
  328. * @param source This parameter can be one of the following values:
  329. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_GPIO
  330. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_COMP1
  331. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_COMP2
  332. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_ADC
  333. * @retval None
  334. */
  335. __STATIC_INLINE void LL_SYSCFG_SetTIM1ETRSource(uint32_t source)
  336. {
  337. MODIFY_REG(SYSCFG->CFGR2, SYSCFG_CFGR2_ETR_SRC_TIM1, source);
  338. }
  339. /**
  340. * @brief Get the TIMER1 ETR input source
  341. * @note Depending on devices and packages, some Peripherals may not be available.
  342. * Refer to device datasheet for Peripherals availability.
  343. * @retval Returned value can be one of the following values:
  344. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_GPIO
  345. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_COMP1
  346. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_COMP2
  347. * @arg @ref LL_SYSCFG_ETR_SRC_TIM1_ADC
  348. * @retval None
  349. */
  350. __STATIC_INLINE uint32_t LL_SYSCFG_GetTIM1ETRSource(void)
  351. {
  352. return (uint32_t)(READ_BIT(SYSCFG->CFGR2, SYSCFG_CFGR2_ETR_SRC_TIM1));
  353. }
  354. /**
  355. * @}
  356. */
  357. /** @defgroup SYSTEM_LL_EF_GPIO_ENS GPIO Filter
  358. * @{
  359. */
  360. /**
  361. * @brief Enable GPIO Filter
  362. * @note Depending on devices and packages, some IOs may not be available.
  363. * Refer to device datasheet for IOs availability.
  364. * @param GPIOPort This parameter can be a combination of the following values:
  365. * @arg @ref LL_SYSCFG_GPIO_PORTA
  366. * @arg @ref LL_SYSCFG_GPIO_PORTB
  367. * @arg @ref LL_SYSCFG_GPIO_PORTC
  368. * @param GPIOPin This parameter can be a combination of the following values:
  369. * @arg @ref LL_SYSCFG_GPIO_PIN_0
  370. * @arg @ref LL_SYSCFG_GPIO_PIN_1
  371. * @arg @ref LL_SYSCFG_GPIO_PIN_2
  372. * @arg @ref LL_SYSCFG_GPIO_PIN_3
  373. * @arg @ref LL_SYSCFG_GPIO_PIN_4
  374. * @arg @ref LL_SYSCFG_GPIO_PIN_5
  375. * @arg @ref LL_SYSCFG_GPIO_PIN_6
  376. * @arg @ref LL_SYSCFG_GPIO_PIN_7
  377. * @retval None
  378. */
  379. __STATIC_INLINE void LL_SYSCFG_EnableGPIOFilter(uint32_t GPIOPort, uint32_t GPIOPin)
  380. {
  381. SET_BIT(SYSCFG->GPIO_ENS, GPIOPin<<GPIOPort);
  382. }
  383. /**
  384. * @brief Disable GPIO Filter
  385. * @note Depending on devices and packages, some IOs may not be available.
  386. * Refer to device datasheet for IOs availability.
  387. * @param GPIOPort This parameter can be a combination of the following values:
  388. * @arg @ref LL_SYSCFG_GPIO_PORTA
  389. * @arg @ref LL_SYSCFG_GPIO_PORTB
  390. * @arg @ref LL_SYSCFG_GPIO_PORTC
  391. * @param GPIOPin This parameter can be a combination of the following values:
  392. * @arg @ref LL_SYSCFG_GPIO_PIN_0
  393. * @arg @ref LL_SYSCFG_GPIO_PIN_1
  394. * @arg @ref LL_SYSCFG_GPIO_PIN_2
  395. * @arg @ref LL_SYSCFG_GPIO_PIN_3
  396. * @arg @ref LL_SYSCFG_GPIO_PIN_4
  397. * @arg @ref LL_SYSCFG_GPIO_PIN_5
  398. * @arg @ref LL_SYSCFG_GPIO_PIN_6
  399. * @arg @ref LL_SYSCFG_GPIO_PIN_7
  400. * @retval None
  401. */
  402. __STATIC_INLINE void LL_SYSCFG_DisableGPIOFilter(uint32_t GPIOPort, uint32_t GPIOPin)
  403. {
  404. CLEAR_BIT(SYSCFG->GPIO_ENS, GPIOPin<<GPIOPort);
  405. }
  406. /**
  407. * @}
  408. */
  409. /** @defgroup SYSTEM_LL_EF_FLASH FLASH Latency
  410. * @{
  411. */
  412. /**
  413. * @brief Set FLASH Latency
  414. * @rmtoll FLASH_ACR FLASH_ACR_LATENCY LL_FLASH_SetLatency
  415. * @param Latency This parameter can be one of the following values:
  416. * @arg @ref LL_FLASH_LATENCY_0
  417. * @arg @ref LL_FLASH_LATENCY_1
  418. * @retval None
  419. */
  420. __STATIC_INLINE void LL_FLASH_SetLatency(uint32_t Latency)
  421. {
  422. MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, Latency);
  423. }
  424. /**
  425. * @brief Get FLASH Latency
  426. * @rmtoll FLASH_ACR FLASH_ACR_LATENCY LL_FLASH_GetLatency
  427. * @retval Returned value can be one of the following values:
  428. * @arg @ref LL_FLASH_LATENCY_0
  429. * @arg @ref LL_FLASH_LATENCY_1
  430. */
  431. __STATIC_INLINE uint32_t LL_FLASH_GetLatency(void)
  432. {
  433. return (uint32_t)(READ_BIT(FLASH->ACR, FLASH_ACR_LATENCY));
  434. }
  435. /**
  436. * @}
  437. */
  438. /** @defgroup SYSTEM_LL_EF_DBGMCU DBGMCU
  439. * @{
  440. */
  441. /**
  442. * @brief Return the device identifier
  443. * @retval Values between Min_Data=0x00 and Max_Data=0xFFF
  444. */
  445. __STATIC_INLINE uint32_t LL_DBGMCU_GetDeviceID(void)
  446. {
  447. return (uint32_t)(READ_BIT(DBGMCU->IDCODE, DBGMCU_IDCODE_DEV_ID));
  448. }
  449. /**
  450. * @brief Return the device revision identifier
  451. * @retval Values between Min_Data=0x00 and Max_Data=0xFFFF
  452. */
  453. __STATIC_INLINE uint32_t LL_DBGMCU_GetRevisionID(void)
  454. {
  455. return (uint32_t)(READ_BIT(DBGMCU->IDCODE, DBGMCU_IDCODE_REV_ID) >> DBGMCU_IDCODE_REV_ID_Pos);
  456. }
  457. /**
  458. * @brief Enable the Debug Module during STOP mode
  459. * @retval None
  460. */
  461. __STATIC_INLINE void LL_DBGMCU_EnableDBGStopMode(void)
  462. {
  463. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
  464. }
  465. /**
  466. * @brief Disable the Debug Module during STOP mode
  467. * @retval None
  468. */
  469. __STATIC_INLINE void LL_DBGMCU_DisableDBGStopMode(void)
  470. {
  471. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
  472. }
  473. /**
  474. * @brief Indicate if enable the Debug Module during STOP mode
  475. * @retval State of bit (1 or 0).
  476. */
  477. __STATIC_INLINE uint32_t LL_DBGMCU_IsEnabledDBGStopMode(void)
  478. {
  479. return ((READ_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP) == (DBGMCU_CR_DBG_STOP)) ? 1UL : 0UL);
  480. }
  481. /**
  482. * @brief Freeze APB1 peripherals (group1 peripherals)
  483. * @note Depending on devices and packages, some Peripherals may not be available.
  484. * Refer to device datasheet for Peripherals availability.
  485. * @param Periphs This parameter can be a combination of the following values:
  486. * @arg @ref LL_DBGMCU_APB1_GRP1_I2C1_STOP
  487. * @arg @ref LL_DBGMCU_APB1_GRP1_IWDG_STOP
  488. * @arg @ref LL_DBGMCU_APB1_GRP1_LPTIM1_STOP
  489. * @retval None
  490. */
  491. __STATIC_INLINE void LL_DBGMCU_APB1_GRP1_FreezePeriph(uint32_t Periphs)
  492. {
  493. SET_BIT(DBGMCU->APBFZ1, Periphs);
  494. }
  495. /**
  496. * @brief Unfreeze APB1 peripherals (group1 peripherals)
  497. * @note Depending on devices and packages, some Peripherals may not be available.
  498. * Refer to device datasheet for Peripherals availability.
  499. * @param Periphs This parameter can be a combination of the following values:
  500. * @arg @ref LL_DBGMCU_APB1_GRP1_I2C1_STOP
  501. * @arg @ref LL_DBGMCU_APB1_GRP1_IWDG_STOP
  502. * @arg @ref LL_DBGMCU_APB1_GRP1_LPTIM1_STOP
  503. * @retval None
  504. */
  505. __STATIC_INLINE void LL_DBGMCU_APB1_GRP1_UnFreezePeriph(uint32_t Periphs)
  506. {
  507. CLEAR_BIT(DBGMCU->APBFZ1, Periphs);
  508. }
  509. /**
  510. * @brief Indicate if Freeze APB1 peripherals (group1 peripherals)
  511. * @note Depending on devices and packages, some Peripherals may not be available.
  512. * Refer to device datasheet for Peripherals availability.
  513. * @param Periphs This parameter can be one of the following values:
  514. * @arg @ref LL_DBGMCU_APB1_GRP1_I2C1_STOP
  515. * @arg @ref LL_DBGMCU_APB1_GRP1_IWDG_STOP
  516. * @arg @ref LL_DBGMCU_APB1_GRP1_LPTIM1_STOP
  517. * @retval State of bit (1 or 0).
  518. */
  519. __STATIC_INLINE uint32_t LL_DBGMCU_APB1_GRP1_IsFreezePeriph(uint32_t Periphs)
  520. {
  521. return ((READ_BIT(DBGMCU->APBFZ1, Periphs) == (Periphs)) ? 1UL : 0UL);
  522. }
  523. /**
  524. * @brief Freeze APB1 peripherals(group2 peripherals)
  525. * @note Depending on devices and packages, some Peripherals may not be available.
  526. * Refer to device datasheet for Peripherals availability.
  527. * @param Periphs This parameter can be a combination of the following values:
  528. * @arg @ref LL_DBGMCU_APB1_GRP2_TIM1_STOP
  529. * @arg @ref LL_DBGMCU_APB1_GRP2_TIM14_STOP
  530. * @retval None
  531. */
  532. __STATIC_INLINE void LL_DBGMCU_APB1_GRP2_FreezePeriph(uint32_t Periphs)
  533. {
  534. SET_BIT(DBGMCU->APBFZ2, Periphs);
  535. }
  536. /**
  537. * @brief Unfreeze APB1 peripherals(group2 peripherals)
  538. * @note Depending on devices and packages, some Peripherals may not be available.
  539. * Refer to device datasheet for Peripherals availability.
  540. * @param Periphs This parameter can be a combination of the following values:
  541. * @arg @ref LL_DBGMCU_APB1_GRP2_TIM1_STOP
  542. * @arg @ref LL_DBGMCU_APB1_GRP2_TIM14_STOP
  543. * @retval None
  544. */
  545. __STATIC_INLINE void LL_DBGMCU_APB1_GRP2_UnFreezePeriph(uint32_t Periphs)
  546. {
  547. CLEAR_BIT(DBGMCU->APBFZ2, Periphs);
  548. }
  549. /**
  550. * @brief Indicate if Freeze APB1 peripherals (group2 peripherals)
  551. * @note Depending on devices and packages, some Peripherals may not be available.
  552. * Refer to device datasheet for Peripherals availability.
  553. * @param Periphs This parameter can be one of the following values:
  554. * @arg @ref LL_DBGMCU_APB1_GRP2_TIM1_STOP
  555. * @arg @ref LL_DBGMCU_APB1_GRP2_TIM14_STOP
  556. * @retval State of bit (1 or 0).
  557. */
  558. __STATIC_INLINE uint32_t LL_DBGMCU_APB1_GRP2_IsFreezePeriph(uint32_t Periphs)
  559. {
  560. return ((READ_BIT(DBGMCU->APBFZ2, Periphs) == (Periphs)) ? 1UL : 0UL);
  561. }
  562. /**
  563. * @}
  564. */
  565. /**
  566. * @}
  567. */
  568. /**
  569. * @}
  570. */
  571. #endif /* defined (FLASH) || defined (SYSCFG) || defined (DBGMCU) */
  572. /**
  573. * @}
  574. */
  575. #ifdef __cplusplus
  576. }
  577. #endif
  578. #endif /* PY32F002B_LL_SYSTEM_H */
  579. /************************ (C) COPYRIGHT Puya *****END OF FILE****/