OpenMPTL - STM32F10X
C++ Microprocessor Template Library
flash.hpp
Go to the documentation of this file.
1 /*
2  * OpenMPTL - C++ Microprocessor Template Library
3  *
4  * Copyright (C) 2012-2017 Axel Burri <axel@tty0.ch>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 /*
22  * This program contains derivative representations of CMSIS System
23  * View Description (SVD) files, and is subject to the "End User
24  * License Agreement for STMicroelectronics" (see "STM_License.html"
25  * in the containing directory).
26  */
27 
28 #ifndef ARCH_REG_FLASH_HPP_INCLUDED
29 #define ARCH_REG_FLASH_HPP_INCLUDED
30 
31 #include <register.hpp>
32 
33 namespace mptl {
34 
35 /**
36  * Embedded Flash memory (FLASH)
37  */
38 
39 /**
40  * FLASH
41  */
42 struct FLASH
43 {
44  static constexpr reg_addr_t base_addr = 0x40022000;
45 
46  /**
47  * Flash access control register
48  */
49  struct ACR
50  : public reg< uint32_t, base_addr + 0x0, rw, 0x00000030 >
51  {
53 
54  using LATENCY = regbits< type, 0, 3 >; /**< Latency */
55  using HLFCYA = regbits< type, 3, 1 >; /**< Flash half cycle access enable */
56  using PRFTBE = regbits< type, 4, 1 >; /**< Prefetch buffer enable */
57  using PRFTBS = regbits< type, 5, 1 >; /**< Prefetch buffer status */
58  };
59 
60  /**
61  * Flash key register
62  */
63  struct KEYR
64  : public reg< uint32_t, base_addr + 0x4, wo, 0x00000000 >
65  {
67 
68  using KEY = regbits< type, 0, 32 >; /**< FPEC key */
69  };
70 
71  /**
72  * Flash option key register
73  */
74  struct OPTKEYR
75  : public reg< uint32_t, base_addr + 0x8, wo, 0x00000000 >
76  {
78 
79  using OPTKEY = regbits< type, 0, 32 >; /**< Option byte key */
80  };
81 
82  /**
83  * Status register
84  */
85  struct SR
86  : public reg< uint32_t, base_addr + 0xc, rw, 0x00000000 >
87  {
89 
90  using EOP = regbits< type, 5, 1 >; /**< End of operation */
91  using WRPRTERR = regbits< type, 4, 1 >; /**< Write protection error */
92  using PGERR = regbits< type, 2, 1 >; /**< Programming error */
93  using BSY = regbits< type, 0, 1 >; /**< Busy */
94  };
95 
96  /**
97  * Control register
98  */
99  struct CR
100  : public reg< uint32_t, base_addr + 0x10, rw, 0x00000080 >
101  {
103 
104  using PG = regbits< type, 0, 1 >; /**< Programming */
105  using PER = regbits< type, 1, 1 >; /**< Page Erase */
106  using MER = regbits< type, 2, 1 >; /**< Mass Erase */
107  using OPTPG = regbits< type, 4, 1 >; /**< Option byte programming */
108  using OPTER = regbits< type, 5, 1 >; /**< Option byte erase */
109  using STRT = regbits< type, 6, 1 >; /**< Start */
110  using LOCK = regbits< type, 7, 1 >; /**< Lock */
111  using OPTWRE = regbits< type, 9, 1 >; /**< Option bytes write enable */
112  using ERRIE = regbits< type, 10, 1 >; /**< Error interrupt enable */
113  using EOPIE = regbits< type, 12, 1 >; /**< End of operation interrupt enable */
114  };
115 
116  /**
117  * Flash address register
118  */
119  struct AR
120  : public reg< uint32_t, base_addr + 0x14, wo, 0x00000000 >
121  {
123 
124  using FAR = regbits< type, 0, 32 >; /**< Flash Address */
125  };
126 
127  /**
128  * Option byte register
129  */
130  struct OBR
131  : public reg< uint32_t, base_addr + 0x1c, ro, 0x03FFFFFC >
132  {
134 
135  using OPTERR = regbits< type, 0, 1 >; /**< Option byte error */
136  using RDPRT = regbits< type, 1, 1 >; /**< Read protection */
137  using WDG_SW = regbits< type, 2, 1 >; /**< WDG_SW */
138  using nRST_STOP = regbits< type, 3, 1 >; /**< nRST_STOP */
139  using nRST_STDBY = regbits< type, 4, 1 >; /**< nRST_STDBY */
140  using Data0 = regbits< type, 10, 8 >; /**< Data0 */
141  using Data1 = regbits< type, 18, 8 >; /**< Data1 */
142  };
143 
144  /**
145  * Write protection register
146  */
147  struct WRPR
148  : public reg< uint32_t, base_addr + 0x20, ro, 0xFFFFFFFF >
149  {
151 
152  using WRP = regbits< type, 0, 32 >; /**< Write protect */
153  };
154 
155 
156 #if 0
157  /**
158  * document me!
159  *
160  * NOTE: only available for XL-density Flash modules
161  */
162  struct KEYR2
163  : public reg< uint32_t, base_addr + 0x44, rw >
164  { };
165 
166  /**
167  * document me!
168  *
169  * NOTE: only available for XL-density Flash modules
170  */
171  struct SR2
172  : public reg< uint32_t, base_addr + 0x4c, rw >
173  { };
174 
175  /**
176  * document me!
177  *
178  * NOTE: only available for XL-density Flash modules
179  */
180  struct CR2
181  : public reg< uint32_t, base_addr + 0x50, rw >
182  { };
183 
184  /**
185  * document me!
186  *
187  * NOTE: only available for XL-density Flash modules
188  */
189  struct AR2
190  : public reg< uint32_t, base_addr + 0x54, rw >
191  { };
192 #endif
193 };
194 
195 } // namespace mptl
196 
197 #endif // ARCH_REG_FLASH_HPP_INCLUDED
uintptr_t reg_addr_t
Option byte register.
Definition: flash.hpp:130
Flash key register.
Definition: flash.hpp:63
Embedded Flash memory (FLASH)
Definition: flash.hpp:42
static constexpr reg_addr_t base_addr
Definition: flash.hpp:44
Flash option key register.
Definition: flash.hpp:74
Write protection register.
Definition: flash.hpp:147
Flash address register.
Definition: flash.hpp:119
Control register.
Definition: flash.hpp:99
Status register.
Definition: flash.hpp:85
Flash access control register.
Definition: flash.hpp:49