Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pwr.h « f7 « stm32 « libopencm3 « include - github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4605571039438b4c6cedacdd6765ccfbbac654f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/** @defgroup pwr_defines PWR Defines

@brief <b>Defined Constants and Types for the STM32F7xx Power Control</b>

@ingroup STM32F7xx_defines

@version 1.0.0

@author @htmlonly &copy; @endhtmlonly 2017 Matthew Lai <m@matthewlai.ca>

@date 12 March 2017

LGPL License Terms @ref lgpl_license
 */
/*
 * This file is part of the libopencm3 project.
 *
 * Copyright (C) 2017 Matthew Lai <m@matthewlai.ca>
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef LIBOPENCM3_PWR_H
#define LIBOPENCM3_PWR_H

/**@{*/

/** @defgroup pwr_registers PWR Registers
 * @ingroup STM32F_pwr_defines
@{*/
/** Power control register (PWR_CR1) */
#define PWR_CR1				MMIO32(POWER_CONTROL_BASE + 0x00)

/** Power control/status register (PWR_CSR1) */
#define PWR_CSR1			MMIO32(POWER_CONTROL_BASE + 0x04)

/** Power control register 2 (PWR_CR2) */
#define PWR_CR2				MMIO32(POWER_CONTROL_BASE + 0x08)

/** Power control/status register 2 (PWR_CSR2) */
#define PWR_CSR2			MMIO32(POWER_CONTROL_BASE + 0x0c)
/*@}*/

/** @defgroup pwr_cr1_defines PWR_CR1 values
 * @ingroup STM32F_pwr_defines
@{*/

/* Bits [31:20]: Reserved, must be kept at reset value. */

/** UDEN[19:18]: Under-drive enable in stop mode */
#define PWR_CR1_UDEN_LSB		18
/** @defgroup pwr_uden Under-drive enable in stop mode
@ingroup STM32F_pwr_defines

@{*/
#define PWR_CR1_UDEN_DISABLED		(0x0 << PWR_CR1_UDEN_LSB)
#define PWR_CR1_UDEN_ENABLED		(0x3 << PWR_CR1_UDEN_LSB)
/**@}*/
#define PWR_CR1_UDEN_MASK		(0x3 << PWR_CR1_UDEN_LSB)

/** ODSWEN: Over-drive switching enabled */
#define PWR_CR1_ODSWEN			(1 << 17)

/** ODEN: Over-drive enable */
#define PWR_CR1_ODEN			(1 << 16)

/* VOS[15:14]: Regulator voltage scaling output selection */
#define PWR_CR1_VOS_LSB			14
/** @defgroup pwr_vos Regulator voltage scaling output selection
@ingroup STM32F_pwr_defines

@{*/
#define PWR_CR1_VOS_SCALE_3		(0x1 << PWR_CR1_VOS_LSB)
#define PWR_CR1_VOS_SCALE_2		(0x2 << PWR_CR1_VOS_LSB)
#define PWR_CR1_VOS_SCALE_1		(0x3 << PWR_CR1_VOS_LSB)
/**@}*/
#define PWR_CR1_VOS_MASK		(0x3 << PWR_CR1_VOS_LSB)

/** ADCDC1: Masks extra flash accesses by prefetch (see AN4073) */
#define PWR_CR1_ADCDC1			(1 << 13)

/* Bit 12: Reserved, must be kept at reset value. */

/** MRUDS: Main regulator in deepsleep under-drive mode */
#define PWR_CR1_MRUDS			(1 << 11)

/** LPUDS: Low-power regulator in deepsleep under-drive mode */
#define PWR_CR1_LPUDS			(1 << 10)

/** FPDS: Flash power-down in Stop mode */
#define PWR_CR1_FPDS			(1 << 9)

/** DBP: Disable backup domain write protection */
#define PWR_CR1_DBP			(1 << 8)

/* PLS[7:5]: PVD level selection */
#define PWR_CR1_PLS_LSB			5
/** @defgroup pwr_pls PVD level selection
@ingroup STM32F_pwr_defines

@{*/
#define PWR_CR1_PLS_2V0			(0x0 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V1			(0x1 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V3			(0x2 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V5			(0x3 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V6			(0x4 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V7			(0x5 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V8			(0x6 << PWR_CR_PLS_LSB)
#define PWR_CR1_PLS_2V9			(0x7 << PWR_CR_PLS_LSB)
/**@}*/
#define PWR_CR1_PLS_MASK		(0x7 << PWR_CR_PLS_LSB)

/** PVDE: Power voltage detector enable */
#define PWR_CR1_PVDE			(1 << 4)

/** CSBF: Clear standby flag */
#define PWR_CR1_CSBF			(1 << 3)

/* Bit 2: Reserved, must be kept at reset value. */

/** PDDS: Power down deepsleep */
#define PWR_CR1_PDDS			(1 << 1)

/** LPDS: Low-power deepsleep */
#define PWR_CR1_LPDS			(1 << 0)
/*@}*/

/** @defgroup pwr_csr1_defines PWR_CSR1 values
 * @ingroup STM32F_pwr_defines
@{*/

/* Bits [31:20]: Reserved, must be kept at reset value. */

/* UDRDY[19:18]: Under-drive ready flag */
#define PWR_CSR1_UDRDY_LSB		18
/** @defgroup pwr_udrdy Under-drive ready flag
@ingroup STM32F_pwr_defines

@{*/
#define PWR_CSR1_UDRDY_DISABLED		(0x0 << PWR_CSR1_UDRDY_LSB)
#define PWR_CSR1_UDRDY_ACTIVATED	(0x3 << PWR_CSR1_UDRDY_LSB)
/**@}*/
#define PWR_CSR1_UDRDY_MASK		(0x3 << PWR_CSR1_UDRDY_LSB)

