libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
l4/pwr.h
Go to the documentation of this file.
1/** @defgroup pwr_defines PWR Defines
2 *
3 * @ingroup STM32L4xx_defines
4 *
5 * @brief <b>Defined Constants and Types for the STM32L4xx Power Control</b>
6 *
7 * @version 1.0.0
8 *
9 * @author @htmlonly &copy; @endhtmlonly 2016 Benjamin Levine <benjamin@jesco.karoo.co.uk>
10 *
11 * @date 12 February 2016
12 *
13 * LGPL License Terms @ref lgpl_license
14 * */
15
16/*
17 * This file is part of the libopencm3 project.
18 *
19 * Copyright (C) 2016 Benjamin Levine <benjamin@jesco.karoo.co.uk>
20 *
21 * This library is free software: you can redistribute it and/or modify
22 * it under the terms of the GNU Lesser General Public License as published by
23 * the Free Software Foundation, either version 3 of the License, or
24 * (at your option) any later version.
25 *
26 * This library is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU Lesser General Public License for more details.
30 *
31 * You should have received a copy of the GNU Lesser General Public License
32 * along with this library. If not, see <http://www.gnu.org/licenses/>.
33 */
34
35/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA PWR.H
36The order of header inclusion is important. pwr.h includes the device
37specific memorymap.h header before including this header file.*/
38
39/**@{*/
40#ifndef LIBOPENCM3_PWR_H
41#define LIBOPENCM3_PWR_H
42
43
44
45/* --- PWR registers ------------------------------------------------------- */
46
47#define PWR_CR1 MMIO32(POWER_CONTROL_BASE + 0x00)
48#define PWR_CR2 MMIO32(POWER_CONTROL_BASE + 0x04)
49#define PWR_CR3 MMIO32(POWER_CONTROL_BASE + 0x08)
50#define PWR_CR4 MMIO32(POWER_CONTROL_BASE + 0x0C)
51#define PWR_SR1 MMIO32(POWER_CONTROL_BASE + 0x10)
52#define PWR_SR2 MMIO32(POWER_CONTROL_BASE + 0x14)
53#define PWR_SCR MMIO32(POWER_CONTROL_BASE + 0x18)
54
55#define PWR_PORT_A MMIO32(POWER_CONTROL_BASE + 0x20)
56#define PWR_PORT_B MMIO32(POWER_CONTROL_BASE + 0x28)
57#define PWR_PORT_C MMIO32(POWER_CONTROL_BASE + 0x30)
58#define PWR_PORT_D MMIO32(POWER_CONTROL_BASE + 0x38)
59#define PWR_PORT_E MMIO32(POWER_CONTROL_BASE + 0x40)
60#define PWR_PORT_F MMIO32(POWER_CONTROL_BASE + 0x48)
61#define PWR_PORT_G MMIO32(POWER_CONTROL_BASE + 0x50)
62#define PWR_PORT_H MMIO32(POWER_CONTROL_BASE + 0x58)
63
64#define PWR_PUCR(pwr_port) MMIO32((pwr_port) + 0x00)
65#define PWR_PDCR(pwr_port) MMIO32((pwr_port) + 0x04)
66
67/* --- PWR_CR1 values ------------------------------------------------------- */
68
69#define PWR_CR1_LPR (1 << 14)
70
71#define PWR_CR1_VOS_SHIFT 9
72#define PWR_CR1_VOS_MASK 0x3
73#define PWR_CR1_VOS_RANGE_1 1
74#define PWR_CR1_VOS_RANGE_2 2
75
76#define PWR_CR1_DBP (1 << 8)
77
78#define PWR_CR1_LPMS_SHIFT 0
79#define PWR_CR1_LPMS_MASK 0x07
80#define PWR_CR1_LPMS_STOP_0 0
81#define PWR_CR1_LPMS_STOP_1 1
82#define PWR_CR1_LPMS_STOP_2 2
83#define PWR_CR1_LPMS_STANDBY 3
84#define PWR_CR1_LPMS_SHUTDOWN 4
85
86/* --- PWR_CR2 values ------------------------------------------------------- */
87
88#define PWR_CR2_USV (1 << 10)
89#define PWR_CR2_IOSV (1 << 9)
90#define PWR_CR2_PVME4 (1 << 7)
91#define PWR_CR2_PVME3 (1 << 6)
92#define PWR_CR2_PVME2 (1 << 5)
93#define PWR_CR2_PVME1 (1 << 4)
94
95#define PWR_CR2_PLS_SHIFT 1
96#define PWR_CR2_PLS_MASK 0x07
97/** @defgroup pwr_pls PVD level selection
98@ingroup STM32L4_pwr_defines
99@{*/
100#define PWR_CR2_PLS_2V0 0x00
101#define PWR_CR2_PLS_2V2 0x01
102#define PWR_CR2_PLS_2V4 0x02
103#define PWR_CR2_PLS_2V5 0x03
104#define PWR_CR2_PLS_2V6 0x04
105#define PWR_CR2_PLS_2V8 0x05
106#define PWR_CR2_PLS_2V9 0x06
107#define PWR_CR2_PLS_PVD_IN 0x07
108/**@}*/
109
110#define PWR_CR2_PVDE (1 << 0)
111
112/* --- PWR_CR3 values ------------------------------------------------------- */
113
114#define PWR_CR3_EIWUL (1 << 15)
115#define PWR_CR3_APC (1 << 10)
116#define PWR_CR3_RRS (1 << 8)
117#define PWR_CR3_EWUP5 (1 << 4)
118#define PWR_CR3_EWUP4 (1 << 3)
119#define PWR_CR3_EWUP3 (1 << 2)
120#define PWR_CR3_EWUP2 (1 << 1)
121#define PWR_CR3_EWUP1 (1 << 0)
122
123/* --- PWR_CR4 values ------------------------------------------------------- */
124
125#define PWR_CR4_VBRS (1 << 9)
126#define PWR_CR4_VBE (1 << 8)
127#define PWR_CR4_WP5 (1 << 4)
128#define PWR_CR4_WP4 (1 << 3)
129#define PWR_CR4_WP3 (1 << 2)
130#define PWR_CR4_WP2 (1 << 1)
131#define PWR_CR4_WP1 (1 << 0)
132
133/* --- PWR_SR1 values ------------------------------------------------------- */
134
135#define PWR_SR1_WUFI (1 << 15)
136#define PWR_SR1_SBF (1 << 8)
137#define PWR_SR1_WUF5 (1 << 4)
138#define PWR_SR1_WUF4 (1 << 3)
139#define PWR_SR1_WUF3 (1 << 2)
140#define PWR_SR1_WUF2 (1 << 1)
141#define PWR_SR1_WUF1 (1 << 0)
142
143/* --- PWR_SR2 values ------------------------------------------------------- */
144
145#define PWR_SR2_PVMO4 (1 << 15)
146#define PWR_SR2_PVMO3 (1 << 14)
147#define PWR_SR2_PVMO2 (1 << 13)
148#define PWR_SR2_PVMO1 (1 << 12)
149#define PWR_SR2_PVDO (1 << 11)
150#define PWR_SR2_VOSF (1 << 10)
151#define PWR_SR2_REGLPF (1 << 9)
152#define PWR_SR2_REGLPS (1 << 8)
153
154/* --- PWR_SCR values ------------------------------------------------------- */
155
156#define PWR_SCR_CSBF (1 << 8)
157#define PWR_SCR_CWUF5 (1 << 4)
158#define PWR_SCR_CWUF4 (1 << 3)
159#define PWR_SCR_CWUF3 (1 << 2)
160#define PWR_SCR_CWUF2 (1 << 1)
161#define PWR_SCR_CWUF1 (1 << 0)
162
163/* --- PWR function prototypes ------------------------------------------- */
164
168};
169
171
172void pwr_set_vos_scale(enum pwr_vos_scale scale);
175
177
178#endif
179/**@}*/
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void pwr_enable_backup_domain_write_protect(void)
Re-enable Backup Domain Write Protection.
Definition: pwr.c:70
void pwr_disable_backup_domain_write_protect(void)
Disable Backup Domain Write Protection.
Definition: pwr.c:61
void pwr_set_vos_scale(enum pwr_vos_scale scale)
Definition: pwr.c:39
pwr_vos_scale
Definition: l4/pwr.h:165
@ PWR_SCALE1
Definition: l4/pwr.h:166
@ PWR_SCALE2
Definition: l4/pwr.h:167