stm32f10x_flash.h
Go to the documentation of this file.
1 
23 /* Define to prevent recursive inclusion -------------------------------------*/
24 #ifndef __STM32F10x_FLASH_H
25 #define __STM32F10x_FLASH_H
26 
27 #ifdef __cplusplus
28  extern "C" {
29 #endif
30 
31 /* Includes ------------------------------------------------------------------*/
32 #include "stm32f10x.h"
33 
50 typedef enum
51 {
58 
71 #define FLASH_Latency_0 ((uint32_t)0x00000000)
72 #define FLASH_Latency_1 ((uint32_t)0x00000001)
73 #define FLASH_Latency_2 ((uint32_t)0x00000002)
74 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
75  ((LATENCY) == FLASH_Latency_1) || \
76  ((LATENCY) == FLASH_Latency_2))
77 
85 #define FLASH_HalfCycleAccess_Enable ((uint32_t)0x00000008)
86 #define FLASH_HalfCycleAccess_Disable ((uint32_t)0x00000000)
87 #define IS_FLASH_HALFCYCLEACCESS_STATE(STATE) (((STATE) == FLASH_HalfCycleAccess_Enable) || \
88  ((STATE) == FLASH_HalfCycleAccess_Disable))
89 
97 #define FLASH_PrefetchBuffer_Enable ((uint32_t)0x00000010)
98 #define FLASH_PrefetchBuffer_Disable ((uint32_t)0x00000000)
99 #define IS_FLASH_PREFETCHBUFFER_STATE(STATE) (((STATE) == FLASH_PrefetchBuffer_Enable) || \
100  ((STATE) == FLASH_PrefetchBuffer_Disable))
101 
109 /* Values to be used with STM32 Low and Medium density devices */
110 #define FLASH_WRProt_Pages0to3 ((uint32_t)0x00000001)
111 #define FLASH_WRProt_Pages4to7 ((uint32_t)0x00000002)
112 #define FLASH_WRProt_Pages8to11 ((uint32_t)0x00000004)
113 #define FLASH_WRProt_Pages12to15 ((uint32_t)0x00000008)
114 #define FLASH_WRProt_Pages16to19 ((uint32_t)0x00000010)
115 #define FLASH_WRProt_Pages20to23 ((uint32_t)0x00000020)
116 #define FLASH_WRProt_Pages24to27 ((uint32_t)0x00000040)
117 #define FLASH_WRProt_Pages28to31 ((uint32_t)0x00000080)
119 /* Values to be used with STM32 Medium-density devices */
120 #define FLASH_WRProt_Pages32to35 ((uint32_t)0x00000100)
121 #define FLASH_WRProt_Pages36to39 ((uint32_t)0x00000200)
122 #define FLASH_WRProt_Pages40to43 ((uint32_t)0x00000400)
123 #define FLASH_WRProt_Pages44to47 ((uint32_t)0x00000800)
124 #define FLASH_WRProt_Pages48to51 ((uint32_t)0x00001000)
125 #define FLASH_WRProt_Pages52to55 ((uint32_t)0x00002000)
126 #define FLASH_WRProt_Pages56to59 ((uint32_t)0x00004000)
127 #define FLASH_WRProt_Pages60to63 ((uint32_t)0x00008000)
128 #define FLASH_WRProt_Pages64to67 ((uint32_t)0x00010000)
129 #define FLASH_WRProt_Pages68to71 ((uint32_t)0x00020000)
130 #define FLASH_WRProt_Pages72to75 ((uint32_t)0x00040000)
131 #define FLASH_WRProt_Pages76to79 ((uint32_t)0x00080000)
132 #define FLASH_WRProt_Pages80to83 ((uint32_t)0x00100000)
133 #define FLASH_WRProt_Pages84to87 ((uint32_t)0x00200000)
134 #define FLASH_WRProt_Pages88to91 ((uint32_t)0x00400000)
135 #define FLASH_WRProt_Pages92to95 ((uint32_t)0x00800000)
136 #define FLASH_WRProt_Pages96to99 ((uint32_t)0x01000000)
137 #define FLASH_WRProt_Pages100to103 ((uint32_t)0x02000000)
138 #define FLASH_WRProt_Pages104to107 ((uint32_t)0x04000000)
139 #define FLASH_WRProt_Pages108to111 ((uint32_t)0x08000000)
140 #define FLASH_WRProt_Pages112to115 ((uint32_t)0x10000000)
141 #define FLASH_WRProt_Pages116to119 ((uint32_t)0x20000000)
142 #define FLASH_WRProt_Pages120to123 ((uint32_t)0x40000000)
143 #define FLASH_WRProt_Pages124to127 ((uint32_t)0x80000000)
145 /* Values to be used with STM32 High-density and STM32F10X Connectivity line devices */
146 #define FLASH_WRProt_Pages0to1 ((uint32_t)0x00000001)
148 #define FLASH_WRProt_Pages2to3 ((uint32_t)0x00000002)
150 #define FLASH_WRProt_Pages4to5 ((uint32_t)0x00000004)
152 #define FLASH_WRProt_Pages6to7 ((uint32_t)0x00000008)
154 #define FLASH_WRProt_Pages8to9 ((uint32_t)0x00000010)
156 #define FLASH_WRProt_Pages10to11 ((uint32_t)0x00000020)
158 #define FLASH_WRProt_Pages12to13 ((uint32_t)0x00000040)
160 #define FLASH_WRProt_Pages14to15 ((uint32_t)0x00000080)
162 #define FLASH_WRProt_Pages16to17 ((uint32_t)0x00000100)
164 #define FLASH_WRProt_Pages18to19 ((uint32_t)0x00000200)
166 #define FLASH_WRProt_Pages20to21 ((uint32_t)0x00000400)
168 #define FLASH_WRProt_Pages22to23 ((uint32_t)0x00000800)
170 #define FLASH_WRProt_Pages24to25 ((uint32_t)0x00001000)
172 #define FLASH_WRProt_Pages26to27 ((uint32_t)0x00002000)
174 #define FLASH_WRProt_Pages28to29 ((uint32_t)0x00004000)
176 #define FLASH_WRProt_Pages30to31 ((uint32_t)0x00008000)
178 #define FLASH_WRProt_Pages32to33 ((uint32_t)0x00010000)
180 #define FLASH_WRProt_Pages34to35 ((uint32_t)0x00020000)
182 #define FLASH_WRProt_Pages36to37 ((uint32_t)0x00040000)
184 #define FLASH_WRProt_Pages38to39 ((uint32_t)0x00080000)
186 #define FLASH_WRProt_Pages40to41 ((uint32_t)0x00100000)
188 #define FLASH_WRProt_Pages42to43 ((uint32_t)0x00200000)
190 #define FLASH_WRProt_Pages44to45 ((uint32_t)0x00400000)
192 #define FLASH_WRProt_Pages46to47 ((uint32_t)0x00800000)
194 #define FLASH_WRProt_Pages48to49 ((uint32_t)0x01000000)
196 #define FLASH_WRProt_Pages50to51 ((uint32_t)0x02000000)
198 #define FLASH_WRProt_Pages52to53 ((uint32_t)0x04000000)
200 #define FLASH_WRProt_Pages54to55 ((uint32_t)0x08000000)
202 #define FLASH_WRProt_Pages56to57 ((uint32_t)0x10000000)
204 #define FLASH_WRProt_Pages58to59 ((uint32_t)0x20000000)
206 #define FLASH_WRProt_Pages60to61 ((uint32_t)0x40000000)
208 #define FLASH_WRProt_Pages62to127 ((uint32_t)0x80000000)
209 #define FLASH_WRProt_Pages62to255 ((uint32_t)0x80000000)
210 #define FLASH_WRProt_Pages62to511 ((uint32_t)0x80000000)
212 #define FLASH_WRProt_AllPages ((uint32_t)0xFFFFFFFF)
214 #define IS_FLASH_WRPROT_PAGE(PAGE) (((PAGE) != 0x00000000))
216 #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF))
217 
218 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
219 
228 #define OB_IWDG_SW ((uint16_t)0x0001)
229 #define OB_IWDG_HW ((uint16_t)0x0000)
230 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
231 
240 #define OB_STOP_NoRST ((uint16_t)0x0002)
241 #define OB_STOP_RST ((uint16_t)0x0000)
242 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
252 #define OB_STDBY_NoRST ((uint16_t)0x0004)
253 #define OB_STDBY_RST ((uint16_t)0x0000)
254 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
255 
256 #ifdef STM32F10X_XL
257 
263 #define FLASH_BOOT_Bank1 ((uint16_t)0x0000)
265 #define FLASH_BOOT_Bank2 ((uint16_t)0x0001)
268 #define IS_FLASH_BOOT(BOOT) (((BOOT) == FLASH_BOOT_Bank1) || ((BOOT) == FLASH_BOOT_Bank2))
269 #endif
270 
276 #ifdef STM32F10X_XL
277 #define FLASH_IT_BANK2_ERROR ((uint32_t)0x80000400)
278 #define FLASH_IT_BANK2_EOP ((uint32_t)0x80001000)
280 #define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR
281 #define FLASH_IT_BANK1_EOP FLASH_IT_EOP
283 #define FLASH_IT_ERROR ((uint32_t)0x00000400)
284 #define FLASH_IT_EOP ((uint32_t)0x00001000)
285 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0x7FFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
286 #else
287 #define FLASH_IT_ERROR ((uint32_t)0x00000400)
288 #define FLASH_IT_EOP ((uint32_t)0x00001000)
289 #define FLASH_IT_BANK1_ERROR FLASH_IT_ERROR
290 #define FLASH_IT_BANK1_EOP FLASH_IT_EOP
292 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
293 #endif
294 
302 #ifdef STM32F10X_XL
303 #define FLASH_FLAG_BANK2_BSY ((uint32_t)0x80000001)
304 #define FLASH_FLAG_BANK2_EOP ((uint32_t)0x80000020)
305 #define FLASH_FLAG_BANK2_PGERR ((uint32_t)0x80000004)
306 #define FLASH_FLAG_BANK2_WRPRTERR ((uint32_t)0x80000010)
308 #define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY
309 #define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP
310 #define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR
311 #define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR
313 #define FLASH_FLAG_BSY ((uint32_t)0x00000001)
314 #define FLASH_FLAG_EOP ((uint32_t)0x00000020)
315 #define FLASH_FLAG_PGERR ((uint32_t)0x00000004)
316 #define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010)
317 #define FLASH_FLAG_OPTERR ((uint32_t)0x00000001)
319 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0x7FFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
320 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
321  ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
322  ((FLAG) == FLASH_FLAG_OPTERR)|| \
323  ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
324  ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
325  ((FLAG) == FLASH_FLAG_BANK2_BSY) || ((FLAG) == FLASH_FLAG_BANK2_EOP) || \
326  ((FLAG) == FLASH_FLAG_BANK2_PGERR) || ((FLAG) == FLASH_FLAG_BANK2_WRPRTERR))
327 #else
328 #define FLASH_FLAG_BSY ((uint32_t)0x00000001)
329 #define FLASH_FLAG_EOP ((uint32_t)0x00000020)
330 #define FLASH_FLAG_PGERR ((uint32_t)0x00000004)
331 #define FLASH_FLAG_WRPRTERR ((uint32_t)0x00000010)
332 #define FLASH_FLAG_OPTERR ((uint32_t)0x00000001)
334 #define FLASH_FLAG_BANK1_BSY FLASH_FLAG_BSY
335 #define FLASH_FLAG_BANK1_EOP FLASH_FLAG_EOP
336 #define FLASH_FLAG_BANK1_PGERR FLASH_FLAG_PGERR
337 #define FLASH_FLAG_BANK1_WRPRTERR FLASH_FLAG_WRPRTERR
339 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFCA) == 0x00000000) && ((FLAG) != 0x00000000))
340 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_EOP) || \
341  ((FLAG) == FLASH_FLAG_PGERR) || ((FLAG) == FLASH_FLAG_WRPRTERR) || \
342  ((FLAG) == FLASH_FLAG_BANK1_BSY) || ((FLAG) == FLASH_FLAG_BANK1_EOP) || \
343  ((FLAG) == FLASH_FLAG_BANK1_PGERR) || ((FLAG) == FLASH_FLAG_BANK1_WRPRTERR) || \
344  ((FLAG) == FLASH_FLAG_OPTERR))
345 #endif
346 
367 /*------------ Functions used for all STM32F10x devices -----*/
368 void FLASH_SetLatency(uint32_t FLASH_Latency);
369 void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess);
370 void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer);
371 void FLASH_Unlock(void);
372 void FLASH_Lock(void);
373 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
374 FLASH_Status FLASH_EraseAllPages(void);
375 FLASH_Status FLASH_EraseOptionBytes(void);
376 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
377 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
378 FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);
379 FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages);
380 FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState);
381 FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY);
382 uint32_t FLASH_GetUserOptionByte(void);
386 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
387 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
388 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
389 FLASH_Status FLASH_GetStatus(void);
390 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
391 
392 /*------------ New function used for all STM32F10x devices -----*/
393 void FLASH_UnlockBank1(void);
394 void FLASH_LockBank1(void);
395 FLASH_Status FLASH_EraseAllBank1Pages(void);
396 FLASH_Status FLASH_GetBank1Status(void);
397 FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout);
398 
399 #ifdef STM32F10X_XL
400 /*---- New Functions used only with STM32F10x_XL density devices -----*/
401 void FLASH_UnlockBank2(void);
402 void FLASH_LockBank2(void);
403 FLASH_Status FLASH_EraseAllBank2Pages(void);
404 FLASH_Status FLASH_GetBank2Status(void);
405 FLASH_Status FLASH_WaitForLastBank2Operation(uint32_t Timeout);
406 FLASH_Status FLASH_BootConfig(uint16_t FLASH_BOOT);
407 #endif
408 
409 #ifdef __cplusplus
410 }
411 #endif
412 
413 #endif /* __STM32F10x_FLASH_H */
414 
426 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
FlagStatus
Definition: stm32f4xx.h:706
FLASH_Status
FLASH Status.
FunctionalState
Definition: stm32f4xx.h:708
FLASH_Status FLASH_EraseAllPages(void)
Erases all FLASH pages.
void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState)
Enables or disables the specified FLASH interrupts.
void FLASH_Lock(void)
Locks the FLASH control register access.
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
Programs a half word (16-bit) at a specified address.
FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data)
Programs a half word at a specified Option Byte Data address.
FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout)
Waits for a Flash operation to complete or a TIMEOUT to occur.
FlagStatus FLASH_GetPrefetchBufferStatus(void)
Checks whether the FLASH Prefetch Buffer status is set or not.
void FLASH_PrefetchBufferCmd(uint32_t FLASH_PrefetchBuffer)
Enables or disables the Prefetch Buffer.
FLASH_Status FLASH_EraseOptionBytes(void)
Erases the FLASH option bytes.
FLASH_Status FLASH_UserOptionByteConfig(uint16_t OB_IWDG, uint16_t OB_STOP, uint16_t OB_STDBY)
Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
void FLASH_UnlockBank1(void)
Unlocks the FLASH Bank1 Program Erase Controller.
void FLASH_ClearFlag(uint32_t FLASH_FLAG)
Clears the FLASH&#39;s pending flags.
FLASH_Status FLASH_GetBank1Status(void)
Returns the FLASH Bank1 Status.
FlagStatus FLASH_GetReadOutProtectionStatus(void)
Checks whether the FLASH Read Out Protection Status is set or not.
FLASH_Status FLASH_GetStatus(void)
Returns the FLASH Status.
FLASH_Status FLASH_EnableWriteProtection(uint32_t FLASH_Pages)
Write protects the desired pages.
uint32_t FLASH_GetUserOptionByte(void)
Returns the FLASH User Option Bytes values.
FLASH_Status FLASH_EraseAllBank1Pages(void)
Erases all Bank1 FLASH pages.
FLASH_Status FLASH_ErasePage(uint32_t Page_Address)
Erases a specified FLASH page.
void FLASH_Unlock(void)
Unlocks the FLASH control register access.
void FLASH_HalfCycleAccessCmd(uint32_t FLASH_HalfCycleAccess)
Enables or disables the Half cycle flash access.
CMSIS Cortex-M3 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
void FLASH_LockBank1(void)
Locks the FLASH Bank1 Program Erase Controller.
FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG)
Checks whether the specified FLASH flag is set or not.
FLASH_Status FLASH_ReadOutProtection(FunctionalState NewState)
Enables or disables the read out protection.
FLASH_Status FLASH_WaitForLastBank1Operation(uint32_t Timeout)
Waits for a Flash operation on Bank1 to complete or a TIMEOUT to occur.
FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
Programs a word (32-bit) at a specified address.
uint32_t FLASH_GetWriteProtectionOptionByte(void)
Returns the FLASH Write Protection Option Bytes Register value.
void FLASH_SetLatency(uint32_t FLASH_Latency)
Sets the code latency value.


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:25