stm32f4xx_flash.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F4xx_FLASH_H
31 #define __STM32F4xx_FLASH_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f4xx.h"
39 
48 /* Exported types ------------------------------------------------------------*/
52 typedef enum
53 {
63 
64 /* Exported constants --------------------------------------------------------*/
65 
73 #define FLASH_Latency_0 ((uint8_t)0x0000)
74 #define FLASH_Latency_1 ((uint8_t)0x0001)
75 #define FLASH_Latency_2 ((uint8_t)0x0002)
76 #define FLASH_Latency_3 ((uint8_t)0x0003)
77 #define FLASH_Latency_4 ((uint8_t)0x0004)
78 #define FLASH_Latency_5 ((uint8_t)0x0005)
79 #define FLASH_Latency_6 ((uint8_t)0x0006)
80 #define FLASH_Latency_7 ((uint8_t)0x0007)
82 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
83  ((LATENCY) == FLASH_Latency_1) || \
84  ((LATENCY) == FLASH_Latency_2) || \
85  ((LATENCY) == FLASH_Latency_3) || \
86  ((LATENCY) == FLASH_Latency_4) || \
87  ((LATENCY) == FLASH_Latency_5) || \
88  ((LATENCY) == FLASH_Latency_6) || \
89  ((LATENCY) == FLASH_Latency_7))
90 
98 #define VoltageRange_1 ((uint8_t)0x00)
99 #define VoltageRange_2 ((uint8_t)0x01)
100 #define VoltageRange_3 ((uint8_t)0x02)
101 #define VoltageRange_4 ((uint8_t)0x03)
103 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == VoltageRange_1) || \
104  ((RANGE) == VoltageRange_2) || \
105  ((RANGE) == VoltageRange_3) || \
106  ((RANGE) == VoltageRange_4))
107 
114 #define FLASH_Sector_0 ((uint16_t)0x0000)
115 #define FLASH_Sector_1 ((uint16_t)0x0008)
116 #define FLASH_Sector_2 ((uint16_t)0x0010)
117 #define FLASH_Sector_3 ((uint16_t)0x0018)
118 #define FLASH_Sector_4 ((uint16_t)0x0020)
119 #define FLASH_Sector_5 ((uint16_t)0x0028)
120 #define FLASH_Sector_6 ((uint16_t)0x0030)
121 #define FLASH_Sector_7 ((uint16_t)0x0038)
122 #define FLASH_Sector_8 ((uint16_t)0x0040)
123 #define FLASH_Sector_9 ((uint16_t)0x0048)
124 #define FLASH_Sector_10 ((uint16_t)0x0050)
125 #define FLASH_Sector_11 ((uint16_t)0x0058)
126 #define FLASH_Sector_12 ((uint16_t)0x0080)
127 #define FLASH_Sector_13 ((uint16_t)0x0088)
128 #define FLASH_Sector_14 ((uint16_t)0x0090)
129 #define FLASH_Sector_15 ((uint16_t)0x0098)
130 #define FLASH_Sector_16 ((uint16_t)0x00A0)
131 #define FLASH_Sector_17 ((uint16_t)0x00A8)
132 #define FLASH_Sector_18 ((uint16_t)0x00B0)
133 #define FLASH_Sector_19 ((uint16_t)0x00B8)
134 #define FLASH_Sector_20 ((uint16_t)0x00C0)
135 #define FLASH_Sector_21 ((uint16_t)0x00C8)
136 #define FLASH_Sector_22 ((uint16_t)0x00D0)
137 #define FLASH_Sector_23 ((uint16_t)0x00D8)
139 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_Sector_0) || ((SECTOR) == FLASH_Sector_1) ||\
140  ((SECTOR) == FLASH_Sector_2) || ((SECTOR) == FLASH_Sector_3) ||\
141  ((SECTOR) == FLASH_Sector_4) || ((SECTOR) == FLASH_Sector_5) ||\
142  ((SECTOR) == FLASH_Sector_6) || ((SECTOR) == FLASH_Sector_7) ||\
143  ((SECTOR) == FLASH_Sector_8) || ((SECTOR) == FLASH_Sector_9) ||\
144  ((SECTOR) == FLASH_Sector_10) || ((SECTOR) == FLASH_Sector_11) ||\
145  ((SECTOR) == FLASH_Sector_12) || ((SECTOR) == FLASH_Sector_13) ||\
146  ((SECTOR) == FLASH_Sector_14) || ((SECTOR) == FLASH_Sector_15) ||\
147  ((SECTOR) == FLASH_Sector_16) || ((SECTOR) == FLASH_Sector_17) ||\
148  ((SECTOR) == FLASH_Sector_18) || ((SECTOR) == FLASH_Sector_19) ||\
149  ((SECTOR) == FLASH_Sector_20) || ((SECTOR) == FLASH_Sector_21) ||\
150  ((SECTOR) == FLASH_Sector_22) || ((SECTOR) == FLASH_Sector_23))
151 
152 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x081FFFFF)) ||\
153  (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) < 0x1FFF7A0F)))
154 
161 #define OB_WRP_Sector_0 ((uint32_t)0x00000001)
162 #define OB_WRP_Sector_1 ((uint32_t)0x00000002)
163 #define OB_WRP_Sector_2 ((uint32_t)0x00000004)
164 #define OB_WRP_Sector_3 ((uint32_t)0x00000008)
165 #define OB_WRP_Sector_4 ((uint32_t)0x00000010)
166 #define OB_WRP_Sector_5 ((uint32_t)0x00000020)
167 #define OB_WRP_Sector_6 ((uint32_t)0x00000040)
168 #define OB_WRP_Sector_7 ((uint32_t)0x00000080)
169 #define OB_WRP_Sector_8 ((uint32_t)0x00000100)
170 #define OB_WRP_Sector_9 ((uint32_t)0x00000200)
171 #define OB_WRP_Sector_10 ((uint32_t)0x00000400)
172 #define OB_WRP_Sector_11 ((uint32_t)0x00000800)
173 #define OB_WRP_Sector_12 ((uint32_t)0x00000001)
174 #define OB_WRP_Sector_13 ((uint32_t)0x00000002)
175 #define OB_WRP_Sector_14 ((uint32_t)0x00000004)
176 #define OB_WRP_Sector_15 ((uint32_t)0x00000008)
177 #define OB_WRP_Sector_16 ((uint32_t)0x00000010)
178 #define OB_WRP_Sector_17 ((uint32_t)0x00000020)
179 #define OB_WRP_Sector_18 ((uint32_t)0x00000040)
180 #define OB_WRP_Sector_19 ((uint32_t)0x00000080)
181 #define OB_WRP_Sector_20 ((uint32_t)0x00000100)
182 #define OB_WRP_Sector_21 ((uint32_t)0x00000200)
183 #define OB_WRP_Sector_22 ((uint32_t)0x00000400)
184 #define OB_WRP_Sector_23 ((uint32_t)0x00000800)
185 #define OB_WRP_Sector_All ((uint32_t)0x00000FFF)
187 #define IS_OB_WRP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
188 
195 #define OB_RDP_Level_0 ((uint8_t)0xAA)
196 #define OB_RDP_Level_1 ((uint8_t)0x55)
197 /*#define OB_RDP_Level_2 ((uint8_t)0xCC)*/
199 #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\
200  ((LEVEL) == OB_RDP_Level_1))/*||\
201  ((LEVEL) == OB_RDP_Level_2))*/
202 
209 #define OB_IWDG_SW ((uint8_t)0x20)
210 #define OB_IWDG_HW ((uint8_t)0x00)
211 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
212 
219 #define OB_STOP_NoRST ((uint8_t)0x40)
220 #define OB_STOP_RST ((uint8_t)0x00)
221 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
222 
230 #define OB_STDBY_NoRST ((uint8_t)0x80)
231 #define OB_STDBY_RST ((uint8_t)0x00)
232 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
233 
240 #define OB_BOR_LEVEL3 ((uint8_t)0x00)
241 #define OB_BOR_LEVEL2 ((uint8_t)0x04)
242 #define OB_BOR_LEVEL1 ((uint8_t)0x08)
243 #define OB_BOR_OFF ((uint8_t)0x0C)
244 #define IS_OB_BOR(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
245  ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
246 
253 #define FLASH_IT_EOP ((uint32_t)0x01000000)
254 #define FLASH_IT_ERR ((uint32_t)0x02000000)
255 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFCFFFFFF) == 0x00000000) && ((IT) != 0x00000000))
256 
263 #define FLASH_FLAG_EOP ((uint32_t)0x00000001)
264 #define FLASH_FLAG_OPERR ((uint32_t)0x00000002)
265 #define FLASH_FLAG_WRPERR ((uint32_t)0x00000010)
266 #define FLASH_FLAG_PGAERR ((uint32_t)0x00000020)
267 #define FLASH_FLAG_PGPERR ((uint32_t)0x00000040)
268 #define FLASH_FLAG_PGSERR ((uint32_t)0x00000080)
269 #define FLASH_FLAG_BSY ((uint32_t)0x00010000)
270 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFE0C) == 0x00000000) && ((FLAG) != 0x00000000))
271 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_EOP) || ((FLAG) == FLASH_FLAG_OPERR) || \
272  ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_PGAERR) || \
273  ((FLAG) == FLASH_FLAG_PGPERR) || ((FLAG) == FLASH_FLAG_PGSERR) || \
274  ((FLAG) == FLASH_FLAG_BSY))
275 
282 #define FLASH_PSIZE_BYTE ((uint32_t)0x00000000)
283 #define FLASH_PSIZE_HALF_WORD ((uint32_t)0x00000100)
284 #define FLASH_PSIZE_WORD ((uint32_t)0x00000200)
285 #define FLASH_PSIZE_DOUBLE_WORD ((uint32_t)0x00000300)
286 #define CR_PSIZE_MASK ((uint32_t)0xFFFFFCFF)
287 
294 #define RDP_KEY ((uint16_t)0x00A5)
295 #define FLASH_KEY1 ((uint32_t)0x45670123)
296 #define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
297 #define FLASH_OPT_KEY1 ((uint32_t)0x08192A3B)
298 #define FLASH_OPT_KEY2 ((uint32_t)0x4C5D6E7F)
299 
306 #define ACR_BYTE0_ADDRESS ((uint32_t)0x40023C00)
307 
310 #define OPTCR_BYTE0_ADDRESS ((uint32_t)0x40023C14)
311 
314 #define OPTCR_BYTE1_ADDRESS ((uint32_t)0x40023C15)
315 
318 #define OPTCR_BYTE2_ADDRESS ((uint32_t)0x40023C16)
319 
322 #define OPTCR_BYTE3_ADDRESS ((uint32_t)0x40023C17)
323 
327 #define OPTCR1_BYTE2_ADDRESS ((uint32_t)0x40023C1A)
328 
333 /* Exported macro ------------------------------------------------------------*/
334 /* Exported functions --------------------------------------------------------*/
335 
336 /* FLASH Interface configuration functions ************************************/
337 void FLASH_SetLatency(uint32_t FLASH_Latency);
340 void FLASH_DataCacheCmd(FunctionalState NewState);
341 void FLASH_InstructionCacheReset(void);
342 void FLASH_DataCacheReset(void);
343 
344 /* FLASH Memory Programming functions *****************************************/
345 void FLASH_Unlock(void);
346 void FLASH_Lock(void);
347 FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange);
348 FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange);
349 FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data);
350 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
351 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
352 FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data);
353 
354 /* Option Bytes Programming functions *****************************************/
355 void FLASH_OB_Unlock(void);
356 void FLASH_OB_Lock(void);
357 void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState);
358 void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState);
359 void FLASH_OB_RDPConfig(uint8_t OB_RDP);
360 void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY);
361 void FLASH_OB_BORConfig(uint8_t OB_BOR);
362 FLASH_Status FLASH_OB_Launch(void);
363 uint8_t FLASH_OB_GetUser(void);
364 uint16_t FLASH_OB_GetWRP(void);
365 uint16_t FLASH_OB_GetWRP1(void);
367 uint8_t FLASH_OB_GetBOR(void);
368 
369 /* Interrupts and flags management functions **********************************/
370 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
371 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
372 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
373 FLASH_Status FLASH_GetStatus(void);
374 FLASH_Status FLASH_WaitForLastOperation(void);
375 
376 #ifdef __cplusplus
377 }
378 #endif
379 
380 #endif /* __STM32F4xx_FLASH_H */
381 
390 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void FLASH_SetLatency(uint32_t FLASH_Latency)
Sets the code latency value.
FLASH_Status FLASH_WaitForLastOperation(void)
Waits for a FLASH operation to complete.
FlagStatus
Definition: stm32f4xx.h:706
void FLASH_Unlock(void)
Unlocks the FLASH control register access.
FunctionalState
Definition: stm32f4xx.h:708
FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange)
Erases all FLASH Sectors.
void FLASH_DataCacheReset(void)
Resets the Data Cache.
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY)
Programs the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.
uint8_t FLASH_OB_GetBOR(void)
Returns the FLASH BOR level.
void FLASH_InstructionCacheCmd(FunctionalState NewState)
Enables or disables the Instruction Cache feature.
void FLASH_PrefetchBufferCmd(FunctionalState NewState)
Enables or disables the Prefetch Buffer.
void FLASH_OB_RDPConfig(uint8_t OB_RDP)
Enables or disables the read out protection.
void FLASH_InstructionCacheReset(void)
Resets the Instruction Cache.
void FLASH_ClearFlag(uint32_t FLASH_FLAG)
Clears the FLASH&#39;s pending flags.
uint8_t FLASH_OB_GetUser(void)
Returns the FLASH User Option Bytes values.
FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data)
Programs a double word (64-bit) at a specified address.
FLASH_Status FLASH_OB_Launch(void)
Launch the option byte loading.
void FLASH_OB_Unlock(void)
Unlocks the option bytes block access.
FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data)
Programs a byte (8-bit) at a specified address.
void FLASH_DataCacheCmd(FunctionalState NewState)
Enables or disables the Data Cache feature.
uint16_t FLASH_OB_GetWRP(void)
Returns the FLASH Write Protection Option Bytes value.
void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState)
Enables or disables the specified FLASH interrupts.
void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState)
Enables or disables the write protection of the desired sectors.
void FLASH_OB_WRP1Config(uint32_t OB_WRP, FunctionalState NewState)
Enables or disables the write protection of the desired sectors.
FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG)
Checks whether the specified FLASH flag is set or not.
FLASH_Status FLASH_GetStatus(void)
Returns the FLASH Status.
void FLASH_OB_BORConfig(uint8_t OB_BOR)
Sets the BOR Level.
FlagStatus FLASH_OB_GetRDP(void)
Checks whether the FLASH Read out Protection Status is set or not.
FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data)
Programs a word at a specified address.
FLASH_Status
FLASH Status.
void FLASH_Lock(void)
Locks the FLASH control register access.
FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange)
Erases a specified FLASH Sector.
uint16_t FLASH_OB_GetWRP1(void)
Returns the FLASH Write Protection Option Bytes value.
void FLASH_OB_Lock(void)
Locks the option bytes block access.
FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data)
Programs a half word at a specified address.


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