annotate f103c8/Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c @ 6:ca42336826bd default tip

working on clock sources
author cin
date Mon, 23 Jan 2017 02:40:17 +0300
parents 0c59e7a7782a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
1 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
2 ******************************************************************************
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
3 * @file stm32f1xx_hal_pwr.c
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
4 * @author MCD Application Team
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
5 * @version V1.0.4
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
6 * @date 29-April-2016
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
7 * @brief PWR HAL module driver.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
8 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
9 * This file provides firmware functions to manage the following
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
10 * functionalities of the Power Controller (PWR) peripheral:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
11 * + Initialization/de-initialization functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
12 * + Peripheral Control functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
13 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
14 ******************************************************************************
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
15 * @attention
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
16 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
17 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
18 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
19 * Redistribution and use in source and binary forms, with or without modification,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
20 * are permitted provided that the following conditions are met:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
21 * 1. Redistributions of source code must retain the above copyright notice,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
22 * this list of conditions and the following disclaimer.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
23 * 2. Redistributions in binary form must reproduce the above copyright notice,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
24 * this list of conditions and the following disclaimer in the documentation
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
25 * and/or other materials provided with the distribution.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
26 * 3. Neither the name of STMicroelectronics nor the names of its contributors
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
27 * may be used to endorse or promote products derived from this software
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
28 * without specific prior written permission.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
29 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
31 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
33 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
36 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
37 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
38 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
39 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
40 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
41 ******************************************************************************
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
42 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
43
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
44 /* Includes ------------------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
45 #include "stm32f1xx_hal.h"
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
46
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
47 /** @addtogroup STM32F1xx_HAL_Driver
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
48 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
49 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
50
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
51 /** @defgroup PWR PWR
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
52 * @brief PWR HAL module driver
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
53 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
54 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
55
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
56 #ifdef HAL_PWR_MODULE_ENABLED
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
57
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
58 /* Private typedef -----------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
59 /* Private define ------------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
60
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
61 /** @defgroup PWR_Private_Constants PWR Private Constants
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
62 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
63 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
64
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
65 /** @defgroup PWR_PVD_Mode_Mask PWR PVD Mode Mask
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
66 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
67 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
68 #define PVD_MODE_IT ((uint32_t)0x00010000)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
69 #define PVD_MODE_EVT ((uint32_t)0x00020000)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
70 #define PVD_RISING_EDGE ((uint32_t)0x00000001)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
71 #define PVD_FALLING_EDGE ((uint32_t)0x00000002)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
72 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
73 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
74 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
75
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
76
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
77 /** @defgroup PWR_register_alias_address PWR Register alias address
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
78 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
79 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
80 /* ------------- PWR registers bit address in the alias region ---------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
81 #define PWR_OFFSET (PWR_BASE - PERIPH_BASE)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
82 #define PWR_CR_OFFSET 0x00
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
83 #define PWR_CSR_OFFSET 0x04
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
84 #define PWR_CR_OFFSET_BB (PWR_OFFSET + PWR_CR_OFFSET)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
85 #define PWR_CSR_OFFSET_BB (PWR_OFFSET + PWR_CSR_OFFSET)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
86 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
87 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
88 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
89
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
90 /** @defgroup PWR_CR_register_alias PWR CR Register alias address
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
91 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
92 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
93 /* --- CR Register ---*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
94 /* Alias word address of LPSDSR bit */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
95 #define LPSDSR_BIT_NUMBER POSITION_VAL(PWR_CR_LPDS)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
96 #define CR_LPSDSR_BB ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32) + (LPSDSR_BIT_NUMBER * 4)))
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
97
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
98 /* Alias word address of DBP bit */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
99 #define DBP_BIT_NUMBER POSITION_VAL(PWR_CR_DBP)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
100 #define CR_DBP_BB ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32) + (DBP_BIT_NUMBER * 4)))
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
101
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
102 /* Alias word address of PVDE bit */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
103 #define PVDE_BIT_NUMBER POSITION_VAL(PWR_CR_PVDE)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
104 #define CR_PVDE_BB ((uint32_t)(PERIPH_BB_BASE + (PWR_CR_OFFSET_BB * 32) + (PVDE_BIT_NUMBER * 4)))
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
105
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
106 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
107 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
108 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
109
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
110 /** @defgroup PWR_CSR_register_alias PWR CSR Register alias address
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
111 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
112 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
113
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
114 /* --- CSR Register ---*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
115 /* Alias word address of EWUP1 bit */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
116 #define CSR_EWUP_BB(VAL) ((uint32_t)(PERIPH_BB_BASE + (PWR_CSR_OFFSET_BB * 32) + (POSITION_VAL(VAL) * 4)))
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
117 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
118 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
119 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
120
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
121 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
122 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
123 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
124
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
125 /* Private variables ---------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
126 /* Private function prototypes -----------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
127 /** @defgroup PWR_Private_Functions PWR Private Functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
128 * brief WFE cortex command overloaded for HAL_PWR_EnterSTOPMode usage only (see Workaround section)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
129 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
130 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
131 static void PWR_OverloadWfe(void);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
132
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
133 /* Private functions ---------------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
134 __NOINLINE
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
135 static void PWR_OverloadWfe(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
136 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
137 __asm volatile( "wfe" );
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
138 __asm volatile( "nop" );
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
139 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
140
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
141 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
142 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
143 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
144
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
145
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
146 /** @defgroup PWR_Exported_Functions PWR Exported Functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
147 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
148 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
149
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
150 /** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
151 * @brief Initialization and de-initialization functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
152 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
153 @verbatim
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
154 ===============================================================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
155 ##### Initialization and de-initialization functions #####
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
156 ===============================================================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
157 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
158 After reset, the backup domain (RTC registers, RTC backup data
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
159 registers) is protected against possible unwanted
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
160 write accesses.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
161 To enable access to the RTC Domain and RTC registers, proceed as follows:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
162 (+) Enable the Power Controller (PWR) APB1 interface clock using the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
163 __HAL_RCC_PWR_CLK_ENABLE() macro.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
164 (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
165
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
166 @endverbatim
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
167 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
168 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
169
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
170 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
171 * @brief Deinitializes the PWR peripheral registers to their default reset values.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
172 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
173 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
174 void HAL_PWR_DeInit(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
175 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
176 __HAL_RCC_PWR_FORCE_RESET();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
177 __HAL_RCC_PWR_RELEASE_RESET();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
178 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
179
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
180 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
181 * @brief Enables access to the backup domain (RTC registers, RTC
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
182 * backup data registers ).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
183 * @note If the HSE divided by 128 is used as the RTC clock, the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
184 * Backup Domain Access should be kept enabled.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
185 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
186 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
187 void HAL_PWR_EnableBkUpAccess(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
188 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
189 /* Enable access to RTC and backup registers */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
190 *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
191 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
192
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
193 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
194 * @brief Disables access to the backup domain (RTC registers, RTC
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
195 * backup data registers).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
196 * @note If the HSE divided by 128 is used as the RTC clock, the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
197 * Backup Domain Access should be kept enabled.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
198 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
199 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
200 void HAL_PWR_DisableBkUpAccess(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
201 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
202 /* Disable access to RTC and backup registers */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
203 *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
204 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
205
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
206 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
207 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
208 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
209
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
210 /** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
211 * @brief Low Power modes configuration functions
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
212 *
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
213 @verbatim
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
214 ===============================================================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
215 ##### Peripheral Control functions #####
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
216 ===============================================================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
217
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
218 *** PVD configuration ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
219 =========================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
220 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
221 (+) The PVD is used to monitor the VDD power supply by comparing it to a
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
222 threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
223
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
224 (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
225 than the PVD threshold. This event is internally connected to the EXTI
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
226 line16 and can generate an interrupt if enabled. This is done through
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
227 __HAL_PVD_EXTI_ENABLE_IT() macro.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
228 (+) The PVD is stopped in Standby mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
229
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
230 *** WakeUp pin configuration ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
231 ================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
232 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
233 (+) WakeUp pin is used to wake up the system from Standby mode. This pin is
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
234 forced in input pull-down configuration and is active on rising edges.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
235 (+) There is one WakeUp pin:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
236 WakeUp Pin 1 on PA.00.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
237
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
238 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
239
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
240 *** Low Power modes configuration ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
241 =====================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
242 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
243 The device features 3 low-power modes:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
244 (+) Sleep mode: CPU clock off, all peripherals including Cortex-M3 core peripherals like
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
245 NVIC, SysTick, etc. are kept running
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
246 (+) Stop mode: All clocks are stopped
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
247 (+) Standby mode: 1.8V domain powered off
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
248
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
249
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
250 *** Sleep mode ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
251 ==================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
252 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
253 (+) Entry:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
254 The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
255 functions with
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
256 (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
257 (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
258
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
259 (+) Exit:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
260 (++) WFI entry mode, Any peripheral interrupt acknowledged by the nested vectored interrupt
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
261 controller (NVIC) can wake up the device from Sleep mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
262 (++) WFE entry mode, Any wakeup event can wake up the device from Sleep mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
263 (+++) Any peripheral interrupt w/o NVIC configuration & SEVONPEND bit set in the Cortex (HAL_PWR_EnableSEVOnPend)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
264 (+++) Any EXTI Line (Internal or External) configured in Event mode
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
265
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
266 *** Stop mode ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
267 =================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
268 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
269 The Stop mode is based on the Cortex-M3 deepsleep mode combined with peripheral
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
270 clock gating. The voltage regulator can be configured either in normal or low-power mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
271 In Stop mode, all clocks in the 1.8 V domain are stopped, the PLL, the HSI and the HSE RC
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
272 oscillators are disabled. SRAM and register contents are preserved.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
273 In Stop mode, all I/O pins keep the same state as in Run mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
274
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
275 (+) Entry:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
276 The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_REGULATOR_VALUE, PWR_SLEEPENTRY_WFx )
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
277 function with:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
278 (++) PWR_REGULATOR_VALUE= PWR_MAINREGULATOR_ON: Main regulator ON.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
279 (++) PWR_REGULATOR_VALUE= PWR_LOWPOWERREGULATOR_ON: Low Power regulator ON.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
280 (++) PWR_SLEEPENTRY_WFx= PWR_SLEEPENTRY_WFI: enter STOP mode with WFI instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
281 (++) PWR_SLEEPENTRY_WFx= PWR_SLEEPENTRY_WFE: enter STOP mode with WFE instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
282 (+) Exit:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
283 (++) WFI entry mode, Any EXTI Line (Internal or External) configured in Interrupt mode with NVIC configured
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
284 (++) WFE entry mode, Any EXTI Line (Internal or External) configured in Event mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
285
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
286 *** Standby mode ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
287 ====================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
288 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
289 The Standby mode allows to achieve the lowest power consumption. It is based on the
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
290 Cortex-M3 deepsleep mode, with the voltage regulator disabled. The 1.8 V domain is
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
291 consequently powered off. The PLL, the HSI oscillator and the HSE oscillator are also
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
292 switched off. SRAM and register contents are lost except for registers in the Backup domain
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
293 and Standby circuitry
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
294
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
295 (+) Entry:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
296 (++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
297 (+) Exit:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
298 (++) WKUP pin rising edge, RTC alarm event rising edge, external Reset in
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
299 NRSTpin, IWDG Reset
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
300
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
301 *** Auto-wakeup (AWU) from low-power mode ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
302 =============================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
303 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
304
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
305 (+) The MCU can be woken up from low-power mode by an RTC Alarm event,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
306 without depending on an external interrupt (Auto-wakeup mode).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
307
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
308 (+) RTC auto-wakeup (AWU) from the Stop and Standby modes
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
309
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
310 (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
311 configure the RTC to generate the RTC alarm using the HAL_RTC_SetAlarm_IT() function.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
312
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
313 *** PWR Workarounds linked to Silicon Limitation ***
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
314 ====================================================
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
315 [..]
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
316 Below the list of all silicon limitations known on STM32F1xx prouct.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
317
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
318 (#)Workarounds Implemented inside PWR HAL Driver
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
319 (##)Debugging Stop mode with WFE entry - overloaded the WFE by an internal function
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
320
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
321 @endverbatim
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
322 * @{
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
323 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
324
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
325 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
326 * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
327 * @param sConfigPVD: pointer to an PWR_PVDTypeDef structure that contains the configuration
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
328 * information for the PVD.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
329 * @note Refer to the electrical characteristics of your device datasheet for
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
330 * more details about the voltage threshold corresponding to each
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
331 * detection level.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
332 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
333 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
334 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
335 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
336 /* Check the parameters */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
337 assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
338 assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
339
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
340 /* Set PLS[7:5] bits according to PVDLevel value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
341 MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
342
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
343 /* Clear any previous config. Keep it clear if no event or IT mode is selected */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
344 __HAL_PWR_PVD_EXTI_DISABLE_EVENT();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
345 __HAL_PWR_PVD_EXTI_DISABLE_IT();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
346 __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
347 __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
348
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
349 /* Configure interrupt mode */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
350 if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
351 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
352 __HAL_PWR_PVD_EXTI_ENABLE_IT();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
353 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
354
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
355 /* Configure event mode */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
356 if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
357 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
358 __HAL_PWR_PVD_EXTI_ENABLE_EVENT();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
359 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
360
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
361 /* Configure the edge */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
362 if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
363 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
364 __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
365 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
366
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
367 if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
368 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
369 __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
370 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
371 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
372
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
373 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
374 * @brief Enables the Power Voltage Detector(PVD).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
375 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
376 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
377 void HAL_PWR_EnablePVD(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
378 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
379 /* Enable the power voltage detector */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
380 *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
381 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
382
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
383 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
384 * @brief Disables the Power Voltage Detector(PVD).
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
385 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
386 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
387 void HAL_PWR_DisablePVD(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
388 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
389 /* Disable the power voltage detector */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
390 *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
391 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
392
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
393 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
394 * @brief Enables the WakeUp PINx functionality.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
395 * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
396 * This parameter can be one of the following values:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
397 * @arg PWR_WAKEUP_PIN1
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
398 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
399 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
400 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
401 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
402 /* Check the parameter */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
403 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
404 /* Enable the EWUPx pin */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
405 *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)ENABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
406 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
407
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
408 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
409 * @brief Disables the WakeUp PINx functionality.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
410 * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
411 * This parameter can be one of the following values:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
412 * @arg PWR_WAKEUP_PIN1
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
413 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
414 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
415 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
416 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
417 /* Check the parameter */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
418 assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
419 /* Disable the EWUPx pin */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
420 *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)DISABLE;
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
421 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
422
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
423 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
424 * @brief Enters Sleep mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
425 * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
426 * @param Regulator: Regulator state as no effect in SLEEP mode - allows to support portability from legacy software
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
427 * @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
428 * When WFI entry is used, tick interrupt have to be disabled if not desired as
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
429 * the interrupt wake up source.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
430 * This parameter can be one of the following values:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
431 * @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
432 * @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
433 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
434 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
435 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
436 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
437 /* Check the parameters */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
438 /* No check on Regulator because parameter not used in SLEEP mode */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
439 assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
440
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
441 /* Clear SLEEPDEEP bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
442 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
443
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
444 /* Select SLEEP mode entry -------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
445 if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
446 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
447 /* Request Wait For Interrupt */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
448 __WFI();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
449 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
450 else
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
451 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
452 /* Request Wait For Event */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
453 __SEV();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
454 __WFE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
455 __WFE();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
456 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
457 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
458
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
459 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
460 * @brief Enters Stop mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
461 * @note In Stop mode, all I/O pins keep the same state as in Run mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
462 * @note When exiting Stop mode by using an interrupt or a wakeup event,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
463 * HSI RC oscillator is selected as system clock.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
464 * @note When the voltage regulator operates in low power mode, an additional
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
465 * startup delay is incurred when waking up from Stop mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
466 * By keeping the internal regulator ON during Stop mode, the consumption
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
467 * is higher although the startup time is reduced.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
468 * @param Regulator: Specifies the regulator state in Stop mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
469 * This parameter can be one of the following values:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
470 * @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
471 * @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
472 * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
473 * This parameter can be one of the following values:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
474 * @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
475 * @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
476 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
477 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
478 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
479 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
480 /* Check the parameters */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
481 assert_param(IS_PWR_REGULATOR(Regulator));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
482 assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
483
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
484 /* Clear PDDS bit in PWR register to specify entering in STOP mode when CPU enter in Deepsleep */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
485 CLEAR_BIT(PWR->CR, PWR_CR_PDDS);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
486
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
487 /* Select the voltage regulator mode by setting LPDS bit in PWR register according to Regulator parameter value */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
488 MODIFY_REG(PWR->CR, PWR_CR_LPDS, Regulator);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
489
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
490 /* Set SLEEPDEEP bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
491 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
492
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
493 /* Select Stop mode entry --------------------------------------------------*/
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
494 if(STOPEntry == PWR_STOPENTRY_WFI)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
495 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
496 /* Request Wait For Interrupt */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
497 __WFI();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
498 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
499 else
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
500 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
501 /* Request Wait For Event */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
502 __SEV();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
503 PWR_OverloadWfe(); /* WFE redefine locally */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
504 PWR_OverloadWfe(); /* WFE redefine locally */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
505 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
506 /* Reset SLEEPDEEP bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
507 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
508 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
509
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
510 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
511 * @brief Enters Standby mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
512 * @note In Standby mode, all I/O pins are high impedance except for:
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
513 * - Reset pad (still available)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
514 * - TAMPER pin if configured for tamper or calibration out.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
515 * - WKUP pin (PA0) if enabled.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
516 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
517 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
518 void HAL_PWR_EnterSTANDBYMode(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
519 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
520 /* Select Standby mode */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
521 SET_BIT(PWR->CR, PWR_CR_PDDS);
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
522
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
523 /* Set SLEEPDEEP bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
524 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
525
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
526 /* This option is used to ensure that store operations are completed */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
527 #if defined ( __CC_ARM)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
528 __force_stores();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
529 #endif
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
530 /* Request Wait For Interrupt */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
531 __WFI();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
532 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
533
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
534
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
535 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
536 * @brief Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
537 * @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
538 * re-enters SLEEP mode when an interruption handling is over.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
539 * Setting this bit is useful when the processor is expected to run only on
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
540 * interruptions handling.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
541 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
542 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
543 void HAL_PWR_EnableSleepOnExit(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
544 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
545 /* Set SLEEPONEXIT bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
546 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
547 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
548
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
549
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
550 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
551 * @brief Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
552 * @note Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
553 * re-enters SLEEP mode when an interruption handling is over.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
554 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
555 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
556 void HAL_PWR_DisableSleepOnExit(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
557 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
558 /* Clear SLEEPONEXIT bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
559 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
560 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
561
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
562
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
563 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
564 * @brief Enables CORTEX M3 SEVONPEND bit.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
565 * @note Sets SEVONPEND bit of SCR register. When this bit is set, this causes
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
566 * WFE to wake up when an interrupt moves from inactive to pended.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
567 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
568 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
569 void HAL_PWR_EnableSEVOnPend(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
570 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
571 /* Set SEVONPEND bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
572 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
573 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
574
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
575
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
576 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
577 * @brief Disables CORTEX M3 SEVONPEND bit.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
578 * @note Clears SEVONPEND bit of SCR register. When this bit is set, this causes
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
579 * WFE to wake up when an interrupt moves from inactive to pended.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
580 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
581 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
582 void HAL_PWR_DisableSEVOnPend(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
583 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
584 /* Clear SEVONPEND bit of Cortex System Control Register */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
585 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
586 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
587
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
588
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
589
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
590 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
591 * @brief This function handles the PWR PVD interrupt request.
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
592 * @note This API should be called under the PVD_IRQHandler().
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
593 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
594 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
595 void HAL_PWR_PVD_IRQHandler(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
596 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
597 /* Check PWR exti flag */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
598 if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
599 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
600 /* PWR PVD interrupt user callback */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
601 HAL_PWR_PVDCallback();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
602
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
603 /* Clear PWR Exti pending bit */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
604 __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
605 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
606 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
607
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
608 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
609 * @brief PWR PVD interrupt callback
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
610 * @retval None
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
611 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
612 __weak void HAL_PWR_PVDCallback(void)
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
613 {
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
614 /* NOTE : This function Should not be modified, when the callback is needed,
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
615 the HAL_PWR_PVDCallback could be implemented in the user file
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
616 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
617 }
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
618
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
619 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
620 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
621 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
622
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
623 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
624 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
625 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
626
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
627 #endif /* HAL_PWR_MODULE_ENABLED */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
628 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
629 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
630 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
631
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
632 /**
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
633 * @}
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
634 */
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
635
0c59e7a7782a Working on GPIO and RCC
cin
parents:
diff changeset
636 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/