libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
f7/pwr.h
Go to the documentation of this file.
1/** @defgroup pwr_defines PWR Defines
2
3@brief <b>Defined Constants and Types for the STM32F7xx Power Control</b>
4
5@ingroup STM32F7xx_defines
6
7@version 1.0.0
8
9@author @htmlonly &copy; @endhtmlonly 2017 Matthew Lai <m@matthewlai.ca>
10
11@date 12 March 2017
12
13LGPL License Terms @ref lgpl_license
14 */
15/*
16 * This file is part of the libopencm3 project.
17 *
18 * Copyright (C) 2017 Matthew Lai <m@matthewlai.ca>
19 *
20 * This library is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU Lesser General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
24 *
25 * This library is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public License
31 * along with this library. If not, see <http://www.gnu.org/licenses/>.
32 */
33
34#ifndef LIBOPENCM3_PWR_H
35#define LIBOPENCM3_PWR_H
36
37/**@{*/
38
39/** @defgroup pwr_registers PWR Registers
40 * @ingroup STM32F_pwr_defines
41@{*/
42/** Power control register (PWR_CR1) */
43#define PWR_CR1 MMIO32(POWER_CONTROL_BASE + 0x00)
44
45/** Power control/status register (PWR_CSR1) */
46#define PWR_CSR1 MMIO32(POWER_CONTROL_BASE + 0x04)
47
48/** Power control register 2 (PWR_CR2) */
49#define PWR_CR2 MMIO32(POWER_CONTROL_BASE + 0x08)
50
51/** Power control/status register 2 (PWR_CSR2) */
52#define PWR_CSR2 MMIO32(POWER_CONTROL_BASE + 0x0c)
53/**@}*/
54
55/** @defgroup pwr_cr1_defines PWR_CR1 values
56 * @ingroup STM32F_pwr_defines
57@{*/
58
59/* Bits [31:20]: Reserved, must be kept at reset value. */
60
61/** UDEN[19:18]: Under-drive enable in stop mode */
62#define PWR_CR1_UDEN_LSB 18
63/** @defgroup pwr_uden Under-drive enable in stop mode
64@ingroup STM32F_pwr_defines
65
66@{*/
67#define PWR_CR1_UDEN_DISABLED (0x0 << PWR_CR1_UDEN_LSB)
68#define PWR_CR1_UDEN_ENABLED (0x3 << PWR_CR1_UDEN_LSB)
69/**@}*/
70#define PWR_CR1_UDEN_MASK (0x3 << PWR_CR1_UDEN_LSB)
71
72/** ODSWEN: Over-drive switching enabled */
73#define PWR_CR1_ODSWEN (1 << 17)
74
75/** ODEN: Over-drive enable */
76#define PWR_CR1_ODEN (1 << 16)
77
78/* VOS[15:14]: Regulator voltage scaling output selection */
79#define PWR_CR1_VOS_LSB 14
80/** @defgroup pwr_vos Regulator voltage scaling output selection
81@ingroup STM32F_pwr_defines
82
83@{*/
84#define PWR_CR1_VOS_SCALE_3 (0x1 << PWR_CR1_VOS_LSB)
85#define PWR_CR1_VOS_SCALE_2 (0x2 << PWR_CR1_VOS_LSB)
86#define PWR_CR1_VOS_SCALE_1 (0x3 << PWR_CR1_VOS_LSB)
87/**@}*/
88#define PWR_CR1_VOS_MASK (0x3 << PWR_CR1_VOS_LSB)
89
90/** ADCDC1: Masks extra flash accesses by prefetch (see AN4073) */
91#define PWR_CR1_ADCDC1 (1 << 13)
92
93/* Bit 12: Reserved, must be kept at reset value. */
94
95/** MRUDS: Main regulator in deepsleep under-drive mode */
96#define PWR_CR1_MRUDS (1 << 11)
97
98/** LPUDS: Low-power regulator in deepsleep under-drive mode */
99#define PWR_CR1_LPUDS (1 << 10)
100
101/** FPDS: Flash power-down in Stop mode */
102#define PWR_CR1_FPDS (1 << 9)
103
104/** DBP: Disable backup domain write protection */
105#define PWR_CR1_DBP (1 << 8)
106
107/* PLS[7:5]: PVD level selection */
108#define PWR_CR1_PLS_LSB 5
109/** @defgroup pwr_pls PVD level selection
110@ingroup STM32F_pwr_defines
111
112@{*/
113#define PWR_CR1_PLS_2V0 (0x0 << PWR_CR_PLS_LSB)
114#define PWR_CR1_PLS_2V1 (0x1 << PWR_CR_PLS_LSB)
115#define PWR_CR1_PLS_2V3 (0x2 << PWR_CR_PLS_LSB)
116#define PWR_CR1_PLS_2V5 (0x3 << PWR_CR_PLS_LSB)
117#define PWR_CR1_PLS_2V6 (0x4 << PWR_CR_PLS_LSB)
118#define PWR_CR1_PLS_2V7 (0x5 << PWR_CR_PLS_LSB)
119#define PWR_CR1_PLS_2V8 (0x6 << PWR_CR_PLS_LSB)
120#define PWR_CR1_PLS_2V9 (0x7 << PWR_CR_PLS_LSB)
121/**@}*/
122#define PWR_CR1_PLS_MASK (0x7 << PWR_CR_PLS_LSB)
123
124/** PVDE: Power voltage detector enable */
125#define PWR_CR1_PVDE (1 << 4)
126
127/** CSBF: Clear standby flag */
128#define PWR_CR1_CSBF (1 << 3)
129
130/* Bit 2: Reserved, must be kept at reset value. */
131
132/** PDDS: Power down deepsleep */
133#define PWR_CR1_PDDS (1 << 1)
134
135/** LPDS: Low-power deepsleep */
136#define PWR_CR1_LPDS (1 << 0)
137/**@}*/
138
139/** @defgroup pwr_csr1_defines PWR_CSR1 values
140 * @ingroup STM32F_pwr_defines
141@{*/
142
143/* Bits [31:20]: Reserved, must be kept at reset value. */
144
145/* UDRDY[19:18]: Under-drive ready flag */
146#define PWR_CSR1_UDRDY_LSB 18
147/** @defgroup pwr_udrdy Under-drive ready flag
148@ingroup STM32F_pwr_defines
149
150@{*/
151#define PWR_CSR1_UDRDY_DISABLED (0x0 << PWR_CSR1_UDRDY_LSB)
152#define PWR_CSR1_UDRDY_ACTIVATED (0x3 << PWR_CSR1_UDRDY_LSB)
153/**@}*/
154#define PWR_CSR1_UDRDY_MASK (0x3 << PWR_CSR1_UDRDY_LSB)
155
156/** ODSWRDY: Over-drive mode switching ready */
157#define PWR_CSR1_ODSWRDY (1 << 17)
158
159/** ODRDY: Over-drive mode ready */
160#define PWR_CSR1_ODRDY (1 << 16)
161
162/* Bit 15: Reserved, must be kept at reset value. */
163
164/** VOSRDY: Regulator voltage scaling output selection ready bit */
165#define PWR_CSR1_VOSRDY (1 << 14)
166
167/* Bits [13:10]: Reserved, must be kept at reset value. */
168
169/** BRE: Backup regulator enable */
170#define PWR_CSR1_BRE (1 << 9)
171
172/** EIWUP: Enable internal wakeup */
173#define PWR_CSR1_EIWUP (1 << 8)
174
175/* Bits [7:4]: Reserved, must be kept at reset value. */
176
177/** BRR: Backup regulator ready */
178#define PWR_CSR1_BRR (1 << 3)
179
180/** PVDO: PVD output */
181#define PWR_CSR1_PVDO (1 << 2)
182
183/** SBF: Standby flag */
184#define PWR_CSR1_SBF (1 << 1)
185
186/** WUIF: Wakeup internal flag */
187#define PWR_CSR1_WUIF (1 << 0)
188/**@}*/
189
190/** @defgroup pwr_cr2_defines PWR_CR2 values
191 * @ingroup STM32F_pwr_defines
192@{*/
193
194/* Bits [31:14]: Reserved, must be kept at reset value. */
195
196/** WUPP6: Wakeup pin polarity bit for PI11 */
197#define PWR_CR2_WUPP6 (1 << 13)
198
199/** WUPP5: Wakeup pin polarity bit for PI8 */
200#define PWR_CR2_WUPP5 (1 << 12)
201
202/** WUPP4: Wakeup pin polarity bit for PC13 */
203#define PWR_CR2_WUPP4 (1 << 11)
204
205/** WUPP3: Wakeup pin polarity bit for PC1 */
206#define PWR_CR2_WUPP3 (1 << 10)
207
208/** WUPP2: Wakeup pin polarity bit for PA2 */
209#define PWR_CR2_WUPP2 (1 << 9)
210
211/** WUPP1: Wakeup pin polarity bit for PA0 */
212#define PWR_CR2_WUPP1 (1 << 8)
213
214/* Bits [7:6]: Reserved, must be kept at reset value. */
215
216/** CWUPF6: Clear Wakeup Pin flag for PI11 */
217#define PWR_CR2_CWUPF6 (1 << 5)
218
219/** CWUPF5: Clear Wakeup Pin flag for PI8 */
220#define PWR_CR2_CWUPF5 (1 << 4)
221
222/** CWUPF4: Clear Wakeup Pin flag for PC13 */
223#define PWR_CR2_CWUPF4 (1 << 3)
224
225/** CWUPF3: Clear Wakeup Pin flag for PC1 */
226#define PWR_CR2_CWUPF3 (1 << 2)
227
228/** CWUPF2: Clear Wakeup Pin flag for PA2 */
229#define PWR_CR2_CWUPF2 (1 << 1)
230
231/** CWUPF1: Clear Wakeup Pin flag for PA0 */
232#define PWR_CR2_CWUPF1 (1 << 0)
233/**@}*/
234
235/** @defgroup pwr_csr2_defines PWR_CSR2 values
236 * @ingroup STM32F_pwr_defines
237@{*/
238
239/* Bits [31:14]: Reserved, must be kept at reset value. */
240
241/** EWUP6: Enable Wakeup pin for PI11 */
242#define PWR_CSR2_EWUP6 (1 << 13)
243
244/** EWUP5: Enable Wakeup pin for PI8 */
245#define PWR_CSR2_EWUP5 (1 << 12)
246
247/** EWUP4: Enable Wakeup pin for PC13 */
248#define PWR_CSR2_EWUP4 (1 << 11)
249
250/** EWUP3: Enable Wakeup pin for PC1 */
251#define PWR_CSR2_EWUP3 (1 << 10)
252
253/** EWUP2: Enable Wakeup pin for PA2 */
254#define PWR_CSR2_EWUP2 (1 << 19)
255
256/** EWUP1: Enable Wakeup pin for PA0 */
257#define PWR_CSR2_EWUP1 (1 << 18)
258
259/* Bits [7:6]: Reserved, must be kept at reset value. */
260
261/** WUPF6: Wakeup Pin flag for PI11 */
262#define PWR_CSR2_WUPF6 (1 << 5)
263
264/** WUPF5: Wakeup Pin flag for PI8 */
265#define PWR_CSR2_WUPF5 (1 << 4)
266
267/** WUPF4: Wakeup Pin flag for PC13 */
268#define PWR_CSR2_WUPF4 (1 << 3)
269
270/** WUPF3: Wakeup Pin flag for PC1 */
271#define PWR_CSR2_WUPF3 (1 << 2)
272
273/** WUPF2: Wakeup Pin flag for PA2 */
274#define PWR_CSR2_WUPF2 (1 << 1)
275
276/** WUPF1: Wakeup Pin flag for PA0 */
277#define PWR_CSR2_WUPF1 (1 << 0)
278/**@}*/
279/* --- Function prototypes ------------------------------------------------- */
280
282 PWR_SCALE1, /** <= 180MHz w/o overdrive, <= 216MHz w/ overdrive */
283 PWR_SCALE2, /** <= 168MHz w/o overdrive, <= 180MHz w/ overdrive */
284 PWR_SCALE3, /** <= 144MHz */
285};
286
288
289void pwr_set_vos_scale(enum pwr_vos_scale scale);
290void pwr_enable_overdrive(void);
291void pwr_disable_overdrive(void);
292
294
295/**@}*/
296
297#endif
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void pwr_enable_overdrive(void)
Definition: pwr.c:56
void pwr_set_vos_scale(enum pwr_vos_scale scale)
Definition: pwr.c:43
pwr_vos_scale
Definition: f7/pwr.h:281
void pwr_disable_overdrive(void)
Definition: pwr.c:64
@ PWR_SCALE1
Definition: f7/pwr.h:282
@ PWR_SCALE2
<= 180MHz w/o overdrive, <= 216MHz w/ overdrive
Definition: f7/pwr.h:283
@ PWR_SCALE3
<= 168MHz w/o overdrive, <= 180MHz w/ overdrive
Definition: f7/pwr.h:284