24 #ifndef __STM32F4xx_FLASH_H
25 #define __STM32F4xx_FLASH_H
54 FLASH_ERROR_OPERATION,
67 #define FLASH_Latency_0 ((uint8_t)0x0000)
68 #define FLASH_Latency_1 ((uint8_t)0x0001)
69 #define FLASH_Latency_2 ((uint8_t)0x0002)
70 #define FLASH_Latency_3 ((uint8_t)0x0003)
71 #define FLASH_Latency_4 ((uint8_t)0x0004)
72 #define FLASH_Latency_5 ((uint8_t)0x0005)
73 #define FLASH_Latency_6 ((uint8_t)0x0006)
74 #define FLASH_Latency_7 ((uint8_t)0x0007)
76 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
77 ((LATENCY) == FLASH_Latency_1) || \
78 ((LATENCY) == FLASH_Latency_2) || \
79 ((LATENCY) == FLASH_Latency_3) || \
80 ((LATENCY) == FLASH_Latency_4) || \
81 ((LATENCY) == FLASH_Latency_5) || \
82 ((LATENCY) == FLASH_Latency_6) || \
83 ((LATENCY) == FLASH_Latency_7))
91 #define VoltageRange_1 ((uint8_t)0x00)
92 #define VoltageRange_2 ((uint8_t)0x01)
93 #define VoltageRange_3 ((uint8_t)0x02)
94 #define VoltageRange_4 ((uint8_t)0x03)
96 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == VoltageRange_1) || \
97 ((RANGE) == VoltageRange_2) || \
98 ((RANGE) == VoltageRange_3) || \
99 ((RANGE) == VoltageRange_4))
107 #define FLASH_Sector_0 ((uint16_t)0x0000)
108 #define FLASH_Sector_1 ((uint16_t)0x0008)
109 #define FLASH_Sector_2 ((uint16_t)0x0010)
110 #define FLASH_Sector_3 ((uint16_t)0x0018)
111 #define FLASH_Sector_4 ((uint16_t)0x0020)
112 #define FLASH_Sector_5 ((uint16_t)0x0028)
113 #define FLASH_Sector_6 ((uint16_t)0x0030)
114 #define FLASH_Sector_7 ((uint16_t)0x0038)
115 #define FLASH_Sector_8 ((uint16_t)0x0040)
116 #define FLASH_Sector_9 ((uint16_t)0x0048)
117 #define FLASH_Sector_10 ((uint16_t)0x0050)
118 #define FLASH_Sector_11 ((uint16_t)0x0058)
119 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_Sector_0) || ((SECTOR) == FLASH_Sector_1) ||\
120 ((SECTOR) == FLASH_Sector_2) || ((SECTOR) == FLASH_Sector_3) ||\
121 ((SECTOR) == FLASH_Sector_4) || ((SECTOR) == FLASH_Sector_5) ||\
122 ((SECTOR) == FLASH_Sector_6) || ((SECTOR) == FLASH_Sector_7) ||\
123 ((SECTOR) == FLASH_Sector_8) || ((SECTOR) == FLASH_Sector_9) ||\
124 ((SECTOR) == FLASH_Sector_10) || ((SECTOR) == FLASH_Sector_11))
125 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= 0x08000000) && ((ADDRESS) < 0x080FFFFF)) ||\
126 (((ADDRESS) >= 0x1FFF7800) && ((ADDRESS) < 0x1FFF7A0F)))
134 #define OB_WRP_Sector_0 ((uint32_t)0x00000001)
135 #define OB_WRP_Sector_1 ((uint32_t)0x00000002)
136 #define OB_WRP_Sector_2 ((uint32_t)0x00000004)
137 #define OB_WRP_Sector_3 ((uint32_t)0x00000008)
138 #define OB_WRP_Sector_4 ((uint32_t)0x00000010)
139 #define OB_WRP_Sector_5 ((uint32_t)0x00000020)
140 #define OB_WRP_Sector_6 ((uint32_t)0x00000040)
141 #define OB_WRP_Sector_7 ((uint32_t)0x00000080)
142 #define OB_WRP_Sector_8 ((uint32_t)0x00000100)
143 #define OB_WRP_Sector_9 ((uint32_t)0x00000200)
144 #define OB_WRP_Sector_10 ((uint32_t)0x00000400)
145 #define OB_WRP_Sector_11 ((uint32_t)0x00000800)
146 #define OB_WRP_Sector_All ((uint32_t)0x00000FFF)
148 #define IS_OB_WRP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
156 #define OB_RDP_Level_0 ((uint8_t)0xAA)
157 #define OB_RDP_Level_1 ((uint8_t)0x55)
160 #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\
161 ((LEVEL) == OB_RDP_Level_1))
170 #define OB_IWDG_SW ((uint8_t)0x20)
171 #define OB_IWDG_HW ((uint8_t)0x00)
172 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
180 #define OB_STOP_NoRST ((uint8_t)0x40)
181 #define OB_STOP_RST ((uint8_t)0x00)
182 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
191 #define OB_STDBY_NoRST ((uint8_t)0x80)
192 #define OB_STDBY_RST ((uint8_t)0x00)
193 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
201 #define OB_BOR_LEVEL3 ((uint8_t)0x00)
202 #define OB_BOR_LEVEL2 ((uint8_t)0x04)
203 #define OB_BOR_LEVEL1 ((uint8_t)0x08)
204 #define OB_BOR_OFF ((uint8_t)0x0C)
205 #define IS_OB_BOR(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
206 ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
214 #define FLASH_IT_EOP ((uint32_t)0x01000000)
215 #define FLASH_IT_ERR ((uint32_t)0x02000000)
216 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFCFFFFFF) == 0x00000000) && ((IT) != 0x00000000))
224 #define FLASH_FLAG_EOP ((uint32_t)0x00000001)
225 #define FLASH_FLAG_OPERR ((uint32_t)0x00000002)
226 #define FLASH_FLAG_WRPERR ((uint32_t)0x00000010)
227 #define FLASH_FLAG_PGAERR ((uint32_t)0x00000020)
228 #define FLASH_FLAG_PGPERR ((uint32_t)0x00000040)
229 #define FLASH_FLAG_PGSERR ((uint32_t)0x00000080)
230 #define FLASH_FLAG_BSY ((uint32_t)0x00010000)
231 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFF0C) == 0x00000000) && ((FLAG) != 0x00000000))
232 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_EOP) || ((FLAG) == FLASH_FLAG_OPERR) || \
233 ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_PGAERR) || \
234 ((FLAG) == FLASH_FLAG_PGPERR) || ((FLAG) == FLASH_FLAG_PGSERR) || \
235 ((FLAG) == FLASH_FLAG_BSY))
243 #define FLASH_PSIZE_BYTE ((uint32_t)0x00000000)
244 #define FLASH_PSIZE_HALF_WORD ((uint32_t)0x00000100)
245 #define FLASH_PSIZE_WORD ((uint32_t)0x00000200)
246 #define FLASH_PSIZE_DOUBLE_WORD ((uint32_t)0x00000300)
247 #define CR_PSIZE_MASK ((uint32_t)0xFFFFFCFF)
255 #define RDP_KEY ((uint16_t)0x00A5)
256 #define FLASH_KEY1 ((uint32_t)0x45670123)
257 #define FLASH_KEY2 ((uint32_t)0xCDEF89AB)
258 #define FLASH_OPT_KEY1 ((uint32_t)0x08192A3B)
259 #define FLASH_OPT_KEY2 ((uint32_t)0x4C5D6E7F)
267 #define ACR_BYTE0_ADDRESS ((uint32_t)0x40023C00)
271 #define OPTCR_BYTE0_ADDRESS ((uint32_t)0x40023C14)
272 #define OPTCR_BYTE1_ADDRESS ((uint32_t)0x40023C15)
273 #define OPTCR_BYTE2_ADDRESS ((uint32_t)0x40023C16)
283 void FLASH_SetLatency(uint32_t FLASH_Latency);
284 void FLASH_PrefetchBufferCmd(FunctionalState NewState);
285 void FLASH_InstructionCacheCmd(FunctionalState NewState);
286 void FLASH_DataCacheCmd(FunctionalState NewState);
287 void FLASH_InstructionCacheReset(
void);
288 void FLASH_DataCacheReset(
void);
291 void FLASH_Unlock(
void);
292 void FLASH_Lock(
void);
293 FLASH_Status FLASH_EraseSector(uint32_t FLASH_Sector, uint8_t VoltageRange);
294 FLASH_Status FLASH_EraseAllSectors(uint8_t VoltageRange);
295 FLASH_Status FLASH_ProgramDoubleWord(uint32_t Address, uint64_t Data);
296 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
297 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
298 FLASH_Status FLASH_ProgramByte(uint32_t Address, uint8_t Data);
301 void FLASH_OB_Unlock(
void);
302 void FLASH_OB_Lock(
void);
303 void FLASH_OB_WRPConfig(uint32_t OB_WRP, FunctionalState NewState);
304 void FLASH_OB_RDPConfig(uint8_t OB_RDP);
305 void FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY);
306 void FLASH_OB_BORConfig(uint8_t OB_BOR);
308 uint8_t FLASH_OB_GetUser(
void);
309 uint16_t FLASH_OB_GetWRP(
void);
310 FlagStatus FLASH_OB_GetRDP(
void);
311 uint8_t FLASH_OB_GetBOR(
void);
314 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
315 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
316 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
CMSIS Cortex-M4 Device Peripheral Access Layer Header File. This file contains all the peripheral reg...
FLASH_Status
FLASH Status.