STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f0xx_flash.h
Go to the documentation of this file.
1 
29 /* Define to prevent recursive inclusion -------------------------------------*/
30 #ifndef __STM32F0XX_FLASH_H
31 #define __STM32F0XX_FLASH_H
32 
33 #ifdef __cplusplus
34  extern "C" {
35 #endif
36 
37 /* Includes ------------------------------------------------------------------*/
38 #include "stm32f0xx.h"
39 
48 /* Exported types ------------------------------------------------------------*/
49 
53 typedef enum
54 {
55  FLASH_BUSY = 1,
56  FLASH_ERROR_WRP,
57  FLASH_ERROR_PROGRAM,
58  FLASH_COMPLETE,
59  FLASH_TIMEOUT
61 
62 /* Exported constants --------------------------------------------------------*/
63 
71 #define FLASH_Latency_0 ((uint32_t)0x00000000)
72 #define FLASH_Latency_1 FLASH_ACR_LATENCY
74 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_Latency_0) || \
75  ((LATENCY) == FLASH_Latency_1))
76 
84 #define FLASH_IT_EOP FLASH_CR_EOPIE
85 #define FLASH_IT_ERR FLASH_CR_ERRIE
86 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && (((IT) != 0x00000000)))
87 
95 #define IS_FLASH_PROGRAM_ADDRESS(ADDRESS) (((ADDRESS) >= 0x08000000) && ((ADDRESS) <= 0x0800FFFF))
96 
104 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
105 
115 #define OB_WRP_Pages0to3 ((uint32_t)0x00000001) /* Write protection of page 0 to 3 */
116 #define OB_WRP_Pages4to7 ((uint32_t)0x00000002) /* Write protection of page 4 to 7 */
117 #define OB_WRP_Pages8to11 ((uint32_t)0x00000004) /* Write protection of page 8 to 11 */
118 #define OB_WRP_Pages12to15 ((uint32_t)0x00000008) /* Write protection of page 12 to 15 */
119 #define OB_WRP_Pages16to19 ((uint32_t)0x00000010) /* Write protection of page 16 to 19 */
120 #define OB_WRP_Pages20to23 ((uint32_t)0x00000020) /* Write protection of page 20 to 23 */
121 #define OB_WRP_Pages24to27 ((uint32_t)0x00000040) /* Write protection of page 24 to 27 */
122 #define OB_WRP_Pages28to31 ((uint32_t)0x00000080) /* Write protection of page 28 to 31 */
123 #define OB_WRP_Pages32to35 ((uint32_t)0x00000100) /* Write protection of page 32 to 35 */
124 #define OB_WRP_Pages36to39 ((uint32_t)0x00000200) /* Write protection of page 36 to 39 */
125 #define OB_WRP_Pages40to43 ((uint32_t)0x00000400) /* Write protection of page 40 to 43 */
126 #define OB_WRP_Pages44to47 ((uint32_t)0x00000800) /* Write protection of page 44 to 47 */
127 #define OB_WRP_Pages48to51 ((uint32_t)0x00001000) /* Write protection of page 48 to 51 */
128 #define OB_WRP_Pages52to55 ((uint32_t)0x00002000) /* Write protection of page 52 to 55 */
129 #define OB_WRP_Pages56to59 ((uint32_t)0x00004000) /* Write protection of page 56 to 59 */
130 #define OB_WRP_Pages60to63 ((uint32_t)0x00008000) /* Write protection of page 60 to 63 */
131 
132 #define OB_WRP_AllPages ((uint32_t)0x0000FFFF)
134 #define IS_OB_WRP(PAGE) (((PAGE) != 0x0000000))
135 
147 #define OB_RDP_Level_0 ((uint8_t)0xAA)
148 #define OB_RDP_Level_1 ((uint8_t)0xBB)
149 /*#define OB_RDP_Level_2 ((uint8_t)0xCC)*/ /* Warning: When enabling read protection level 2
150  it's no more possible to go back to level 1 or 0 */
151 
152 #define IS_OB_RDP(LEVEL) (((LEVEL) == OB_RDP_Level_0)||\
153  ((LEVEL) == OB_RDP_Level_1))/*||\
154  ((LEVEL) == OB_RDP_Level_2))*/
155 
163 #define OB_IWDG_SW ((uint8_t)0x01)
164 #define OB_IWDG_HW ((uint8_t)0x00)
165 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
166 
175 #define OB_STOP_NoRST ((uint8_t)0x02)
176 #define OB_STOP_RST ((uint8_t)0x00)
177 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NoRST) || ((SOURCE) == OB_STOP_RST))
178 
187 #define OB_STDBY_NoRST ((uint8_t)0x04)
188 #define OB_STDBY_RST ((uint8_t)0x00)
189 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NoRST) || ((SOURCE) == OB_STDBY_RST))
190 
199 #define OB_BOOT1_RESET ((uint8_t)0x00)
200 #define OB_BOOT1_SET ((uint8_t)0x10)
201 #define IS_OB_BOOT1(BOOT1) (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET))
202 
211 #define OB_VDDA_ANALOG_ON ((uint8_t)0x00)
212 #define OB_VDDA_ANALOG_OFF ((uint8_t)0x20)
214 #define IS_OB_VDDA_ANALOG(ANALOG) (((ANALOG) == OB_VDDA_ANALOG_ON) || ((ANALOG) == OB_VDDA_ANALOG_OFF))
215 
224 #define OB_SRAM_PARITY_SET ((uint8_t)0x00)
225 #define OB_SRAM_PARITY_RESET ((uint8_t)0x40)
227 #define IS_OB_SRAM_PARITY(PARITY) (((PARITY) == OB_SRAM_PARITY_SET) || ((PARITY) == OB_SRAM_PARITY_RESET))
228 
237 #define FLASH_FLAG_BSY FLASH_SR_BSY
238 #define FLASH_FLAG_PGERR FLASH_SR_PGERR
239 #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR
240 #define FLASH_FLAG_EOP FLASH_SR_EOP
242 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFC3) == 0x00000000) && ((FLAG) != 0x00000000))
243 
244 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_PGERR) || \
245  ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_EOP))
246 
253 #define FLASH_ER_PRG_TIMEOUT ((uint32_t)0x000B0000)
254 
263 /* Exported macro ------------------------------------------------------------*/
264 /* Exported functions ------------------------------------------------------- */
265 
269 /* FLASH Interface configuration functions ************************************/
270 void FLASH_SetLatency(uint32_t FLASH_Latency);
271 void FLASH_PrefetchBufferCmd(FunctionalState NewState);
272 FlagStatus FLASH_GetPrefetchBufferStatus(void);
273 
274 /* FLASH Memory Programming functions *****************************************/
275 void FLASH_Unlock(void);
276 void FLASH_Lock(void);
277 FLASH_Status FLASH_ErasePage(uint32_t Page_Address);
279 FLASH_Status FLASH_ProgramWord(uint32_t Address, uint32_t Data);
280 FLASH_Status FLASH_ProgramHalfWord(uint32_t Address, uint16_t Data);
281 
282 /* FLASH Option Bytes Programming functions *****************************************/
283 void FLASH_OB_Unlock(void);
284 void FLASH_OB_Lock(void);
285 void FLASH_OB_Launch(void);
287 FLASH_Status FLASH_OB_EnableWRP(uint32_t OB_WRP);
288 FLASH_Status FLASH_OB_RDPConfig(uint8_t OB_RDP);
289 FLASH_Status FLASH_OB_UserConfig(uint8_t OB_IWDG, uint8_t OB_STOP, uint8_t OB_STDBY);
290 FLASH_Status FLASH_OB_BOOTConfig(uint8_t OB_BOOT1);
291 FLASH_Status FLASH_OB_VDDAConfig(uint8_t OB_VDDA_ANALOG);
292 FLASH_Status FLASH_OB_SRAMParityConfig(uint8_t OB_SRAM_Parity);
293 FLASH_Status FLASH_OB_WriteUser(uint8_t OB_USER);
294 FLASH_Status FLASH_ProgramOptionByteData(uint32_t Address, uint8_t Data);
295 uint8_t FLASH_OB_GetUser(void);
296 uint32_t FLASH_OB_GetWRP(void);
297 FlagStatus FLASH_OB_GetRDP(void);
298 
299 /* FLASH Interrupts and flags management functions **********************************/
300 void FLASH_ITConfig(uint32_t FLASH_IT, FunctionalState NewState);
301 FlagStatus FLASH_GetFlagStatus(uint32_t FLASH_FLAG);
302 void FLASH_ClearFlag(uint32_t FLASH_FLAG);
304 FLASH_Status FLASH_WaitForLastOperation(uint32_t Timeout);
305 
306 #ifdef __cplusplus
307 }
308 #endif
309 
310 #endif /* __STM32F0XX_FLASH_H */
311 
320 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/