You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

2728 lines
93 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32wbxx_ll_pwr.h
  4. * @author MCD Application Team
  5. * @brief Header file of PWR LL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST 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. */
  19. /* Define to prevent recursive inclusion -------------------------------------*/
  20. #ifndef STM32WBxx_LL_PWR_H
  21. #define STM32WBxx_LL_PWR_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32wbxx.h"
  27. /** @addtogroup STM32WBxx_LL_Driver
  28. * @{
  29. */
  30. #if defined(PWR)
  31. /** @defgroup PWR_LL PWR
  32. * @{
  33. */
  34. /* Private types -------------------------------------------------------------*/
  35. /* Private variables ---------------------------------------------------------*/
  36. /* Private constants ---------------------------------------------------------*/
  37. /** @defgroup PWR_LL_Private_Constants PWR Private Constants
  38. * @{
  39. */
  40. #if defined(PWR_CR5_SMPSEN)
  41. /** @defgroup PWR_SMPS_Calibration PWR SMPS calibration
  42. * @{
  43. */
  44. #define SMPS_VOLTAGE_CAL_ADDR ((uint32_t*) (0x1FFF7558UL)) /* SMPS output voltage calibration level corresponding to voltage "SMPS_VOLTAGE_CAL_VOLTAGE_MV" */
  45. #define SMPS_VOLTAGE_CAL_POS (8UL) /* SMPS output voltage calibration level bitfield position */
  46. #define SMPS_VOLTAGE_CAL (0xFUL << SMPS_VOLTAGE_CAL_POS) /* SMPS output voltage calibration level bitfield mask */
  47. #define SMPS_VOLTAGE_CAL_VOLTAGE_MV (1500UL) /* SMPS output voltage calibration value (unit: mV) */
  48. #define SMPS_VOLTAGE_BASE_MV (1200UL) /* SMPS output voltage base value (unit: mV) */
  49. #define SMPS_VOLTAGE_STEP_MV ( 50UL) /* SMPS output voltage step (unit: mV) */
  50. /**
  51. * @}
  52. */
  53. #endif
  54. /**
  55. * @}
  56. */
  57. /* Private macros ------------------------------------------------------------*/
  58. /* Exported types ------------------------------------------------------------*/
  59. /* Exported constants --------------------------------------------------------*/
  60. /** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
  61. * @{
  62. */
  63. /** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines
  64. * @brief Flags defines which can be used with LL_PWR_WriteReg function
  65. * @{
  66. */
  67. #define LL_PWR_SCR_CWUF PWR_SCR_CWUF
  68. #if defined(PWR_CR3_EWUP2)
  69. #define LL_PWR_SCR_CWUF5 PWR_SCR_CWUF5
  70. #endif
  71. #define LL_PWR_SCR_CWUF4 PWR_SCR_CWUF4
  72. #if defined(PWR_CR3_EWUP3)
  73. #define LL_PWR_SCR_CWUF3 PWR_SCR_CWUF3
  74. #endif
  75. #if defined(PWR_CR3_EWUP2)
  76. #define LL_PWR_SCR_CWUF2 PWR_SCR_CWUF2
  77. #endif
  78. #define LL_PWR_SCR_CWUF1 PWR_SCR_CWUF1
  79. #define LL_PWR_SCR_CC2HF PWR_SCR_CC2HF
  80. #define LL_PWR_SCR_CBLEAF PWR_SCR_CBLEAF
  81. #define LL_PWR_SCR_CCRPEF PWR_SCR_CCRPEF
  82. #if defined(PWR_CR3_E802A)
  83. #define LL_PWR_SCR_C802AF PWR_SCR_C802AF
  84. #define LL_PWR_SCR_C802WUF PWR_SCR_C802WUF
  85. #endif
  86. #define LL_PWR_SCR_CBLEWUF PWR_SCR_CBLEWUF
  87. #if defined(PWR_CR5_SMPSEN)
  88. #define LL_PWR_SCR_CBORHF PWR_SCR_CBORHF
  89. #define LL_PWR_SCR_CSMPSFBF PWR_SCR_CSMPSFBF
  90. #endif
  91. #define LL_PWR_EXTSCR_CCRPF PWR_EXTSCR_CCRPF
  92. #define LL_PWR_EXTSCR_C2CSSF PWR_EXTSCR_C2CSSF
  93. #define LL_PWR_EXTSCR_C1CSSF PWR_EXTSCR_C1CSSF
  94. /**
  95. * @}
  96. */
  97. /** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines
  98. * @brief Flags defines which can be used with LL_PWR_ReadReg function
  99. * @{
  100. */
  101. #define LL_PWR_SR1_WUFI PWR_SR1_WUFI
  102. #if defined(PWR_CR3_EWUP5)
  103. #define LL_PWR_SR1_WUF5 PWR_SR1_WUF5
  104. #endif
  105. #define LL_PWR_SR1_WUF4 PWR_SR1_WUF4
  106. #if defined(PWR_CR3_EWUP3)
  107. #define LL_PWR_SR1_WUF3 PWR_SR1_WUF3
  108. #endif
  109. #if defined(PWR_CR3_EWUP2)
  110. #define LL_PWR_SR1_WUF2 PWR_SR1_WUF2
  111. #endif
  112. #define LL_PWR_SR1_WUF1 PWR_SR1_WUF1
  113. #define LL_PWR_SR2_PVMO3 PWR_SR2_PVMO3
  114. #if defined(PWR_CR2_PVME1)
  115. #define LL_PWR_SR2_PVMO1 PWR_SR2_PVMO1
  116. #endif
  117. #define LL_PWR_SR2_PVDO PWR_SR2_PVDO
  118. #if defined(PWR_CR1_VOS)
  119. #define LL_PWR_SR2_VOSF PWR_SR2_VOSF
  120. #endif
  121. #define LL_PWR_SR2_REGLPF PWR_SR2_REGLPF
  122. #define LL_PWR_SR2_REGLPS PWR_SR2_REGLPS
  123. /* BOR flags */
  124. #define LL_PWR_FLAG_BORH PWR_SR1_BORHF /* BORH interrupt flag */
  125. #if defined(PWR_CR5_SMPSEN)
  126. /* SMPS flags */
  127. #define LL_PWR_FLAG_SMPS PWR_SR2_SMPSF /* SMPS step down converter ready flag */
  128. #define LL_PWR_FLAG_SMPSB PWR_SR2_SMPSBF /* SMPS step down converter in bypass mode flag */
  129. #define LL_PWR_FLAG_SMPSFB PWR_SR1_SMPSFB /* SMPS step down converter forced in bypass mode interrupt flag */
  130. #endif
  131. /* Radio (BLE or 802.15.4) flags */
  132. #define LL_PWR_FLAG_BLEWU PWR_SR1_BLEWUF /* BLE wakeup interrupt flag */
  133. #define LL_PWR_FLAG_BLEA PWR_SR1_BLEAF /* BLE end of activity interrupt flag */
  134. #if defined(PWR_CR3_E802A)
  135. #define LL_PWR_FLAG_802WU PWR_SR1_802WUF /* 802.15.4 wakeup interrupt flag */
  136. #define LL_PWR_FLAG_802A PWR_SR1_802AF /* 802.15.4 end of activity interrupt flag */
  137. #endif
  138. #define LL_PWR_FLAG_CRPE PWR_SR1_CRPEF /* Critical radio phase end of activity interrupt flag */
  139. #define LL_PWR_FLAG_CRP PWR_EXTSCR_CRPF /* Critical radio system phase */
  140. /* Multicore flags */
  141. #define LL_PWR_EXTSCR_C1SBF PWR_EXTSCR_C1SBF /* System standby flag for CPU1 */
  142. #define LL_PWR_EXTSCR_C1STOPF PWR_EXTSCR_C1STOPF /* System stop flag for CPU1 */
  143. #define LL_PWR_EXTSCR_C1DS PWR_EXTSCR_C1DS /* CPU1 deepsleep mode */
  144. #define LL_PWR_EXTSCR_C2SBF PWR_EXTSCR_C2SBF /* System standby flag for CPU2 */
  145. #define LL_PWR_EXTSCR_C2STOPF PWR_EXTSCR_C2STOPF /* System stop flag for CPU2 */
  146. #define LL_PWR_EXTSCR_C2DS PWR_EXTSCR_C2DS /* CPU2 deepsleep mode */
  147. #define LL_PWR_SR1_C2HF PWR_SR1_C2HF /* CPU2 hold interrupt flag */
  148. /**
  149. * @}
  150. */
  151. #if defined(PWR_CR1_VOS)
  152. /** @defgroup PWR_LL_EC_REGU_VOLTAGE REGU VOLTAGE
  153. * @{
  154. */
  155. #define LL_PWR_REGU_VOLTAGE_SCALE1 (PWR_CR1_VOS_0) /* Regulator voltage output range 1 mode, typical output voltage at 1.2 V, system frequency up to 64 MHz. */
  156. #define LL_PWR_REGU_VOLTAGE_SCALE2 (PWR_CR1_VOS_1) /* Regulator voltage output range 2 mode, typical output voltage at 1.0 V, system frequency up to 16 MHz. */
  157. /**
  158. * @}
  159. */
  160. #endif
  161. /** @defgroup PWR_LL_EC_MODE_PWR MODE PWR
  162. * @{
  163. */
  164. #define LL_PWR_MODE_STOP0 (0x000000000U)
  165. #define LL_PWR_MODE_STOP1 (PWR_CR1_LPMS_0)
  166. #if defined(PWR_SUPPORT_STOP2)
  167. #define LL_PWR_MODE_STOP2 (PWR_CR1_LPMS_1)
  168. #endif
  169. #define LL_PWR_MODE_STANDBY (PWR_CR1_LPMS_1 | PWR_CR1_LPMS_0)
  170. #define LL_PWR_MODE_SHUTDOWN (PWR_CR1_LPMS_2)
  171. /**
  172. * @}
  173. */
  174. /** @defgroup PWR_LL_EC_FLASH_LPRUN_POWER_DOWN_MODE Flash power-down mode during low-power run mode
  175. * @{
  176. */
  177. #define LL_PWR_FLASH_LPRUN_MODE_IDLE (0x000000000U)
  178. #define LL_PWR_FLASH_LPRUN_MODE_POWER_DOWN (PWR_CR1_FPDR)
  179. /**
  180. * @}
  181. */
  182. /** @defgroup PWR_LL_EC_FLASH_SLEEP_POWER_DOWN_MODE Flash power-down mode during sleep mode
  183. * @{
  184. */
  185. #define LL_PWR_FLASH_SLEEP_MODE_IDLE (0x000000000U)
  186. #define LL_PWR_FLASH_SLEEP_MODE_POWER_DOWN (PWR_CR1_FPDS)
  187. /**
  188. * @}
  189. */
  190. /** @defgroup PWR_LL_EC_PVM Peripheral voltage monitoring
  191. * @{
  192. */
  193. #if defined(PWR_CR2_PVME1)
  194. #define LL_PWR_PVM_VDDUSB_1_2V (PWR_CR2_PVME1) /* Monitoring VDDUSB vs. 1.2V */
  195. #endif
  196. #define LL_PWR_PVM_VDDA_1_62V (PWR_CR2_PVME3) /* Monitoring VDDA vs. 1.62V */
  197. /**
  198. * @}
  199. */
  200. /** @defgroup PWR_LL_EC_PVDLEVEL PVDLEVEL
  201. * @{
  202. */
  203. #define LL_PWR_PVDLEVEL_0 (0x00000000U) /* VPVD0 around 2.0 V */
  204. #define LL_PWR_PVDLEVEL_1 (PWR_CR2_PLS_0) /* VPVD1 around 2.2 V */
  205. #define LL_PWR_PVDLEVEL_2 (PWR_CR2_PLS_1) /* VPVD2 around 2.4 V */
  206. #define LL_PWR_PVDLEVEL_3 (PWR_CR2_PLS_1 | PWR_CR2_PLS_0) /* VPVD3 around 2.5 V */
  207. #define LL_PWR_PVDLEVEL_4 (PWR_CR2_PLS_2) /* VPVD4 around 2.6 V */
  208. #define LL_PWR_PVDLEVEL_5 (PWR_CR2_PLS_2 | PWR_CR2_PLS_0) /* VPVD5 around 2.8 V */
  209. #define LL_PWR_PVDLEVEL_6 (PWR_CR2_PLS_2 | PWR_CR2_PLS_1) /* VPVD6 around 2.9 V */
  210. #define LL_PWR_PVDLEVEL_7 (PWR_CR2_PLS_2 | PWR_CR2_PLS_1 | PWR_CR2_PLS_0) /* External input analog voltage (Compare internally to VREFINT) */
  211. /**
  212. * @}
  213. */
  214. /** @defgroup PWR_LL_EC_WAKEUP WAKEUP
  215. * @{
  216. */
  217. #define LL_PWR_WAKEUP_PIN1 (PWR_CR3_EWUP1)
  218. #if defined(PWR_CR3_EWUP2)
  219. #define LL_PWR_WAKEUP_PIN2 (PWR_CR3_EWUP2)
  220. #endif
  221. #if defined(PWR_CR3_EWUP3)
  222. #define LL_PWR_WAKEUP_PIN3 (PWR_CR3_EWUP3)
  223. #endif
  224. #define LL_PWR_WAKEUP_PIN4 (PWR_CR3_EWUP4)
  225. #if defined(PWR_CR3_EWUP5)
  226. #define LL_PWR_WAKEUP_PIN5 (PWR_CR3_EWUP5)
  227. #endif
  228. /**
  229. * @}
  230. */
  231. /** @defgroup PWR_LL_EC_BATT_CHARG_RESISTOR BATT CHARG RESISTOR
  232. * @{
  233. */
  234. #define LL_PWR_BATT_CHARG_RESISTOR_5K (0x00000000U)
  235. #define LL_PWR_BATT_CHARGRESISTOR_1_5K (PWR_CR4_VBRS)
  236. /**
  237. * @}
  238. */
  239. /** @defgroup PWR_LL_EC_GPIO GPIO
  240. * @{
  241. */
  242. #define LL_PWR_GPIO_A ((uint32_t)(&(PWR->PUCRA)))
  243. #define LL_PWR_GPIO_B ((uint32_t)(&(PWR->PUCRB)))
  244. #define LL_PWR_GPIO_C ((uint32_t)(&(PWR->PUCRC)))
  245. #define LL_PWR_GPIO_D ((uint32_t)(&(PWR->PUCRD)))
  246. #define LL_PWR_GPIO_E ((uint32_t)(&(PWR->PUCRE)))
  247. #define LL_PWR_GPIO_H ((uint32_t)(&(PWR->PUCRH)))
  248. /**
  249. * @}
  250. */
  251. /** @defgroup PWR_LL_EC_GPIO_BIT GPIO BIT
  252. * @{
  253. */
  254. #if defined(PWR_PUCRC_PC0)
  255. /* Note: LL_PWR_GPIO_BIT_x defined from port C because all pins are available */
  256. /* for PWR pull-up and pull-down. */
  257. #define LL_PWR_GPIO_BIT_0 (PWR_PUCRC_PC0)
  258. #define LL_PWR_GPIO_BIT_1 (PWR_PUCRC_PC1)
  259. #define LL_PWR_GPIO_BIT_2 (PWR_PUCRC_PC2)
  260. #define LL_PWR_GPIO_BIT_3 (PWR_PUCRC_PC3)
  261. #define LL_PWR_GPIO_BIT_4 (PWR_PUCRC_PC4)
  262. #define LL_PWR_GPIO_BIT_5 (PWR_PUCRC_PC5)
  263. #define LL_PWR_GPIO_BIT_6 (PWR_PUCRC_PC6)
  264. #define LL_PWR_GPIO_BIT_7 (PWR_PUCRC_PC7)
  265. #define LL_PWR_GPIO_BIT_8 (PWR_PUCRC_PC8)
  266. #define LL_PWR_GPIO_BIT_9 (PWR_PUCRC_PC9)
  267. #define LL_PWR_GPIO_BIT_10 (PWR_PUCRC_PC10)
  268. #define LL_PWR_GPIO_BIT_11 (PWR_PUCRC_PC11)
  269. #define LL_PWR_GPIO_BIT_12 (PWR_PUCRC_PC12)
  270. #define LL_PWR_GPIO_BIT_13 (PWR_PUCRC_PC13)
  271. #define LL_PWR_GPIO_BIT_14 (PWR_PUCRC_PC14)
  272. #define LL_PWR_GPIO_BIT_15 (PWR_PUCRC_PC15)
  273. #else
  274. #define LL_PWR_GPIO_BIT_0 (PWR_PUCRA_PA0)
  275. #define LL_PWR_GPIO_BIT_1 (PWR_PUCRA_PA1)
  276. #define LL_PWR_GPIO_BIT_2 (PWR_PUCRA_PA2)
  277. #define LL_PWR_GPIO_BIT_3 (PWR_PUCRA_PA3)
  278. #define LL_PWR_GPIO_BIT_4 (PWR_PUCRA_PA4)
  279. #define LL_PWR_GPIO_BIT_5 (PWR_PUCRA_PA5)
  280. #define LL_PWR_GPIO_BIT_6 (PWR_PUCRA_PA6)
  281. #define LL_PWR_GPIO_BIT_7 (PWR_PUCRA_PA7)
  282. #define LL_PWR_GPIO_BIT_8 (PWR_PUCRA_PA8)
  283. #define LL_PWR_GPIO_BIT_9 (PWR_PUCRA_PA9)
  284. #define LL_PWR_GPIO_BIT_10 (PWR_PUCRA_PA10)
  285. #define LL_PWR_GPIO_BIT_11 (PWR_PUCRA_PA11)
  286. #define LL_PWR_GPIO_BIT_12 (PWR_PUCRA_PA12)
  287. #define LL_PWR_GPIO_BIT_13 (PWR_PUCRA_PA13)
  288. #define LL_PWR_GPIO_BIT_14 (PWR_PUCRC_PC14)
  289. #define LL_PWR_GPIO_BIT_15 (PWR_PUCRC_PC15)
  290. #endif
  291. /**
  292. * @}
  293. */
  294. #if defined(PWR_CR5_SMPSEN)
  295. /** @defgroup PWR_LL_EC_BOR_CONFIGURATION BOR configuration
  296. * @{
  297. */
  298. #define LL_PWR_BOR_SYSTEM_RESET (0x00000000U) /*!< BOR will generate a system reset */
  299. #define LL_PWR_BOR_SMPS_FORCE_BYPASS (PWR_CR5_BORHC) /*!< BOR will for SMPS step down converter in bypass mode */
  300. /**
  301. * @}
  302. */
  303. /** @defgroup PWR_LL_EC_SMPS_OPERATING_MODES SMPS step down converter operating modes
  304. * @{
  305. */
  306. /* Note: Literals values are defined from register SR2 bits SMPSF and SMPSBF */
  307. /* but they are also used as register CR5 bits SMPSEN and SMPSBEN, */
  308. /* as used by all SMPS operating mode functions targetting different */
  309. /* registers: */
  310. /* "LL_PWR_SMPS_SetMode()", "LL_PWR_SMPS_GetMode()" */
  311. /* and "LL_PWR_SMPS_GetEffectiveMode()". */
  312. #define LL_PWR_SMPS_BYPASS (PWR_SR2_SMPSBF) /*!< SMPS step down in bypass mode. */
  313. #define LL_PWR_SMPS_STEP_DOWN (PWR_SR2_SMPSF) /*!< SMPS step down in step down mode if system low power mode is run, LP run or stop0. If system low power mode is stop1, stop2, standby, shutdown, then SMPS is forced in mode open to preserve energy stored in decoupling capacitor as long as possible. */
  314. /**
  315. * @}
  316. */
  317. /** @defgroup PWR_LL_EC_SMPS_STARTUP_CURRENT SMPS step down converter supply startup current selection
  318. * @{
  319. */
  320. #define LL_PWR_SMPS_STARTUP_CURRENT_80MA (0x00000000U) /*!< SMPS step down converter supply startup current 80mA */
  321. #define LL_PWR_SMPS_STARTUP_CURRENT_100MA ( PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 100mA */
  322. #define LL_PWR_SMPS_STARTUP_CURRENT_120MA ( PWR_CR5_SMPSSC_1 ) /*!< SMPS step down converter supply startup current 120mA */
  323. #define LL_PWR_SMPS_STARTUP_CURRENT_140MA ( PWR_CR5_SMPSSC_1 | PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 140mA */
  324. #define LL_PWR_SMPS_STARTUP_CURRENT_160MA (PWR_CR5_SMPSSC_2 ) /*!< SMPS step down converter supply startup current 160mA */
  325. #define LL_PWR_SMPS_STARTUP_CURRENT_180MA (PWR_CR5_SMPSSC_2 | PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 180mA */
  326. #define LL_PWR_SMPS_STARTUP_CURRENT_200MA (PWR_CR5_SMPSSC_2 | PWR_CR5_SMPSSC_1 ) /*!< SMPS step down converter supply startup current 200mA */
  327. #define LL_PWR_SMPS_STARTUP_CURRENT_220MA (PWR_CR5_SMPSSC_2 | PWR_CR5_SMPSSC_1 | PWR_CR5_SMPSSC_0) /*!< SMPS step down converter supply startup current 220mA */
  328. /**
  329. * @}
  330. */
  331. /** @defgroup PWR_LL_EC_SMPS_OUTPUT_VOLTAGE_LEVEL SMPS step down converter output voltage scaling voltage level
  332. * @{
  333. */
  334. /* Note: SMPS voltage is trimmed during device production to control
  335. the actual voltage level variation from device to device. */
  336. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V20 (0x00000000U) /*!< SMPS step down converter supply output voltage 1.20V */
  337. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V25 ( PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.25V */
  338. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V30 ( PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.30V */
  339. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V35 ( PWR_CR5_SMPSVOS_1 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.35V */
  340. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V40 ( PWR_CR5_SMPSVOS_2 ) /*!< SMPS step down converter supply output voltage 1.40V */
  341. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V45 ( PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.45V */
  342. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V50 ( PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.50V */
  343. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V55 ( PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_1 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.55V */
  344. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V60 (PWR_CR5_SMPSVOS_3 ) /*!< SMPS step down converter supply output voltage 1.60V */
  345. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V65 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.65V */
  346. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V70 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.70V */
  347. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V75 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_1 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.75V */
  348. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V80 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_2 ) /*!< SMPS step down converter supply output voltage 1.80V */
  349. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V85 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_0) /*!< SMPS step down converter supply output voltage 1.85V */
  350. #define LL_PWR_SMPS_OUTPUT_VOLTAGE_1V90 (PWR_CR5_SMPSVOS_3 | PWR_CR5_SMPSVOS_2 | PWR_CR5_SMPSVOS_1 ) /*!< SMPS step down converter supply output voltage 1.90V */
  351. /**
  352. * @}
  353. */
  354. #endif
  355. /**
  356. * @}
  357. */
  358. /* Exported macro ------------------------------------------------------------*/
  359. /** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
  360. * @{
  361. */
  362. /** @defgroup PWR_LL_EM_WRITE_READ Common Write and read registers Macros
  363. * @{
  364. */
  365. /**
  366. * @brief Write a value in PWR register
  367. * @param __REG__ Register to be written
  368. * @param __VALUE__ Value to be written in the register
  369. * @retval None
  370. */
  371. #define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
  372. /**
  373. * @brief Read a value in PWR register
  374. * @param __REG__ Register to be read
  375. * @retval Register value
  376. */
  377. #define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
  378. /**
  379. * @}
  380. */
  381. /**
  382. * @}
  383. */
  384. /* Exported functions --------------------------------------------------------*/
  385. /** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
  386. * @{
  387. */
  388. /** @defgroup PWR_LL_EF_Configuration Configuration
  389. * @{
  390. */
  391. /**
  392. * @brief Switch from run main mode to run low-power mode.
  393. * @rmtoll CR1 LPR LL_PWR_EnterLowPowerRunMode
  394. * @retval None
  395. */
  396. __STATIC_INLINE void LL_PWR_EnterLowPowerRunMode(void)
  397. {
  398. SET_BIT(PWR->CR1, PWR_CR1_LPR);
  399. }
  400. /**
  401. * @brief Switch from run main mode to low-power mode.
  402. * @rmtoll CR1 LPR LL_PWR_ExitLowPowerRunMode
  403. * @retval None
  404. */
  405. __STATIC_INLINE void LL_PWR_ExitLowPowerRunMode(void)
  406. {
  407. CLEAR_BIT(PWR->CR1, PWR_CR1_LPR);
  408. }
  409. /**
  410. * @brief Check if the regulator is in low-power mode
  411. * @rmtoll CR1 LPR LL_PWR_IsEnabledLowPowerRunMode
  412. * @retval State of bit (1 or 0).
  413. */
  414. __STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRunMode(void)
  415. {
  416. return ((READ_BIT(PWR->CR1, PWR_CR1_LPR) == (PWR_CR1_LPR)) ? 1UL : 0UL);
  417. }
  418. #if defined(PWR_CR1_VOS)
  419. /**
  420. * @brief Set the main internal regulator output voltage
  421. * @note A delay is required for the internal regulator to be ready
  422. * after the voltage scaling has been changed.
  423. * Check whether regulator reached the selected voltage level
  424. * can be done using function @ref LL_PWR_IsActiveFlag_VOS().
  425. * @rmtoll CR1 VOS LL_PWR_SetRegulVoltageScaling
  426. * @param VoltageScaling This parameter can be one of the following values:
  427. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  428. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  429. * @retval None
  430. */
  431. __STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling)
  432. {
  433. MODIFY_REG(PWR->CR1, PWR_CR1_VOS, VoltageScaling);
  434. }
  435. /**
  436. * @brief Get the main internal regulator output voltage
  437. * @rmtoll CR1 VOS LL_PWR_GetRegulVoltageScaling
  438. * @retval Returned value can be one of the following values:
  439. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  440. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  441. */
  442. __STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void)
  443. {
  444. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_VOS));
  445. }
  446. #endif
  447. /**
  448. * @brief Enable access to the backup domain
  449. * @rmtoll CR1 DBP LL_PWR_EnableBkUpAccess
  450. * @retval None
  451. */
  452. __STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
  453. {
  454. SET_BIT(PWR->CR1, PWR_CR1_DBP);
  455. }
  456. /**
  457. * @brief Disable access to the backup domain
  458. * @rmtoll CR1 DBP LL_PWR_DisableBkUpAccess
  459. * @retval None
  460. */
  461. __STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
  462. {
  463. CLEAR_BIT(PWR->CR1, PWR_CR1_DBP);
  464. }
  465. /**
  466. * @brief Check if the backup domain is enabled
  467. * @rmtoll CR1 DBP LL_PWR_IsEnabledBkUpAccess
  468. * @retval State of bit (1 or 0).
  469. */
  470. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
  471. {
  472. return ((READ_BIT(PWR->CR1, PWR_CR1_DBP) == (PWR_CR1_DBP)) ? 1UL : 0UL);
  473. }
  474. /**
  475. * @brief Set Low-Power mode
  476. * @rmtoll CR1 LPMS LL_PWR_SetPowerMode
  477. * @param LowPowerMode This parameter can be one of the following values:
  478. * @arg @ref LL_PWR_MODE_STOP0
  479. * @arg @ref LL_PWR_MODE_STOP1
  480. * @arg @ref LL_PWR_MODE_STOP2 (*)
  481. * @arg @ref LL_PWR_MODE_STANDBY
  482. * @arg @ref LL_PWR_MODE_SHUTDOWN
  483. *
  484. * (*) Not available on devices STM32WB15xx, STM32WB10xx
  485. * @retval None
  486. */
  487. __STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t LowPowerMode)
  488. {
  489. MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, LowPowerMode);
  490. }
  491. /**
  492. * @brief Get Low-Power mode
  493. * @rmtoll CR1 LPMS LL_PWR_GetPowerMode
  494. * @retval Returned value can be one of the following values:
  495. * @arg @ref LL_PWR_MODE_STOP0
  496. * @arg @ref LL_PWR_MODE_STOP1
  497. * @arg @ref LL_PWR_MODE_STOP2 (*)
  498. * @arg @ref LL_PWR_MODE_STANDBY
  499. * @arg @ref LL_PWR_MODE_SHUTDOWN
  500. *
  501. * (*) Not available on devices STM32WB15xx, STM32WB10xx
  502. */
  503. __STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void)
  504. {
  505. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_LPMS));
  506. }
  507. /**
  508. * @brief Set flash power-down mode during low-power run mode
  509. * @rmtoll CR1 FPDR LL_PWR_SetFlashPowerModeLPRun
  510. * @param FlashLowPowerMode This parameter can be one of the following values:
  511. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_IDLE
  512. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_POWER_DOWN
  513. * @retval None
  514. */
  515. __STATIC_INLINE void LL_PWR_SetFlashPowerModeLPRun(uint32_t FlashLowPowerMode)
  516. {
  517. /* Unlock bit FPDR */
  518. WRITE_REG(PWR->CR1, 0x0000C1B0UL);
  519. /* Update bit FPDR */
  520. MODIFY_REG(PWR->CR1, PWR_CR1_FPDR, FlashLowPowerMode);
  521. }
  522. /**
  523. * @brief Get flash power-down mode during low-power run mode
  524. * @rmtoll CR1 FPDR LL_PWR_GetFlashPowerModeLPRun
  525. * @retval Returned value can be one of the following values:
  526. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_IDLE
  527. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_POWER_DOWN
  528. */
  529. __STATIC_INLINE uint32_t LL_PWR_GetFlashPowerModeLPRun(void)
  530. {
  531. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_FPDR));
  532. }
  533. /**
  534. * @brief Set flash power-down mode during sleep mode
  535. * @rmtoll CR1 FPDS LL_PWR_SetFlashPowerModeSleep
  536. * @param FlashLowPowerMode This parameter can be one of the following values:
  537. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_IDLE
  538. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_POWER_DOWN
  539. * @retval None
  540. */
  541. __STATIC_INLINE void LL_PWR_SetFlashPowerModeSleep(uint32_t FlashLowPowerMode)
  542. {
  543. MODIFY_REG(PWR->CR1, PWR_CR1_FPDS, FlashLowPowerMode);
  544. }
  545. /**
  546. * @brief Get flash power-down mode during sleep mode
  547. * @rmtoll CR1 FPDS LL_PWR_GetFlashPowerModeSleep
  548. * @retval Returned value can be one of the following values:
  549. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_IDLE
  550. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_POWER_DOWN
  551. */
  552. __STATIC_INLINE uint32_t LL_PWR_GetFlashPowerModeSleep(void)
  553. {
  554. return (uint32_t)(READ_BIT(PWR->CR1, PWR_CR1_FPDS));
  555. }
  556. #if defined(PWR_CR2_PVME1)
  557. /**
  558. * @brief Enable VDDUSB supply
  559. * @rmtoll CR2 USV LL_PWR_EnableVddUSB
  560. * @retval None
  561. */
  562. __STATIC_INLINE void LL_PWR_EnableVddUSB(void)
  563. {
  564. SET_BIT(PWR->CR2, PWR_CR2_USV);
  565. }
  566. /**
  567. * @brief Disable VDDUSB supply
  568. * @rmtoll CR2 USV LL_PWR_DisableVddUSB
  569. * @retval None
  570. */
  571. __STATIC_INLINE void LL_PWR_DisableVddUSB(void)
  572. {
  573. CLEAR_BIT(PWR->CR2, PWR_CR2_USV);
  574. }
  575. /**
  576. * @brief Check if VDDUSB supply is enabled
  577. * @rmtoll CR2 USV LL_PWR_IsEnabledVddUSB
  578. * @retval State of bit (1 or 0).
  579. */
  580. __STATIC_INLINE uint32_t LL_PWR_IsEnabledVddUSB(void)
  581. {
  582. return ((READ_BIT(PWR->CR2, PWR_CR2_USV) == (PWR_CR2_USV)) ? 1UL : 0UL);
  583. }
  584. #endif
  585. /**
  586. * @brief Enable the Power Voltage Monitoring on a peripheral
  587. * @rmtoll CR2 PVME1 LL_PWR_EnablePVM\n
  588. * CR2 PVME3 LL_PWR_EnablePVM
  589. * @param PeriphVoltage This parameter can be one of the following values:
  590. * @arg @ref LL_PWR_PVM_VDDUSB_1_2V (*)
  591. * @arg @ref LL_PWR_PVM_VDDA_1_62V
  592. *
  593. * (*) Not available on devices STM32WB50xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  594. * @retval None
  595. */
  596. __STATIC_INLINE void LL_PWR_EnablePVM(uint32_t PeriphVoltage)
  597. {
  598. SET_BIT(PWR->CR2, PeriphVoltage);
  599. }
  600. /**
  601. * @brief Disable the Power Voltage Monitoring on a peripheral
  602. * @rmtoll CR2 PVME1 LL_PWR_DisablePVM\n
  603. * CR2 PVME3 LL_PWR_DisablePVM
  604. * @param PeriphVoltage This parameter can be one of the following values:
  605. * @arg @ref LL_PWR_PVM_VDDUSB_1_2V (*)
  606. * @arg @ref LL_PWR_PVM_VDDA_1_62V
  607. *
  608. * (*) Not available on devices STM32WB50xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  609. * @retval None
  610. */
  611. __STATIC_INLINE void LL_PWR_DisablePVM(uint32_t PeriphVoltage)
  612. {
  613. CLEAR_BIT(PWR->CR2, PeriphVoltage);
  614. }
  615. /**
  616. * @brief Check if Power Voltage Monitoring is enabled on a peripheral
  617. * @rmtoll CR2 PVME1 LL_PWR_IsEnabledPVM\n
  618. * CR2 PVME3 LL_PWR_IsEnabledPVM
  619. * @param PeriphVoltage This parameter can be one of the following values:
  620. * @arg @ref LL_PWR_PVM_VDDUSB_1_2V (*)
  621. * @arg @ref LL_PWR_PVM_VDDA_1_62V
  622. *
  623. * (*) Not available on devices STM32WB50xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  624. * @retval State of bit (1 or 0).
  625. */
  626. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVM(uint32_t PeriphVoltage)
  627. {
  628. return ((READ_BIT(PWR->CR2, PeriphVoltage) == (PeriphVoltage)) ? 1UL : 0UL);
  629. }
  630. /**
  631. * @brief Configure the voltage threshold detected by the Power Voltage Detector
  632. * @rmtoll CR2 PLS LL_PWR_SetPVDLevel
  633. * @param PVDLevel This parameter can be one of the following values:
  634. * @arg @ref LL_PWR_PVDLEVEL_0
  635. * @arg @ref LL_PWR_PVDLEVEL_1
  636. * @arg @ref LL_PWR_PVDLEVEL_2
  637. * @arg @ref LL_PWR_PVDLEVEL_3
  638. * @arg @ref LL_PWR_PVDLEVEL_4
  639. * @arg @ref LL_PWR_PVDLEVEL_5
  640. * @arg @ref LL_PWR_PVDLEVEL_6
  641. * @arg @ref LL_PWR_PVDLEVEL_7
  642. * @retval None
  643. */
  644. __STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
  645. {
  646. MODIFY_REG(PWR->CR2, PWR_CR2_PLS, PVDLevel);
  647. }
  648. /**
  649. * @brief Get the voltage threshold detection
  650. * @rmtoll CR2 PLS LL_PWR_GetPVDLevel
  651. * @retval Returned value can be one of the following values:
  652. * @arg @ref LL_PWR_PVDLEVEL_0
  653. * @arg @ref LL_PWR_PVDLEVEL_1
  654. * @arg @ref LL_PWR_PVDLEVEL_2
  655. * @arg @ref LL_PWR_PVDLEVEL_3
  656. * @arg @ref LL_PWR_PVDLEVEL_4
  657. * @arg @ref LL_PWR_PVDLEVEL_5
  658. * @arg @ref LL_PWR_PVDLEVEL_6
  659. * @arg @ref LL_PWR_PVDLEVEL_7
  660. */
  661. __STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
  662. {
  663. return (uint32_t)(READ_BIT(PWR->CR2, PWR_CR2_PLS));
  664. }
  665. /**
  666. * @brief Enable Power Voltage Detector
  667. * @rmtoll CR2 PVDE LL_PWR_EnablePVD
  668. * @retval None
  669. */
  670. __STATIC_INLINE void LL_PWR_EnablePVD(void)
  671. {
  672. SET_BIT(PWR->CR2, PWR_CR2_PVDE);
  673. }
  674. /**
  675. * @brief Disable Power Voltage Detector
  676. * @rmtoll CR2 PVDE LL_PWR_DisablePVD
  677. * @retval None
  678. */
  679. __STATIC_INLINE void LL_PWR_DisablePVD(void)
  680. {
  681. CLEAR_BIT(PWR->CR2, PWR_CR2_PVDE);
  682. }
  683. /**
  684. * @brief Check if Power Voltage Detector is enabled
  685. * @rmtoll CR2 PVDE LL_PWR_IsEnabledPVD
  686. * @retval State of bit (1 or 0).
  687. */
  688. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
  689. {
  690. return ((READ_BIT(PWR->CR2, PWR_CR2_PVDE) == (PWR_CR2_PVDE)) ? 1UL : 0UL);
  691. }
  692. /**
  693. * @brief Enable Internal Wake-up line
  694. * @rmtoll CR3 EIWF LL_PWR_EnableInternWU
  695. * @retval None
  696. */
  697. __STATIC_INLINE void LL_PWR_EnableInternWU(void)
  698. {
  699. SET_BIT(PWR->CR3, PWR_CR3_EIWUL);
  700. }
  701. /**
  702. * @brief Disable Internal Wake-up line
  703. * @rmtoll CR3 EIWF LL_PWR_DisableInternWU
  704. * @retval None
  705. */
  706. __STATIC_INLINE void LL_PWR_DisableInternWU(void)
  707. {
  708. CLEAR_BIT(PWR->CR3, PWR_CR3_EIWUL);
  709. }
  710. /**
  711. * @brief Check if Internal Wake-up line is enabled
  712. * @rmtoll CR3 EIWF LL_PWR_IsEnabledInternWU
  713. * @retval State of bit (1 or 0).
  714. */
  715. __STATIC_INLINE uint32_t LL_PWR_IsEnabledInternWU(void)
  716. {
  717. return ((READ_BIT(PWR->CR3, PWR_CR3_EIWUL) == (PWR_CR3_EIWUL)) ? 1UL : 0UL);
  718. }
  719. /**
  720. * @brief Enable pull-up and pull-down configuration
  721. * @rmtoll CR3 APC LL_PWR_EnablePUPDCfg
  722. * @retval None
  723. */
  724. __STATIC_INLINE void LL_PWR_EnablePUPDCfg(void)
  725. {
  726. SET_BIT(PWR->CR3, PWR_CR3_APC);
  727. }
  728. /**
  729. * @brief Disable pull-up and pull-down configuration
  730. * @rmtoll CR3 APC LL_PWR_DisablePUPDCfg
  731. * @retval None
  732. */
  733. __STATIC_INLINE void LL_PWR_DisablePUPDCfg(void)
  734. {
  735. CLEAR_BIT(PWR->CR3, PWR_CR3_APC);
  736. }
  737. /**
  738. * @brief Check if pull-up and pull-down configuration is enabled
  739. * @rmtoll CR3 APC LL_PWR_IsEnabledPUPDCfg
  740. * @retval State of bit (1 or 0).
  741. */
  742. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPUPDCfg(void)
  743. {
  744. return ((READ_BIT(PWR->CR3, PWR_CR3_APC) == (PWR_CR3_APC)) ? 1UL : 0UL);
  745. }
  746. /**
  747. * @brief Enable SRAM2a content retention in Standby mode
  748. * @note On devices STM32WB15xx, STM32WB10xx, retention is extended
  749. * to SRAM1, SRAM2a and SRAM2b.
  750. * @rmtoll CR3 RRS LL_PWR_EnableSRAM2Retention
  751. * @retval None
  752. */
  753. __STATIC_INLINE void LL_PWR_EnableSRAM2Retention(void)
  754. {
  755. SET_BIT(PWR->CR3, PWR_CR3_RRS);
  756. }
  757. /**
  758. * @brief Disable SRAM2a content retention in Standby mode
  759. * @note On devices STM32WB15xx, STM32WB10xx, retention is extended
  760. * to SRAM1, SRAM2a and SRAM2b.
  761. * @rmtoll CR3 RRS LL_PWR_DisableSRAM2Retention
  762. * @retval None
  763. */
  764. __STATIC_INLINE void LL_PWR_DisableSRAM2Retention(void)
  765. {
  766. CLEAR_BIT(PWR->CR3, PWR_CR3_RRS);
  767. }
  768. /**
  769. * @brief Check if SRAM2 content retention in Standby mode is enabled
  770. * @note On devices STM32WB15xx, STM32WB10xx, retention is extended
  771. * to SRAM1, SRAM2a and SRAM2b.
  772. * @rmtoll CR3 RRS LL_PWR_IsEnabledSRAM2Retention
  773. * @retval State of bit (1 or 0).
  774. */
  775. __STATIC_INLINE uint32_t LL_PWR_IsEnabledSRAM2Retention(void)
  776. {
  777. return ((READ_BIT(PWR->CR3, PWR_CR3_RRS) == (PWR_CR3_RRS)) ? 1UL : 0UL);
  778. }
  779. /**
  780. * @brief Enable the WakeUp PINx functionality
  781. * @rmtoll CR3 EWUP1 LL_PWR_EnableWakeUpPin\n
  782. * CR3 EWUP2 LL_PWR_EnableWakeUpPin\n
  783. * CR3 EWUP3 LL_PWR_EnableWakeUpPin\n
  784. * CR3 EWUP4 LL_PWR_EnableWakeUpPin\n
  785. * CR3 EWUP5 LL_PWR_EnableWakeUpPin\n
  786. * @param WakeUpPin This parameter can be one of the following values:
  787. * @arg @ref LL_PWR_WAKEUP_PIN1
  788. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  789. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  790. * @arg @ref LL_PWR_WAKEUP_PIN4
  791. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  792. *
  793. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  794. * @retval None
  795. */
  796. __STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
  797. {
  798. SET_BIT(PWR->CR3, WakeUpPin);
  799. }
  800. /**
  801. * @brief Disable the WakeUp PINx functionality
  802. * @rmtoll CR3 EWUP1 LL_PWR_DisableWakeUpPin\n
  803. * CR3 EWUP2 LL_PWR_DisableWakeUpPin\n
  804. * CR3 EWUP3 LL_PWR_DisableWakeUpPin\n
  805. * CR3 EWUP4 LL_PWR_DisableWakeUpPin\n
  806. * CR3 EWUP5 LL_PWR_DisableWakeUpPin\n
  807. * @param WakeUpPin This parameter can be one of the following values:
  808. * @arg @ref LL_PWR_WAKEUP_PIN1
  809. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  810. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  811. * @arg @ref LL_PWR_WAKEUP_PIN4
  812. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  813. *
  814. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  815. * @retval None
  816. */
  817. __STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
  818. {
  819. CLEAR_BIT(PWR->CR3, WakeUpPin);
  820. }
  821. /**
  822. * @brief Check if the WakeUp PINx functionality is enabled
  823. * @rmtoll CR3 EWUP1 LL_PWR_IsEnabledWakeUpPin\n
  824. * CR3 EWUP2 LL_PWR_IsEnabledWakeUpPin\n
  825. * CR3 EWUP3 LL_PWR_IsEnabledWakeUpPin\n
  826. * CR3 EWUP4 LL_PWR_IsEnabledWakeUpPin\n
  827. * CR3 EWUP5 LL_PWR_IsEnabledWakeUpPin\n
  828. * @param WakeUpPin This parameter can be one of the following values:
  829. * @arg @ref LL_PWR_WAKEUP_PIN1
  830. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  831. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  832. * @arg @ref LL_PWR_WAKEUP_PIN4
  833. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  834. *
  835. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  836. * @retval State of bit (1 or 0).
  837. */
  838. __STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
  839. {
  840. return ((READ_BIT(PWR->CR3, WakeUpPin) == (WakeUpPin)) ? 1UL : 0UL);
  841. }
  842. /**
  843. * @brief Set the resistor impedance
  844. * @rmtoll CR4 VBRS LL_PWR_SetBattChargResistor
  845. * @param Resistor This parameter can be one of the following values:
  846. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_5K
  847. * @arg @ref LL_PWR_BATT_CHARGRESISTOR_1_5K
  848. * @retval None
  849. */
  850. __STATIC_INLINE void LL_PWR_SetBattChargResistor(uint32_t Resistor)
  851. {
  852. MODIFY_REG(PWR->CR4, PWR_CR4_VBRS, Resistor);
  853. }
  854. /**
  855. * @brief Get the resistor impedance
  856. * @rmtoll CR4 VBRS LL_PWR_GetBattChargResistor
  857. * @retval Returned value can be one of the following values:
  858. * @arg @ref LL_PWR_BATT_CHARG_RESISTOR_5K
  859. * @arg @ref LL_PWR_BATT_CHARGRESISTOR_1_5K
  860. */
  861. __STATIC_INLINE uint32_t LL_PWR_GetBattChargResistor(void)
  862. {
  863. return (uint32_t)(READ_BIT(PWR->CR4, PWR_CR4_VBRS));
  864. }
  865. /**
  866. * @brief Enable battery charging
  867. * @rmtoll CR4 VBE LL_PWR_EnableBatteryCharging
  868. * @retval None
  869. */
  870. __STATIC_INLINE void LL_PWR_EnableBatteryCharging(void)
  871. {
  872. SET_BIT(PWR->CR4, PWR_CR4_VBE);
  873. }
  874. /**
  875. * @brief Disable battery charging
  876. * @rmtoll CR4 VBE LL_PWR_DisableBatteryCharging
  877. * @retval None
  878. */
  879. __STATIC_INLINE void LL_PWR_DisableBatteryCharging(void)
  880. {
  881. CLEAR_BIT(PWR->CR4, PWR_CR4_VBE);
  882. }
  883. /**
  884. * @brief Check if battery charging is enabled
  885. * @rmtoll CR4 VBE LL_PWR_IsEnabledBatteryCharging
  886. * @retval State of bit (1 or 0).
  887. */
  888. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBatteryCharging(void)
  889. {
  890. return ((READ_BIT(PWR->CR4, PWR_CR4_VBE) == (PWR_CR4_VBE)) ? 1UL : 0UL);
  891. }
  892. /**
  893. * @brief Set the Wake-Up pin polarity low for the event detection
  894. * @rmtoll CR4 WP1 LL_PWR_SetWakeUpPinPolarityLow\n
  895. * CR4 WP2 LL_PWR_SetWakeUpPinPolarityLow\n
  896. * CR4 WP3 LL_PWR_SetWakeUpPinPolarityLow\n
  897. * CR4 WP4 LL_PWR_SetWakeUpPinPolarityLow\n
  898. * CR4 WP5 LL_PWR_SetWakeUpPinPolarityLow
  899. * @param WakeUpPin This parameter can be one of the following values:
  900. * @arg @ref LL_PWR_WAKEUP_PIN1
  901. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  902. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  903. * @arg @ref LL_PWR_WAKEUP_PIN4
  904. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  905. *
  906. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  907. * @retval None
  908. */
  909. __STATIC_INLINE void LL_PWR_SetWakeUpPinPolarityLow(uint32_t WakeUpPin)
  910. {
  911. SET_BIT(PWR->CR4, WakeUpPin);
  912. }
  913. /**
  914. * @brief Set the Wake-Up pin polarity high for the event detection
  915. * @rmtoll CR4 WP1 LL_PWR_SetWakeUpPinPolarityHigh\n
  916. * CR4 WP2 LL_PWR_SetWakeUpPinPolarityHigh\n
  917. * CR4 WP3 LL_PWR_SetWakeUpPinPolarityHigh\n
  918. * CR4 WP4 LL_PWR_SetWakeUpPinPolarityHigh\n
  919. * CR4 WP5 LL_PWR_SetWakeUpPinPolarityHigh
  920. * @param WakeUpPin This parameter can be one of the following values:
  921. * @arg @ref LL_PWR_WAKEUP_PIN1
  922. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  923. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  924. * @arg @ref LL_PWR_WAKEUP_PIN4
  925. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  926. *
  927. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  928. * @retval None
  929. */
  930. __STATIC_INLINE void LL_PWR_SetWakeUpPinPolarityHigh(uint32_t WakeUpPin)
  931. {
  932. CLEAR_BIT(PWR->CR4, WakeUpPin);
  933. }
  934. /**
  935. * @brief Get the Wake-Up pin polarity for the event detection
  936. * @rmtoll CR4 WP1 LL_PWR_IsWakeUpPinPolarityLow\n
  937. * CR4 WP2 LL_PWR_IsWakeUpPinPolarityLow\n
  938. * CR4 WP3 LL_PWR_IsWakeUpPinPolarityLow\n
  939. * CR4 WP4 LL_PWR_IsWakeUpPinPolarityLow\n
  940. * CR4 WP5 LL_PWR_IsWakeUpPinPolarityLow
  941. * @param WakeUpPin This parameter can be one of the following values:
  942. * @arg @ref LL_PWR_WAKEUP_PIN1
  943. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  944. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  945. * @arg @ref LL_PWR_WAKEUP_PIN4
  946. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  947. *
  948. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  949. * @retval State of bit (1 or 0).
  950. */
  951. __STATIC_INLINE uint32_t LL_PWR_IsWakeUpPinPolarityLow(uint32_t WakeUpPin)
  952. {
  953. return ((READ_BIT(PWR->CR4, WakeUpPin) == (WakeUpPin)) ? 1UL : 0UL);
  954. }
  955. /**
  956. * @brief Enable GPIO pull-up state in Standby and Shutdown modes
  957. * @note Some pins are not configurable for pulling in Standby and Shutdown
  958. * modes. Refer to reference manual for available pins and ports.
  959. * @rmtoll PUCRA PU0-15 LL_PWR_EnableGPIOPullUp\n
  960. * PUCRB PU0-15 LL_PWR_EnableGPIOPullUp\n
  961. * PUCRC PU0-15 LL_PWR_EnableGPIOPullUp\n
  962. * PUCRD PU0-15 LL_PWR_EnableGPIOPullUp\n
  963. * PUCRE PU0-15 LL_PWR_EnableGPIOPullUp\n
  964. * PUCRH PU0-15 LL_PWR_EnableGPIOPullUp
  965. * @param GPIO This parameter can be one of the following values:
  966. * @arg @ref LL_PWR_GPIO_A
  967. * @arg @ref LL_PWR_GPIO_B
  968. * @arg @ref LL_PWR_GPIO_C
  969. * @arg @ref LL_PWR_GPIO_D
  970. * @arg @ref LL_PWR_GPIO_E
  971. * @arg @ref LL_PWR_GPIO_H
  972. * @param GPIONumber This parameter can be one of the following values:
  973. * @arg @ref LL_PWR_GPIO_BIT_0
  974. * @arg @ref LL_PWR_GPIO_BIT_1
  975. * @arg @ref LL_PWR_GPIO_BIT_2
  976. * @arg @ref LL_PWR_GPIO_BIT_3
  977. * @arg @ref LL_PWR_GPIO_BIT_4
  978. * @arg @ref LL_PWR_GPIO_BIT_5
  979. * @arg @ref LL_PWR_GPIO_BIT_6
  980. * @arg @ref LL_PWR_GPIO_BIT_7
  981. * @arg @ref LL_PWR_GPIO_BIT_8
  982. * @arg @ref LL_PWR_GPIO_BIT_9
  983. * @arg @ref LL_PWR_GPIO_BIT_10
  984. * @arg @ref LL_PWR_GPIO_BIT_11
  985. * @arg @ref LL_PWR_GPIO_BIT_12
  986. * @arg @ref LL_PWR_GPIO_BIT_13
  987. * @arg @ref LL_PWR_GPIO_BIT_14
  988. * @arg @ref LL_PWR_GPIO_BIT_15
  989. * @retval None
  990. */
  991. __STATIC_INLINE void LL_PWR_EnableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  992. {
  993. SET_BIT(*((__IO uint32_t *)GPIO), GPIONumber);
  994. }
  995. /**
  996. * @brief Disable GPIO pull-up state in Standby and Shutdown modes
  997. * @note Some pins are not configurable for pulling in Standby and Shutdown
  998. * modes. Refer to reference manual for available pins and ports.
  999. * @rmtoll PUCRA PU0-15 LL_PWR_DisableGPIOPullUp\n
  1000. * PUCRB PU0-15 LL_PWR_DisableGPIOPullUp\n
  1001. * PUCRC PU0-15 LL_PWR_DisableGPIOPullUp\n
  1002. * PUCRD PU0-15 LL_PWR_DisableGPIOPullUp\n
  1003. * PUCRE PU0-15 LL_PWR_DisableGPIOPullUp\n
  1004. * PUCRH PU0-15 LL_PWR_DisableGPIOPullUp
  1005. * @param GPIO This parameter can be one of the following values:
  1006. * @arg @ref LL_PWR_GPIO_A
  1007. * @arg @ref LL_PWR_GPIO_B
  1008. * @arg @ref LL_PWR_GPIO_C
  1009. * @arg @ref LL_PWR_GPIO_D
  1010. * @arg @ref LL_PWR_GPIO_E
  1011. * @arg @ref LL_PWR_GPIO_H
  1012. * @param GPIONumber This parameter can be one of the following values:
  1013. * @arg @ref LL_PWR_GPIO_BIT_0
  1014. * @arg @ref LL_PWR_GPIO_BIT_1
  1015. * @arg @ref LL_PWR_GPIO_BIT_2
  1016. * @arg @ref LL_PWR_GPIO_BIT_3
  1017. * @arg @ref LL_PWR_GPIO_BIT_4
  1018. * @arg @ref LL_PWR_GPIO_BIT_5
  1019. * @arg @ref LL_PWR_GPIO_BIT_6
  1020. * @arg @ref LL_PWR_GPIO_BIT_7
  1021. * @arg @ref LL_PWR_GPIO_BIT_8
  1022. * @arg @ref LL_PWR_GPIO_BIT_9
  1023. * @arg @ref LL_PWR_GPIO_BIT_10
  1024. * @arg @ref LL_PWR_GPIO_BIT_11
  1025. * @arg @ref LL_PWR_GPIO_BIT_12
  1026. * @arg @ref LL_PWR_GPIO_BIT_13
  1027. * @arg @ref LL_PWR_GPIO_BIT_14
  1028. * @arg @ref LL_PWR_GPIO_BIT_15
  1029. * @retval None
  1030. */
  1031. __STATIC_INLINE void LL_PWR_DisableGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  1032. {
  1033. CLEAR_BIT(*((__IO uint32_t *)GPIO), GPIONumber);
  1034. }
  1035. /**
  1036. * @brief Check if GPIO pull-up state is enabled
  1037. * @rmtoll PUCRA PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1038. * PUCRB PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1039. * PUCRC PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1040. * PUCRD PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1041. * PUCRE PU0-15 LL_PWR_IsEnabledGPIOPullUp\n
  1042. * PUCRH PU0-15 LL_PWR_IsEnabledGPIOPullUp
  1043. * @param GPIO This parameter can be one of the following values:
  1044. * @arg @ref LL_PWR_GPIO_A
  1045. * @arg @ref LL_PWR_GPIO_B
  1046. * @arg @ref LL_PWR_GPIO_C
  1047. * @arg @ref LL_PWR_GPIO_D
  1048. * @arg @ref LL_PWR_GPIO_E
  1049. * @arg @ref LL_PWR_GPIO_H
  1050. * @param GPIONumber This parameter can be one of the following values:
  1051. * @arg @ref LL_PWR_GPIO_BIT_0
  1052. * @arg @ref LL_PWR_GPIO_BIT_1
  1053. * @arg @ref LL_PWR_GPIO_BIT_2
  1054. * @arg @ref LL_PWR_GPIO_BIT_3
  1055. * @arg @ref LL_PWR_GPIO_BIT_4
  1056. * @arg @ref LL_PWR_GPIO_BIT_5
  1057. * @arg @ref LL_PWR_GPIO_BIT_6
  1058. * @arg @ref LL_PWR_GPIO_BIT_7
  1059. * @arg @ref LL_PWR_GPIO_BIT_8
  1060. * @arg @ref LL_PWR_GPIO_BIT_9
  1061. * @arg @ref LL_PWR_GPIO_BIT_10
  1062. * @arg @ref LL_PWR_GPIO_BIT_11
  1063. * @arg @ref LL_PWR_GPIO_BIT_12
  1064. * @arg @ref LL_PWR_GPIO_BIT_13
  1065. * @arg @ref LL_PWR_GPIO_BIT_14
  1066. * @arg @ref LL_PWR_GPIO_BIT_15
  1067. * @retval State of bit (1 or 0).
  1068. */
  1069. __STATIC_INLINE uint32_t LL_PWR_IsEnabledGPIOPullUp(uint32_t GPIO, uint32_t GPIONumber)
  1070. {
  1071. return ((READ_BIT(*((__IO uint32_t *)GPIO), GPIONumber) == (GPIONumber)) ? 1UL : 0UL);
  1072. }
  1073. /**
  1074. * @brief Enable GPIO pull-down state in Standby and Shutdown modes
  1075. * @note Some pins are not configurable for pulling in Standby and Shutdown
  1076. * modes. Refer to reference manual for available pins and ports.
  1077. * @rmtoll PDCRA PD0-15 LL_PWR_EnableGPIOPullDown\n
  1078. * PDCRB PD0-15 LL_PWR_EnableGPIOPullDown\n
  1079. * PDCRC PD0-15 LL_PWR_EnableGPIOPullDown\n
  1080. * PDCRD PD0-15 LL_PWR_EnableGPIOPullDown\n
  1081. * PDCRE PD0-15 LL_PWR_EnableGPIOPullDown\n
  1082. * PDCRH PD0-15 LL_PWR_EnableGPIOPullDown
  1083. * @param GPIO This parameter can be one of the following values:
  1084. * @arg @ref LL_PWR_GPIO_A
  1085. * @arg @ref LL_PWR_GPIO_B
  1086. * @arg @ref LL_PWR_GPIO_C
  1087. * @arg @ref LL_PWR_GPIO_D
  1088. * @arg @ref LL_PWR_GPIO_E
  1089. * @arg @ref LL_PWR_GPIO_H
  1090. * @param GPIONumber This parameter can be one of the following values:
  1091. * @arg @ref LL_PWR_GPIO_BIT_0
  1092. * @arg @ref LL_PWR_GPIO_BIT_1
  1093. * @arg @ref LL_PWR_GPIO_BIT_2
  1094. * @arg @ref LL_PWR_GPIO_BIT_3
  1095. * @arg @ref LL_PWR_GPIO_BIT_4
  1096. * @arg @ref LL_PWR_GPIO_BIT_5
  1097. * @arg @ref LL_PWR_GPIO_BIT_6
  1098. * @arg @ref LL_PWR_GPIO_BIT_7
  1099. * @arg @ref LL_PWR_GPIO_BIT_8
  1100. * @arg @ref LL_PWR_GPIO_BIT_9
  1101. * @arg @ref LL_PWR_GPIO_BIT_10
  1102. * @arg @ref LL_PWR_GPIO_BIT_11
  1103. * @arg @ref LL_PWR_GPIO_BIT_12
  1104. * @arg @ref LL_PWR_GPIO_BIT_13
  1105. * @arg @ref LL_PWR_GPIO_BIT_14
  1106. * @arg @ref LL_PWR_GPIO_BIT_15
  1107. * @retval None
  1108. */
  1109. __STATIC_INLINE void LL_PWR_EnableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  1110. {
  1111. SET_BIT(*((__IO uint32_t *)(GPIO + 4UL)), GPIONumber);
  1112. }
  1113. /**
  1114. * @brief Disable GPIO pull-down state in Standby and Shutdown modes
  1115. * @note Some pins are not configurable for pulling in Standby and Shutdown
  1116. * modes. Refer to reference manual for available pins and ports.
  1117. * @rmtoll PDCRA PD0-15 LL_PWR_DisableGPIOPullDown\n
  1118. * PDCRB PD0-15 LL_PWR_DisableGPIOPullDown\n
  1119. * PDCRC PD0-15 LL_PWR_DisableGPIOPullDown\n
  1120. * PDCRD PD0-15 LL_PWR_DisableGPIOPullDown\n
  1121. * PDCRE PD0-15 LL_PWR_DisableGPIOPullDown\n
  1122. * PDCRH PD0-15 LL_PWR_DisableGPIOPullDown
  1123. * @param GPIO This parameter can be one of the following values:
  1124. * @arg @ref LL_PWR_GPIO_A
  1125. * @arg @ref LL_PWR_GPIO_B
  1126. * @arg @ref LL_PWR_GPIO_C
  1127. * @arg @ref LL_PWR_GPIO_D
  1128. * @arg @ref LL_PWR_GPIO_E
  1129. * @arg @ref LL_PWR_GPIO_H
  1130. * @param GPIONumber This parameter can be one of the following values:
  1131. * @arg @ref LL_PWR_GPIO_BIT_0
  1132. * @arg @ref LL_PWR_GPIO_BIT_1
  1133. * @arg @ref LL_PWR_GPIO_BIT_2
  1134. * @arg @ref LL_PWR_GPIO_BIT_3
  1135. * @arg @ref LL_PWR_GPIO_BIT_4
  1136. * @arg @ref LL_PWR_GPIO_BIT_5
  1137. * @arg @ref LL_PWR_GPIO_BIT_6
  1138. * @arg @ref LL_PWR_GPIO_BIT_7
  1139. * @arg @ref LL_PWR_GPIO_BIT_8
  1140. * @arg @ref LL_PWR_GPIO_BIT_9
  1141. * @arg @ref LL_PWR_GPIO_BIT_10
  1142. * @arg @ref LL_PWR_GPIO_BIT_11
  1143. * @arg @ref LL_PWR_GPIO_BIT_12
  1144. * @arg @ref LL_PWR_GPIO_BIT_13
  1145. * @arg @ref LL_PWR_GPIO_BIT_14
  1146. * @arg @ref LL_PWR_GPIO_BIT_15
  1147. * @retval None
  1148. */
  1149. __STATIC_INLINE void LL_PWR_DisableGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  1150. {
  1151. CLEAR_BIT(*((__IO uint32_t *)(GPIO + 4UL)), GPIONumber);
  1152. }
  1153. /**
  1154. * @brief Check if GPIO pull-down state is enabled
  1155. * @rmtoll PDCRA PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1156. * PDCRB PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1157. * PDCRC PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1158. * PDCRD PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1159. * PDCRE PD0-15 LL_PWR_IsEnabledGPIOPullDown\n
  1160. * PDCRH PD0-15 LL_PWR_IsEnabledGPIOPullDown
  1161. * @param GPIO This parameter can be one of the following values:
  1162. * @arg @ref LL_PWR_GPIO_A
  1163. * @arg @ref LL_PWR_GPIO_B
  1164. * @arg @ref LL_PWR_GPIO_C
  1165. * @arg @ref LL_PWR_GPIO_D
  1166. * @arg @ref LL_PWR_GPIO_E
  1167. * @arg @ref LL_PWR_GPIO_H
  1168. * @param GPIONumber This parameter can be one of the following values:
  1169. * @arg @ref LL_PWR_GPIO_BIT_0
  1170. * @arg @ref LL_PWR_GPIO_BIT_1
  1171. * @arg @ref LL_PWR_GPIO_BIT_2
  1172. * @arg @ref LL_PWR_GPIO_BIT_3
  1173. * @arg @ref LL_PWR_GPIO_BIT_4
  1174. * @arg @ref LL_PWR_GPIO_BIT_5
  1175. * @arg @ref LL_PWR_GPIO_BIT_6
  1176. * @arg @ref LL_PWR_GPIO_BIT_7
  1177. * @arg @ref LL_PWR_GPIO_BIT_8
  1178. * @arg @ref LL_PWR_GPIO_BIT_9
  1179. * @arg @ref LL_PWR_GPIO_BIT_10
  1180. * @arg @ref LL_PWR_GPIO_BIT_11
  1181. * @arg @ref LL_PWR_GPIO_BIT_12
  1182. * @arg @ref LL_PWR_GPIO_BIT_13
  1183. * @arg @ref LL_PWR_GPIO_BIT_14
  1184. * @arg @ref LL_PWR_GPIO_BIT_15
  1185. * @retval State of bit (1 or 0).
  1186. */
  1187. __STATIC_INLINE uint32_t LL_PWR_IsEnabledGPIOPullDown(uint32_t GPIO, uint32_t GPIONumber)
  1188. {
  1189. return ((READ_BIT(*((__IO uint32_t *)(GPIO + 4UL)), GPIONumber) == (GPIONumber)) ? 1UL : 0UL);
  1190. }
  1191. #if defined(PWR_CR5_SMPSEN)
  1192. /**
  1193. * @brief Set BOR configuration
  1194. * @rmtoll CR5 BORHC LL_PWR_SetBORConfig
  1195. * @param BORConfiguration This parameter can be one of the following values:
  1196. * @arg @ref LL_PWR_BOR_SYSTEM_RESET
  1197. * @arg @ref LL_PWR_BOR_SMPS_FORCE_BYPASS
  1198. */
  1199. __STATIC_INLINE void LL_PWR_SetBORConfig(uint32_t BORConfiguration)
  1200. {
  1201. MODIFY_REG(PWR->CR5, PWR_CR5_BORHC, BORConfiguration);
  1202. }
  1203. /**
  1204. * @brief Get BOR configuration
  1205. * @rmtoll CR5 BORHC LL_PWR_GetBORConfig
  1206. * @retval Returned value can be one of the following values:
  1207. * @arg @ref LL_PWR_BOR_SYSTEM_RESET
  1208. * @arg @ref LL_PWR_BOR_SMPS_FORCE_BYPASS
  1209. */
  1210. __STATIC_INLINE uint32_t LL_PWR_GetBORConfig(void)
  1211. {
  1212. return (uint32_t)(READ_BIT(PWR->CR5, PWR_CR5_BORHC));
  1213. }
  1214. #endif
  1215. /**
  1216. * @}
  1217. */
  1218. #if defined(PWR_CR5_SMPSEN)
  1219. /** @defgroup PWR_LL_EF_Configuration_SMPS Configuration of SMPS
  1220. * @{
  1221. */
  1222. /**
  1223. * @brief Set SMPS operating mode
  1224. * @note When SMPS step down converter SMPS mode is enabled,
  1225. * it is good practice to enable the BORH to monitor the supply:
  1226. * in this case, when the supply drops below the SMPS step down
  1227. * converter SMPS mode operating supply level,
  1228. * switching on the fly is performed automaticcaly
  1229. * and interruption is generated.
  1230. * Refer to function @ref LL_PWR_SetBORConfig().
  1231. * @note Occurence of SMPS step down converter forced in bypass mode
  1232. * can be monitored by flag and interruption.
  1233. * Refer to functions
  1234. * @ref LL_PWR_IsActiveFlag_SMPSFB(), @ref LL_PWR_ClearFlag_SMPSFB(),
  1235. * @ref LL_PWR_EnableIT_BORH_SMPSFB().
  1236. * @rmtoll CR5 SMPSEN LL_PWR_SMPS_SetMode \n
  1237. * CR5 SMPSBEN LL_PWR_SMPS_SetMode
  1238. * @param OperatingMode This parameter can be one of the following values:
  1239. * @arg @ref LL_PWR_SMPS_BYPASS
  1240. * @arg @ref LL_PWR_SMPS_STEP_DOWN (1)
  1241. *
  1242. * (1) SMPS operating mode step down or open depends on system low-power mode:
  1243. * - step down mode if system low power mode is run, LP run or stop0,
  1244. * - open mode if system low power mode is Stop1, Stop2, Standby or Shutdown
  1245. * @retval None
  1246. */
  1247. __STATIC_INLINE void LL_PWR_SMPS_SetMode(uint32_t OperatingMode)
  1248. {
  1249. /* Note: Operation on bits performed to keep compatibility of literals */
  1250. /* for all SMPS operating mode functions: */
  1251. /* "LL_PWR_SMPS_SetMode()", "LL_PWR_SMPS_GetMode()" */
  1252. /* and "LL_PWR_SMPS_GetEffectiveMode()". */
  1253. MODIFY_REG(PWR->CR5, PWR_CR5_SMPSEN, (OperatingMode & PWR_SR2_SMPSF) << (PWR_CR5_SMPSEN_Pos - PWR_SR2_SMPSF_Pos));
  1254. }
  1255. /**
  1256. * @brief Get SMPS operating mode
  1257. * @rmtoll CR5 SMPSEN LL_PWR_SMPS_GetMode \n
  1258. * CR5 SMPSBEN LL_PWR_SMPS_GetMode
  1259. * @retval Returned value can be one of the following values:
  1260. * @arg @ref LL_PWR_SMPS_BYPASS
  1261. * @arg @ref LL_PWR_SMPS_STEP_DOWN (1)
  1262. *
  1263. * (1) SMPS operating mode step down or open depends on system low-power mode:
  1264. * - step down mode if system low power mode is run, LP run or stop0,
  1265. * - open mode if system low power mode is Stop1, Stop2, Standby or Shutdown
  1266. */
  1267. __STATIC_INLINE uint32_t LL_PWR_SMPS_GetMode(void)
  1268. {
  1269. /* Note: Operation on bits performed to keep compatibility of literals */
  1270. /* for all SMPS operating mode functions: */
  1271. /* "LL_PWR_SMPS_SetMode()", "LL_PWR_SMPS_GetMode()" */
  1272. /* and "LL_PWR_SMPS_GetEffectiveMode()". */
  1273. uint32_t OperatingMode = (READ_BIT(PWR->CR5, PWR_CR5_SMPSEN) >> (PWR_CR5_SMPSEN_Pos - PWR_SR2_SMPSF_Pos));
  1274. OperatingMode = (OperatingMode | ((~OperatingMode >> 1U) & PWR_SR2_SMPSBF));
  1275. return OperatingMode;
  1276. }
  1277. /**
  1278. * @brief Get SMPS effective operating mode
  1279. * @note SMPS operating mode can be changed by hardware, therefore
  1280. * requested operating mode can differ from effective low power mode.
  1281. * - dependency on system low-power mode:
  1282. * - step down mode if system low power mode is run, LP run or stop0,
  1283. * - open mode if system low power mode is Stop1, Stop2, Standby or Shutdown
  1284. * - dependency on BOR level:
  1285. * - bypass mode if supply voltage drops below BOR level
  1286. * @note This functions check flags of SMPS operating modes step down
  1287. * and bypass. If the SMPS is not among these 2 operating modes,
  1288. * then it can be in mode off or open.
  1289. * @rmtoll SR2 SMPSF LL_PWR_SMPS_GetEffectiveMode \n
  1290. * SR2 SMPSBF LL_PWR_SMPS_GetEffectiveMode
  1291. * @retval Returned value can be one of the following values:
  1292. * @arg @ref LL_PWR_SMPS_BYPASS
  1293. * @arg @ref LL_PWR_SMPS_STEP_DOWN (1)
  1294. *
  1295. * (1) SMPS operating mode step down or open depends on system low-power mode:
  1296. * - step down mode if system low power mode is run, LP run or stop0,
  1297. * - open mode if system low power mode is Stop1, Stop2, Standby or Shutdown
  1298. */
  1299. __STATIC_INLINE uint32_t LL_PWR_SMPS_GetEffectiveMode(void)
  1300. {
  1301. return (uint32_t)(READ_BIT(PWR->SR2, (PWR_SR2_SMPSF | PWR_SR2_SMPSBF)));
  1302. }
  1303. /**
  1304. * @brief SMPS step down converter enable
  1305. * @note This function can be used for specific usage of the SMPS,
  1306. * for general usage of the SMPS the function
  1307. * @ref LL_PWR_SMPS_SetMode() should be used instead.
  1308. * @rmtoll CR5 SMPSEN LL_PWR_SMPS_Enable
  1309. * @retval None
  1310. */
  1311. __STATIC_INLINE void LL_PWR_SMPS_Enable(void)
  1312. {
  1313. SET_BIT(PWR->CR5, PWR_CR5_SMPSEN);
  1314. }
  1315. /**
  1316. * @brief SMPS step down converter enable
  1317. * @note This function can be used for specific usage of the SMPS,
  1318. * for general usage of the SMPS the function
  1319. * @ref LL_PWR_SMPS_SetMode() should be used instead.
  1320. * @rmtoll CR5 SMPSEN LL_PWR_SMPS_Disable
  1321. * @retval None
  1322. */
  1323. __STATIC_INLINE void LL_PWR_SMPS_Disable(void)
  1324. {
  1325. CLEAR_BIT(PWR->CR5, PWR_CR5_SMPSEN);
  1326. }
  1327. /**
  1328. * @brief Check if the SMPS step down converter is enabled
  1329. * @rmtoll CR5 SMPSEN LL_PWR_SMPS_IsEnabled
  1330. * @retval State of bit (1 or 0).
  1331. */
  1332. __STATIC_INLINE uint32_t LL_PWR_SMPS_IsEnabled(void)
  1333. {
  1334. return ((READ_BIT(PWR->CR5, PWR_CR5_SMPSEN) == (PWR_CR5_SMPSEN)) ? 1UL : 0UL);
  1335. }
  1336. /**
  1337. * @brief Set SMPS step down converter supply startup current selection
  1338. * @rmtoll CR5 SMPSSC LL_PWR_SMPS_SetStartupCurrent
  1339. * @param StartupCurrent This parameter can be one of the following values:
  1340. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_80MA
  1341. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_100MA
  1342. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_120MA
  1343. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_140MA
  1344. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_160MA
  1345. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_180MA
  1346. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_200MA
  1347. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_220MA
  1348. * @retval None
  1349. */
  1350. __STATIC_INLINE void LL_PWR_SMPS_SetStartupCurrent(uint32_t StartupCurrent)
  1351. {
  1352. MODIFY_REG(PWR->CR5, PWR_CR5_SMPSSC, StartupCurrent);
  1353. }
  1354. /**
  1355. * @brief Get SMPS step down converter supply startup current selection
  1356. * @rmtoll CR5 SMPSSC LL_PWR_SMPS_GetStartupCurrent
  1357. * @retval Returned value can be one of the following values:
  1358. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_80MA
  1359. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_100MA
  1360. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_120MA
  1361. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_140MA
  1362. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_160MA
  1363. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_180MA
  1364. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_200MA
  1365. * @arg @ref LL_PWR_SMPS_STARTUP_CURRENT_220MA
  1366. */
  1367. __STATIC_INLINE uint32_t LL_PWR_SMPS_GetStartupCurrent(void)
  1368. {
  1369. return (uint32_t)(READ_BIT(PWR->CR5, PWR_CR5_SMPSSC));
  1370. }
  1371. /**
  1372. * @brief Set SMPS step down converter output voltage scaling
  1373. * @note SMPS output voltage is calibrated in production,
  1374. * calibration parameters are applied to the voltage level parameter
  1375. * to reach the requested voltage value.
  1376. * @rmtoll CR5 SMPSVOS LL_PWR_SMPS_SetOutputVoltageLevel
  1377. * @param OutputVoltageLevel This parameter can be one of the following values:
  1378. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V20
  1379. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V25
  1380. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V30
  1381. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V35
  1382. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V40
  1383. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V45
  1384. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V50
  1385. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V55
  1386. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V60
  1387. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V65
  1388. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V70
  1389. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V75
  1390. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V80
  1391. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V85
  1392. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V90
  1393. * @retval None
  1394. */
  1395. __STATIC_INLINE void LL_PWR_SMPS_SetOutputVoltageLevel(uint32_t OutputVoltageLevel)
  1396. {
  1397. __IO const uint32_t OutputVoltageLevel_calibration = (((*SMPS_VOLTAGE_CAL_ADDR) & SMPS_VOLTAGE_CAL) >> SMPS_VOLTAGE_CAL_POS); /* SMPS output voltage level calibrated in production */
  1398. int32_t TrimmingSteps; /* Trimming steps between theorical output voltage and calibrated output voltage */
  1399. int32_t OutputVoltageLevelTrimmed; /* SMPS output voltage level after calibration: trimming value added to required level */
  1400. if(OutputVoltageLevel_calibration == 0UL)
  1401. {
  1402. /* Device with SMPS output voltage not calibrated in production: Apply output voltage value directly */
  1403. /* Update register */
  1404. MODIFY_REG(PWR->CR5, PWR_CR5_SMPSVOS, OutputVoltageLevel);
  1405. }
  1406. else
  1407. {
  1408. /* Device with SMPS output voltage calibrated in production: Apply output voltage value after correction by calibration value */
  1409. TrimmingSteps = ((int32_t)OutputVoltageLevel_calibration - (int32_t)(LL_PWR_SMPS_OUTPUT_VOLTAGE_1V50 >> PWR_CR5_SMPSVOS_Pos));
  1410. OutputVoltageLevelTrimmed = ((int32_t)((uint32_t)(OutputVoltageLevel >> PWR_CR5_SMPSVOS_Pos)) + (int32_t)TrimmingSteps);
  1411. /* Clamp value to voltage trimming bitfield range */
  1412. if(OutputVoltageLevelTrimmed < 0)
  1413. {
  1414. OutputVoltageLevelTrimmed = 0;
  1415. }
  1416. else
  1417. {
  1418. if(OutputVoltageLevelTrimmed > (int32_t)PWR_CR5_SMPSVOS)
  1419. {
  1420. OutputVoltageLevelTrimmed = (int32_t)PWR_CR5_SMPSVOS;
  1421. }
  1422. }
  1423. /* Update register */
  1424. MODIFY_REG(PWR->CR5, PWR_CR5_SMPSVOS, (uint32_t)OutputVoltageLevelTrimmed);
  1425. }
  1426. }
  1427. /**
  1428. * @brief Get SMPS step down converter output voltage scaling
  1429. * @note SMPS output voltage is calibrated in production,
  1430. * calibration parameters are applied to the voltage level parameter
  1431. * to return the effective voltage value.
  1432. * @rmtoll CR5 SMPSVOS LL_PWR_SMPS_GetOutputVoltageLevel
  1433. * @retval Returned value can be one of the following values:
  1434. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V20
  1435. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V25
  1436. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V30
  1437. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V35
  1438. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V40
  1439. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V45
  1440. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V50
  1441. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V55
  1442. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V60
  1443. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V65
  1444. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V70
  1445. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V75
  1446. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V80
  1447. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V85
  1448. * @arg @ref LL_PWR_SMPS_OUTPUT_VOLTAGE_1V90
  1449. */
  1450. __STATIC_INLINE uint32_t LL_PWR_SMPS_GetOutputVoltageLevel(void)
  1451. {
  1452. __IO const uint32_t OutputVoltageLevel_calibration = (((*SMPS_VOLTAGE_CAL_ADDR) & SMPS_VOLTAGE_CAL) >> SMPS_VOLTAGE_CAL_POS); /* SMPS output voltage level calibrated in production */
  1453. int32_t TrimmingSteps; /* Trimming steps between theorical output voltage and calibrated output voltage */
  1454. int32_t OutputVoltageLevelTrimmed; /* SMPS output voltage level after calibration: trimming value added to required level */
  1455. if(OutputVoltageLevel_calibration == 0UL)
  1456. {
  1457. /* Device with SMPS output voltage not calibrated in production: Return output voltage value directly */
  1458. return (uint32_t)(READ_BIT(PWR->CR5, PWR_CR5_SMPSVOS));
  1459. }
  1460. else
  1461. {
  1462. /* Device with SMPS output voltage calibrated in production: Return output voltage value after correction by calibration value */
  1463. TrimmingSteps = ((int32_t)OutputVoltageLevel_calibration - (int32_t)(LL_PWR_SMPS_OUTPUT_VOLTAGE_1V50 >> PWR_CR5_SMPSVOS_Pos)); /* Trimming steps between theorical output voltage and calibrated output voltage */
  1464. OutputVoltageLevelTrimmed = ((int32_t)((uint32_t)READ_BIT(PWR->CR5, PWR_CR5_SMPSVOS)) - TrimmingSteps);
  1465. /* Clamp value to voltage range */
  1466. if(OutputVoltageLevelTrimmed < 0)
  1467. {
  1468. OutputVoltageLevelTrimmed = (int32_t)LL_PWR_SMPS_OUTPUT_VOLTAGE_1V20;
  1469. }
  1470. else
  1471. {
  1472. if(OutputVoltageLevelTrimmed > (int32_t)PWR_CR5_SMPSVOS)
  1473. {
  1474. OutputVoltageLevelTrimmed = (int32_t)LL_PWR_SMPS_OUTPUT_VOLTAGE_1V90;
  1475. }
  1476. }
  1477. return (uint32_t)OutputVoltageLevelTrimmed;
  1478. }
  1479. }
  1480. /**
  1481. * @}
  1482. */
  1483. #endif
  1484. /** @defgroup PWR_LL_EF_Configuration_Multicore Configuration of multicore, intended to be executed by CPU1
  1485. * @{
  1486. */
  1487. /**
  1488. * @brief Boot CPU2 after reset or wakeup from stop or standby modes
  1489. * @rmtoll CR4 C2BOOT LL_PWR_EnableBootC2
  1490. * @retval None
  1491. */
  1492. __STATIC_INLINE void LL_PWR_EnableBootC2(void)
  1493. {
  1494. SET_BIT(PWR->CR4, PWR_CR4_C2BOOT);
  1495. }
  1496. /**
  1497. * @brief Release bit to boot CPU2 after reset or wakeup from stop or standby
  1498. * modes
  1499. * @rmtoll CR4 C2BOOT LL_PWR_DisableBootC2
  1500. * @retval None
  1501. */
  1502. __STATIC_INLINE void LL_PWR_DisableBootC2(void)
  1503. {
  1504. CLEAR_BIT(PWR->CR4, PWR_CR4_C2BOOT);
  1505. }
  1506. /**
  1507. * @brief Check if bit to boot CPU2 after reset or wakeup from stop or standby
  1508. * modes is set
  1509. * @rmtoll CR4 C2BOOT LL_PWR_IsEnabledBootC2
  1510. * @retval State of bit (1 or 0)
  1511. */
  1512. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBootC2(void)
  1513. {
  1514. return ((READ_BIT(PWR->CR4, PWR_CR4_C2BOOT) == (PWR_CR4_C2BOOT)) ? 1UL : 0UL);
  1515. }
  1516. /**
  1517. * @}
  1518. */
  1519. /** @defgroup PWR_LL_EF_Configuration_CPU2 Configuration of CPU2, intended to be executed by CPU2
  1520. * @{
  1521. */
  1522. /**
  1523. * @brief Set Low-Power mode for CPU2
  1524. * @rmtoll C2CR1 LPMS LL_C2_PWR_SetPowerMode
  1525. * @param LowPowerMode This parameter can be one of the following values:
  1526. * @arg @ref LL_PWR_MODE_STOP0
  1527. * @arg @ref LL_PWR_MODE_STOP1
  1528. * @arg @ref LL_PWR_MODE_STOP2 (*)
  1529. * @arg @ref LL_PWR_MODE_STANDBY
  1530. * @arg @ref LL_PWR_MODE_SHUTDOWN
  1531. *
  1532. * (*) Not available on devices STM32WB15xx, STM32WB10xx
  1533. * @retval None
  1534. */
  1535. __STATIC_INLINE void LL_C2_PWR_SetPowerMode(uint32_t LowPowerMode)
  1536. {
  1537. MODIFY_REG(PWR->C2CR1, PWR_C2CR1_LPMS, LowPowerMode);
  1538. }
  1539. /**
  1540. * @brief Get Low-Power mode for CPU2
  1541. * @rmtoll C2CR1 LPMS LL_C2_PWR_GetPowerMode
  1542. * @retval Returned value can be one of the following values:
  1543. * @arg @ref LL_PWR_MODE_STOP0
  1544. * @arg @ref LL_PWR_MODE_STOP1
  1545. * @arg @ref LL_PWR_MODE_STOP2 (*)
  1546. * @arg @ref LL_PWR_MODE_STANDBY
  1547. * @arg @ref LL_PWR_MODE_SHUTDOWN
  1548. *
  1549. * (*) Not available on devices STM32WB15xx, STM32WB10xx
  1550. */
  1551. __STATIC_INLINE uint32_t LL_C2_PWR_GetPowerMode(void)
  1552. {
  1553. return (uint32_t)(READ_BIT(PWR->C2CR1, PWR_C2CR1_LPMS));
  1554. }
  1555. /**
  1556. * @brief Set flash power-down mode during low-power run mode for CPU2
  1557. * @rmtoll C2CR1 FPDR LL_C2_PWR_SetFlashPowerModeLPRun
  1558. * @param FlashLowPowerMode This parameter can be one of the following values:
  1559. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_IDLE
  1560. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_POWER_DOWN
  1561. * @retval None
  1562. */
  1563. __STATIC_INLINE void LL_C2_PWR_SetFlashPowerModeLPRun(uint32_t FlashLowPowerMode)
  1564. {
  1565. /* Unlock bit FPDR */
  1566. WRITE_REG(PWR->C2CR1, 0x0000C1B0UL);
  1567. /* Update bit FPDR */
  1568. MODIFY_REG(PWR->C2CR1, PWR_C2CR1_FPDR, FlashLowPowerMode);
  1569. }
  1570. /**
  1571. * @brief Get flash power-down mode during low-power run mode for CPU2
  1572. * @rmtoll C2CR1 FPDR LL_C2_PWR_GetFlashPowerModeLPRun
  1573. * @retval Returned value can be one of the following values:
  1574. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_IDLE
  1575. * @arg @ref LL_PWR_FLASH_LPRUN_MODE_POWER_DOWN
  1576. */
  1577. __STATIC_INLINE uint32_t LL_C2_PWR_GetFlashPowerModeLPRun(void)
  1578. {
  1579. return (uint32_t)(READ_BIT(PWR->C2CR1, PWR_C2CR1_FPDR));
  1580. }
  1581. /**
  1582. * @brief Set flash power-down mode during sleep mode for CPU2
  1583. * @rmtoll C2CR1 FPDS LL_C2_PWR_SetFlashPowerModeSleep
  1584. * @param FlashLowPowerMode This parameter can be one of the following values:
  1585. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_IDLE
  1586. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_POWER_DOWN
  1587. * @retval None
  1588. */
  1589. __STATIC_INLINE void LL_C2_PWR_SetFlashPowerModeSleep(uint32_t FlashLowPowerMode)
  1590. {
  1591. MODIFY_REG(PWR->C2CR1, PWR_C2CR1_FPDS, FlashLowPowerMode);
  1592. }
  1593. /**
  1594. * @brief Get flash power-down mode during sleep mode for CPU2
  1595. * @rmtoll C2CR1 FPDS LL_C2_PWR_GetFlashPowerModeSleep
  1596. * @retval Returned value can be one of the following values:
  1597. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_IDLE
  1598. * @arg @ref LL_PWR_FLASH_SLEEP_MODE_POWER_DOWN
  1599. */
  1600. __STATIC_INLINE uint32_t LL_C2_PWR_GetFlashPowerModeSleep(void)
  1601. {
  1602. return (uint32_t)(READ_BIT(PWR->C2CR1, PWR_C2CR1_FPDS));
  1603. }
  1604. /**
  1605. * @brief Enable Internal Wake-up line for CPU2
  1606. * @rmtoll C2CR3 EIWUL LL_C2_PWR_EnableInternWU
  1607. * @retval None
  1608. */
  1609. __STATIC_INLINE void LL_C2_PWR_EnableInternWU(void)
  1610. {
  1611. SET_BIT(PWR->C2CR3, PWR_C2CR3_EIWUL);
  1612. }
  1613. /**
  1614. * @brief Disable Internal Wake-up line for CPU2
  1615. * @rmtoll C2CR3 EIWUL LL_C2_PWR_DisableInternWU
  1616. * @retval None
  1617. */
  1618. __STATIC_INLINE void LL_C2_PWR_DisableInternWU(void)
  1619. {
  1620. CLEAR_BIT(PWR->C2CR3, PWR_C2CR3_EIWUL);
  1621. }
  1622. /**
  1623. * @brief Check if Internal Wake-up line is enabled for CPU2
  1624. * @rmtoll C2CR3 EIWUL LL_C2_PWR_IsEnabledInternWU
  1625. * @retval State of bit (1 or 0).
  1626. */
  1627. __STATIC_INLINE uint32_t LL_C2_PWR_IsEnabledInternWU(void)
  1628. {
  1629. return ((READ_BIT(PWR->C2CR3, PWR_C2CR3_EIWUL) == (PWR_C2CR3_EIWUL)) ? 1UL : 0UL);
  1630. }
  1631. /**
  1632. * @brief Enable the WakeUp PINx functionality
  1633. * @rmtoll C2CR3 EWUP1 LL_C2_PWR_EnableWakeUpPin\n
  1634. * C2CR3 EWUP2 LL_C2_PWR_EnableWakeUpPin\n
  1635. * C2CR3 EWUP3 LL_C2_PWR_EnableWakeUpPin\n
  1636. * C2CR3 EWUP4 LL_C2_PWR_EnableWakeUpPin\n
  1637. * C2CR3 EWUP5 LL_C2_PWR_EnableWakeUpPin
  1638. * @param WakeUpPin This parameter can be one of the following values:
  1639. * @arg @ref LL_PWR_WAKEUP_PIN1
  1640. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  1641. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  1642. * @arg @ref LL_PWR_WAKEUP_PIN4
  1643. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  1644. *
  1645. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  1646. * @retval None
  1647. */
  1648. __STATIC_INLINE void LL_C2_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
  1649. {
  1650. SET_BIT(PWR->C2CR3, WakeUpPin);
  1651. }
  1652. /**
  1653. * @brief Disable the WakeUp PINx functionality
  1654. * @rmtoll C2CR3 EWUP1 LL_C2_PWR_DisableWakeUpPin\n
  1655. * C2CR3 EWUP2 LL_C2_PWR_DisableWakeUpPin\n
  1656. * C2CR3 EWUP3 LL_C2_PWR_DisableWakeUpPin\n
  1657. * C2CR3 EWUP4 LL_C2_PWR_DisableWakeUpPin\n
  1658. * C2CR3 EWUP5 LL_C2_PWR_DisableWakeUpPin
  1659. * @param WakeUpPin This parameter can be one of the following values:
  1660. * @arg @ref LL_PWR_WAKEUP_PIN1
  1661. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  1662. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  1663. * @arg @ref LL_PWR_WAKEUP_PIN4
  1664. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  1665. *
  1666. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  1667. * @retval None
  1668. */
  1669. __STATIC_INLINE void LL_C2_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
  1670. {
  1671. CLEAR_BIT(PWR->C2CR3, WakeUpPin);
  1672. }
  1673. /**
  1674. * @brief Check if the WakeUp PINx functionality is enabled
  1675. * @rmtoll C2CR3 EWUP1 LL_C2_PWR_IsEnabledWakeUpPin\n
  1676. * C2CR3 EWUP2 LL_C2_PWR_IsEnabledWakeUpPin\n
  1677. * C2CR3 EWUP3 LL_C2_PWR_IsEnabledWakeUpPin\n
  1678. * C2CR3 EWUP4 LL_C2_PWR_IsEnabledWakeUpPin\n
  1679. * C2CR3 EWUP5 LL_C2_PWR_IsEnabledWakeUpPin
  1680. * @param WakeUpPin This parameter can be one of the following values:
  1681. * @arg @ref LL_PWR_WAKEUP_PIN1
  1682. * @arg @ref LL_PWR_WAKEUP_PIN2 (*)
  1683. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  1684. * @arg @ref LL_PWR_WAKEUP_PIN4
  1685. * @arg @ref LL_PWR_WAKEUP_PIN5 (*)
  1686. *
  1687. * (*) Not available on devices STM32WB50xx, STM32WB35xx, STM32WB30xx, STM32WB15xx, STM32WB10xx
  1688. * @retval None
  1689. */
  1690. __STATIC_INLINE uint32_t LL_C2_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
  1691. {
  1692. return ((READ_BIT(PWR->C2CR3, WakeUpPin) == (WakeUpPin)) ? 1UL : 0UL);
  1693. }
  1694. /**
  1695. * @brief Enable pull-up and pull-down configuration for CPU2
  1696. * @rmtoll C2CR3 APC LL_C2_PWR_EnablePUPDCfg
  1697. * @retval None
  1698. */
  1699. __STATIC_INLINE void LL_C2_PWR_EnablePUPDCfg(void)
  1700. {
  1701. SET_BIT(PWR->C2CR3, PWR_C2CR3_APC);
  1702. }
  1703. /**
  1704. * @brief Disable pull-up and pull-down configuration for CPU2
  1705. * @rmtoll C2CR3 APC LL_C2_PWR_DisablePUPDCfg
  1706. * @retval None
  1707. */
  1708. __STATIC_INLINE void LL_C2_PWR_DisablePUPDCfg(void)
  1709. {
  1710. CLEAR_BIT(PWR->C2CR3, PWR_C2CR3_APC);
  1711. }
  1712. /**
  1713. * @brief Check if pull-up and pull-down configuration is enabled for CPU2
  1714. * @rmtoll C2CR3 APC LL_C2_PWR_IsEnabledPUPDCfg
  1715. * @retval State of bit (1 or 0).
  1716. */
  1717. __STATIC_INLINE uint32_t LL_C2_PWR_IsEnabledPUPDCfg(void)
  1718. {
  1719. return ((READ_BIT(PWR->C2CR3, PWR_C2CR3_APC) == (PWR_C2CR3_APC)) ? 1UL : 0UL);
  1720. }
  1721. /**
  1722. * @}
  1723. */
  1724. /** @defgroup PWR_LL_EF_Configuration_CPU2_Radio Configuration of radio (BLE or 802.15.4) of CPU2, intended to be executed by CPU2
  1725. * @{
  1726. */
  1727. /**
  1728. * @brief Wakeup BLE controller from its sleep mode
  1729. * @note This bit is automatically reset when BLE controller
  1730. * exit its sleep mode.
  1731. * @rmtoll C2CR1 BLEEWKUP LL_C2_PWR_WakeUp_BLE
  1732. * @retval None
  1733. */
  1734. __STATIC_INLINE void LL_C2_PWR_WakeUp_BLE(void)
  1735. {
  1736. SET_BIT(PWR->C2CR1, PWR_C2CR1_BLEEWKUP);
  1737. }
  1738. /**
  1739. * @brief Check if the BLE controller is woken-up from
  1740. * low-power mode.
  1741. * @rmtoll C2CR1 BLEEWKUP LL_C2_PWR_IsWokenUp_BLE
  1742. * @retval State of bit (1 or 0) (value "0": BLE is not woken-up)
  1743. */
  1744. __STATIC_INLINE uint32_t LL_C2_PWR_IsWokenUp_BLE(void)
  1745. {
  1746. return ((READ_BIT(PWR->C2CR1, PWR_C2CR1_BLEEWKUP) == (PWR_C2CR1_BLEEWKUP)) ? 1UL : 0UL);
  1747. }
  1748. #if defined(PWR_CR3_E802A)
  1749. /**
  1750. * @brief Wakeup 802.15.4 controller from its sleep mode
  1751. * @note This bit is automatically reset when 802.15.4 controller
  1752. * exit its sleep mode.
  1753. * @rmtoll C2CR1 802EWKUP LL_C2_PWR_WakeUp_802_15_4
  1754. * @retval None
  1755. */
  1756. __STATIC_INLINE void LL_C2_PWR_WakeUp_802_15_4(void)
  1757. {
  1758. SET_BIT(PWR->C2CR1, PWR_C2CR1_802EWKUP);
  1759. }
  1760. /**
  1761. * @brief Check if the 802.15.4 controller is woken-up from
  1762. * low-power mode.
  1763. * @rmtoll C2CR1 802EWKUP LL_C2_PWR_IsWokenUp_802_15_4
  1764. * @retval State of bit (1 or 0) (value "0": 802.15.4 is not woken-up)
  1765. */
  1766. __STATIC_INLINE uint32_t LL_C2_PWR_IsWokenUp_802_15_4(void)
  1767. {
  1768. return ((READ_BIT(PWR->C2CR1, PWR_C2CR1_802EWKUP) == (PWR_C2CR1_802EWKUP)) ? 1UL : 0UL);
  1769. }
  1770. #endif
  1771. /**
  1772. * @}
  1773. */
  1774. /** @defgroup PWR_LL_EF_FLAG_Management FLAG_Management
  1775. * @{
  1776. */
  1777. /**
  1778. * @brief Get Internal Wake-up line Flag
  1779. * @rmtoll SR1 WUFI LL_PWR_IsActiveFlag_InternWU
  1780. * @retval State of bit (1 or 0).
  1781. */
  1782. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_InternWU(void)
  1783. {
  1784. return ((READ_BIT(PWR->SR1, PWR_SR1_WUFI) == (PWR_SR1_WUFI)) ? 1UL : 0UL);
  1785. }
  1786. #if defined(PWR_CR3_EWUP5)
  1787. /**
  1788. * @brief Get Wake-up Flag 5
  1789. * @rmtoll SR1 WUF5 LL_PWR_IsActiveFlag_WU5
  1790. * @retval State of bit (1 or 0).
  1791. */
  1792. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU5(void)
  1793. {
  1794. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF5) == (PWR_SR1_WUF5)) ? 1UL : 0UL);
  1795. }
  1796. #endif
  1797. /**
  1798. * @brief Get Wake-up Flag 4
  1799. * @rmtoll SR1 WUF4 LL_PWR_IsActiveFlag_WU4
  1800. * @retval State of bit (1 or 0).
  1801. */
  1802. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU4(void)
  1803. {
  1804. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF4) == (PWR_SR1_WUF4)) ? 1UL : 0UL);
  1805. }
  1806. #if defined(PWR_CR3_EWUP3)
  1807. /**
  1808. * @brief Get Wake-up Flag 3
  1809. * @rmtoll SR1 WUF3 LL_PWR_IsActiveFlag_WU3
  1810. * @retval State of bit (1 or 0).
  1811. */
  1812. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU3(void)
  1813. {
  1814. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF3) == (PWR_SR1_WUF3)) ? 1UL : 0UL);
  1815. }
  1816. #endif
  1817. #if defined(PWR_CR3_EWUP2)
  1818. /**
  1819. * @brief Get Wake-up Flag 2
  1820. * @rmtoll SR1 WUF2 LL_PWR_IsActiveFlag_WU2
  1821. * @retval State of bit (1 or 0).
  1822. */
  1823. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU2(void)
  1824. {
  1825. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF2) == (PWR_SR1_WUF2)) ? 1UL : 0UL);
  1826. }
  1827. #endif
  1828. /**
  1829. * @brief Get Wake-up Flag 1
  1830. * @rmtoll SR1 WUF1 LL_PWR_IsActiveFlag_WU1
  1831. * @retval State of bit (1 or 0).
  1832. */
  1833. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU1(void)
  1834. {
  1835. return ((READ_BIT(PWR->SR1, PWR_SR1_WUF1) == (PWR_SR1_WUF1)) ? 1UL : 0UL);
  1836. }
  1837. /**
  1838. * @brief Clear Wake-up Flags
  1839. * @rmtoll SCR CWUF LL_PWR_ClearFlag_WU
  1840. * @retval None
  1841. */
  1842. __STATIC_INLINE void LL_PWR_ClearFlag_WU(void)
  1843. {
  1844. WRITE_REG(PWR->SCR, PWR_SCR_CWUF);
  1845. }
  1846. #if defined(PWR_CR3_EWUP5)
  1847. /**
  1848. * @brief Clear Wake-up Flag 5
  1849. * @rmtoll SCR CWUF5 LL_PWR_ClearFlag_WU5
  1850. * @retval None
  1851. */
  1852. __STATIC_INLINE void LL_PWR_ClearFlag_WU5(void)
  1853. {
  1854. WRITE_REG(PWR->SCR, PWR_SCR_CWUF5);
  1855. }
  1856. #endif
  1857. /**
  1858. * @brief Clear Wake-up Flag 4
  1859. * @rmtoll SCR CWUF4 LL_PWR_ClearFlag_WU4
  1860. * @retval None
  1861. */
  1862. __STATIC_INLINE void LL_PWR_ClearFlag_WU4(void)
  1863. {
  1864. WRITE_REG(PWR->SCR, PWR_SCR_CWUF4);
  1865. }
  1866. #if defined(PWR_CR3_EWUP3)
  1867. /**
  1868. * @brief Clear Wake-up Flag 3
  1869. * @rmtoll SCR CWUF3 LL_PWR_ClearFlag_WU3
  1870. * @retval None
  1871. */
  1872. __STATIC_INLINE void LL_PWR_ClearFlag_WU3(void)
  1873. {
  1874. WRITE_REG(PWR->SCR, PWR_SCR_CWUF3);
  1875. }
  1876. #endif
  1877. #if defined(PWR_CR3_EWUP2)
  1878. /**
  1879. * @brief Clear Wake-up Flag 2
  1880. * @rmtoll SCR CWUF2 LL_PWR_ClearFlag_WU2
  1881. * @retval None
  1882. */
  1883. __STATIC_INLINE void LL_PWR_ClearFlag_WU2(void)
  1884. {
  1885. WRITE_REG(PWR->SCR, PWR_SCR_CWUF2);
  1886. }
  1887. #endif
  1888. /**
  1889. * @brief Clear Wake-up Flag 1
  1890. * @rmtoll SCR CWUF1 LL_PWR_ClearFlag_WU1
  1891. * @retval None
  1892. */
  1893. __STATIC_INLINE void LL_PWR_ClearFlag_WU1(void)
  1894. {
  1895. WRITE_REG(PWR->SCR, PWR_SCR_CWUF1);
  1896. }
  1897. /**
  1898. * @brief Indicate whether VDDA voltage is below or above PVM3 threshold
  1899. * @rmtoll SR2 PVMO3 LL_PWR_IsActiveFlag_PVMO3
  1900. * @retval State of bit (1 or 0).
  1901. */
  1902. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVMO3(void)
  1903. {
  1904. return ((READ_BIT(PWR->SR2, PWR_SR2_PVMO3) == (PWR_SR2_PVMO3)) ? 1UL : 0UL);
  1905. }
  1906. #if defined(PWR_CR2_PVME1)
  1907. /**
  1908. * @brief Indicate whether VDDUSB voltage is below or above PVM1 threshold
  1909. * @rmtoll SR2 PVMO1 LL_PWR_IsActiveFlag_PVMO1
  1910. * @retval State of bit (1 or 0).
  1911. */
  1912. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVMO1(void)
  1913. {
  1914. return ((READ_BIT(PWR->SR2, PWR_SR2_PVMO1) == (PWR_SR2_PVMO1)) ? 1UL : 0UL);
  1915. }
  1916. #endif
  1917. /**
  1918. * @brief Indicate whether VDD voltage is below or above the selected PVD threshold
  1919. * @rmtoll SR2 PVDO LL_PWR_IsActiveFlag_PVDO
  1920. * @retval State of bit (1 or 0).
  1921. */
  1922. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
  1923. {
  1924. return ((READ_BIT(PWR->SR2, PWR_SR2_PVDO) == (PWR_SR2_PVDO)) ? 1UL : 0UL);
  1925. }
  1926. #if defined(PWR_CR1_VOS)
  1927. /**
  1928. * @brief Indicate whether the regulator is ready in the selected voltage range or if its output voltage is still changing to the required voltage level
  1929. * @rmtoll SR2 VOSF LL_PWR_IsActiveFlag_VOS
  1930. * @retval State of bit (1 or 0).
  1931. */
  1932. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOS(void)
  1933. {
  1934. return ((READ_BIT(PWR->SR2, PWR_SR2_VOSF) == (PWR_SR2_VOSF)) ? 1UL : 0UL);
  1935. }
  1936. #endif
  1937. /**
  1938. * @brief Indicate whether the regulator is ready in main mode or is in low-power mode
  1939. * @note Take care, return value "0" means the regulator is ready. Return value "1" means the output voltage range is still changing.
  1940. * @rmtoll SR2 REGLPF LL_PWR_IsActiveFlag_REGLPF
  1941. * @retval State of bit (1 or 0).
  1942. */
  1943. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_REGLPF(void)
  1944. {
  1945. return ((READ_BIT(PWR->SR2, PWR_SR2_REGLPF) == (PWR_SR2_REGLPF)) ? 1UL : 0UL);
  1946. }
  1947. /**
  1948. * @brief Indicate whether or not the low-power regulator is ready
  1949. * @rmtoll SR2 REGLPS LL_PWR_IsActiveFlag_REGLPS
  1950. * @retval State of bit (1 or 0).
  1951. */
  1952. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_REGLPS(void)
  1953. {
  1954. return ((READ_BIT(PWR->SR2, PWR_SR2_REGLPS) == (PWR_SR2_REGLPS)) ? 1UL : 0UL);
  1955. }
  1956. /**
  1957. * @brief Get BORH interrupt flag
  1958. * @rmtoll SR1 BORHF LL_PWR_IsActiveFlag_BORH
  1959. * @retval State of bit (1 or 0).
  1960. */
  1961. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_BORH(void)
  1962. {
  1963. return ((READ_BIT(PWR->SR1, PWR_SR1_BORHF) == (PWR_SR1_BORHF)) ? 1UL : 0UL);
  1964. }
  1965. /**
  1966. * @brief Clear BORH interrupt flag
  1967. * @rmtoll SCR CBORHF LL_PWR_ClearFlag_BORH
  1968. * @retval None
  1969. */
  1970. __STATIC_INLINE void LL_PWR_ClearFlag_BORH(void)
  1971. {
  1972. WRITE_REG(PWR->SCR, PWR_SCR_CBORHF);
  1973. }
  1974. /**
  1975. * @}
  1976. */
  1977. #if defined(PWR_CR5_SMPSEN)
  1978. /** @defgroup PWR_LL_EF_FLAG_Management_SMPS FLAG management for SMPS
  1979. * @{
  1980. */
  1981. /**
  1982. * @brief Get SMPS step down converter forced in bypass mode interrupt flag
  1983. * @note To activate flag of SMPS step down converter forced in bypass mode
  1984. * by BORH, BOR must be preliminarily configured to control SMPS
  1985. * operating mode.
  1986. * Refer to function @ref LL_PWR_SetBORConfig().
  1987. * @rmtoll SR1 SMPSFBF LL_PWR_IsActiveFlag_SMPSFB
  1988. * @retval State of bit (1 or 0).
  1989. */
  1990. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SMPSFB(void)
  1991. {
  1992. return ((READ_BIT(PWR->SR1, PWR_SR1_SMPSFBF) == (PWR_SR1_SMPSFBF)) ? 1UL : 0UL);
  1993. }
  1994. /**
  1995. * @brief Clear SMPS step down converter forced in bypass mode interrupt flag
  1996. * @note To activate flag of SMPS step down converter forced in bypass mode
  1997. * by BORH, BOR must be preliminarily configured to control SMPS
  1998. * operating mode.
  1999. * Refer to function @ref LL_PWR_SetBORConfig().
  2000. * @rmtoll SCR CSMPSFBF LL_PWR_ClearFlag_SMPSFB
  2001. * @retval None
  2002. */
  2003. __STATIC_INLINE void LL_PWR_ClearFlag_SMPSFB(void)
  2004. {
  2005. WRITE_REG(PWR->SCR, PWR_SCR_CSMPSFBF);
  2006. }
  2007. /**
  2008. * @}
  2009. */
  2010. #endif
  2011. /** @defgroup PWR_LL_EF_FLAG_Management_Radio FLAG management for radio (BLE or 802.15.4)
  2012. * @{
  2013. */
  2014. /**
  2015. * @brief Get BLE wakeup interrupt flag
  2016. * @rmtoll SR1 BLEWUF LL_PWR_IsActiveFlag_BLEWU
  2017. * @retval State of bit (1 or 0).
  2018. */
  2019. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_BLEWU(void)
  2020. {
  2021. return ((READ_BIT(PWR->SR1, PWR_SR1_BLEWUF) == (PWR_SR1_BLEWUF)) ? 1UL : 0UL);
  2022. }
  2023. #if defined(PWR_CR3_E802A)
  2024. /**
  2025. * @brief Get 802.15.4 wakeup interrupt flag
  2026. * @rmtoll SR1 802WUF LL_PWR_IsActiveFlag_802WU
  2027. * @retval State of bit (1 or 0).
  2028. */
  2029. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_802WU(void)
  2030. {
  2031. return ((READ_BIT(PWR->SR1, PWR_SR1_802WUF) == (PWR_SR1_802WUF)) ? 1UL : 0UL);
  2032. }
  2033. #endif
  2034. /**
  2035. * @brief Get BLE end of activity interrupt flag
  2036. * @rmtoll SR1 BLEAF LL_PWR_IsActiveFlag_BLEA
  2037. * @retval State of bit (1 or 0).
  2038. */
  2039. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_BLEA(void)
  2040. {
  2041. return ((READ_BIT(PWR->SR1, PWR_SR1_BLEAF) == (PWR_SR1_BLEAF)) ? 1UL : 0UL);
  2042. }
  2043. #if defined(PWR_CR3_E802A)
  2044. /**
  2045. * @brief Get 802.15.4 end of activity interrupt flag
  2046. * @rmtoll SR1 802AF LL_PWR_IsActiveFlag_802A
  2047. * @retval State of bit (1 or 0).
  2048. */
  2049. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_802A(void)
  2050. {
  2051. return ((READ_BIT(PWR->SR1, PWR_SR1_802AF) == (PWR_SR1_802AF)) ? 1UL : 0UL);
  2052. }
  2053. #endif
  2054. /**
  2055. * @brief Get critical radio phase end of activity interrupt flag
  2056. * @rmtoll SR1 CRPEF LL_PWR_IsActiveFlag_CRPE
  2057. * @retval State of bit (1 or 0).
  2058. */
  2059. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_CRPE(void)
  2060. {
  2061. return ((READ_BIT(PWR->SR1, PWR_SR1_CRPEF) == (PWR_SR1_CRPEF)) ? 1UL : 0UL);
  2062. }
  2063. /**
  2064. * @brief Get critical radio system phase flag
  2065. * @rmtoll EXTSCR CRPF LL_PWR_IsActiveFlag_CRP
  2066. * @retval State of bit (1 or 0).
  2067. */
  2068. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_CRP(void)
  2069. {
  2070. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_CRPF) == (PWR_EXTSCR_CRPF)) ? 1UL : 0UL);
  2071. }
  2072. /**
  2073. * @brief Clear BLE wakeup interrupt flag
  2074. * @rmtoll SCR BLEWU LL_PWR_ClearFlag_BLEWU
  2075. * @retval None
  2076. */
  2077. __STATIC_INLINE void LL_PWR_ClearFlag_BLEWU(void)
  2078. {
  2079. WRITE_REG(PWR->SCR, PWR_SCR_CBLEWUF);
  2080. }
  2081. #if defined(PWR_CR3_E802A)
  2082. /**
  2083. * @brief Clear 802.15.4 wakeup interrupt flag
  2084. * @rmtoll SCR 802WU LL_PWR_ClearFlag_802WU
  2085. * @retval None
  2086. */
  2087. __STATIC_INLINE void LL_PWR_ClearFlag_802WU(void)
  2088. {
  2089. WRITE_REG(PWR->SCR, PWR_SCR_C802WUF);
  2090. }
  2091. #endif
  2092. /**
  2093. * @brief Clear BLE end of activity interrupt flag
  2094. * @rmtoll SCR BLEAF LL_PWR_ClearFlag_BLEA
  2095. * @retval None
  2096. */
  2097. __STATIC_INLINE void LL_PWR_ClearFlag_BLEA(void)
  2098. {
  2099. WRITE_REG(PWR->SCR, PWR_SCR_CBLEAF);
  2100. }
  2101. #if defined(PWR_CR3_E802A)
  2102. /**
  2103. * @brief Clear 802.15.4 end of activity interrupt flag
  2104. * @rmtoll SCR 802AF LL_PWR_ClearFlag_802A
  2105. * @retval None
  2106. */
  2107. __STATIC_INLINE void LL_PWR_ClearFlag_802A(void)
  2108. {
  2109. WRITE_REG(PWR->SCR, PWR_SCR_C802AF);
  2110. }
  2111. #endif
  2112. /**
  2113. * @brief Clear critical radio phase end of activity interrupt flag
  2114. * @rmtoll SCR CCRPEF LL_PWR_ClearFlag_CRPE
  2115. * @retval None
  2116. */
  2117. __STATIC_INLINE void LL_PWR_ClearFlag_CRPE(void)
  2118. {
  2119. WRITE_REG(PWR->SCR, PWR_SCR_CCRPEF);
  2120. }
  2121. /**
  2122. * @brief Clear critical radio system phase flag
  2123. * @rmtoll EXTSCR CCRP LL_PWR_ClearFlag_CRP
  2124. * @retval None
  2125. */
  2126. __STATIC_INLINE void LL_PWR_ClearFlag_CRP(void)
  2127. {
  2128. WRITE_REG(PWR->EXTSCR, PWR_EXTSCR_CCRPF);
  2129. }
  2130. /**
  2131. * @}
  2132. */
  2133. /** @defgroup PWR_LL_EF_FLAG_Management_Multicore FLAG management for multicore
  2134. * @{
  2135. */
  2136. /**
  2137. * @brief Get CPU2 hold interrupt flag
  2138. * @rmtoll SCR CC2HF LL_PWR_IsActiveFlag_C2H
  2139. * @retval State of bit (1 or 0).
  2140. */
  2141. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C2H(void)
  2142. {
  2143. return ((READ_BIT(PWR->SR1, PWR_SR1_C2HF) == (PWR_SR1_C2HF)) ? 1UL : 0UL);
  2144. }
  2145. /**
  2146. * @brief Get system stop flag for CPU1
  2147. * @rmtoll EXTSCR C1STOPF LL_PWR_IsActiveFlag_C1STOP
  2148. * @retval State of bit (1 or 0).
  2149. */
  2150. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C1STOP(void)
  2151. {
  2152. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_C1STOPF) == (PWR_EXTSCR_C1STOPF)) ? 1UL : 0UL);
  2153. }
  2154. /**
  2155. * @brief Get system standby flag for CPU1
  2156. * @rmtoll EXTSCR C1SBF LL_PWR_IsActiveFlag_C1SB
  2157. * @retval State of bit (1 or 0).
  2158. */
  2159. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C1SB(void)
  2160. {
  2161. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_C1SBF) == (PWR_EXTSCR_C1SBF)) ? 1UL : 0UL);
  2162. }
  2163. /**
  2164. * @brief Get deepsleep mode for CPU1
  2165. * @rmtoll EXTSCR C1DS LL_PWR_IsActiveFlag_C1DS
  2166. * @retval State of bit (1 or 0).
  2167. */
  2168. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C1DS(void)
  2169. {
  2170. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_C1DS) == (PWR_EXTSCR_C1DS)) ? 1UL : 0UL);
  2171. }
  2172. /**
  2173. * @brief System stop flag for CPU2
  2174. * @rmtoll EXTSCR C2STOPF LL_PWR_IsActiveFlag_C2STOP
  2175. * @retval State of bit (1 or 0).
  2176. */
  2177. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C2STOP(void)
  2178. {
  2179. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_C2STOPF) == (PWR_EXTSCR_C2STOPF)) ? 1UL : 0UL);
  2180. }
  2181. /**
  2182. * @brief System standby flag for CPU2
  2183. * @rmtoll EXTSCR C2SBF LL_PWR_IsActiveFlag_C2SB
  2184. * @retval State of bit (1 or 0).
  2185. */
  2186. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C2SB(void)
  2187. {
  2188. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_C2SBF) == (PWR_EXTSCR_C2SBF)) ? 1UL : 0UL);
  2189. }
  2190. /**
  2191. * @brief Get deepsleep mode for CPU2
  2192. * @rmtoll EXTSCR C2DS LL_PWR_IsActiveFlag_C2DS
  2193. * @retval State of bit (1 or 0).
  2194. */
  2195. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_C2DS(void)
  2196. {
  2197. return ((READ_BIT(PWR->EXTSCR, PWR_EXTSCR_C2DS) == (PWR_EXTSCR_C2DS)) ? 1UL : 0UL);
  2198. }
  2199. /**
  2200. * @brief Clear CPU2 hold interrupt flag
  2201. * @rmtoll SCR CC2HF LL_PWR_ClearFlag_C2H
  2202. * @retval None
  2203. */
  2204. __STATIC_INLINE void LL_PWR_ClearFlag_C2H(void)
  2205. {
  2206. WRITE_REG(PWR->SCR, PWR_SCR_CC2HF);
  2207. }
  2208. /**
  2209. * @brief Clear standby and stop flags for CPU1
  2210. * @rmtoll EXTSCR C1CSSF LL_PWR_ClearFlag_C1STOP_C1STB
  2211. * @retval None
  2212. */
  2213. __STATIC_INLINE void LL_PWR_ClearFlag_C1STOP_C1STB(void)
  2214. {
  2215. WRITE_REG(PWR->EXTSCR, PWR_EXTSCR_C1CSSF);
  2216. }
  2217. /**
  2218. * @brief Clear standby and stop flags for CPU2
  2219. * @rmtoll EXTSCR C2CSSF LL_PWR_ClearFlag_C2STOP_C2STB
  2220. * @retval None
  2221. */
  2222. __STATIC_INLINE void LL_PWR_ClearFlag_C2STOP_C2STB(void)
  2223. {
  2224. WRITE_REG(PWR->EXTSCR, PWR_EXTSCR_C2CSSF);
  2225. }
  2226. /**
  2227. * @}
  2228. */
  2229. #if defined(PWR_CR5_SMPSEN)
  2230. /** @defgroup PWR_LL_EF_IT_Management_SMPS PWR IT management for SMPS
  2231. * @{
  2232. */
  2233. /**
  2234. * @brief Enable SMPS step down converter forced in bypass mode by BORH
  2235. * interrupt for CPU1
  2236. * @note To activate flag of SMPS step down converter forced in bypass mode
  2237. * by BORH, BOR must be preliminarily configured to control SMPS
  2238. * operating mode.
  2239. * Refer to function @ref LL_PWR_SetBORConfig().
  2240. * @rmtoll CR3 EBORHSMPSFB LL_PWR_EnableIT_BORH_SMPSFB
  2241. * @retval None
  2242. */
  2243. __STATIC_INLINE void LL_PWR_EnableIT_BORH_SMPSFB(void)
  2244. {
  2245. SET_BIT(PWR->CR3, PWR_CR3_EBORHSMPSFB);
  2246. }
  2247. /**
  2248. * @brief Disable SMPS step down converter forced in bypass mode by BORH
  2249. * interrupt for CPU1
  2250. * @rmtoll CR3 EBORHSMPSFB LL_PWR_DisableIT_BORH_SMPSFB
  2251. * @retval None
  2252. */
  2253. __STATIC_INLINE void LL_PWR_DisableIT_BORH_SMPSFB(void)
  2254. {
  2255. CLEAR_BIT(PWR->CR3, PWR_CR3_EBORHSMPSFB);
  2256. }
  2257. /**
  2258. * @brief Check if SMPS step down converter forced in bypass mode by BORH
  2259. * interrupt is enabled for CPU1
  2260. * @rmtoll CR3 EBORHSMPSFB LL_PWR_IsEnabledIT_BORH_SMPSFB
  2261. * @retval State of bit (1 or 0).
  2262. */
  2263. __STATIC_INLINE uint32_t LL_PWR_IsEnabledIT_BORH_SMPSFB(void)
  2264. {
  2265. return ((READ_BIT(PWR->CR3, PWR_CR3_EBORHSMPSFB) == (PWR_CR3_EBORHSMPSFB)) ? 1UL : 0UL);
  2266. }
  2267. /**
  2268. * @}
  2269. */
  2270. #endif
  2271. /** @defgroup PWR_LL_EF_IT_Management_Radio PWR IT management for radio (BLE or 802.15.4)
  2272. * @{
  2273. */
  2274. /**
  2275. * @brief Enable BLE end of activity interrupt for CPU1
  2276. * @rmtoll CR3 EBLEA LL_PWR_EnableIT_BLEA
  2277. * @retval None
  2278. */
  2279. __STATIC_INLINE void LL_PWR_EnableIT_BLEA(void)
  2280. {
  2281. SET_BIT(PWR->CR3, PWR_CR3_EBLEA);
  2282. }
  2283. #if defined(PWR_CR3_E802A)
  2284. /**
  2285. * @brief Enable 802.15.4 end of activity interrupt for CPU1
  2286. * @rmtoll CR3 E802A LL_PWR_EnableIT_802A
  2287. * @retval None
  2288. */
  2289. __STATIC_INLINE void LL_PWR_EnableIT_802A(void)
  2290. {
  2291. SET_BIT(PWR->CR3, PWR_CR3_E802A);
  2292. }
  2293. #endif
  2294. /**
  2295. * @brief Disable BLE end of activity interrupt for CPU1
  2296. * @rmtoll CR3 EBLEA LL_PWR_DisableIT_BLEA
  2297. * @retval None
  2298. */
  2299. __STATIC_INLINE void LL_PWR_DisableIT_BLEA(void)
  2300. {
  2301. CLEAR_BIT(PWR->CR3, PWR_CR3_EBLEA);
  2302. }
  2303. #if defined(PWR_CR3_E802A)
  2304. /**
  2305. * @brief Disable 802.15.4 end of activity interrupt for CPU1
  2306. * @rmtoll CR3 E802A LL_PWR_DisableIT_802A
  2307. * @retval None
  2308. */
  2309. __STATIC_INLINE void LL_PWR_DisableIT_802A(void)
  2310. {
  2311. CLEAR_BIT(PWR->CR3, PWR_CR3_E802A);
  2312. }
  2313. #endif
  2314. /**
  2315. * @brief Check if BLE end of activity interrupt is enabled for CPU1
  2316. * @rmtoll CR3 EBLEA LL_PWR_IsEnabledIT_BLEA
  2317. * @retval State of bit (1 or 0).
  2318. */
  2319. __STATIC_INLINE uint32_t LL_PWR_IsEnabledIT_BLEA(void)
  2320. {
  2321. return ((READ_BIT(PWR->CR3, PWR_CR3_EBLEA) == (PWR_CR3_EBLEA)) ? 1UL : 0UL);
  2322. }
  2323. #if defined(PWR_CR3_E802A)
  2324. /**
  2325. * @brief Check if 802.15.4 end of activity interrupt is enabled for CPU1
  2326. * @rmtoll CR3 E802A LL_PWR_IsEnabledIT_802A
  2327. * @retval State of bit (1 or 0).
  2328. */
  2329. __STATIC_INLINE uint32_t LL_PWR_IsEnabledIT_802A(void)
  2330. {
  2331. return ((READ_BIT(PWR->CR3, PWR_CR3_E802A) == (PWR_CR3_E802A)) ? 1UL : 0UL);
  2332. }
  2333. #endif
  2334. /**
  2335. * @brief Enable critical radio phase end of activity interrupt for CPU1
  2336. * @rmtoll CR3 ECRPE LL_PWR_EnableIT_802A
  2337. * @retval None
  2338. */
  2339. __STATIC_INLINE void LL_PWR_EnableIT_CRPE(void)
  2340. {
  2341. SET_BIT(PWR->CR3, PWR_CR3_ECRPE);
  2342. }
  2343. /**
  2344. * @brief Disable critical radio phase end of activity interrupt for CPU1
  2345. * @rmtoll CR3 ECRPE LL_PWR_DisableIT_802A
  2346. * @retval None
  2347. */
  2348. __STATIC_INLINE void LL_PWR_DisableIT_CRPE(void)
  2349. {
  2350. CLEAR_BIT(PWR->CR3, PWR_CR3_ECRPE);
  2351. }
  2352. /**
  2353. * @brief Check if critical radio phase end of activity interrupt is enabled for CPU1
  2354. * @rmtoll CR3 ECRPE LL_PWR_IsEnabledIT_802A
  2355. * @retval State of bit (1 or 0).
  2356. */
  2357. __STATIC_INLINE uint32_t LL_PWR_IsEnabledIT_CRPE(void)
  2358. {
  2359. return ((READ_BIT(PWR->CR3, PWR_CR3_ECRPE) == (PWR_CR3_ECRPE)) ? 1UL : 0UL);
  2360. }
  2361. /**
  2362. * @}
  2363. */
  2364. /** @defgroup PWR_LL_EF_IT_Management_Multicore PWR IT management for multicore
  2365. * @{
  2366. */
  2367. /**
  2368. * @brief Enable CPU2 hold interrupt for CPU1
  2369. * @rmtoll CR3 EC2H LL_PWR_EnableIT_HoldCPU2
  2370. * @retval None
  2371. */
  2372. __STATIC_INLINE void LL_PWR_EnableIT_HoldCPU2(void)
  2373. {
  2374. SET_BIT(PWR->CR3, PWR_CR3_EC2H);
  2375. }
  2376. /**
  2377. * @brief Disable 802.15.4 host wakeup interrupt for CPU2
  2378. * @rmtoll CR3 EC2H LL_PWR_DisableIT_HoldCPU2
  2379. * @retval None
  2380. */
  2381. __STATIC_INLINE void LL_PWR_DisableIT_HoldCPU2(void)
  2382. {
  2383. CLEAR_BIT(PWR->CR3, PWR_CR3_EC2H);
  2384. }
  2385. /**
  2386. * @brief Check if BLE host wakeup interrupt is enabled for CPU2
  2387. * @rmtoll CR3 EC2H LL_PWR_IsEnabledIT_HoldCPU2
  2388. * @retval State of bit (1 or 0).
  2389. */
  2390. __STATIC_INLINE uint32_t LL_PWR_IsEnabledIT_HoldCPU2(void)
  2391. {
  2392. return ((READ_BIT(PWR->CR3, PWR_CR3_EC2H) == (PWR_CR3_EC2H)) ? 1UL : 0UL);
  2393. }
  2394. /**
  2395. * @}
  2396. */
  2397. /** @defgroup PWR_LL_EF_IT_Management_CPU2 PWR IT management of CPU2, intended to be executed by CPU2
  2398. * @{
  2399. */
  2400. /**
  2401. * @brief Enable BLE host wakeup interrupt for CPU2
  2402. * @rmtoll C2CR3 EBLEWUP LL_C2_PWR_EnableIT_BLEWU
  2403. * @retval None
  2404. */
  2405. __STATIC_INLINE void LL_C2_PWR_EnableIT_BLEWU(void)
  2406. {
  2407. SET_BIT(PWR->C2CR3, PWR_C2CR3_EBLEWUP);
  2408. }
  2409. #if defined(PWR_CR3_E802A)
  2410. /**
  2411. * @brief Enable 802.15.4 host wakeup interrupt for CPU2
  2412. * @rmtoll C2CR3 E802WUP LL_C2_PWR_EnableIT_802WU
  2413. * @retval None
  2414. */
  2415. __STATIC_INLINE void LL_C2_PWR_EnableIT_802WU(void)
  2416. {
  2417. SET_BIT(PWR->C2CR3, PWR_C2CR3_E802WUP);
  2418. }
  2419. #endif
  2420. /**
  2421. * @brief Disable BLE host wakeup interrupt for CPU2
  2422. * @rmtoll C2CR3 EBLEWUP LL_C2_PWR_DisableIT_BLEWU
  2423. * @retval None
  2424. */
  2425. __STATIC_INLINE void LL_C2_PWR_DisableIT_BLEWU(void)
  2426. {
  2427. CLEAR_BIT(PWR->C2CR3, PWR_C2CR3_EBLEWUP);
  2428. }
  2429. #if defined(PWR_CR3_E802A)
  2430. /**
  2431. * @brief Disable 802.15.4 host wakeup interrupt for CPU2
  2432. * @rmtoll C2CR3 E802WUP LL_C2_PWR_DisableIT_802WU
  2433. * @retval None
  2434. */
  2435. __STATIC_INLINE void LL_C2_PWR_DisableIT_802WU(void)
  2436. {
  2437. CLEAR_BIT(PWR->C2CR3, PWR_C2CR3_E802WUP);
  2438. }
  2439. #endif
  2440. /**
  2441. * @brief Check if BLE host wakeup interrupt is enabled for CPU2
  2442. * @rmtoll C2CR3 EBLEWUP LL_C2_PWR_IsEnabledIT_BLEWU
  2443. * @retval State of bit (1 or 0).
  2444. */
  2445. __STATIC_INLINE uint32_t LL_C2_PWR_IsEnabledIT_BLEWU(void)
  2446. {
  2447. return ((READ_BIT(PWR->C2CR3, PWR_C2CR3_EBLEWUP) == (PWR_C2CR3_EBLEWUP)) ? 1UL : 0UL);
  2448. }
  2449. #if defined(PWR_CR3_E802A)
  2450. /**
  2451. * @brief Check if 802.15.4 host wakeup interrupt is enabled for CPU2
  2452. * @rmtoll C2CR3 E802WUP LL_C2_PWR_IsEnabledIT_802WU
  2453. * @retval State of bit (1 or 0).
  2454. */
  2455. __STATIC_INLINE uint32_t LL_C2_PWR_IsEnabledIT_802WU(void)
  2456. {
  2457. return ((READ_BIT(PWR->C2CR3, PWR_C2CR3_E802WUP) == (PWR_C2CR3_E802WUP)) ? 1UL : 0UL);
  2458. }
  2459. #endif
  2460. /**
  2461. * @}
  2462. */
  2463. #if defined(USE_FULL_LL_DRIVER)
  2464. /** @defgroup PWR_LL_EF_Init De-initialization function
  2465. * @{
  2466. */
  2467. ErrorStatus LL_PWR_DeInit(void);
  2468. /**
  2469. * @}
  2470. */
  2471. #endif /* USE_FULL_LL_DRIVER */
  2472. /**
  2473. * @}
  2474. */
  2475. /**
  2476. * @}
  2477. */
  2478. #endif /* defined(PWR) */
  2479. /**
  2480. * @}
  2481. */
  2482. #ifdef __cplusplus
  2483. }
  2484. #endif
  2485. #endif /* STM32WBxx_LL_PWR_H */
  2486. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/