fix based on https://gist.github.com/timbrom/1942280
[DSO138] / Libraries / STM32F10x_StdPeriph_Driver / inc / stm32f10x_flash.h
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f10x_flash.h\r
4   * @author  MCD Application Team\r
5   * @version V3.3.0\r
6   * @date    04/16/2010\r
7   * @brief   This file contains all the functions prototypes for the FLASH \r
8   *          firmware library.\r
9   ******************************************************************************\r
10   * @copy\r
11   *\r
12   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
13   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
14   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
15   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
16   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
17   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
18   *\r
19   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>\r
20   */ \r
21 \r
22 /* Define to prevent recursive inclusion -------------------------------------*/\r
23 #ifndef __STM32F10x_FLASH_H\r
24 #define __STM32F10x_FLASH_H\r
25 \r
26 #ifdef __cplusplus\r
27  extern "C" {\r
28 #endif\r
29 \r
30 /* Includes ------------------------------------------------------------------*/\r
31 #include "stm32f10x.h"\r
32 \r
33 /** @addtogroup STM32F10x_StdPeriph_Driver\r
34   * @{\r
35   */\r
36 \r
37 /** @addtogroup FLASH\r
38   * @{\r
39   */\r
40 \r
41 /** @defgroup FLASH_Exported_Types\r
42   * @{\r
43   */\r
44 \r
45 /** \r
46   * @brief  FLASH Status  \r
47   */\r
48 \r
49 typedef enum\r
50\r
51   FLASH_BUSY = 1,\r
52   FLASH_ERROR_PG,\r
53   FLASH_ERROR_WRP,\r
54   FLASH_COMPLETE,\r
55   FLASH_TIMEOUT\r
56 }FLASH_Status;\r
57 \r
58 /**\r
59   * @}\r
60   */\r
61 \r
62 /** @defgroup FLASH_Exported_Constants\r
63   * @{\r
64   */\r
65 \r
66 /** @defgroup Flash_Latency \r
67   * @{\r
68   */\r
69 \r
70 #define FLASH_Latency_0                ((uint32_t)0x00000000)  /*!< FLASH Zero Latency cycle */\r
71 #define FLASH_Latency_1                ((uint32_t)0x00000001)  /*!< FLASH One Latency cycle */\r
72 #define FLASH_Latency_2                ((uint32_t)0x00000002)  /*!< FLASH Two Latency cycles */\r
73 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \\r
74                                    ((LATENCY) == FLASH_Latency_1) || \\r
75                                    ((LATENCY) == FLASH_Latency_2))\r
76 /**\r
77   * @}\r
78   */\r
79 \r
80 /** @defgroup Half_Cycle_Enable_Disable \r
81   * @{\r
82   */\r
83 \r
84 #define FLASH_HalfCycleAccess_Enable   ((uint32_t)0x00000008)  /*!< FLASH Half Cycle Enable */\r
85 #define FLASH_HalfCycleAccess_Disable  ((uint32_t)0x00000000)  /*!< FLASH Half Cycle Disable */\r
86 #define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \\r
87                                                ((STATE) == FLASH_HalfCycleAccess_Disable)) \r
88 /**\r
89   * @}\r
90   */\r
91 \r
92 /** @defgroup Prefetch_Buffer_Enable_Disable \r
93   * @{\r
94   */\r
95 \r
96 #define FLASH_PrefetchBuffer_Enable    ((uint32_t)0x00000010)  /*!< FLASH Prefetch Buffer Enable */\r
97 #define FLASH_PrefetchBuffer_Disable   ((uint32_t)0x00000000)  /*!< FLASH Prefetch Buffer Disable */\r
98 #define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \\r
99                                               ((STATE) == FLASH_PrefetchBuffer_Disable)) \r
100 /**\r
101   * @}\r
102   */\r
103 \r
104 /** @defgroup Option_Bytes_Write_Protection \r
105   * @{\r
106   */\r
107 \r
108 /* Values to be used with STM32 Low and Medium density devices */\r
109 #define FLASH_WRProt_Pages0to3         ((uint32_t)0x00000001) /*!< STM32 Low and Medium density devices: Write protection of page 0 to 3 */\r
110 #define FLASH_WRProt_Pages4to7         ((uint32_t)0x00000002) /*!< STM32 Low and Medium density devices: Write protection of page 4 to 7 */\r
111 #define FLASH_WRProt_Pages8to11        ((uint32_t)0x00000004) /*!< STM32 Low and Medium density devices: Write protection of page 8 to 11 */\r
112 #define FLASH_WRProt_Pages12to15       ((uint32_t)0x00000008) /*!< STM32 Low and Medium density devices: Write protection of page 12 to 15 */\r
113 #define FLASH_WRProt_Pages16to19       ((uint32_t)0x00000010) /*!< STM32 Low and Medium density devices: Write protection of page 16 to 19 */\r
114 #define FLASH_WRProt_Pages20to23       ((uint32_t)0x00000020) /*!< STM32 Low and Medium density devices: Write protection of page 20 to 23 */\r
115 #define FLASH_WRProt_Pages24to27       ((uint32_t)0x00000040) /*!< STM32 Low and Medium density devices: Write protection of page 24 to 27 */\r
116 #define FLASH_WRProt_Pages28to31       ((uint32_t)0x00000080) /*!< STM32 Low and Medium density devices: Write protection of page 28 to 31 */\r
117 \r
118 /* Values to be used with STM32 Medium-density devices */\r
119 #define FLASH_WRProt_Pages32to35       ((uint32_t)0x00000100) /*!< STM32 Medium-density devices: Write protection of page 32 to 35 */\r
120 #define FLASH_WRProt_Pages36to39       ((uint32_t)0x00000200) /*!< STM32 Medium-density devices: Write protection of page 36 to 39 */\r
121 #define FLASH_WRProt_Pages40to43       ((uint32_t)0x00000400) /*!< STM32 Medium-density devices: Write protection of page 40 to 43 */\r
122 #define FLASH_WRProt_Pages44to47       ((uint32_t)0x00000800) /*!< STM32 Medium-density devices: Write protection of page 44 to 47 */\r
123 #define FLASH_WRProt_Pages48to51       ((uint32_t)0x00001000) /*!< STM32 Medium-density devices: Write protection of page 48 to 51 */\r
124 #define FLASH_WRProt_Pages52to55       ((uint32_t)0x00002000) /*!< STM32 Medium-density devices: Write protection of page 52 to 55 */\r
125 #define FLASH_WRProt_Pages56to59       ((uint32_t)0x00004000) /*!< STM32 Medium-density devices: Write protection of page 56 to 59 */\r
126 #define FLASH_WRProt_Pages60to63       ((uint32_t)0x00008000) /*!< STM32 Medium-density devices: Write protection of page 60 to 63 */\r
127 #define FLASH_WRProt_Pages64to67       ((uint32_t)0x00010000) /*!< STM32 Medium-density devices: Write protection of page 64 to 67 */\r
128 #define FLASH_WRProt_Pages68to71       ((uint32_t)0x00020000) /*!< STM32 Medium-density devices: Write protection of page 68 to 71 */\r
129 #define FLASH_WRProt_Pages72to75       ((uint32_t)0x00040000) /*!< STM32 Medium-density devices: Write protection of page 72 to 75 */\r
130 #define FLASH_WRProt_Pages76to79       ((uint32_t)0x00080000) /*!< STM32 Medium-density devices: Write protection of page 76 to 79 */\r
131 #define FLASH_WRProt_Pages80to83       ((uint32_t)0x00100000) /*!< STM32 Medium-density devices: Write protection of page 80 to 83 */\r
132 #define FLASH_WRProt_Pages84to87       ((uint32_t)0x00200000) /*!< STM32 Medium-density devices: Write protection of page 84 to 87 */\r
133 #define FLASH_WRProt_Pages88to91       ((uint32_t)0x00400000) /*!< STM32 Medium-density devices: Write protection of page 88 to 91 */\r
134 #define FLASH_WRProt_Pages92to95       ((uint32_t)0x00800000) /*!< STM32 Medium-density devices: Write protection of page 92 to 95 */\r
135 #define FLASH_WRProt_Pages96to99       ((uint32_t)0x01000000) /*!< STM32 Medium-density devices: Write protection of page 96 to 99 */\r
136 #define FLASH_WRProt_Pages100to103     ((uint32_t)0x02000000) /*!< STM32 Medium-density devices: Write protection of page 100 to 103 */\r
137 #define FLASH_WRProt_Pages104to107     ((uint32_t)0x04000000) /*!< STM32 Medium-density devices: Write protection of page 104 to 107 */\r
138 #define FLASH_WRProt_Pages108to111     ((uint32_t)0x08000000) /*!< STM32 Medium-density devices: Write protection of page 108 to 111 */\r
139 #define FLASH_WRProt_Pages112to115     ((uint32_t)0x10000000) /*!< STM32 Medium-density devices: Write protection of page 112 to 115 */\r
140 #define FLASH_WRProt_Pages116to119     ((uint32_t)0x20000000) /*!< STM32 Medium-density devices: Write protection of page 115 to 119 */\r
141 #define FLASH_WRProt_Pages120to123     ((uint32_t)0x40000000) /*!< STM32 Medium-density devices: Write protection of page 120 to 123 */\r
142 #define FLASH_WRProt_Pages124to127     ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 124 to 127 */\r
143 \r
144 /* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */\r
145 #define FLASH_WRProt_Pages0to1         ((uint32_t)0x00000001) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
146                                                                    Write protection of page 0 to 1 */\r
147 #define FLASH_WRProt_Pages2to3         ((uint32_t)0x00000002) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
148                                                                    Write protection of page 2 to 3 */\r
149 #define FLASH_WRProt_Pages4to5         ((uint32_t)0x00000004) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
150                                                                    Write protection of page 4 to 5 */\r
151 #define FLASH_WRProt_Pages6to7         ((uint32_t)0x00000008) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
152                                                                    Write protection of page 6 to 7 */\r
153 #define FLASH_WRProt_Pages8to9         ((uint32_t)0x00000010) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
154                                                                    Write protection of page 8 to 9 */\r
155 #define FLASH_WRProt_Pages10to11       ((uint32_t)0x00000020) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
156                                                                    Write protection of page 10 to 11 */\r
157 #define FLASH_WRProt_Pages12to13       ((uint32_t)0x00000040) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
158                                                                    Write protection of page 12 to 13 */\r
159 #define FLASH_WRProt_Pages14to15       ((uint32_t)0x00000080) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
160                                                                    Write protection of page 14 to 15 */\r
161 #define FLASH_WRProt_Pages16to17       ((uint32_t)0x00000100) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
162                                                                    Write protection of page 16 to 17 */\r
163 #define FLASH_WRProt_Pages18to19       ((uint32_t)0x00000200) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
164                                                                    Write protection of page 18 to 19 */\r
165 #define FLASH_WRProt_Pages20to21       ((uint32_t)0x00000400) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
166                                                                    Write protection of page 20 to 21 */\r
167 #define FLASH_WRProt_Pages22to23       ((uint32_t)0x00000800) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
168                                                                    Write protection of page 22 to 23 */\r
169 #define FLASH_WRProt_Pages24to25       ((uint32_t)0x00001000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
170                                                                    Write protection of page 24 to 25 */\r
171 #define FLASH_WRProt_Pages26to27       ((uint32_t)0x00002000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
172                                                                    Write protection of page 26 to 27 */\r
173 #define FLASH_WRProt_Pages28to29       ((uint32_t)0x00004000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
174                                                                    Write protection of page 28 to 29 */\r
175 #define FLASH_WRProt_Pages30to31       ((uint32_t)0x00008000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
176                                                                    Write protection of page 30 to 31 */\r
177 #define FLASH_WRProt_Pages32to33       ((uint32_t)0x00010000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
178                                                                    Write protection of page 32 to 33 */\r
179 #define FLASH_WRProt_Pages34to35       ((uint32_t)0x00020000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
180                                                                    Write protection of page 34 to 35 */\r
181 #define FLASH_WRProt_Pages36to37       ((uint32_t)0x00040000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
182                                                                    Write protection of page 36 to 37 */\r
183 #define FLASH_WRProt_Pages38to39       ((uint32_t)0x00080000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
184                                                                    Write protection of page 38 to 39 */\r
185 #define FLASH_WRProt_Pages40to41       ((uint32_t)0x00100000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
186                                                                    Write protection of page 40 to 41 */\r
187 #define FLASH_WRProt_Pages42to43       ((uint32_t)0x00200000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
188                                                                    Write protection of page 42 to 43 */\r
189 #define FLASH_WRProt_Pages44to45       ((uint32_t)0x00400000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
190                                                                    Write protection of page 44 to 45 */\r
191 #define FLASH_WRProt_Pages46to47       ((uint32_t)0x00800000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
192                                                                    Write protection of page 46 to 47 */\r
193 #define FLASH_WRProt_Pages48to49       ((uint32_t)0x01000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
194                                                                    Write protection of page 48 to 49 */\r
195 #define FLASH_WRProt_Pages50to51       ((uint32_t)0x02000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
196                                                                    Write protection of page 50 to 51 */\r
197 #define FLASH_WRProt_Pages52to53       ((uint32_t)0x04000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
198                                                                    Write protection of page 52 to 53 */\r
199 #define FLASH_WRProt_Pages54to55       ((uint32_t)0x08000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
200                                                                    Write protection of page 54 to 55 */\r
201 #define FLASH_WRProt_Pages56to57       ((uint32_t)0x10000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
202                                                                    Write protection of page 56 to 57 */\r
203 #define FLASH_WRProt_Pages58to59       ((uint32_t)0x20000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
204                                                                    Write protection of page 58 to 59 */\r
205 #define FLASH_WRProt_Pages60to61       ((uint32_t)0x40000000) /*!< STM32 High-density, XL-density and Connectivity line devices:\r
206                                                                    Write protection of page 60 to 61 */\r
207 #define FLASH_WRProt_Pages62to127      ((uint32_t)0x80000000) /*!< STM32 Connectivity line devices: Write protection of page 62 to 127 */\r
208 #define FLASH_WRProt_Pages62to255      ((uint32_t)0x80000000) /*!< STM32 Medium-density devices: Write protection of page 62 to 255 */\r
209 #define FLASH_WRProt_Pages62to511      ((uint32_t)0x80000000) /*!< STM32 XL-density devices: Write protection of page 62 to 511 */\r
210 \r
211 #define FLASH_WRProt_AllPages          ((uint32_t)0xFFFFFFFF) /*!< Write protection of all Pages */\r
212 \r
213 #define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))\r
214 \r
215 #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF))\r
216 \r
217 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))\r
218 \r
219 /**\r
220   * @}\r
221   */\r
222 \r
223 /** @defgroup Option_Bytes_IWatchdog \r
224   * @{\r
225   */\r
226 \r
227 #define OB_IWDG_SW                     ((uint16_t)0x0001)  /*!< Software IWDG selected */\r
228 #define OB_IWDG_HW                     ((uint16_t)0x0000)  /*!< Hardware IWDG selected */\r
229 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))\r
230 \r
231 /**\r
232   * @}\r
233   */\r
234 \r
235 /** @defgroup Option_Bytes_nRST_STOP \r
236   * @{\r
237   */\r
238 \r
239 #define OB_STOP_NoRST                  ((uint16_t)0x0002) /*!< No reset generated when entering in STOP */\r
240 #define OB_STOP_RST                    ((uint16_t)0x0000) /*!< Reset generated when entering in STOP */\r
241 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))\r
242 \r
243 /**\r
244   * @}\r
245   */\r
246 \r
247 /** @defgroup Option_Bytes_nRST_STDBY \r
248   * @{\r
249   */\r
250 \r
251 #define OB_STDBY_NoRST                 ((uint16_t)0x0004) /*!< No reset generated when entering in STANDBY */\r
252 #define OB_STDBY_RST                   ((uint16_t)0x0000) /*!< Reset generated when entering in STANDBY */\r
253 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))\r
254 \r
255 #ifdef STM32F10X_XL\r
256 /**\r
257   * @}\r
258   */\r
259 /** @defgroup FLASH_Boot\r
260   * @{\r
261   */\r
262 #define FLASH_BOOT_Bank1  ((uint16_t)0x0000) /*!< At startup, if boot pins are set in boot from user Flash position\r
263                                                   and this parameter is selected the device will boot from Bank1(Default) */\r
264 #define FLASH_BOOT_Bank2  ((uint16_t)0x0001) /*!< At startup, if boot pins are set in boot from user Flash position\r
265                                                   and this parameter is selected the device will boot from Bank 2 or Bank 1,\r
266                                                   depending on the activation of the bank */\r
267 #define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2))\r
268 #endif\r
269 /**\r
270   * @}\r
271   */\r
272 /** @defgroup FLASH_Interrupts \r
273   * @{\r
274   */\r
275 #ifdef STM32F10X_XL\r
276 #define FLASH_IT_BANK2_ERROR                 ((uint32_t)0x80000400)  /*!< FPEC BANK2 error interrupt source */\r
277 #define FLASH_IT_BANK2_EOP                   ((uint32_t)0x80001000)  /*!< End of FLASH BANK2 Operation Interrupt source */\r
278 \r
279 #define FLASH_IT_BANK1_ERROR                 FLASH_IT_ERROR          /*!< FPEC BANK1 error interrupt source */\r
280 #define FLASH_IT_BANK1_EOP                   FLASH_IT_EOP            /*!< End of FLASH BANK1 Operation Interrupt source */\r
281 \r
282 #define FLASH_IT_ERROR                 ((uint32_t)0x00000400)  /*!< FPEC BANK1 error interrupt source */\r
283 #define FLASH_IT_EOP                   ((uint32_t)0x00001000)  /*!< End of FLASH BANK1 Operation Interrupt source */\r
284 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))\r
285 #else\r
286 #define FLASH_IT_ERROR                 ((uint32_t)0x00000400)  /*!< FPEC error interrupt source */\r
287 #define FLASH_IT_EOP                   ((uint32_t)0x00001000)  /*!< End of FLASH Operation Interrupt source */\r
288 #define FLASH_IT_BANK1_ERROR           FLASH_IT_ERROR          /*!< FPEC BANK1 error interrupt source */\r
289 #define FLASH_IT_BANK1_EOP             FLASH_IT_EOP            /*!< End of FLASH BANK1 Operation Interrupt source */\r
290 \r
291 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))\r
292 #endif\r
293 \r
294 /**\r
295   * @}\r
296   */\r
297 \r
298 /** @defgroup FLASH_Flags \r
299   * @{\r
300   */\r
301 #ifdef STM32F10X_XL\r
302 #define FLASH_FLAG_BANK2_BSY                 ((uint32_t)0x80000001)  /*!< FLASH BANK2 Busy flag */\r
303 #define FLASH_FLAG_BANK2_EOP                 ((uint32_t)0x80000020)  /*!< FLASH BANK2 End of Operation flag */\r
304 #define FLASH_FLAG_BANK2_PGERR               ((uint32_t)0x80000004)  /*!< FLASH BANK2 Program error flag */\r
305 #define FLASH_FLAG_BANK2_WRPRTERR            ((uint32_t)0x80000010)  /*!< FLASH BANK2 Write protected error flag */\r
306 \r
307 #define FLASH_FLAG_BANK1_BSY                 FLASH_FLAG_BSY       /*!< FLASH BANK1 Busy flag*/\r
308 #define FLASH_FLAG_BANK1_EOP                 FLASH_FLAG_EOP       /*!< FLASH BANK1 End of Operation flag */\r
309 #define FLASH_FLAG_BANK1_PGERR               FLASH_FLAG_PGERR     /*!< FLASH BANK1 Program error flag */\r
310 #define FLASH_FLAG_BANK1_WRPRTERR            FLASH_FLAG_WRPRTERR  /*!< FLASH BANK1 Write protected error flag */\r
311 \r
312 #define FLASH_FLAG_BSY                 ((uint32_t)0x00000001)  /*!< FLASH Busy flag */\r
313 #define FLASH_FLAG_EOP                 ((uint32_t)0x00000020)  /*!< FLASH End of Operation flag */\r
314 #define FLASH_FLAG_PGERR               ((uint32_t)0x00000004)  /*!< FLASH Program error flag */\r
315 #define FLASH_FLAG_WRPRTERR            ((uint32_t)0x00000010)  /*!< FLASH Write protected error flag */\r
316 #define FLASH_FLAG_OPTERR              ((uint32_t)0x00000001)  /*!< FLASH Option Byte error flag */\r
317  \r
318 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))\r
319 #define IS_FLASH_GET_FLAG(FLAG)  (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \\r
320                                   ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \\r
321                                   ((FLAG) == FLASH_FLAG_OPTERR)|| \\r
322                                   ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \\r
323                                   ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \\r
324                                   ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \\r
325                                   ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR))\r
326 #else\r
327 #define FLASH_FLAG_BSY                 ((uint32_t)0x00000001)  /*!< FLASH Busy flag */\r
328 #define FLASH_FLAG_EOP                 ((uint32_t)0x00000020)  /*!< FLASH End of Operation flag */\r
329 #define FLASH_FLAG_PGERR               ((uint32_t)0x00000004)  /*!< FLASH Program error flag */\r
330 #define FLASH_FLAG_WRPRTERR            ((uint32_t)0x00000010)  /*!< FLASH Write protected error flag */\r
331 #define FLASH_FLAG_OPTERR              ((uint32_t)0x00000001)  /*!< FLASH Option Byte error flag */\r
332 \r
333 #define FLASH_FLAG_BANK1_BSY                 FLASH_FLAG_BSY       /*!< FLASH BANK1 Busy flag*/\r
334 #define FLASH_FLAG_BANK1_EOP                 FLASH_FLAG_EOP       /*!< FLASH BANK1 End of Operation flag */\r
335 #define FLASH_FLAG_BANK1_PGERR               FLASH_FLAG_PGERR     /*!< FLASH BANK1 Program error flag */\r
336 #define FLASH_FLAG_BANK1_WRPRTERR            FLASH_FLAG_WRPRTERR  /*!< FLASH BANK1 Write protected error flag */\r
337  \r
338 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))\r
339 #define IS_FLASH_GET_FLAG(FLAG)  (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \\r
340                                   ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \\r
341                                                                   ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \\r
342                                   ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \\r
343                                   ((FLAG) == FLASH_FLAG_OPTERR))\r
344 #endif\r
345 \r
346 /**\r
347   * @}\r
348   */\r
349 \r
350 /**\r
351   * @}\r
352   */\r
353 \r
354 /** @defgroup FLASH_Exported_Macros\r
355   * @{\r
356   */\r
357 \r
358 /**\r
359   * @}\r
360   */\r
361 \r
362 /** @defgroup FLASH_Exported_Functions\r
363   * @{\r
364   */\r
365 \r
366 /*------------ Functions used for all STM32F10x devices -----*/\r
367 void FLASH_SetLatency(uint32_t FLASH_Latency);\r
368 void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess);\r
369 void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer);\r
370 void FLASH_Unlock(void);\r
371 void FLASH_Lock(void);\r
372 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);\r
373 FLASH_Status FLASH_EraseAllPages(void);\r
374 FLASH_Status FLASH_EraseOptionBytes(void);\r
375 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);\r
376 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);\r
377 FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);\r
378 FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages);\r
379 FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);\r
380 FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY);\r
381 uint32_t FLASH_GetUserOptionByte(void);\r
382 uint32_t FLASH_GetWriteProtectionOptionByte(void);\r
383 FlagStatus FLASH_GetReadOutProtectionStatus(void);\r
384 FlagStatus FLASH_GetPrefetchBufferStatus(void);\r
385 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);\r
386 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);\r
387 void FLASH_ClearFlag(uint32_t FLASH_FLAG);\r
388 FLASH_Status FLASH_GetStatus(void);\r
389 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);\r
390 \r
391 /*------------ New function used for all STM32F10x devices -----*/\r
392 void FLASH_UnlockBank1(void);\r
393 void FLASH_LockBank1(void);\r
394 FLASH_Status FLASH_EraseAllBank1Pages(void);\r
395 FLASH_Status FLASH_GetBank1Status(void);\r
396 FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout);\r
397 \r
398 #ifdef STM32F10X_XL\r
399 /*---- New Functions used only with STM32F10x_XL density devices -----*/\r
400 void FLASH_UnlockBank2(void);\r
401 void FLASH_LockBank2(void);\r
402 FLASH_Status FLASH_EraseAllBank2Pages(void);\r
403 FLASH_Status FLASH_GetBank2Status(void);\r
404 FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout);\r
405 FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT);\r
406 #endif\r
407 \r
408 #ifdef __cplusplus\r
409 }\r
410 #endif\r
411 \r
412 #endif /* __STM32F10x_FLASH_H */\r
413 /**\r
414   * @}\r
415   */\r
416 \r
417 /**\r
418   * @}\r
419   */\r
420 \r
421 /**\r
422   * @}\r
423   */\r
424 \r
425 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/\r