/** ODSWRDY: Over-drive mode switching ready */
#define PWR_CSR1_ODSWRDY		(1 << 17)

/** ODRDY: Over-drive mode ready */
#define PWR_CSR1_ODRDY			(1 << 16)

/* Bit 15: Reserved, must be kept at reset value. */

/** VOSRDY: Regulator voltage scaling output selection ready bit */
#define PWR_CSR1_VOSRDY			(1 << 14)

/* Bits [13:10]: Reserved, must be kept at reset value. */

/** BRE: Backup regulator enable */
#define PWR_CSR1_BRE			(1 << 9)

/** EIWUP: Enable internal wakeup */
#define PWR_CSR1_EIWUP			(1 << 8)

/* Bits [7:4]: Reserved, must be kept at reset value. */

/** BRR: Backup regulator ready */
#define PWR_CSR1_BRR			(1 << 3)

/** PVDO: PVD output */
#define PWR_CSR1_PVDO			(1 << 2)

/** SBF: Standby flag */
#define PWR_CSR1_SBF			(1 << 1)

/** WUIF: Wakeup internal flag */
#define PWR_CSR1_WUIF			(1 << 0)
/*@}*/

/** @defgroup pwr_cr2_defines PWR_CR2 values
 * @ingroup STM32F_pwr_defines
@{*/

/* Bits [31:14]: Reserved, must be kept at reset value. */

/** WUPP6: Wakeup pin polarity bit for PI11 */
#define PWR_CR2_WUPP6			(1 << 13)

/** WUPP5: Wakeup pin polarity bit for PI8 */
#define PWR_CR2_WUPP5			(1 << 12)

/** WUPP4: Wakeup pin polarity bit for PC13 */
#define PWR_CR2_WUPP4			(1 << 11)

/** WUPP3: Wakeup pin polarity bit for PC1 */
#define PWR_CR2_WUPP3			(1 << 10)

/** WUPP2: Wakeup pin polarity bit for PA2 */
#define PWR_CR2_WUPP2			(1 << 9)

/** WUPP1: Wakeup pin polarity bit for PA0 */
#define PWR_CR2_WUPP1			(1 << 8)

/* Bits [7:6]: Reserved, must be kept at reset value. */

/** CWUPF6: Clear Wakeup Pin flag for PI11 */
#define PWR_CR2_CWUPF6			(1 << 5)

/** CWUPF5: Clear Wakeup Pin flag for PI8 */
#define PWR_CR2_CWUPF5			(1 << 4)

/** CWUPF4: Clear Wakeup Pin flag for PC13 */
#define PWR_CR2_CWUPF4			(1 << 3)

/** CWUPF3: Clear Wakeup Pin flag for PC1 */
#define PWR_CR2_CWUPF3			(1 << 2)

/** CWUPF2: Clear Wakeup Pin flag for PA2 */
#define PWR_CR2_CWUPF2			(1 << 1)

/** CWUPF1: Clear Wakeup Pin flag for PA0 */
#define PWR_CR2_CWUPF1			(1 << 0)
/*@}*/

/** @defgroup pwr_csr2_defines PWR_CSR2 values
 * @ingroup STM32F_pwr_defines
@{*/

/* Bits [31:14]: Reserved, must be kept at reset value. */

/** EWUP6: Enable Wakeup pin for PI11 */
#define PWR_CSR2_EWUP6			(1 << 13)

/** EWUP5: Enable Wakeup pin for PI8 */
#define PWR_CSR2_EWUP5			(1 << 12)

/** EWUP4: Enable Wakeup pin for PC13 */
#define PWR_CSR2_EWUP4			(1 << 11)

/** EWUP3: Enable Wakeup pin for PC1 */
#define PWR_CSR2_EWUP3			(1 << 10)

/** EWUP2: Enable Wakeup pin for PA2 */
#define PWR_CSR2_EWUP2			(1 << 19)

/** EWUP1: Enable Wakeup pin for PA0 */
#define PWR_CSR2_EWUP1			(1 << 18)

/* Bits [7:6]: Reserved, must be kept at reset value. */

/** WUPF6: Wakeup Pin flag for PI11 */
#define PWR_CSR2_WUPF6			(1 << 5)

/** WUPF5: Wakeup Pin flag for PI8 */
#define PWR_CSR2_WUPF5			(1 << 4)

/** WUPF4: Wakeup Pin flag for PC13 */
#define PWR_CSR2_WUPF4			(1 << 3)

/** WUPF3: Wakeup Pin flag for PC1 */
#define PWR_CSR2_WUPF3			(1 << 2)

/** WUPF2: Wakeup Pin flag for PA2 */
#define PWR_CSR2_WUPF2			(1 << 1)

/** WUPF1: Wakeup Pin flag for PA0 */
#define PWR_CSR2_WUPF1			(1 << 0)
/*@}*/
/* --- Function prototypes ------------------------------------------------- */

enum pwr_vos_scale {
	PWR_SCALE1, /** <= 180MHz w/o overdrive, <= 216MHz w/ overdrive */
	PWR_SCALE2, /** <= 168MHz w/o overdrive, <= 180MHz w/ overdrive */
	PWR_SCALE3, /** <= 144MHz */
};

BEGIN_DECLS

void pwr_set_vos_scale(enum pwr_vos_scale scale);
void pwr_enable_overdrive(void);
void pwr_disable_overdrive(void);

END_DECLS

/**@}*/

#endif