Rev 50 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 50 | Rev 77 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32l1xx_hal_pwr_ex.c |
3 | * @file stm32l1xx_hal_pwr_ex.c |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Extended PWR HAL module driver. |
5 | * @brief Extended PWR HAL module driver. |
6 | * This file provides firmware functions to manage the following |
6 | * This file provides firmware functions to manage the following |
7 | * functionalities of the Power Controller (PWR) peripheral: |
7 | * functionalities of the Power Controller (PWR) peripheral: |
8 | * + Extended Initialization and de-initialization functions |
8 | * + Extended Initialization and de-initialization functions |
9 | * + Extended Peripheral Control functions |
9 | * + Extended Peripheral Control functions |
10 | * |
10 | * |
11 | ****************************************************************************** |
11 | ****************************************************************************** |
12 | * @attention |
12 | * @attention |
13 | * |
13 | * |
14 | * <h2><center>© Copyright (c) 2017 STMicroelectronics. |
14 | * Copyright (c) 2017 STMicroelectronics. |
15 | * All rights reserved.</center></h2> |
15 | * All rights reserved. |
16 | * |
16 | * |
17 | * This software component is licensed by ST under BSD 3-Clause license, |
17 | * This software is licensed under terms that can be found in the LICENSE file |
18 | * the "License"; You may not use this file except in compliance with the |
18 | * in the root directory of this software component. |
19 | * License. You may obtain a copy of the License at: |
19 | * If no LICENSE file comes with this software, it is provided AS-IS. |
20 | * opensource.org/licenses/BSD-3-Clause |
20 | * |
21 | * |
21 | ****************************************************************************** |
22 | ****************************************************************************** |
22 | */ |
23 | */ |
23 | |
24 | 24 | /* Includes ------------------------------------------------------------------*/ |
|
25 | /* Includes ------------------------------------------------------------------*/ |
25 | #include "stm32l1xx_hal.h" |
26 | #include "stm32l1xx_hal.h" |
26 | |
27 | 27 | /** @addtogroup STM32L1xx_HAL_Driver |
|
28 | /** @addtogroup STM32L1xx_HAL_Driver |
28 | * @{ |
29 | * @{ |
29 | */ |
30 | */ |
30 | |
31 | 31 | /** @defgroup PWREx PWREx |
|
32 | /** @defgroup PWREx PWREx |
32 | * @brief PWR HAL module driver |
33 | * @brief PWR HAL module driver |
33 | * @{ |
34 | * @{ |
34 | */ |
35 | */ |
35 | |
36 | 36 | #ifdef HAL_PWR_MODULE_ENABLED |
|
37 | #ifdef HAL_PWR_MODULE_ENABLED |
37 | |
38 | 38 | /* Private typedef -----------------------------------------------------------*/ |
|
39 | /* Private typedef -----------------------------------------------------------*/ |
39 | /* Private define ------------------------------------------------------------*/ |
40 | /* Private define ------------------------------------------------------------*/ |
40 | /* Private macro -------------------------------------------------------------*/ |
41 | /* Private macro -------------------------------------------------------------*/ |
41 | /* Private variables ---------------------------------------------------------*/ |
42 | /* Private variables ---------------------------------------------------------*/ |
42 | /* Private function prototypes -----------------------------------------------*/ |
43 | /* Private function prototypes -----------------------------------------------*/ |
43 | /* Private functions ---------------------------------------------------------*/ |
44 | /* Private functions ---------------------------------------------------------*/ |
44 | |
45 | 45 | /** @defgroup PWREx_Exported_Functions PWREx Exported Functions |
|
46 | /** @defgroup PWREx_Exported_Functions PWREx Exported Functions |
46 | * @{ |
47 | * @{ |
47 | */ |
48 | */ |
48 | |
49 | 49 | /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions |
|
50 | /** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions |
50 | * @brief Low Power modes configuration functions |
51 | * @brief Low Power modes configuration functions |
51 | * |
52 | * |
52 | @verbatim |
53 | @verbatim |
53 | |
54 | 54 | =============================================================================== |
|
55 | =============================================================================== |
55 | ##### Peripheral extended features functions ##### |
56 | ##### Peripheral extended features functions ##### |
56 | =============================================================================== |
57 | =============================================================================== |
57 | @endverbatim |
58 | @endverbatim |
58 | * @{ |
59 | * @{ |
59 | */ |
60 | */ |
60 | |
61 | 61 | /** |
|
62 | /** |
62 | * @brief Return Voltage Scaling Range. |
63 | * @brief Return Voltage Scaling Range. |
63 | * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3) |
64 | * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3) |
64 | */ |
65 | */ |
65 | uint32_t HAL_PWREx_GetVoltageRange(void) |
66 | uint32_t HAL_PWREx_GetVoltageRange(void) |
66 | { |
67 | { |
67 | return (PWR->CR & PWR_CR_VOS); |
68 | return (PWR->CR & PWR_CR_VOS); |
68 | } |
69 | } |
69 | |
70 | 70 | ||
71 | 71 | /** |
|
72 | /** |
72 | * @brief Enables the Fast WakeUp from Ultra Low Power mode. |
73 | * @brief Enables the Fast WakeUp from Ultra Low Power mode. |
73 | * @note This bit works in conjunction with ULP bit. |
74 | * @note This bit works in conjunction with ULP bit. |
74 | * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when |
75 | * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when |
75 | * exiting from low power mode. |
76 | * exiting from low power mode. |
76 | * @retval None |
77 | * @retval None |
77 | */ |
78 | */ |
78 | void HAL_PWREx_EnableFastWakeUp(void) |
79 | void HAL_PWREx_EnableFastWakeUp(void) |
79 | { |
80 | { |
80 | /* Enable the fast wake up */ |
81 | /* Enable the fast wake up */ |
81 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE; |
82 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE; |
82 | } |
83 | } |
83 | |
84 | 84 | /** |
|
85 | /** |
85 | * @brief Disables the Fast WakeUp from Ultra Low Power mode. |
86 | * @brief Disables the Fast WakeUp from Ultra Low Power mode. |
86 | * @retval None |
87 | * @retval None |
87 | */ |
88 | */ |
88 | void HAL_PWREx_DisableFastWakeUp(void) |
89 | void HAL_PWREx_DisableFastWakeUp(void) |
89 | { |
90 | { |
90 | /* Disable the fast wake up */ |
91 | /* Disable the fast wake up */ |
91 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE; |
92 | *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE; |
92 | } |
93 | } |
93 | |
94 | 94 | /** |
|
95 | /** |
95 | * @brief Enables the Ultra Low Power mode |
96 | * @brief Enables the Ultra Low Power mode |
96 | * @retval None |
97 | * @retval None |
97 | */ |
98 | */ |
98 | void HAL_PWREx_EnableUltraLowPower(void) |
99 | void HAL_PWREx_EnableUltraLowPower(void) |
99 | { |
100 | { |
100 | /* Enable the Ultra Low Power mode */ |
101 | /* Enable the Ultra Low Power mode */ |
101 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE; |
102 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE; |
102 | } |
103 | } |
103 | |
104 | 104 | /** |
|
105 | /** |
105 | * @brief Disables the Ultra Low Power mode |
106 | * @brief Disables the Ultra Low Power mode |
106 | * @retval None |
107 | * @retval None |
107 | */ |
108 | */ |
108 | void HAL_PWREx_DisableUltraLowPower(void) |
109 | void HAL_PWREx_DisableUltraLowPower(void) |
109 | { |
110 | { |
110 | /* Disable the Ultra Low Power mode */ |
111 | /* Disable the Ultra Low Power mode */ |
111 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE; |
112 | *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE; |
112 | } |
113 | } |
113 | |
114 | 114 | /** |
|
115 | /** |
115 | * @brief Enters the Low Power Run mode. |
116 | * @brief Enters the Low Power Run mode. |
116 | * @note Low power run mode can only be entered when VCORE is in range 2. |
117 | * @note Low power run mode can only be entered when VCORE is in range 2. |
117 | * In addition, the dynamic voltage scaling must not be used when Low |
118 | * In addition, the dynamic voltage scaling must not be used when Low |
118 | * power run mode is selected. Only Stop and Sleep modes with regulator |
119 | * power run mode is selected. Only Stop and Sleep modes with regulator |
119 | * configured in Low power mode is allowed when Low power run mode is |
120 | * configured in Low power mode is allowed when Low power run mode is |
120 | * selected. |
121 | * selected. |
121 | * @note In Low power run mode, all I/O pins keep the same state as in Run mode. |
122 | * @note In Low power run mode, all I/O pins keep the same state as in Run mode. |
122 | * @retval None |
123 | * @retval None |
123 | */ |
124 | */ |
124 | void HAL_PWREx_EnableLowPowerRunMode(void) |
125 | void HAL_PWREx_EnableLowPowerRunMode(void) |
125 | { |
126 | { |
126 | /* Enters the Low Power Run mode */ |
127 | /* Enters the Low Power Run mode */ |
127 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE; |
128 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE; |
128 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE; |
129 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE; |
129 | } |
130 | } |
130 | |
131 | 131 | /** |
|
132 | /** |
132 | * @brief Exits the Low Power Run mode. |
133 | * @brief Exits the Low Power Run mode. |
133 | * @retval None |
134 | * @retval None |
134 | */ |
135 | */ |
135 | HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void) |
136 | HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void) |
136 | { |
137 | { |
137 | /* Exits the Low Power Run mode */ |
138 | /* Exits the Low Power Run mode */ |
138 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE; |
139 | *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE; |
139 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE; |
140 | *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE; |
140 | return HAL_OK; |
141 | return HAL_OK; |
141 | } |
142 | } |
142 | |
143 | 143 | /** |
|
144 | /** |
144 | * @} |
145 | * @} |
145 | */ |
146 | */ |
146 | |
147 | 147 | /** |
|
148 | /** |
148 | * @} |
149 | * @} |
149 | */ |
150 | */ |
150 | |
151 | 151 | #endif /* HAL_PWR_MODULE_ENABLED */ |
|
152 | #endif /* HAL_PWR_MODULE_ENABLED */ |
152 | /** |
153 | /** |
153 | * @} |
154 | * @} |
154 | */ |
155 | */ |
155 | |
156 | 156 | /** |
|
157 | /** |
157 | * @} |
158 | * @} |
158 | */ |
159 | */ |
- | |
160 | - | ||
161 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |