Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
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.
 
 
 
 
 
 

760 lines
26 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l0xx_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) 2016 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L0xx_LL_PWR_H
  37. #define __STM32L0xx_LL_PWR_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. /* Includes ------------------------------------------------------------------*/
  42. #include "stm32l0xx.h"
  43. /** @addtogroup STM32L0xx_LL_Driver
  44. * @{
  45. */
  46. #if defined(PWR)
  47. /** @defgroup PWR_LL PWR
  48. * @{
  49. */
  50. /* Private types -------------------------------------------------------------*/
  51. /* Private variables ---------------------------------------------------------*/
  52. /* Private constants ---------------------------------------------------------*/
  53. /* Private macros ------------------------------------------------------------*/
  54. /* Exported types ------------------------------------------------------------*/
  55. /* Exported constants --------------------------------------------------------*/
  56. /** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
  57. * @{
  58. */
  59. /** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines
  60. * @brief Flags defines which can be used with LL_PWR_WriteReg function
  61. * @{
  62. */
  63. #define LL_PWR_CR_CSBF PWR_CR_CSBF /*!< Clear standby flag */
  64. #define LL_PWR_CR_CWUF PWR_CR_CWUF /*!< Clear wakeup flag */
  65. /**
  66. * @}
  67. */
  68. /** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines
  69. * @brief Flags defines which can be used with LL_PWR_ReadReg function
  70. * @{
  71. */
  72. #define LL_PWR_CSR_WUF PWR_CSR_WUF /*!< Wakeup flag */
  73. #define LL_PWR_CSR_SBF PWR_CSR_SBF /*!< Standby flag */
  74. #if defined(PWR_PVD_SUPPORT)
  75. #define LL_PWR_CSR_PVDO PWR_CSR_PVDO /*!< Power voltage detector output flag */
  76. #endif /* PWR_PVD_SUPPORT */
  77. #if defined(PWR_CSR_VREFINTRDYF)
  78. #define LL_PWR_CSR_VREFINTRDYF PWR_CSR_VREFINTRDYF /*!< VREFINT ready flag */
  79. #endif /* PWR_CSR_VREFINTRDYF */
  80. #define LL_PWR_CSR_VOS PWR_CSR_VOSF /*!< Voltage scaling select flag */
  81. #define LL_PWR_CSR_REGLPF PWR_CSR_REGLPF /*!< Regulator low power flag */
  82. #define LL_PWR_CSR_EWUP1 PWR_CSR_EWUP1 /*!< Enable WKUP pin 1 */
  83. #define LL_PWR_CSR_EWUP2 PWR_CSR_EWUP2 /*!< Enable WKUP pin 2 */
  84. #if defined(PWR_CSR_EWUP3)
  85. #define LL_PWR_CSR_EWUP3 PWR_CSR_EWUP3 /*!< Enable WKUP pin 3 */
  86. #endif /* PWR_CSR_EWUP3 */
  87. /**
  88. * @}
  89. */
  90. /** @defgroup PWR_LL_EC_REGU_VOLTAGE Regulator Voltage
  91. * @{
  92. */
  93. #define LL_PWR_REGU_VOLTAGE_SCALE1 (PWR_CR_VOS_0) /*!< 1.8V (range 1) */
  94. #define LL_PWR_REGU_VOLTAGE_SCALE2 (PWR_CR_VOS_1) /*!< 1.5V (range 2) */
  95. #define LL_PWR_REGU_VOLTAGE_SCALE3 (PWR_CR_VOS_0 | PWR_CR_VOS_1) /*!< 1.2V (range 3) */
  96. /**
  97. * @}
  98. */
  99. /** @defgroup PWR_LL_EC_MODE_PWR Mode Power
  100. * @{
  101. */
  102. #define LL_PWR_MODE_STOP 0x00000000U /*!< Enter Stop mode when the CPU enters deepsleep */
  103. #define LL_PWR_MODE_STANDBY (PWR_CR_PDDS) /*!< Enter Standby mode when the CPU enters deepsleep */
  104. /**
  105. * @}
  106. */
  107. /** @defgroup PWR_LL_EC_REGU_MODE_LP_MODES Regulator Mode In Low Power Modes
  108. * @{
  109. */
  110. #define LL_PWR_REGU_LPMODES_MAIN 0x00000000U /*!< Voltage regulator in main mode during deepsleep/sleep/low-power run mode */
  111. #define LL_PWR_REGU_LPMODES_LOW_POWER (PWR_CR_LPSDSR) /*!< Voltage regulator in low-power mode during deepsleep/sleep/low-power run mode */
  112. /**
  113. * @}
  114. */
  115. #if defined(PWR_CR_LPDS)
  116. /** @defgroup PWR_LL_EC_REGU_MODE_DS_MODE Regulator Mode In Deep Sleep Mode
  117. * @{
  118. */
  119. #define LL_PWR_REGU_DSMODE_MAIN 0x00000000U /*!< Voltage regulator in main mode during deepsleep mode when PWR_CR_LPSDSR = 0 */
  120. #define LL_PWR_REGU_DSMODE_LOW_POWER (PWR_CR_LPDS) /*!< Voltage regulator in low-power mode during deepsleep mode when PWR_CR_LPSDSR = 0 */
  121. /**
  122. * @}
  123. */
  124. #endif /* PWR_CR_LPDS */
  125. #if defined(PWR_PVD_SUPPORT)
  126. /** @defgroup PWR_LL_EC_PVDLEVEL Power Voltage Detector Level
  127. * @{
  128. */
  129. #define LL_PWR_PVDLEVEL_0 (PWR_CR_PLS_LEV0) /*!< Voltage threshold detected by PVD 1.9 V */
  130. #define LL_PWR_PVDLEVEL_1 (PWR_CR_PLS_LEV1) /*!< Voltage threshold detected by PVD 2.1 V */
  131. #define LL_PWR_PVDLEVEL_2 (PWR_CR_PLS_LEV2) /*!< Voltage threshold detected by PVD 2.3 V */
  132. #define LL_PWR_PVDLEVEL_3 (PWR_CR_PLS_LEV3) /*!< Voltage threshold detected by PVD 2.5 V */
  133. #define LL_PWR_PVDLEVEL_4 (PWR_CR_PLS_LEV4) /*!< Voltage threshold detected by PVD 2.7 V */
  134. #define LL_PWR_PVDLEVEL_5 (PWR_CR_PLS_LEV5) /*!< Voltage threshold detected by PVD 2.9 V */
  135. #define LL_PWR_PVDLEVEL_6 (PWR_CR_PLS_LEV6) /*!< Voltage threshold detected by PVD 3.1 V */
  136. #define LL_PWR_PVDLEVEL_7 (PWR_CR_PLS_LEV7) /*!< External input analog voltage (Compare internally to VREFINT) */
  137. /**
  138. * @}
  139. */
  140. #endif /* PWR_PVD_SUPPORT */
  141. /** @defgroup PWR_LL_EC_WAKEUP_PIN Wakeup Pins
  142. * @{
  143. */
  144. #define LL_PWR_WAKEUP_PIN1 (PWR_CSR_EWUP1) /*!< WKUP pin 1 : PA0 */
  145. #define LL_PWR_WAKEUP_PIN2 (PWR_CSR_EWUP2) /*!< WKUP pin 2 : PC13 */
  146. #if defined(PWR_CSR_EWUP3)
  147. #define LL_PWR_WAKEUP_PIN3 (PWR_CSR_EWUP3) /*!< WKUP pin 3 : PE6 or PA2 according to device */
  148. #endif /* PWR_CSR_EWUP3 */
  149. /**
  150. * @}
  151. */
  152. /**
  153. * @}
  154. */
  155. /* Exported macro ------------------------------------------------------------*/
  156. /** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
  157. * @{
  158. */
  159. /** @defgroup PWR_LL_EM_WRITE_READ Common write and read registers Macros
  160. * @{
  161. */
  162. /**
  163. * @brief Write a value in PWR register
  164. * @param __REG__ Register to be written
  165. * @param __VALUE__ Value to be written in the register
  166. * @retval None
  167. */
  168. #define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
  169. /**
  170. * @brief Read a value in PWR register
  171. * @param __REG__ Register to be read
  172. * @retval Register value
  173. */
  174. #define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
  175. /**
  176. * @}
  177. */
  178. /**
  179. * @}
  180. */
  181. /* Exported functions --------------------------------------------------------*/
  182. /** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
  183. * @{
  184. */
  185. /** @defgroup PWR_LL_EF_Configuration Configuration
  186. * @{
  187. */
  188. /**
  189. * @brief Switch the regulator from main mode to low-power mode
  190. * @rmtoll CR LPRUN LL_PWR_EnableLowPowerRunMode
  191. * @note Remind to set the regulator to low power before enabling
  192. * LowPower run mode (bit @ref LL_PWR_REGU_LPMODES_LOW_POWER).
  193. * @retval None
  194. */
  195. __STATIC_INLINE void LL_PWR_EnableLowPowerRunMode(void)
  196. {
  197. SET_BIT(PWR->CR, PWR_CR_LPRUN);
  198. }
  199. /**
  200. * @brief Switch the regulator from low-power mode to main mode
  201. * @rmtoll CR LPRUN LL_PWR_DisableLowPowerRunMode
  202. * @retval None
  203. */
  204. __STATIC_INLINE void LL_PWR_DisableLowPowerRunMode(void)
  205. {
  206. CLEAR_BIT(PWR->CR, PWR_CR_LPRUN);
  207. }
  208. /**
  209. * @brief Check if the regulator is in low-power mode
  210. * @rmtoll CR LPRUN LL_PWR_IsEnabledLowPowerRunMode
  211. * @retval State of bit (1 or 0).
  212. */
  213. __STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRunMode(void)
  214. {
  215. return (READ_BIT(PWR->CR, PWR_CR_LPRUN) == (PWR_CR_LPRUN));
  216. }
  217. /**
  218. * @brief Set voltage regulator to low-power and switch from
  219. * run main mode to run low-power mode.
  220. * @rmtoll CR LPSDSR LL_PWR_EnterLowPowerRunMode\n
  221. * CR LPRUN LL_PWR_EnterLowPowerRunMode
  222. * @note This "high level" function is introduced to provide functional
  223. * compatibility with other families. Notice that the two registers
  224. * have to be written sequentially, so this function is not atomic.
  225. * To assure atomicity you can call separately the following functions:
  226. * - @ref LL_PWR_SetRegulModeLP(@ref LL_PWR_REGU_LPMODES_LOW_POWER);
  227. * - @ref LL_PWR_EnableLowPowerRunMode();
  228. * @retval None
  229. */
  230. __STATIC_INLINE void LL_PWR_EnterLowPowerRunMode(void)
  231. {
  232. SET_BIT(PWR->CR, PWR_CR_LPSDSR); /* => LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_LOW_POWER) */
  233. SET_BIT(PWR->CR, PWR_CR_LPRUN); /* => LL_PWR_EnableLowPowerRunMode() */
  234. }
  235. /**
  236. * @brief Set voltage regulator to main and switch from
  237. * run main mode to low-power mode.
  238. * @rmtoll CR LPSDSR LL_PWR_ExitLowPowerRunMode\n
  239. * CR LPRUN LL_PWR_ExitLowPowerRunMode
  240. * @note This "high level" function is introduced to provide functional
  241. * compatibility with other families. Notice that the two registers
  242. * have to be written sequentially, so this function is not atomic.
  243. * To assure atomicity you can call separately the following functions:
  244. * - @ref LL_PWR_DisableLowPowerRunMode();
  245. * - @ref LL_PWR_SetRegulModeLP(@ref LL_PWR_REGU_LPMODES_MAIN);
  246. * @retval None
  247. */
  248. __STATIC_INLINE void LL_PWR_ExitLowPowerRunMode(void)
  249. {
  250. CLEAR_BIT(PWR->CR, PWR_CR_LPRUN); /* => LL_PWR_DisableLowPowerRunMode() */
  251. CLEAR_BIT(PWR->CR, PWR_CR_LPSDSR); /* => LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_MAIN) */
  252. }
  253. /**
  254. * @brief Set the main internal regulator output voltage
  255. * @rmtoll CR VOS LL_PWR_SetRegulVoltageScaling
  256. * @param VoltageScaling This parameter can be one of the following values:
  257. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  258. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  259. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
  260. * @retval None
  261. */
  262. __STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling)
  263. {
  264. MODIFY_REG(PWR->CR, PWR_CR_VOS, VoltageScaling);
  265. }
  266. /**
  267. * @brief Get the main internal regulator output voltage
  268. * @rmtoll CR VOS LL_PWR_GetRegulVoltageScaling
  269. * @retval Returned value can be one of the following values:
  270. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
  271. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
  272. * @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
  273. */
  274. __STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void)
  275. {
  276. return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_VOS));
  277. }
  278. /**
  279. * @brief Enable access to the backup domain
  280. * @rmtoll CR DBP LL_PWR_EnableBkUpAccess
  281. * @retval None
  282. */
  283. __STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
  284. {
  285. SET_BIT(PWR->CR, PWR_CR_DBP);
  286. }
  287. /**
  288. * @brief Disable access to the backup domain
  289. * @rmtoll CR DBP LL_PWR_DisableBkUpAccess
  290. * @retval None
  291. */
  292. __STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
  293. {
  294. CLEAR_BIT(PWR->CR, PWR_CR_DBP);
  295. }
  296. /**
  297. * @brief Check if the backup domain is enabled
  298. * @rmtoll CR DBP LL_PWR_IsEnabledBkUpAccess
  299. * @retval State of bit (1 or 0).
  300. */
  301. __STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
  302. {
  303. return (READ_BIT(PWR->CR, PWR_CR_DBP) == (PWR_CR_DBP));
  304. }
  305. /**
  306. * @brief Set voltage regulator mode during low power modes
  307. * @rmtoll CR LPSDSR LL_PWR_SetRegulModeLP
  308. * @param RegulMode This parameter can be one of the following values:
  309. * @arg @ref LL_PWR_REGU_LPMODES_MAIN
  310. * @arg @ref LL_PWR_REGU_LPMODES_LOW_POWER
  311. * @retval None
  312. */
  313. __STATIC_INLINE void LL_PWR_SetRegulModeLP(uint32_t RegulMode)
  314. {
  315. MODIFY_REG(PWR->CR, PWR_CR_LPSDSR, RegulMode);
  316. }
  317. /**
  318. * @brief Get voltage regulator mode during low power modes
  319. * @rmtoll CR LPSDSR LL_PWR_GetRegulModeLP
  320. * @retval Returned value can be one of the following values:
  321. * @arg @ref LL_PWR_REGU_LPMODES_MAIN
  322. * @arg @ref LL_PWR_REGU_LPMODES_LOW_POWER
  323. */
  324. __STATIC_INLINE uint32_t LL_PWR_GetRegulModeLP(void)
  325. {
  326. return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_LPSDSR));
  327. }
  328. #if defined(PWR_CR_LPDS)
  329. /**
  330. * @brief Set voltage regulator mode during deep sleep mode
  331. * @rmtoll CR LPDS LL_PWR_SetRegulModeDS
  332. * @param RegulMode This parameter can be one of the following values:
  333. * @arg @ref LL_PWR_REGU_DSMODE_MAIN
  334. * @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER
  335. * @retval None
  336. */
  337. __STATIC_INLINE void LL_PWR_SetRegulModeDS(uint32_t RegulMode)
  338. {
  339. MODIFY_REG(PWR->CR, PWR_CR_LPDS, RegulMode);
  340. }
  341. /**
  342. * @brief Get voltage regulator mode during deep sleep mode
  343. * @rmtoll CR LPDS LL_PWR_GetRegulModeDS
  344. * @retval Returned value can be one of the following values:
  345. * @arg @ref LL_PWR_REGU_DSMODE_MAIN
  346. * @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER
  347. */
  348. __STATIC_INLINE uint32_t LL_PWR_GetRegulModeDS(void)
  349. {
  350. return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_LPDS));
  351. }
  352. #endif /* PWR_CR_LPDS */
  353. /**
  354. * @brief Set power down mode when CPU enters deepsleep
  355. * @rmtoll CR PDDS LL_PWR_SetPowerMode
  356. * @param PDMode This parameter can be one of the following values:
  357. * @arg @ref LL_PWR_MODE_STOP
  358. * @arg @ref LL_PWR_MODE_STANDBY
  359. * @note Set the regulator to low power (bit @ref LL_PWR_REGU_LPMODES_LOW_POWER)
  360. * before setting MODE_STOP. If the regulator remains in "main mode",
  361. * it consumes more power without providing any additional feature.
  362. * In MODE_STANDBY the regulator is automatically off.
  363. * @retval None
  364. */
  365. __STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t PDMode)
  366. {
  367. MODIFY_REG(PWR->CR, PWR_CR_PDDS, PDMode);
  368. }
  369. /**
  370. * @brief Get power down mode when CPU enters deepsleep
  371. * @rmtoll CR PDDS LL_PWR_GetPowerMode
  372. * @retval Returned value can be one of the following values:
  373. * @arg @ref LL_PWR_MODE_STOP
  374. * @arg @ref LL_PWR_MODE_STANDBY
  375. */
  376. __STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void)
  377. {
  378. return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_PDDS));
  379. }
  380. #if defined(PWR_PVD_SUPPORT)
  381. /**
  382. * @brief Configure the voltage threshold detected by the Power Voltage Detector
  383. * @rmtoll CR PLS LL_PWR_SetPVDLevel
  384. * @param PVDLevel This parameter can be one of the following values:
  385. * @arg @ref LL_PWR_PVDLEVEL_0
  386. * @arg @ref LL_PWR_PVDLEVEL_1
  387. * @arg @ref LL_PWR_PVDLEVEL_2
  388. * @arg @ref LL_PWR_PVDLEVEL_3
  389. * @arg @ref LL_PWR_PVDLEVEL_4
  390. * @arg @ref LL_PWR_PVDLEVEL_5
  391. * @arg @ref LL_PWR_PVDLEVEL_6
  392. * @arg @ref LL_PWR_PVDLEVEL_7
  393. * @retval None
  394. */
  395. __STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
  396. {
  397. MODIFY_REG(PWR->CR, PWR_CR_PLS, PVDLevel);
  398. }
  399. /**
  400. * @brief Get the voltage threshold detection
  401. * @rmtoll CR PLS LL_PWR_GetPVDLevel
  402. * @retval Returned value can be one of the following values:
  403. * @arg @ref LL_PWR_PVDLEVEL_0
  404. * @arg @ref LL_PWR_PVDLEVEL_1
  405. * @arg @ref LL_PWR_PVDLEVEL_2
  406. * @arg @ref LL_PWR_PVDLEVEL_3
  407. * @arg @ref LL_PWR_PVDLEVEL_4
  408. * @arg @ref LL_PWR_PVDLEVEL_5
  409. * @arg @ref LL_PWR_PVDLEVEL_6
  410. * @arg @ref LL_PWR_PVDLEVEL_7
  411. */
  412. __STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
  413. {
  414. return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_PLS));
  415. }
  416. /**
  417. * @brief Enable Power Voltage Detector
  418. * @rmtoll CR PVDE LL_PWR_EnablePVD
  419. * @retval None
  420. */
  421. __STATIC_INLINE void LL_PWR_EnablePVD(void)
  422. {
  423. SET_BIT(PWR->CR, PWR_CR_PVDE);
  424. }
  425. /**
  426. * @brief Disable Power Voltage Detector
  427. * @rmtoll CR PVDE LL_PWR_DisablePVD
  428. * @retval None
  429. */
  430. __STATIC_INLINE void LL_PWR_DisablePVD(void)
  431. {
  432. CLEAR_BIT(PWR->CR, PWR_CR_PVDE);
  433. }
  434. /**
  435. * @brief Check if Power Voltage Detector is enabled
  436. * @rmtoll CR PVDE LL_PWR_IsEnabledPVD
  437. * @retval State of bit (1 or 0).
  438. */
  439. __STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
  440. {
  441. return (READ_BIT(PWR->CR, PWR_CR_PVDE) == (PWR_CR_PVDE));
  442. }
  443. #endif /* PWR_PVD_SUPPORT */
  444. /**
  445. * @brief Enable the WakeUp PINx functionality
  446. * @rmtoll CSR EWUP1 LL_PWR_EnableWakeUpPin\n
  447. * @rmtoll CSR EWUP2 LL_PWR_EnableWakeUpPin\n
  448. * @rmtoll CSR EWUP3 LL_PWR_EnableWakeUpPin
  449. * @param WakeUpPin This parameter can be one of the following values:
  450. * @arg @ref LL_PWR_WAKEUP_PIN1
  451. * @arg @ref LL_PWR_WAKEUP_PIN2
  452. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  453. *
  454. * (*) not available on all devices
  455. * @retval None
  456. */
  457. __STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
  458. {
  459. SET_BIT(PWR->CSR, WakeUpPin);
  460. }
  461. /**
  462. * @brief Disable the WakeUp PINx functionality
  463. * @rmtoll CSR EWUP1 LL_PWR_DisableWakeUpPin\n
  464. * @rmtoll CSR EWUP2 LL_PWR_DisableWakeUpPin\n
  465. * @rmtoll CSR EWUP3 LL_PWR_DisableWakeUpPin
  466. * @param WakeUpPin This parameter can be one of the following values:
  467. * @arg @ref LL_PWR_WAKEUP_PIN1
  468. * @arg @ref LL_PWR_WAKEUP_PIN2
  469. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  470. *
  471. * (*) not available on all devices
  472. * @retval None
  473. */
  474. __STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
  475. {
  476. CLEAR_BIT(PWR->CSR, WakeUpPin);
  477. }
  478. /**
  479. * @brief Check if the WakeUp PINx functionality is enabled
  480. * @rmtoll CSR EWUP1 LL_PWR_IsEnabledWakeUpPin\n
  481. * @rmtoll CSR EWUP2 LL_PWR_IsEnabledWakeUpPin\n
  482. * @rmtoll CSR EWUP3 LL_PWR_IsEnabledWakeUpPin
  483. * @param WakeUpPin This parameter can be one of the following values:
  484. * @arg @ref LL_PWR_WAKEUP_PIN1
  485. * @arg @ref LL_PWR_WAKEUP_PIN2
  486. * @arg @ref LL_PWR_WAKEUP_PIN3 (*)
  487. *
  488. * (*) not available on all devices
  489. * @retval State of bit (1 or 0).
  490. */
  491. __STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
  492. {
  493. return (READ_BIT(PWR->CSR, WakeUpPin) == (WakeUpPin));
  494. }
  495. /**
  496. * @brief Enable ultra low-power mode by enabling VREFINT switch off in low-power modes
  497. * @rmtoll CR ULP LL_PWR_EnableUltraLowPower
  498. * @retval None
  499. */
  500. __STATIC_INLINE void LL_PWR_EnableUltraLowPower(void)
  501. {
  502. SET_BIT(PWR->CR, PWR_CR_ULP);
  503. }
  504. /**
  505. * @brief Disable ultra low-power mode by disabling VREFINT switch off in low-power modes
  506. * @rmtoll CR ULP LL_PWR_DisableUltraLowPower
  507. * @retval None
  508. */
  509. __STATIC_INLINE void LL_PWR_DisableUltraLowPower(void)
  510. {
  511. CLEAR_BIT(PWR->CR, PWR_CR_ULP);
  512. }
  513. /**
  514. * @brief Check if ultra low-power mode is enabled by checking if VREFINT switch off in low-power modes is enabled
  515. * @rmtoll CR ULP LL_PWR_IsEnabledUltraLowPower
  516. * @retval State of bit (1 or 0).
  517. */
  518. __STATIC_INLINE uint32_t LL_PWR_IsEnabledUltraLowPower(void)
  519. {
  520. return (READ_BIT(PWR->CR, PWR_CR_ULP) == (PWR_CR_ULP));
  521. }
  522. /**
  523. * @brief Enable fast wakeup by ignoring VREFINT startup time when exiting from low-power mode
  524. * @rmtoll CR FWU LL_PWR_EnableFastWakeUp
  525. * @note Works in conjunction with ultra low power mode.
  526. * @retval None
  527. */
  528. __STATIC_INLINE void LL_PWR_EnableFastWakeUp(void)
  529. {
  530. SET_BIT(PWR->CR, PWR_CR_FWU);
  531. }
  532. /**
  533. * @brief Disable fast wakeup by waiting VREFINT startup time when exiting from low-power mode
  534. * @rmtoll CR FWU LL_PWR_DisableFastWakeUp
  535. * @note Works in conjunction with ultra low power mode.
  536. * @retval None
  537. */
  538. __STATIC_INLINE void LL_PWR_DisableFastWakeUp(void)
  539. {
  540. CLEAR_BIT(PWR->CR, PWR_CR_FWU);
  541. }
  542. /**
  543. * @brief Check if fast wakeup is enabled by checking if VREFINT startup time when exiting from low-power mode is ignored
  544. * @rmtoll CR FWU LL_PWR_IsEnabledFastWakeUp
  545. * @retval State of bit (1 or 0).
  546. */
  547. __STATIC_INLINE uint32_t LL_PWR_IsEnabledFastWakeUp(void)
  548. {
  549. return (READ_BIT(PWR->CR, PWR_CR_FWU) == (PWR_CR_FWU));
  550. }
  551. /**
  552. * @brief Enable non-volatile memory (Flash and EEPROM) keeping off feature when exiting from low-power mode
  553. * @rmtoll CR DS_EE_KOFF LL_PWR_EnableNVMKeptOff
  554. * @note When enabled, after entering low-power mode (Stop or Standby only), if RUN_PD of FLASH_ACR register
  555. * is also set, the Flash memory will not be woken up when exiting from deepsleep mode.
  556. * When enabled, the EEPROM will not be woken up when exiting from low-power mode (if the bit RUN_PD is set)
  557. * @retval None
  558. */
  559. __STATIC_INLINE void LL_PWR_EnableNVMKeptOff(void)
  560. {
  561. SET_BIT(PWR->CR, PWR_CR_DSEEKOFF);
  562. }
  563. /**
  564. * @brief Disable non-volatile memory (Flash and EEPROM) keeping off feature when exiting from low-power mode
  565. * @rmtoll CR DS_EE_KOFF LL_PWR_DisableNVMKeptOff
  566. * @note When disabled, Flash memory is woken up when exiting from deepsleep mode even if the bit RUN_PD is set
  567. * @retval None
  568. */
  569. __STATIC_INLINE void LL_PWR_DisableNVMKeptOff(void)
  570. {
  571. CLEAR_BIT(PWR->CR, PWR_CR_DSEEKOFF);
  572. }
  573. /**
  574. * @brief Check if non-volatile memory (Flash and EEPROM) keeping off feature when exiting from low-power mode is enabled
  575. * @rmtoll CR DS_EE_KOFF LL_PWR_IsEnabledNVMKeptOff
  576. * @retval State of bit (1 or 0).
  577. */
  578. __STATIC_INLINE uint32_t LL_PWR_IsEnabledNVMKeptOff(void)
  579. {
  580. return (READ_BIT(PWR->CR, PWR_CR_DSEEKOFF) == (PWR_CR_DSEEKOFF));
  581. }
  582. /**
  583. * @}
  584. */
  585. /** @defgroup PWR_LL_EF_FLAG_Management FLAG_Management
  586. * @{
  587. */
  588. /**
  589. * @brief Get Wake-up Flag
  590. * @rmtoll CSR WUF LL_PWR_IsActiveFlag_WU
  591. * @retval State of bit (1 or 0).
  592. */
  593. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU(void)
  594. {
  595. return (READ_BIT(PWR->CSR, PWR_CSR_WUF) == (PWR_CSR_WUF));
  596. }
  597. /**
  598. * @brief Get Standby Flag
  599. * @rmtoll CSR SBF LL_PWR_IsActiveFlag_SB
  600. * @retval State of bit (1 or 0).
  601. */
  602. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SB(void)
  603. {
  604. return (READ_BIT(PWR->CSR, PWR_CSR_SBF) == (PWR_CSR_SBF));
  605. }
  606. #if defined(PWR_PVD_SUPPORT)
  607. /**
  608. * @brief Indicate whether VDD voltage is below the selected PVD threshold
  609. * @rmtoll CSR PVDO LL_PWR_IsActiveFlag_PVDO
  610. * @retval State of bit (1 or 0).
  611. */
  612. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
  613. {
  614. return (READ_BIT(PWR->CSR, PWR_CSR_PVDO) == (PWR_CSR_PVDO));
  615. }
  616. #endif /* PWR_PVD_SUPPORT */
  617. #if defined(PWR_CSR_VREFINTRDYF)
  618. /**
  619. * @brief Get Internal Reference VrefInt Flag
  620. * @rmtoll CSR VREFINTRDYF LL_PWR_IsActiveFlag_VREFINTRDY
  621. * @retval State of bit (1 or 0).
  622. */
  623. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VREFINTRDY(void)
  624. {
  625. return (READ_BIT(PWR->CSR, PWR_CSR_VREFINTRDYF) == (PWR_CSR_VREFINTRDYF));
  626. }
  627. #endif /* PWR_CSR_VREFINTRDYF */
  628. /**
  629. * @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
  630. * @rmtoll CSR VOSF LL_PWR_IsActiveFlag_VOSF
  631. * @retval State of bit (1 or 0).
  632. */
  633. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOSF(void)
  634. {
  635. return (READ_BIT(PWR->CSR, LL_PWR_CSR_VOS) == (LL_PWR_CSR_VOS));
  636. }
  637. /**
  638. * @brief Indicate whether the regulator is ready in main mode or is in low-power mode
  639. * @rmtoll CSR REGLPF LL_PWR_IsActiveFlag_REGLPF
  640. * @note Take care, return value "0" means the regulator is ready. Return value "1" means the output voltage range is still changing.
  641. * @retval State of bit (1 or 0).
  642. */
  643. __STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_REGLPF(void)
  644. {
  645. return (READ_BIT(PWR->CSR, PWR_CSR_REGLPF) == (PWR_CSR_REGLPF));
  646. }
  647. /**
  648. * @brief Clear Standby Flag
  649. * @rmtoll CR CSBF LL_PWR_ClearFlag_SB
  650. * @retval None
  651. */
  652. __STATIC_INLINE void LL_PWR_ClearFlag_SB(void)
  653. {
  654. SET_BIT(PWR->CR, PWR_CR_CSBF);
  655. }
  656. /**
  657. * @brief Clear Wake-up Flags
  658. * @rmtoll CR CWUF LL_PWR_ClearFlag_WU
  659. * @retval None
  660. */
  661. __STATIC_INLINE void LL_PWR_ClearFlag_WU(void)
  662. {
  663. SET_BIT(PWR->CR, PWR_CR_CWUF);
  664. }
  665. #if defined(USE_FULL_LL_DRIVER)
  666. /** @defgroup PWR_LL_EF_Init De-initialization function
  667. * @{
  668. */
  669. ErrorStatus LL_PWR_DeInit(void);
  670. /**
  671. * @}
  672. */
  673. #endif /* USE_FULL_LL_DRIVER */
  674. /**
  675. * @}
  676. */
  677. /**
  678. * @}
  679. */
  680. /**
  681. * @}
  682. */
  683. #endif /* defined(PWR) */
  684. /**
  685. * @}
  686. */
  687. #ifdef __cplusplus
  688. }
  689. #endif
  690. #endif /* __STM32L0xx_LL_PWR_H */
  691. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/